/* ================================================================================  */
/* -- C23 PLAYER CODE v1 ----------------------------------------------------------  */
/* ================================================================================  */




/* -- INTERACTIONS ----------------------------------------------------------------  */


function chargementInterface(){ 
			
			// LISTENERS
	$("#twitb").click(function(event){ if ( $("#faceblock").css('opacity')>0 ) {$("#faceblock").stop().fadeTo(100,0);};
												$("#twitblock").fadeTo(600,0.8,function(event){$("#twitblock").delay(2000).fadeTo(100,0);});
												//$("#twitblock").css("bottom","50");
												 });
	$("#faceb").click(function(event){ if ( $("#twitblock").css('opacity')>0) {$("#twitblock").stop().fadeTo(0);};
												$("#faceblock").fadeTo(600,0.8,function(event){$("#faceblock").delay(2000).fadeTo(100,0);}) });
	$("#twitblock").mouseover(function(event){
										
										$('#twitblock').stop();
										if ( $('#twitblock').css('opacity')<0.8 && $('#twitblock').css('opacity')!=0) {
											 	$('#twitblock').fadeTo(250,0.8); }; });							
	$("#twitblock").mouseleave(function(event){ $("#twitblock").fadeTo(400,0,function(){$("#twitblock").css('display','none');});});
	$("#faceblock").mouseover(function(event){
										//console.log("FB display :"+$("#faceblock").css('display'));
										$("#faceblock").stop();
										if ( $("#faceblock").css('opacity')<0.8 && $('#faceblock').css('opacity')!=0 ) {
												$("#faceblock").fadeTo(250,0.8); }; });
	$("#faceblock").mouseleave(function(event){ $("#faceblock").fadeTo(400,0,function(){$("#faceblock").css('display','none');});});
			
	//$("#chevaldeuxtrois").click(function(event){window.location.assign('mailto:contact@chevaldeuxtrois.com');});
	
	$("#chevaldeuxtrois").click(function(event){contact();});
	$("#pdf").mouseover(function(event){$("#logo").css('background-image','url(graph/fleche.gif)').css('margin-left','25px'); });
	$("#pdf").mouseleave(function(event){$("#logo").css('background-image','url(graph/logo_Cheval.png)').css('margin-left','15px');});
	$("#pdf").click(function(event){window.open('doc/chevaldeuxtrois.pdf');});
	
	//$("#flashContent").click(function(){if(gCvisible){pause('flash');}});
	//$("#son").click(function(event){volume(2);});
	//$("#son").mouseover(function(event){$("#son").css("background-position","30px 0px");});
	//$("#son").mouseout(function(event){if (gVol==0){ $("#son").css("background-position","0px 0px");}});
	//$("#fullScreen").click(function(event){full();});
	//$("#fullScreen").mouseover(function(event){$("#fullScreen").css("background-position","30px 0px");});
	//$("#fullScreen").mouseout(function(event){$("#fullScreen").css("background-position","0px 0px");});
	
	}

function start() { $('#barre_du_bas').fadeIn(500);}

function setFirstVolume() {volume(gVol);} // Quand Flash est pret on règle le volume d'après la var vol
    
function volume(lvl) { // envoye le volume à flash
					//alert(gVol);
					if (lvl==2) {
							if (gVol==0){$("#son").css("background-position","30px 0px"); gVol=1;}
							else {$("#son").css("background-position","0px 0px");gVol=0;}
						}
					else {
							if (lvl>0){$("#son").css("background-position","30px 0");}
							else {$("#son").css("background-position","0 0");}
							gVol=lvl;
						}
					window.document.C23_flash.changeVolume(lvl);} // 2 => on/off

function full(){
	//alert("merde");
	window.resizeTo(400,400);

	}


/* -- HTLM5 PLAYER PORT ----------------------------------------------------------------  */  
   	
     
function lecture(id) { if (id==1){document.getElementById("C23_1").play();} else {document.getElementById("C23_2").play();}
     		};
     	
     
 /*function volume(valeur){
     		if(valeur==null) { 	if (soundVolume>0) 	{ document.getElementById("C23_1").volume=0; document.getElementById("C23_2").volume=0; localStorage.volume=0; soundVolume=0; }
     							else 				{ document.getElementById("C23_1").volume=1; document.getElementById("C23_2").volume=1; localStorage.volume=1; soundVolume=1; };
     						}
     		else {document.getElementById("C23_1").volume=valeur;document.getElementById("C23_2").volume=valeur; localStorage.volume=valeur; soundVolume=valeur;}
     		
     		if(soundVolume==0){$('#son').css("background-position","0 0");}
     		else{$('#son').css("background-position","0 35px");}
    };*/
     		
function setTitle(cible,numero) {

   		var imageId=0;
   		   		
   		switch (numero)
   			{
   			case 1 :
   			case 2 :
   			case 3 :
   				imageId=1;
   				break;
   			case 4 :
   			case 5 :
   			case 6 :
   				imageId=4;
   				break;
   			
   			default: imageId=numero;
   			}

   		if (cible==1)
   			{$('#titreIMGone').attr("src","video/0"+ imageId +".png"); $('#titreONE').css('display','none');}
   		else 
   			{$('#titreIMGtwo').attr("src","video/0"+ imageId +".png"); $('#titreTWO').css('display','none');}
   	
   		};
   
function hazard(max){return Math.floor(Math.random() * max) + 1;};

function zap(laVideo){
     	
     		var nVid = 0;
     		
     		while (nVid==0||nVid==cVid) {nVid=hazard(8);}
     		
     		cVid=nVid;	
     		
				if (laVideo==1) {	var theVideo = document.getElementById("C23_1");
									setTitle(1,cVid);}
				
				else 			{	var theVideo = document.getElementById("C23_2");
									setTitle(2,cVid);}

			theVideo.pause();

     		if (navigator.userAgent.match("Firefox")){
	     			theVideo.src = "video/0"+ cVid +".ogg";
	     			theVideo.type='video/ogg; codecs="theora, vorbis"';}
     		else {  //theVideo.src = "http://www.chevaldeuxtrois.com/C23/video/0"+ cVid +".mp4";}
     				theVideo.src = "video/0"+ cVid +".mp4";}
			
     
     		// this.vid.load(); OBLIGATOIRE pour Firefox
     		theVideo.load(); 

     	};	
     
function playIt(lecteur){ 
     		if (lecteur==1) { $('#vidTWO').fadeOut(800).delay(800).css('display','none'); document.getElementById("C23_1").play(); $('#vidONE').fadeIn(2000); setTimeout("zap(2)",100); }
     		else			{ $('#vidONE').fadeOut(800).delay(800).css('display','none'); document.getElementById("C23_2").play(); $('#vidTWO').fadeIn(2000); setTimeout("zap(1)",100); }
		};


