
//----- sIFR
function cp_init_sIFR(){
	
	if(sIFR){
		sIFR.replace(sifr_gillsans, {
             selector: '#p-rcb h2.small_green'
             ,css: '.sIFR-root {color:#76a505;font-size:24px; background-color:none;}'
             ,wmode: 'transparent'    
         });
		sIFR.replace(sifr_gillsans, {
             selector: '#p-rcb h2.green'
             ,css: '.sIFR-root {color:#76a505;font-size:34px; background-color:none;}'
             ,wmode: 'transparent'    
         });
		sIFR.replace(sifr_gillsans, {
            selector: '#p-rcb h2.blue'
            ,css: '.sIFR-root {color:#00a7bc;font-size:20px; background-color:none;}'
            ,wmode: 'transparent'    
        });
		  sIFR.replace(sifr_gillsans, {
             selector: '#p-rcb h2.centered'
             ,css: '.sIFR-root {color:#ffffff;font-size:28px; background-color:none; text-align:center;}'
             ,wmode: 'transparent'    
         });
		  sIFR.replace(sifr_gillsans, {
	          selector: '#p-rcb h2.bold'
	          ,css: '.sIFR-root {color:#ffffff;font-size:30px; background-color:none; font-weight:bold};'
	          ,wmode: 'transparent'    
	         });
		  sIFR.replace(sifr_gillsans, {
		  		selector: '#p-rcb h2'
		  		,css: '.sIFR-root {color:#ffffff;font-size:22px; background-color:none;}'
		  		,wmode: 'transparent'	
		  	});
		  
		  sIFR.replace(sifr_gillsans, {
	            selector: '#p-rcb h3.home'
	            ,css: '.sIFR-root {color:#ffffff;font-size:13px; background-color:none;text-align:center;}'
	            ,wmode: 'transparent'    
	        });
		  
		  sIFR.replace(sifr_gillsans, {
	            selector: '#p-rcb h3.switcher'
	            ,css: '.sIFR-root {color:#ffffff;font-size:18px; background-color:none;text-align:center;}'
	            ,wmode: 'transparent'    
	        });
		  sIFR.replace(sifr_gillsans, {
	            selector: '#p-rcb h3.n25'
	            ,css: '.sIFR-root {color:#ffffff;font-size:25px; background-color:none;}'
	            ,wmode: 'transparent'    
	        });
		  sIFR.replace(sifr_gillsans, {
	            selector: '#p-rcb h3.n25bold'
	            ,css: '.sIFR-root {color:#ffffff;font-size:18px; background-color:none;font-weight:bold;}'
	            ,wmode: 'transparent'    
	        });
		  
		  sIFR.replace(sifr_gillsans, {
	            selector: '#p-rcb h3.n25'
	            ,css: '.sIFR-root {color:#00a7bc;font-size:30px; background-color:none;}'
	            ,wmode: 'transparent'    
	        });
		  
		  sIFR.replace(sifr_gillsans, {
				selector: '#p-rcb h3.n30blue'
			  	,css: '.sIFR-root {color:#00a7bc;font-size:30px;background-color:none;}'
			  	,wmode: 'transparent'	
			  	});
		  
		  sIFR.replace(sifr_gillsans, {
				selector: '#p-rcb h3.n27'
			  	,css: '.sIFR-root {color:#ffffff;font-size:27px;background-color:none;}'
			  	,wmode: 'transparent'	
			  	});
		  sIFR.replace(sifr_gillsans, {
				selector: '#p-rcb h3.n27grey'
			  	,css: '.sIFR-root {color:#888888;font-size:27px;background-color:none;}'
			  	,wmode: 'transparent'	
			  	});
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb h3.eco'
	  		,css: '.sIFR-root {color:#b5a089;font-size:20px;font-weight:bold;background-color:none;}'
	  		,wmode: 'transparent'	
	  	});
		  sIFR.replace(sifr_gillsans, {
			selector: '#p-rcb h3.white'
		  	,css: '.sIFR-root {color:#ffffff;font-size:29px;background-color:none;}'
		  	,wmode: 'transparent'	
		  	});
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb h3.grey'
	  		,css: '.sIFR-root {color:#999999;font-size:30px; background-color:none; font-style:italic; }'
	  		,wmode: 'transparent'	
	  	});
		  sIFR.replace(sifr_gillsans, {
		  		selector: '#p-rcb h3.difference'
		  		,css: '.sIFR-root {color:#ffffff;font-size:20px; background-color:none; }'
		  		,wmode: 'transparent'	
		});
		sIFR.replace(sifr_gillsans, {
		  		selector: '#p-rcb h3'
		  		,css: '.sIFR-root {color:#ffffff;font-size:30px; background-color:none;}'
		  		,wmode: 'transparent'	
		  	});
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb h4.centered'
	  		,css: '.sIFR-root {color:#ffffff;font-size:22px; background-color:none; text-align:center;}'
	  		,wmode: 'transparent'	
	  	});
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb h4'
	  		,css: '.sIFR-root {color:#ffffff;font-size:22px; background-color:none; }'
	  		,wmode: 'transparent'	
	  	});
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb h5'
	  		,css: '.sIFR-root {color:#ffffff;font-size:26px;background-color:none;}'
	  		,wmode: 'transparent'	
	  	});
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb h6'
	  		,css: '.sIFR-root {color:#ffffff;font-size:16px;background-color:none; }'
	  		,wmode: 'transparent'	
	  	});
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb h7'
	  		,css: '.sIFR-root {color:#ffffff;font-size:14px; background-color:none;}'
	  		,wmode: 'transparent'	
	  	});
		  
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb .section_range .title'
	  		,css: '.sIFR-root {color:#ffffff;font-size:14px;margin:0px; background-color:none;}'
	  		,wmode: 'transparent'	
	  	});
		  
		  sIFR.replace(sifr_gillsans, {
	  		selector: '#p-rcb p.bubble_txt'
	  		,css: '.sIFR-root {color:#ffffff;font-size:16px;margin:0px; background-color:none; font-style:inherit; text-align:center; }'
	  		,wmode: 'transparent'	
	  	});
		  
	}
}


