var image_curr='';


function hasloaded(image,wintop,largeur,hauteur)
{
  

	if(hauteur-image.height>0)
	{
    
		var posh=wintop+(hauteur-image.height)/2;
  
	}
	else
	{
    
		var posh=wintop+10;
  
	}
 

 	if(largeur-image.width>0)
	{
    
		var posl=(largeur-image.width)/2;
  
	}
  
	else
	{
    
		var posl=10;
  
	}
  

	var img1 = '<img src="/images/shadow.png" border="0" width="1" height="'+image.height+'" class="png" alt="" />';
  
	var img2 = '<img src="/images/shadow_bottom.png" border="0" width="'+image.width+'" height="1" class="png" alt="" />';
  
	var img3 = '<img src="/images/shadow_corner.png" border="0" width="1" height="1" class="png" alt="" />';
	

	if((image_curr!='') && (image_curr!=image.src) && (document.getElementById("fullimage").style.display=="block"))
  
	{
    
		document.getElementById("fullimage").innerHTML = "";
    		
		document.getElementById("fullimage").style.display = "none";
    
		document.getElementById("fullimage").style.top = posh+"px";
    
		document.getElementById("fullimage").style.left = posl+"px";
    
		document.getElementById("fullimage").innerHTML = "<div class=\"dropshadow2\"><div class=\"dropshadow2\"><a href=\"javascript:FullImage('"+image.src+"')\"><img title=\"Fermer\" alt=\"Fermer\" src=\""+image.src+"\" width="+image.width+" height="+image.height+" border=\"0\" /></a>"+img1+"</div>"+img2+""+img3+"</div>";
    
		document.getElementById("fullimage").style.display = "block";
    
		document.getElementById("fullimage").style.zIndex = 101000;

  
	}
	else if(document.getElementById("fullimage").style.display=="none")
	{
    
		document.getElementById("fullimage").style.top = posh+"px";
    
		document.getElementById("fullimage").style.left = posl+"px";
    
		document.getElementById("fullimage").innerHTML = "<div class=\"dropshadow2\"><div class=\"dropshadow2\"><a href=\"javascript:FullImage('"+image.src+"')\"><img title=\"Fermer\" alt=\"Fermer\" src=\""+image.src+"\" width="+image.width+" height="+image.height+" border=\"0\" /></a>"+img1+"</div>"+img2+""+img3+"</div>";
    
		document.getElementById("fullimage").style.display = "block";
    
		document.getElementById("fullimage").style.zIndex = 500000;
  
	}
	else
	{
 
	   	document.getElementById("fullimage").innerHTML = "";
    		
		document.getElementById("fullimage").style.display = "none";
  
	}
  
	image_curr=image.src;

}




function FullImage(arg)
{
	

	var wintop=10;
	
	if (document.getElementById) 
	{ 
		//IE5
		
		var wintop=parseInt(document.body.scrollTop);
		
		var hauteur=document.body.clientHeight;
		
		var largeur=document.body.clientWidth;
	
	}
	

	if ((document.getElementById) && (document.all)) 
	{ 
		//IE6
		
		var wintop=parseInt(document.documentElement.scrollTop);
		
		var hauteur=document.documentElement.clientHeight;
		
		var largeur=document.documentElement.clientWidth;
	
	}
	

	if ((document.getElementById) && (!document.all)) 
	{ 
		//NS6
		
		var wintop=parseInt(window.pageYOffset);
		
		var hauteur=window.innerHeight;
		
		var largeur=window.innerWidth;
	
	}
	

	var image=new Image;
	
	image.src=arg;
	
	if(!image.complete)		
	image.onload = function(){hasloaded(this,wintop,largeur,hauteur)};
	
	else hasloaded(image,wintop,largeur,hauteur);


}






