/* +------------------------------------------------------+
 * |                      pPPa                            |
 * |                    pPPAPPp                           |
 * |                   APP  PPa                           |
 * |                  APA  pPP  PapA  PapA                |
 * |                 PPA   APA pP  P pP  P                |
 * |             APPPPPPPA PPp Ap Ap Ap Ap                |
 * |             apPPA    aPP  P     P                    |
 * |              APA     pPP  p     p                    |
 * |             pPP      PPA                             |
 * |             PPp      PPPp                            |
 * |                                                      |
 * | Created by:    App Software                          |
 * | Email:         info@appsoftware.nl                   |
 * | Web:           http://www.appsoftware.nl/            |
 * |                                                      |
 * +------------------------------------------------------+
 * 
 * CMS Main
 * 
 * 
 */

var Jeugdbieb = {};

Jeugdbieb.Main = function() {
    
    var title='';
    
	var str_default_color = 'blue';
	
	var dummyFunction = function() {
	};
    
    return {
        init : function(def_color) {	

			str_default_color = def_color;
					
            $('.bg_tab_blue').click(function() {
				Jeugdbieb.Main.switchBackground('blue');
			});
            $('.bg_tab_pink').click(function() {
				Jeugdbieb.Main.switchBackground('pink');
			});
            $('.bg_tab_orange').click(function() {
				Jeugdbieb.Main.switchBackground('orange');
			});
            $('.bg_tab_purple').click(function() {
				Jeugdbieb.Main.switchBackground('purple');
			});
            $('.bg_tab_green').click(function() {
				Jeugdbieb.Main.switchBackground('green');
			});
            this.switchBackground(str_default_color);
			
			this.resetMainPanels();
        },
        switchBackground : function(new_color) {        	
			var c = BART.Front.Util.readCookie('jb_bg');
			
			if (c == null || c == undefined) {
		        prev_color = 'gray';
		        var background_color = 'blue';
			} else {
				prev_color = c;
				var background_color = new_color || c;
			}
			
			$("body").removeClass(prev_color);
			$("body").addClass(background_color);
			
			BART.Front.Util.createCookie('jb_bg', background_color, 365);   	        
		},
		resetMainPanels : function() {
//			$("a .image_spacer").each(function(j) {
//				$(this).width( $(this).find("img").width() );
//			});										
			
			$(".middle").each(function(i){
                var obj_tag = $(this).find('object');

                if (obj_tag.attr('height') === undefined){
                    $(this).find(".content_background img").height($(this).height());
                } else {
					$(this).find(".content_background img").height($(this).height());					
//                    var int_height = Number($(this).height()) + Number(obj_tag.attr('height'));
//                    $(this).find(".content_background img").height(int_height);
                }
			});
		},
		imageHide : function() {
			$(".portal .block").hide();
			$(".portal .menu").hide();
		},		
		imageFadeIn : function() {
			setTimeout(function(){				
				//$(".portal .image").fadeIn(1500);
				$(".portal .block").fadeIn(1500);
				$(".portal .menu").fadeIn(1500);
			}, 1000);
		}		
    }    
}();
