var sens = -2;
var pilePage = new Array();
function retour(){


	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		

	    	 
	    	  var contenu =  document.getElementById('contenu');
	    	  contenu.innerHTML = xhr.responseText;
	    	  set_tomax_height('contenu',-40);
	      }
	      };

		  pilePage.pop();
		//  alert ('retour'+pilePage[pilePage.length-1]);
	  xhr.open("POST", pilePage[pilePage.length-1],true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="";
		        
	  xhr.send(data);

	
	
	
}
function clickSejour(cible,sousdoss){
	
	


	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  $('voletcentre').innerHTML = "";
	    	 // alert('reponse='+ xhr.responseText);
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  
	      }
	      };

		//  pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/sejours/"+sousdoss+"/"+cible.id+"/"+cible.id+".html";

	       
	  xhr.send(data);

	
	
}
function creerSejours(){

	var xhr = new XMLHttpRequest();	 
// sejours au maroc
	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	//  alert(xhr.responseText);
	    	 
	    	  var sejoursmaroc =  document.getElementById('sejoursmaroc');
	    	  sejoursmaroc.innerHTML = xhr.responseText;
	    	  xhr.responseText.evalScripts();
	      }
	      };

	//	  pilePage.push("personnes.php");
	  xhr.open("POST", "creerSejours.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="dirnom=./ressources/sejours/maroc";

		        
	  xhr.send(data);
	  
	  
//sejours dans les cevennes
	  var xhr2 = new XMLHttpRequest();	 
	  xhr2.onreadystatechange = function() { 
	      if (xhr2.readyState === 4) { 
	    		
	    	//  alert(xhr2.responseText);
	    	 
	    	  var sejourscevennes =  document.getElementById('sejourscevennes');
	    	  sejourscevennes.innerHTML = xhr2.responseText;
	    	  xhr2.responseText.evalScripts();

	      }
	      };

	//	  pilePage.push("personnes.php");
	      xhr2.open("POST", "creerSejours.php",true);
	      xhr2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="dirnom=./ressources/sejours/cevennes";

		        
	  xhr2.send(data);
}
function ethique(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

	//	  pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/ethique.html";

	//  alert ('ethique '+ data);               
	  xhr.send(data);

	
	
	
}
function defileBandeau(longueur){
	if ($("zoneDefilement")){
	posleftx= $("zoneDefilement").getStyle('left');
	if (posleftx){
	posleft = parseInt(posleftx.substr(0,posleftx.length-2));}
	else {posleft = 0;}
	tailleParent = parseInt($("centreTop").getStyle('width').substr(0,$("centreTop").getStyle('width').length-2));
	if (Math.abs(posleft) + tailleParent >= longueur)
	 {sens = sens * -1;}
	//alert ('longueur='+longueur+'posleft='+posleft+'sens='+sens+'/'+tailleParent);
	 $("zoneDefilement").setStyle({left:(posleft + sens)+'px'});
	if ( $("zoneDefilement").getStyle('left') == '0px' )
	 {sens = sens * -1;}
}else{defillTimer = null;}
	}
function creeDefilement(){
//alert('cree defilement');
	var xhr = new XMLHttpRequest();	 
// sejours au maroc
	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	//  alert(xhr.responseText);
	    	 
	    	  var zoneDefilement =  document.getElementById('centreTop');
	    	  zoneDefilement.innerHTML = xhr.responseText;
	    	  xhr.responseText.evalScripts();
	      }
	      };

	//	  pilePage.push("personnes.php");
	  xhr.open("POST", "lireDefilement.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="dirnom=./ressources/images/defilement";

		        
	  xhr.send(data);
	  
	
}

