// pour ajouter un évènement au onload !
function addEvent(obj, event, fct) {
	if (obj.attachEvent){
		obj.attachEvent("on" + event, fct); 
	}	
	else{
		obj.addEventListener(event, fct, true);
	}
}


function ouvre_boite(bloc_div){

	$("#"+bloc_div).fadeIn(800);

}




function MM_openBrWindow(theURL,winName,features)
{ 
  window.open(theURL,winName,features);
}




/* scripts ajax */

var xhr = null;

/* Fonction de creation de l'objet XMLHttpRequest qui resservira pour chaques fonctions AJAX*/
function getXhr()
{
  if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); 
  else if(window.ActiveXObject)
   {  
    try
     {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch (e)
     {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
   }
  else 
   { 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest, veuillez le mettre à jour"); 
    xhr = false; 
   } 
}





function affiche_page_flash(nom_page)
{
	getXhr();	

	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			$(".menu_selected").css("background-color", "transparent");
			$("#fenetre_over").fadeOut(300, function(){
				$("#contenu_site_contenu").fadeOut(600, function(){
					$("#contenu_site_contenu").html(xhr.responseText);	
					$("#contenu_site_contenu").fadeIn(600);		
				});
				
		   
		   });
	
		}
	}

	xhr.open("POST",'inc/affiche_page_flash.php',true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("nom_de_la_page="+nom_page);
}




 // gestion vidéos
 function change_video(id_video)
 {
  getXhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
	    if(xhr.responseText!=0){
			var divid = document.getElementById("iphone_liste_video"); 

			tableau_videos=divid.getElementsByTagName('p');
			
			for(i=0;i<tableau_videos.length;i++){
				tableau_videos[i].className="";
			}	
			document.getElementById('video_'+id_video).className="video_selected";
			
			
			document.getElementById('iphone_player_video').innerHTML="";
			
			document.getElementById('iphone_player_video').innerHTML="";
			document.getElementById('iphone_player_video').style.display="none";
			document.getElementById('iphone_player_video').innerHTML=xhr.responseText;			
			document.getElementById('iphone_player_video').style.display="block";

		}
     }
   }
  // On envoie la requete 
  xhr.open("POST",'inc/change_video.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

  // On envoie au fichier php
  xhr.send("id_video="+id_video);
  
  return 1;
 }
 
 
 
  // gestion vidéos
 function change_video_select()
 {
 
	id_video=document.getElementById('choix_video').options[document.getElementById('choix_video').selectedIndex].value;
 
  getXhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
	    if(xhr.responseText!=0){
		/*
			var divid = document.getElementById("iphone_liste_video"); 

			tableau_videos=divid.getElementsByTagName('p');
			
			for(i=0;i<tableau_videos.length;i++){
				tableau_videos[i].className="";
			}	
			document.getElementById('video_'+id_video).className="video_selected";
			*/
			
			document.getElementById('iphone_player_video').innerHTML="";
			
			document.getElementById('iphone_player_video').innerHTML="";
			document.getElementById('iphone_player_video').style.display="none";
			document.getElementById('iphone_player_video').innerHTML=xhr.responseText;			
			document.getElementById('iphone_player_video').style.display="block";

		}
     }
   }
  // On envoie la requete 
  xhr.open("POST",'inc/change_video.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

  // On envoie au fichier php
  xhr.send("id_video="+id_video);
  
  return 1;
 }
 
 
 

 function callFancy(my_href) {
    /*var j1 = document.getElementsByClassName("a_video");
    j1.href = my_href;*/
    $('#a_video').trigger('click');
 }
 
 
/* change la ville choisie */
function changeVille(id_ville) {
   getXhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
	    if(xhr.responseText!=0){
			

		}
     }
   }
  // On envoie la requete 
  xhr.open("POST",'inc/change_ville.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

  // On envoie au fichier php
  xhr.send("id_ville="+id_ville+"&lance_commande=2");
  
  return 1;
}


function change_tableau_stages_tarifs(){
	idzone=$("#select_tableau_stages_tarifs").val();
	$( "div.contenutab_zones" ).css("display", "none");

	$( "#contenutab_zone_"+idzone).fadeIn(800);

}


