// JavaScript Document
function sequentialgallery()
{
	var picId='bigDynPic';
	var d=document.getElementById('thumbs');
	if(!d){return;}
	var piclinks=d.getElementsByTagName('a');
	var divs=d.getElementsByTagName('div');
	for(var i=0;i<piclinks.length;i++)
	{
		piclinks[i].i=i;

		piclinks[i].onclick=function()
		{
			if(!/sequential/.test(d.className)){d.className='sequential';}
			
			for(var j=0;j<piclinks.length;j++)
			{
				piclinks[j].parentNode.className=(j==this.i)?'current':'';
				if (j==this.i+1){			
				piclinks[j].parentNode.className='rights';}
				if (j==this.i-1){
				piclinks[j].parentNode.className='lefts';}
				piclinks[j].parentNode.style.display=(j<this.i-1 || j==this.i || j>this.i+1)?'none':'block';
			}
			var oldprev=document.getElementById('prevId');
			if(oldprev)
			{
			 oldprev.parentNode.removeChild(oldprev);
			}
			prev = document.createTextNode("précédente ");
			prevp = document.createElement('span');
			prevp.id='prevId'; 
			prevp.appendChild(prev);
			if (this.i != 0) {
				piclinks.item(this.i-1).insertBefore(prevp, piclinks.item(this.i-1).getElementsByTagName('img')[0] );
				}
			next = document.createTextNode(" suivante");
			nextp = document.createElement('span');
			nextp.id='nextId'; 
			nextp.appendChild(next);
			var oldnext=document.getElementById('nextId');
			if(oldnext)
			{
			 oldnext.parentNode.removeChild(oldnext);
			}
			if (this.i+1 < divs.length) {
				piclinks.item(this.i+1).appendChild(nextp);}
			
			var oldp=document.getElementById(picId);
			if(oldp)
			{
			 oldp.parentNode.removeChild(oldp);
			}
			var nc=document.createElement('div');
			lastdiv=document.getElementById('last');
			lastdiv.parentNode.insertBefore(nc, lastdiv);
			nc.style.display='none';
			nc.id=picId;
			var newpic=document.createElement('img');
			newpic.src=this.href;
			newpic.alt=this.getElementsByTagName('img')[0].alt;
			newpic.title='Cliquer pour revenir aux photos';
			newpic.onclick=function()
			{
				window.location=window.location;
			}
			nc.appendChild(newpic);
			np=document.createElement('p');
			np.appendChild(document.createTextNode(''));
			nc.appendChild(np);
			
			nc.style.display='block';
			return false;
		}
	}		

}

window.onload=function()
{
	if(document.getElementById && document.createTextNode)
	{
		document.body.onmouseover=function()
		{
			sequentialgallery();	
		}																
	}
}