function pageAcceuil(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	 // $('centreTop').innerHTML = '<img id="imgCentreTop" alt="" src="./ressources/images/banniereEntree.jpg" style="z-index:-1;   height:320px;width:100%;"/>';
	    	  creeDefilement();
	    	  $('centreTop').setStyle({zIndex:'1000'});
	    	
	    	  var contenu =  document.getElementById('voletcentre');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		//  pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/pageAcceuil.html";

//	  alert ('acceuilxx '+ data);               
	  xhr.send(data);

	
	
	
}
function impressions(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		

	    	  set_tomax_height('voletcentre',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    		    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		//  pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/impressions.html";

//	  alert ('impressions '+ data);             
	  xhr.send(data);

	
	
	
}
function liens(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		

	    	  set_tomax_height('voletcentre',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    		    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		//  pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/liens.html";

//	  alert ('impressions '+ data);             
	  xhr.send(data);

	
	
	
}
function infosPratiques(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		

	    	  set_tomax_height('voletcentre',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    		    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		//  pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/infosPratiques.html";

//	  alert ('impressions '+ data);             
	  xhr.send(data);

	
	
	
}
function albums(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		

	    	  set_tomax_height('voletcentre',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    		    	  contenu.innerHTML = xhr.responseText;
	    		    	  xhr.responseText.evalScripts();
	      }
	      };

		//  pilePage.push("personnes.php");
	  xhr.open("POST", "listAlbums.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="";

	               
	  xhr.send(data);

	
	
	
}
function unAlbum(nomAlbum){

//	alert ('album'+nomAlbum);
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		

	    	  set_tomax_height('voletcentre',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    		    	  contenu.innerHTML = xhr.responseText;
	    		    	  xhr.responseText.evalScripts();
	      }
	      };

		//  pilePage.push("personnes.php");
	  xhr.open("POST", "lireAlbum.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="album=./ressources/images/photos/"+nomAlbum;

	     
	  xhr.send(data);

	
	
	
}
function histoire(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	 // alert ('ap zIndex 1001');
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

	//	  pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/histoire.html";

//	  alert ('histoire'+ data);              
	  xhr.send(data);

	
	
	
}
function quiSommesNous(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		 // pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/quiSommesNous.html";

//	  alert ('qui '+ data);              
	  xhr.send(data);

	
	
	
}
function mentionsLegales(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		 // pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/mentionsLegales.html";

//	  alert ('qui '+ data);              
	  xhr.send(data);

	
	
	
}
function contact(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		 // pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/contact.html";

//	  alert ('qui '+ data);              
	  xhr.send(data);

	
	
	
}
function actualites(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		 // pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/actualites.html";

//	  alert ('qui '+ data);              
	  xhr.send(data);

	
	
	
}
function testActualites(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() {
	      if (xhr.readyState === 4) { 
	    		xhr.responseText.evalScripts();
	      }
	      };

		 // pilePage.push("personnes.php");
	  xhr.open("POST", "testExisteActualites.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/actualites.html";

//	  alert ('qui '+ data);              
	  xhr.send(data);

	
	
	
}

function education(){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		 // pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data="fichier=./ressources/textes/education.html";
	  
//	  alert ('education '+ data);       
		        
	  xhr.send(data);

	
	
	
}

function presentationPays(pays){

	
	

	var xhr = new XMLHttpRequest();	 

	  xhr.onreadystatechange = function() { 
	      if (xhr.readyState === 4) { 
	    		
	    	  set_tomax_height('centreTop',-400);
	    	  $('voletcentre').innerHTML = "";
	    	  $('voletcentre').setStyle({zIndex:'1000'});
	    	  var contenu =  document.getElementById('centreTop');
	    	  contenu.setStyle({zIndex:'1001'});
	    	  contenu.innerHTML = xhr.responseText;
	    	  $("imgEncartCoords").setAttribute('src',"./ressources/images/anes.jpg")
	    	  $("encartCoords").innerHTML = "";
	      }
	      };

		 // pilePage.push("personnes.php");
	  xhr.open("POST", "lireText.php",true);
	  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  var data='fichier=./ressources/sejours/'+pays+'/presentation.html';
	  
//	  alert ('education '+ data);       
		        
	  xhr.send(data);

	
	
	
}
	


function set_tomax_height(id_element, majo) {
    if ($(id_element)) {
        var position_element=Position.positionedOffset($(id_element));
        var pos_y=position_element.last();
        $(id_element).style.height = (getWindowHeight()-pos_y+majo)+"px";
    //	alert(id_element+'='+(getWindowHeight())+"px");
    }
}

function set_tomax_width(id_element, majo) {
    if ($(id_element)) {
        var position_element=Position.positionedOffset($(id_element));
        var pos_x=position_element.first();
        $(id_element).style.width = (getWindowWidth()-pos_x+majo)+"px";
    	//alert(id_element+'='+(getWindowWidth()-pos_x+majo)+"px");
    }
}
function getWindowHeight() {
    var windowHeight=0;
   
    	if (document.body&&document.body.clientHeight) {
    //		alert('body');
        windowHeight=document.body.clientHeight;
    }
       
        else { if (document.documentElement&&
            document.documentElement.clientHeight) {
    //		alert('docele');
            windowHeight = document.documentElement.clientHeight;
        }
           
        
    }
    return windowHeight;
}
//renvois de la largeur de la fenetre

function getWindowWidth() {
    var windowWidth=0;
    if (typeof(window.innerWidth)=='number') {
        windowWidth=window.innerWidth;
    }
    else {
        if (document.documentElement&&
            document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        }
        else {
            if (document.body&&document.body.clientWidth) {
                windowWidth=document.body.clientWidth;
            }
        }
    }
    return windowWidth;
}
function ajouteAnimation() {
var contenu =  document.getElementById('contenu');

var obj =  document.createElement("object");
obj.setAttribute("id", "Object1");
obj.setAttribute("type", "application/x-shockwave-flash");
obj.setAttribute("data", "player_flv_mini.swf");
obj.setAttribute("width", "320");
obj.setAttribute("height", "240");
contenu.appendChild(obj);


var parm =  document.createElement("param");
parm.setAttribute("name", "movie");
parm.setAttribute("value", "player_flv_mini.swf");
obj.appendChild(parm);


parm =  document.createElement("param");
parm.setAttribute("name", "wmode");
parm.setAttribute("value", "popaque");
obj.appendChild(parm);

parm =  document.createElement("param");
parm.setAttribute("name", "allowScriptAccess");
parm.setAttribute("value", "sameDomain");
obj.appendChild(parm);

parm =  document.createElement("param");
parm.setAttribute("name", "quality");
parm.setAttribute("value", "high");
obj.appendChild(parm);

parm =  document.createElement("param");
parm.setAttribute("name", "autoplay");
parm.setAttribute("value", "false");
obj.appendChild(parm);

parm =  document.createElement("param");
parm.setAttribute("name", "autoload");
parm.setAttribute("value", "false");
obj.appendChild(parm);

parm =  document.createElement("param");
parm.setAttribute("name", "FlashVars");
parm.setAttribute("value", "flv=P1030890(2).flv&width=320&height=240&autoplay=0&autoload=0&buffer=5&playercolor=000000 &loadingcolor=9b9a9a&buttoncolor=ffffff&slidercolor=ffffff");
obj.appendChild(parm);

}