function openGal(idArt) 
{
	
	window.location.href = "#";
	
	if(typeof(eval(refrech)) != 'undefined') clearTimeout(refrech);
	
	if(!document.getElementById("loading")) 
	{
	  
		loading = document.createElement("div");
	  
		loading.id = "loading";
	  
		loading.className = "loading";
	  
		try
 {
 document.getElementsByTagName("body")[0].appendChild(loading);
}
  	
		catch(error)
 {
  window.setTimeout("openGal("+idArt+")", 1000);
 }
	
	}
	
	loading.innerHTML = 'chargement...';
	
	gal_opened = true;
	
	if(document.getElementById("pubTop")) document.getElementById("pubTop").style.display='none';
	
	if(document.getElementById("pubPave")) document.getElementById("pubPave").style.display='none';
	
	if(document.getElementById("pubSky")) document.getElementById("pubSky").style.display='none';
	
	if(!document.getElementById("galFade")) 
	{
	  
		div1 = document.createElement("div");
	  
		div1.id = "galFade";
	  
		div1.className = "gal_fade";
	  
		div1.onclick = closeGal;
	  
		div1.style.height = (document.body.scrollHeight)+"px";
	  
		div1.style.width = (document.body.scrollWidth)+"px";
    
		document.getElementsByTagName("body")[0].appendChild(div1);

	}
	
	if(!document.getElementById("galConteneurFond")) 
	{
	  
		div2 = document.createElement("div");
	  
		div2.id = "galConteneurFond";
	  
		div2.className = "gal_conteneurfond";
    
		document.getElementsByTagName("body")[0].appendChild(div2);
	
	}
	
	if(!document.getElementById("galConteneur")) 
	{
	  
		div3 = document.createElement("div");
	  
		div3.id = "galConteneur";
	  
		div3.className = "gal_conteneur";
    
		document.getElementsByTagName("body")[0].appendChild(div3);
	
	}

	

	var fadeFond = document.getElementById("galFade");
	
	var divPlaceFond = document.getElementById("galConteneurFond");
	
	var divPlace = document.getElementById("galConteneur");
	divPlace.innerHTML = '';
	
	
	

	if (divPlace.style.display!='block') 
	{
	  	
	//fadeFond.style.display = 'block';

	//divPlace.style.display = 'block';
	
		
  	
	frame = document.createElement("iframe");
  	
	frame.scrolling = "no";
  	
	frame.frameBorder = "0";
  	
	frame.name = "galFrame";
  	
	frame.className = "gal_frame";
	

	if(idArt==0) frame.src = "/diaporama.php";
  	
	else frame.src = "/diaporama.php?id="+idArt;
		




	function addLoadEvent(func) 
	{
		  
		var oldonload = frame.onload;
		  
		if (typeof frame.onload != 'function') 
		{
		    
			frame.onload = func;
		  
		} 
		else 
		{
		    
			frame.onload = function() 
			{
		      
				if (oldonload) {
 oldonload();
 }
		      			
				func();
		    
			}
		  
		}
		

	}
		

	addLoadEvent(function() {
 document.getElementById("loading").style.display="none";
 });		
  	
	divPlace.appendChild(frame);
		
	var t1 = new Sequence();
		
	fadeFond.style.display="block";	
		
	divPlaceFond.style.display="block";	
		
	divPlace.style.display="block";	
		
	
	opacityTween1 = new OpacityTween(fadeFond,Tween.regularEaseOut, 0, 85, 0.2);
		
	opacityTween3 = new OpacityTween(divPlace,Tween.regularEaseOut, 0, 100, 0.5);
		
		
	sizeTween2 = new Tween(divPlaceFond.style,'height',Tween.regularEaseOut,0,680,0.2,'px');
		
		
	t1.addChild(opacityTween1);
		
	t1.addChild(sizeTween2);
		
	t1.addChild(opacityTween3);
	
		
	t1.play();
	
	}
	
	else 
	{
		
	document.getElementById("pubTop").style.display='block';
		
	document.getElementById("pubPave").style.display='block';
	  
	fadeFond.style.display = 'none';
	  	
	divPlace.style.display = 'none';
	
	}
	

	if(document.documentElement.clientHeight<500 || document.documentElement.clientWidth<500) galPos();


}





var refrech;


