var idVideoEnCours = 0;
var other_params = "";

function afficherMentions(){

	window.open('mentions.html','','width=640, height=480, status=no, scrollbars=yes, menubar=no, top=50, left=50');

}

function rechercher(recherche){
	
	
	cacherInfos();
	
	
	flashrecherche.addVariable("recherche", recherche);
	flashrecherche.write("search");
	
	if($('resultats_search').style.display!='block'){
		Effect.Appear('resultats_search');
		Effect.Appear('croixSearch');
	}
	
	
	if(recherche==''){
		cacherSearch();
	}
}

function chargeVideo(identifiant){
	
	cacherSearch();
	cacherInfos();
	
	if(idVideoEnCours != 0){ appelFlash("laVisionneuse").getStats(); }
	
	idVideoEnCours = identifiant;
	
	var myAjax = new Ajax.Request(
								  	'ajax/getVideo.php',
									{
										method:'post',
										parameters:'id='+idVideoEnCours,
										onComplete:afficherVisio
									}
								);

	
	
	
	
	var marqueurs = new SWFObject("/flash/marqueurs.swf", "marqs", "440", "390", "9", "#ffffff");
    marqueurs.addParam("wmode","transparent");
	marqueurs.addVariable("idVideo", idVideoEnCours);
	marqueurs.write("marqueurs");
	
	var listeVideos = new SWFObject("/flash/listeVideos.swf", "liste_videos", "925", "130", "9", "#ffffff");
    listeVideos.addParam("wmode","transparent");
	listeVideos.addVariable("idVideoExclue", idVideoEnCours+other_params);
	listeVideos.write("listeVideos");
	
	
}

function afficherVisio(requete){
	
	var tmp = requete.responseText.split("||");
	v.addVariable('imageBeforePlay', 'http://www.colmar-vod.fr/videoimages/imageBeforePlay/'+tmp[0]+'.jpg');
	v.addVariable('fichier',tmp[0]);
	v.addVariable('idVideo', idVideoEnCours);
	
	/*if(idVideoEnCours == 4)
	{
		v.addVariable('tcIn', '180');
		v.addVariable('tcOut', '14313');
	}*/
	v.addVariable('tcIn', (parseInt(tmp[1])> 0)?tmp[1]:'');
	v.addVariable('tcOut', (parseInt(tmp[2])> 0)?tmp[2]:'');
	//v.addVariable('urlMarqueurs', 'http://www.colmar-vod.fr/ajax/marqueurs.php?idVideo=' + idVideoEnCours);
	v.write('visionneuse');
}

function goTo(timecode){
	appelFlash("laVisionneuse").seekVideo(timecode);	
}

function cacherInfos(){
	Effect.Fade('infos_video');
}

function cacherSearch(){
	Effect.Fade('resultats_search');
	Effect.Fade('croixSearch');
}

function infosVideo(id){
	
	cacherSearch();
	
	
	Effect.Appear('infos_video');
	
	var myAjax = new Ajax.Updater(
								  	'infos_video',
									'ajax/getInfos.php',
									{
										method:'post',
										parameters:'id='+id
									}
								);
	

}
