// JavaScript Document
function affiche (obj) {
		var i = document.getElementById("div_image");
		var p = document.getElementById("div_photo");
		document.getElementById("bouton_fermer").style.visibility = "hidden";
		image = obj.name;
		height = obj.title;
		height = height*1;
		width = obj.alt;
		width = width*1;
		nb = obj.id;
		nb = nb*1;
		nb_total = document.getElementById("nombre").value;
		i.src = "./images/"+image;
		p.height = height;
		p.width = width;
		appear("div_noircir",70,8);
		i.style.visibility = "visible";
		document.getElementById("div_photo").style.visibility = "visible";
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
		grandit("div_image",7,height,width);
		setTimeout('document.getElementById("bouton_fermer").style.visibility = "visible"',1000);
		if (nb!=1) setTimeout('document.getElementById("bouton_prec").style.visibility = "visible"',1000);
		if (nb != (nb_total-1)) setTimeout('document.getElementById("bouton_suiv").style.visibility = "visible"',1000);
		}
		else {
		grandit("div_image",70,height,width);
		setTimeout('document.getElementById("bouton_fermer").style.visibility = "visible"',1000);
		if (nb!=1) setTimeout('document.getElementById("bouton_prec").style.visibility = "visible"',1000);
		if (nb != (nb_total-1)) setTimeout('document.getElementById("bouton_suiv").style.visibility = "visible"',1000);
		}
}
function ferme (obj) {
		fade("div_noircir",70,8);
		document.getElementById("div_photo").style.visibility = "hidden";
		document.getElementById("div_image").style.visibility = "hidden";
		document.getElementById("bouton_fermer").style.visibility = "hidden";
		document.getElementById("bouton_suiv").style.visibility = "hidden";
		document.getElementById("bouton_prec").style.visibility = "hidden";
		var i = document.getElementById("div_image")
		i.src= "../images/chargeur02.gif"		
}
function image_prec() {
		nb = nb*1;
		var n = nb-1;
		chgt(n);
		/*xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Your browser does not support AJAX!");
  			return;
  		}
		var url="changer_image.php";
		url=url+"?i="+image+"&sens=moins";
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChanged;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);*/
}
function image_suiv() {
		nb = nb*1;
		var n = nb+1;
		chgt(n);
		/*xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Your browser does not support AJAX!");
  			return;
  		}
		var url="changer_image.php";
		url=url+"?i="+image+"&sens=plus";
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=stateChanged;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);*/
}
function chgt(n) {
		var g = document.getElementById(n);
		var im = g.name;
		var h = g.title;
		h = h*1;
		//document.write(h);
		var l = g.alt;
		l = l*1;
		var p = document.getElementById("div_photo");
		p.style.backgroundColor = "#000000";
		p.height = h;
		p.width = l;
		var i = document.getElementById("div_image");
		//fade("div_image",70,10);
		i.src = "./images/"+im;
		i.height = h;
		i.width = l;
		//appear("div_image",70,10);
		//setOpacity("div_image",10)
		image=im;
		nb = n;
		var i = document.getElementById("bouton_prec");
		i.style.visibility = "visible";
		if (nb == 1) i.style.visibility = "hidden";
		var i = document.getElementById("bouton_suiv");
		i.style.visibility = "visible";
		var k = document.getElementById("nombre").value;
		if (nb == k-1) i.style.visibility = "hidden";
}
function setOpacity(domId, val) {
	if (val > 10) val = 10;
	obj = document.getElementById(domId);
	obj.style.MozOpacity = val;
	obj.style.opacity = val/10;
	var val2 = val*10;
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
		obj.filters.alpha.opacity = val2;
	}
}
function fade(domId,time,opacite){
	obj = document.getElementById(domId);
	//if(obj.style.visibility == "hidden") return false;
	var alpha = opacite;
	function f(){ //Internal function
		alpha--; //Decrement the alpha value  
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
	 	if(alpha > -1){ //If alpha is still bigger than -1 then..   
	 		setTimeout(f, time); //..then call the function again after 100 milliseconds
	  		}
	  	else { //otherwise..   
	  		obj.style.visibility = "hidden"; //..otherwise now that we cant see the element anyways, hide it  
	  		}
	 }
	  setTimeout(f, time); //This is where we call the f() function for the first time
}
function appear(domId,time,opacite){
	obj = document.getElementById(domId); 
	//if (obj.style.visibility != "hidden") return false;
	var alpha = 0; //Set the initial value of alpha to 0 (invisible)
	setOpacity(domId, alpha);
	obj.style.visibility = "visible";
	function a(){ //Internal function  
		alpha++; //Increment alpha  
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha  
		if(alpha < opacite)setTimeout(a, time);/*Till alpha is 10, keep calling thea() function after 100 milliseconds */
	}
	setTimeout(a, time); //This is where we call the a() function for the first time
}
function setsize(domId,h,l,hauteur,largeur) {
	obj = document.getElementById(domId);
	obj.height = h;
	obj.width = l;
	/*var la=hauteur/2-h/2;
	var ha=largeur/2-l/2;
	obj.style.left = la;
	obj.style.top = ha;*/
}
function grandit(domId,time,hauteur,largeur){
	obj = document.getElementById(domId); 
	//if (obj.style.visibility != "hidden") return false;
	var h = 0;
	var l = 0;
	setsize(domId,h,l,hauteur,largeur);
	obj.style.visibility = "visible";
	function a(){ //Internal function  
		h=h+(hauteur/9);
		l=l+(largeur/9);
		setsize(domId,h,l,hauteur,largeur);
		if(h < hauteur)setTimeout(a, time);
	}
	setTimeout(a, time); //This is where we call the a() function for the first time
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		var im = xmlhttp.responseText;
		//document.write(im);
		//document.write(n);
		var h = document.getElementById(n).title;
		h = h*1;
		//document.write(h);
		var l = document.getElementById(n).alt;
		l = l*1;
		var p = document.getElementById("div_photo");
		p.style.backgroundColor = "#000000";
		p.height = h;
		p.width = l;
		var i = document.getElementById("div_image");
		//fade("div_image",70,10);
		i.src = "./images/"+im;
		i.height = h;
		i.width = l;
		//appear("div_image",70,10);
		//setOpacity("div_image",10)
		image=im;
		nb = n;
		var i = document.getElementById("bouton_prec");
		i.style.visibility = "visible";
		if (nb == 1) i.style.visibility = "hidden";
		var i = document.getElementById("bouton_suiv");
		i.style.visibility = "visible";
		var k = document.getElementById("nombre").value;
		if (nb == k-1) i.style.visibility = "hidden";
	}
}