function closePopup(){
	//close the popup and tell it to remove the flash content with the id flashcontent
	popupMan.close({swf:"myExperience"});
}


function openBrightcove(playerId){
	currentVideoId = playerId; // FIX	
	var params = {
	centerOnResize:true,
	centerOnScroll:false,
	background:true,
	backgroundClick:false,
	backgroundAlpha:0.5,
	hasFlash:true,
	popupWidth:506,
    popupHeight:468
	};
	
	//open the popup
	popupMan.open("#overlayDiv",params);
	
	//dynamicly create a brightcove player
	createBrightcovePlayer({    
							id:"myExperience",
							containerId:"flashcontent",
							playerId:23188062001,
							publisherID:1875254528,
							width:486,
							height:412,
							videoPlayer:playerId,
							autoStart:"false"
							});
}
function cp_flattv_ambilight_resize(h) {
	$("#cp_header").css("height", h + "px");
	$("#cp_headerAnimation").css("height", h + "px");
	$("#cp_headerAnimation").css("background-color", "#000000");
}


$.cp.pageOpenedCallback = function(){
	
	cp_flattv_ambilight_resize(275);
	
	$("#tooltip").each(function(){$(this).hide();});
	
	$("#cp_mainmenu ul").each(function(){
		this.FMenu.searchByAttribute("href","#"+$.cp.mapObject.id);
	});

	$("#cp_submenu_difference").hide();
	$("#cp_submenu_latest").hide();
				
	$("#cp_submenu_latest ul").each(function(){
		if(this.FMenu) this.FMenu.deselect();
	});

	$("#cp_submenu_difference ul").each(function(){
		if(this.FMenu) this.FMenu.deselect();
	});
	
	
	if($.cp.mapObject.id.substring(0,"/difference".length) == "/difference"){
		if($.cp.mapObject.id=="/difference"){
			cp_currentSection = "/difference";
			
		}else{
			if(cp_currentSection!="/difference"){
				cp_currentSection = "/difference";
				
				$("#cp_mainmenu ul").each(function(){
					if(this.FMenu) this.FMenu.searchByAttribute("href","#/difference");
				});
				
			}

			$("#cp_submenu_difference ul").each(function(){
				
				if(this.FMenu) this.FMenu.searchByAttribute("href","#"+$.cp.mapObject.id);
			});
			
		}
		$("#cp_submenu_difference").show();
		$("#cp_submenu_latest ul").each(function(){
			if(this.FMenu) this.FMenu.deselect();
		});
	}else if($.cp.mapObject.id.substring(0,"/latest".length) == "/latest"){
		if($.cp.mapObject.id=="/latest"){
			cp_currentSection = "/latest";
			
		}else{
			if(cp_currentSection!="/latest"){
				cp_currentSection = "/latest";
				
				$("#cp_mainmenu ul").each(function(){
					if(this.FMenu) this.FMenu.searchByAttribute("href","#/latest");
				});
			}
			
			$("#cp_submenu_latest ul").each(function(){
				if(this.FMenu) this.FMenu.searchByAttribute("href","#"+$.cp.mapObject.id);
			});
			
		}
		$("#cp_submenu_latest").show();
		$("#cp_submenu_difference ul").each(function(){
			if(this.FMenu) this.FMenu.deselect();
		});
	}else{
		cp_currentSection = null;

		$("#cp_submenu_difference ul").each(function(){
			if(this.FMenu) this.FMenu.deselect();
		});

		$("#cp_submenu_latest ul").each(function(){
			if(this.FMenu) this.FMenu.deselect();
		});
	}
	
	cp_init_sIFR();
}

$(document).ready(function() {
	this.FMenu = $("#cp_mainmenu ul").FMenu({});
	$("#cp_submenu_difference ul").FMenu({});
	$("#cp_submenu_latest ul").FMenu({});	
});

if(SWFAddress){
	SWFAddress.onChange = function(){
		var name = SWFAddress.getValue();
		
		$.cp.openPage(name);
	}
}

