
// On declare les variables necessaire à notre effet
	var voletDroit=null;
// On definit notre effet
	function Move()
	{
		var style=voletDroit.style;
		var marginRight=parseInt(style.marginRight)+Move.step;
		if(marginRight<=Move.end)
		{
			style.marginRight=Move.end+"px";
			window.clearInterval(Move.timer);
		}
		else
		{
			style.marginRight=marginRight+"px";
		}
	}
	Move.value=0;
	Move.step=1;
	Move.timer=null;
	Move.fps=25;
	Move.duration=500;
	Move.start=250;
	Move.end=0;



function getBox(obj)
{
	var rectangle=new Array();
	if(!obj) alert("getAbsoluteRect: obj n'existe pas");
	rectangle.left=0;
	rectangle.top=0;
	var borderLeftWidth=parseInt(obj.style.borderLeftWidth) || 0;
	var borderRightWidth=parseInt(obj.style.borderRightWidth) || 0;
	var borderTopWidth=parseInt(obj.style.borderTopWidth) || 0;
	var borderBottomWidth=parseInt(obj.style.borderBottomWidth) || 0;
	rectangle.width=parseInt(obj.offsetWidth)-borderLeftWidth-borderRightWidth;
	rectangle.height=parseInt(obj.offsetHeight)-borderTopWidth-borderBottomWidth;
	if(obj.offsetParent)
	{
		rectangle.left=obj.offsetLeft;
		rectangle.top=obj.offsetTop;
		while(obj=obj.offsetParent)
		{
			rectangle.left+=obj.offsetLeft;
			rectangle.top+=obj.offsetTop;
		}
	}
	return rectangle;
}
	
function initMove(node)
{
	var style=node.style;
		style.marginRight=Move.start+"px";
		var interval=Move.fps/(1000/Move.duration);
		Move.step=(Move.end-Move.start)/interval;
	//	alert(Move.step);
	// On lance l'effet
		Move.timer=window.setInterval("Move()",interval);
}
function openMenu()
{
	var flyer=document.getElementById("voletGauche");
	var content=Menu.getContent(this.getAttribute("id"));
	if(content)
	{
		var box=getBox(this);
			flyer.style.left=box.left+"px";
			flyer.style.top=(box.top+this.offsetHeight)+"px";
			while(flyer.childNodes.length)
			{
				flyer.removeChild(flyer.childNodes[0]);
			}
			flyer.appendChild(content);
		flyer.parentNode.appendChild(flyer);
		flyer.style.visibility="visible";
	}
	else
	{
		flyer.style.visibility="hidden";
	}
}
function loaded()
{
	// On precharge notre jeu d'image
		var content=document.getElementById("content");
		var suppr=document.getElementById("suppr");
			content.removeChild(suppr);
		var rect=getBox(content);
	/*
			content.style.height=rect.height+"px";
			content.style.overflow="hidden";
			ImageSet.width=rect.width;
			ImageSet.height=rect.height;
			ImageSet.preLoad();
	*/
	// On cache le volet droit pour lui donner un ptit effet
		//voletDroit=document.getElementById("voletDroit");
		//	voletDroit.style.visibility="hidden";
		//	voletDroit.style.position="absolute";
		//	voletDroit.style.top=rect.top+"px";
		//	voletDroit.style.width=(rect.width/3)+"px";
		//	voletDroit.style.heigth=rect.height+"px";
		//	voletDroit.style.left=(rect.left+rect.width-voletDroit.offsetWidth)+"px";
		//document.getElementsByTagName("body")[0].appendChild(voletDroit);
	// Entre temps, on fabrique notre menu flotant
		var sousMenu=document.getElementById("voletGauche");
			sousMenu.style.position="absolute";
			sousMenu.style.visibility="hidden";
			sousMenu.style.marginLeft="0px";
			sousMenu.style.marginRight="0px";
			sousMenu.style.marginTop="0px";
			sousMenu.style.marginBottom="0px";
			/*sousMenu.style.opacity="0.7";*/
		document.getElementsByTagName("body")[0].appendChild(sousMenu);
		var menu=document.getElementById("menu");
			var maxi=menu.childNodes.length;
			for(var i=0;i<maxi;i++)
			{
				menu.childNodes[i].onmouseover=openMenu;
			}
	// On l'affiche
	//	voletDroit.style.visibility="visible";
	//	initMove(voletDroit);
	
	
	
	
}








