var xhr = null;
function getXhr(){
				if(window.XMLHttpRequest) // Firefox et autres
				   xhr = new XMLHttpRequest(); 
				else if(window.ActiveXObject){ // Internet Explorer 
				   try {
			                xhr = new ActiveXObject("Msxml2.XMLHTTP");
			            } catch (e) {
			                xhr = new ActiveXObject("Microsoft.XMLHTTP");
			            }
				}
				else { // XMLHttpRequest non supporté par le navigateur 
				   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
				   xhr = false; 
				} 
}

function aff_auto(page){
				getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						document.getElementById('aff_auto_site').innerHTML = xhr.responseText;
					}
				}
				xhr.open("POST","aff_auto_site.php",true);
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				xhr.send('PG='+page);
     window.setTimeout("aff_auto('"+page+"')",5000) ;
}

function open_menu_temp(id){
				getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						// On se sert de innerHTML pour rajouter de l'information
						document.getElementById('win_menu_temp').innerHTML = xhr.responseText;
					}
				}
				xhr.open("POST","img/page_menu.php",true);
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded','charset= iso-8859-15');
				xhr.send("id="+id);
				//document.getElementById('fond').style.height = '100%';
				//document.getElementById('fond').style.width = '100%';
        document.getElementById('win_menu_temp').innerHTML = '<em>Chargement...</em>';
}

/*
         on load init(page)
// mettre un minimum de 4 images !!!

var coef = 0.05 ; // avancement de l'opacité
var temps = 50 ; // temps entre chaque changement d'opacité
var temps_pause = 10000 ; // temps d'attente entre 2 changements d'images
var nombre_image = 6 ; // nombre d'images a faire bouger
var prefix_image = 'fond/fond_img_'; // chemin + prefix du nom des images
var suffix_image = '.jpg' ; // suffix + '.extension' du nom des images

// pas touche
var indice = 1; // les 2 premiere image sont deja charger dans le HTML, on commence a la 3eme
var isIE = navigator.userAgent.toLowerCase().indexOf('msie')!=-1 ;
var img1 = null;
var img2 = null ;
var sens = 1;
var tabImg;  // tab contenant les images

function prechargerImg(){
  tabImg = new Array(nombre_image);
  for (i=0; i<=nombre_image -1; i++){
	tabImg[i]=new Image();
	tabImg[i].background = prefix_image+(i+1)+suffix_image;
  }
}

function init(page)
{
	aff_auto(page) ; // affichage automatique des infos
  img1 = document.getElementById("defilement");
	img2 = document.getElementById("defilement");
  //img1 = document.getElementById("defilement") ;
	//img2 = document.getElementById("defilement") ;

	prechargerImg();
	change_opacity();
}

function change_opacity()
{	
	var opacity1 = 0 ;
	var opacity2 = 0 ;

	// on fait varié le sens d'opacité du bazar
	if (opacity2  <= 0)
	{	img2.background=tabImg[indice++].background;
		sens = 0;
		if (indice == (tabImg.length)) indice=0;
		window.setTimeout("change_opacity()",temps_pause) ; // attente
		return 0;
	}
	else if (opacity1 <= 0)
	{	img1.background=tabImg[indice++].background;
		sens = 1;
		if (indice == (tabImg.length)) indice=0;
		window.setTimeout("change_opacity()",temps_pause) ; // attente
		return 0;
	}
	//window.status = "opa1 : " + img1.style.MozOpacity + "  opa2 : " + img2.style.MozOpacity + "   indice : "+indice;
	window.setTimeout("change_opacity()",temps) ; // recursion toutes les 30 millisec
}
*/
