var scriptsFlash = {
	init: function () {
		$("#fermerPopinMag").click(
			function(){
				scriptsFlash.fermerPopinMag();
				return false;
			}
		);

		$("#fermerPopinVideo").click(
			function(){
				scriptsFlash.fermerPopinVideo();
				return false;
			}
		);
		$("#mag .parties a.affPopin").click(
			function(){
				scriptsFlash.afficherPopinMag($(this));
				var strWhereISearch = String(window.location);
				if(strWhereISearch.indexOf("planete2049/mag2049.html")>0){
					if(strWhereISearch.indexOf("#")>0){
						window.location = strWhereISearch.split('#')[0]+'#';
					}else{
						window.location = strWhereISearch+'#';		
					}
				}

				return false;
			}
		);
		// Fiche 2048
		$(".partieMag .parties a:not(.affPopin):not(.popup)").click(
			function(){
				scriptsFlash.afficherFiche($(this));
				return false;
			}
		);

		$('.vidBac .teaser').click(
			function(){
				scriptsFlash.afficherPopinBac($(this));
				return false;
			}
		);
		$('.listVidBac .teaser').click(
			function(){
				scriptsFlash.afficherPopinBac($(this));
				return false;
			}
		);

		$('#laFranceEnQuestion .aside .teaser').click(
			function(){
				scriptsFlash.afficherPopinBac($(this));
				return false;
			}
		);
		$('.yamina .teaser').click(
			function(){
				scriptsFlash.afficherPopinBac($(this));
				return false;
			}
		);

		$('.20-ans-de-capa .teaser').click(
			function(){
				scriptsFlash.afficherPopinBac($(this));
				$('#contenuProgrammes #planeteVideo1').css('display','none');
				$('#contenuProgrammes #planeteVideo2').css('display','none');
				$('#contenuProgrammes #planeteVideo6').css('display','none');
				$('#contenuProgrammes #planeteVideo7').css('display','none');
				$('#contenuProgrammes #planeteVideo8').css('display','none');
				$('#contenuProgrammes #planeteVideo9').css('display','none');
				return false;
			}
		);



		if($('#conteneur.home #scope').length>0){	
		
			var flashvars = {
				configXML:"xml/config.xml"
			};	
			var params = {
				allowScriptAccess: "always",
				wmode:"opaque"
			};
			var attributes = {
				id: "planeteSwf",
				name: "planeteSwf"
			};

			swfobject.embedSWF("swf/planete.swf", "scope", "900", "480", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

		}

		if($('#cntFlash #flashVideo').length>0){


			var flashvars = {
				flvPath:'http://vod-flash.mth.net/PLANETE/PROGRESSIF/s11plan_planetebac_580326.flv',
								skinPath :"swf/skinSmall.swf"
			};	
			var params = {
				allowScriptAccess: "always",
				wmode:"transparent"
			};
			var attributes = {
				id: "planeteVideo",
				name: "planeteVideo"
			};
			swfobject.embedSWF("swf/playerPlanete.swf", "cntFlash", "310", "284", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
		}
	},
	// Affiche la popin d'une video
	afficherPopinMag: function(lien){

		var video = "http://vod-flash.mth.net/PLANETE/PROGRESSIF/"+$(lien).attr("rel");
		var titre = $(lien).attr("title");
		var flashvars = {
			flvPath:video,
			skinPath :"swf/skinBig.swf",
			title:titre
		};	
		var params = {
			allowScriptAccess: "always",
			wmode:"transparent"
		};
		var attributes = {
			id: "planeteVideo",
			name: "planeteVideo"
		};

		swfobject.embedSWF("swf/playerPlanete.swf", "flashPopin", "600", "500", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

if(845<$('#cntMag').css('height').split('px')[0]){
		$("#overlay").css("height", $('#cntMag').css('height'));
}else{
		$("#overlay").css("height", "845px");
}

		$("#overlay").css("display", "block");
		$("#popinMag").css("display", "block");


		//$("#popinMag h3:eq(0)").html(titre);
	},
	// Affiche la popin d'une video
	afficherPopinBac: function(lien){

		var video = "http://vod-flash.mth.net/PLANETE/PROGRESSIF/"+$(lien).attr("rel");
		var titre = $(lien).attr("title");
		var flashvars = {
			flvPath:video,
			skinPath :"swf/skinBig.swf",
			title:titre
		};	
		var params = {
			allowScriptAccess: "always",
			wmode:"transparent"
		};
		var attributes = {
			id: "planeteVideo",
			name: "planeteVideo"
		};

		swfobject.embedSWF("swf/playerPlanete.swf", "flashPopinVideo", "600", "500", "9.0.0", "expressInstall.swf", flashvars, params, attributes);


		$("#overlayVideo").css("display", "block");
		$("#popinVideo").css("display", "block");


		//$("#popinMag h3:eq(0)").html(titre);
	},
	fermerPopinVideo: function(image){
		$('#pushs #conteneurFlash').html('<div id="cntFlash"><div id="flashVideo"></div></div>');
		$("#conteneurFlashVideo").html('<div id="flashPopinVideo">  </div>');
		$("#overlayVideo").css("display", "none");
		$("#popinVideo").css("display", "none");
		$('#pushs').css("display", "block");

		if($('.20-ans-de-capa #contenuProgrammes #planeteVideo1').length>0){
			$('#contenuProgrammes #planeteVideo1').css('display','block');
			$('#contenuProgrammes #planeteVideo2').css('display','block');
			$('#contenuProgrammes #planeteVideo6').css('display','block');
			$('#contenuProgrammes #planeteVideo7').css('display','block');
			$('#contenuProgrammes #planeteVideo8').css('display','block');
			$('#contenuProgrammes #planeteVideo9').css('display','block');
		}
		if($('#cntFlash #flashVideo').length>0){


			var flashvars = {
				flvPath:'http://vod-flash.mth.net/PLANETE/PROGRESSIF/s11plan_planetebac_580326.flv',
				skinPath :"swf/skinSmall.swf"
			};	
			var params = {
				allowScriptAccess: "always",
				wmode:"transparent"
			};
			var attributes = {
				id: "planeteVideo",
				name: "planeteVideo"
			};
			swfobject.embedSWF("swf/playerPlanete.swf", "cntFlash", "310", "284", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
		}
	},
	afficherFiche: function(lien){
		var rel = $(lien).attr("rel");
		if($(lien).attr("rev")){

		var video = "http://vod-flash.mth.net/PLANETE/PROGRESSIF/"+$(lien).attr("rev");
		var title = $(lien).attr("title");
		var cible = "flash_fiche"+$(lien).attr("ref");


		var flashvars = {
			flvPath:video,
			skinPath :"swf/skinBig.swf",
			title:title 
		};	
		var params = {
			allowScriptAccess: "always",
			wmode:"transparent"
		};
		var attributes = {
			id: "planeteVideo",
			name: "planeteVideo"
		};
		swfobject.embedSWF("swf/playerPlanete.swf", cible, "600", "500", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
		}



		
		$(".parties").css("display", "none");
		$(".fiches").css("display", "block");
		$(".fiches li").css("display", "none");
		$("#fiche"+rel).css("display", "block");
		
		if($("#mag .fiches #fiche"+rel+" .texte .jScrollPaneDrag").length == 0){
			$("#mag .fiches #fiche"+rel+" .cntLiens").jScrollPane({animateTo:true, showArrows:false, scrollbarWidth: 7});
			$("#mag .fiches #fiche"+rel+" .texte .jScrollPaneDrag").css({width: "3px", marginLeft: "2px"});
			$(".cntLiens.ascenseur").css("width","525px");
		}
		setTimeout("scripts.modifierHauteurMag()", 1000);
	},
	// Ferme la popin 2048
	fermerPopinMag: function(image){
		$("#conteneurFlash").html('<div id="flashPopin"></div>');
		$("#overlay").css("display", "none");
		$("#popinMag").css("display", "none");
	},
	reculerJour: function(){
		if(scripts.curJour ==1) return;
		this.curJour--;
		
		this.afficherJour();
	}
}
$(document).ready(
	scriptsFlash.init
);