function Ouvrir()
{
	var stop=false;
	var style=Ouvrir.haut.style;
		var marginTop=parseInt(style.marginTop);
		if(-marginTop<Ouvrir.haut.offsetHeight) style.marginTop=(marginTop-10)+"px";
		else stop=true;
	var style=Ouvrir.bas.style;
		var marginTop=parseInt(style.marginTop);
		if(marginTop<Ouvrir.bas.offsetHeight) style.marginTop=(marginTop+10)+"px";
		else if(stop)
			{
				window.clearInterval(Ouvrir.timer);
				Ouvrir.haut.parentNode.parentNode.removeChild(Ouvrir.haut.parentNode);
				Ouvrir.bas.parentNode.parentNode.removeChild(Ouvrir.bas.parentNode);
				diaporama();
			}
}
Ouvrir.timer=null;

function Ouverture()
{
	var main=document.getElementById("main");
	var rect=getBox(main);
	
	var IMG_HAUT=document.getElementById("porte_haut");
		IMG_HAUT.style.margin="0px";
		IMG_HAUT.style.padding="0px";
	var DIV_HAUT=IMG_HAUT.parentNode;
		DIV_HAUT.style.position="absolute";
		DIV_HAUT.style.top="0px";
		DIV_HAUT.style.left=rect.left+"px";
		DIV_HAUT.style.height=IMG_HAUT.offsetHeight+"px";
		DIV_HAUT.style.margin="0px";
		DIV_HAUT.style.padding="0px";
	var IMG_BAS=document.getElementById("porte_bas");
		IMG_BAS.style.margin="0px";
		IMG_BAS.style.padding="0px";
	var DIV_BAS=IMG_BAS.parentNode;
		DIV_BAS.style.position="absolute";
		DIV_BAS.style.top=IMG_HAUT.offsetHeight+"px";
		DIV_BAS.style.height=IMG_HAUT.offsetHeight+"px";
		DIV_BAS.style.left=rect.left+"px";
		DIV_BAS.style.margin="0px";
		DIV_BAS.style.padding="0px";
		
	DIV_HAUT.style.visibility="visible";
	DIV_BAS.style.visibility="visible";
	DIV_HAUT.parentNode.appendChild(DIV_HAUT);
	DIV_BAS.parentNode.appendChild(DIV_BAS);
	Ouvrir.haut=IMG_HAUT;
	Ouvrir.bas=IMG_BAS;
	
	
	ImageSet.oncomplete=function() {window.setTimeout("OuvertureGo();",1500);};
	ImageSet.preLoad();
}


function OuvertureGo()
{
	Ouvrir.timer=window.setInterval("Ouvrir()",100);
}





function diaporama()
{
	var width=diaporama.width;
	var height=diaporama.height;
		var content=document.getElementById("content");
		var voletDroit=document.getElementById("voletDroit");
			var cHeight=content.offsetHeight;
			var mHeight=height;
			if(mHeight>cHeight) mHeight=cHeight-voletDroit.offsetHeight;
		var DIV=document.createElement("div");
			DIV.style.width=width+"px";
			DIV.style.height=mHeight+"px";
			var v1=document.createElement("img");
				v1.setAttribute("src",ImageSet.getNext());
				v1.style.backgroundColor="black";
				v1.style.width=width+"px";
				v1.style.height=mHeight+"px";
				v1.style.position="absolute";
				v1.style.visibility="hidden";
				v1.style.marginLeft=((voletDroit.offsetWidth-width)/2)+"px";
			document.getElementsByTagName("body")[0].appendChild(v1);
		voletDroit.appendChild(DIV);
		var box=getBox(DIV);
		v1.style.left=box.left+"px";
		v1.style.top=box.top+"px";
		v1.style.visibility="visible";
		nextPict.v1=v1;
		window.setInterval("nextPict()",5000);
}
diaporama.width=800;
diaporama.height=800;



function nextPict()
{
	nextPict.v1.setAttribute("src",ImageSet.getNext());
}





function showPict()
{
	var src=this.getAttribute("src");
	var content=document.getElementById("content");
		content.style.backgroundImage="url(./"+src+")";
}






