var isf={'clock':null,'fade':true,'count':1}
var imageLoaded=false;function swapfade(obj,src,height,width,title,duration,resolution)
{if(isf.clock==null)
{var image=new Image();image.src=src;isf.obj=obj;isf.src=src;isf.height=height;isf.width=width;if(typeof isf.obj.style.opacity!='undefined')
{isf.type='w3c';}
else if(typeof isf.obj.style.MozOpacity!='undefined')
{isf.type='moz';}
else if(typeof isf.obj.style.KhtmlOpacity!='undefined')
{isf.type='khtml';}
else if(typeof isf.obj.filters=='object')
{isf.type=(isf.obj.filters.length>0&&typeof isf.obj.filters.alpha=='object'&&typeof isf.obj.filters.alpha.opacity=='number')?'ie':'none';}
else
{isf.type='none';}
isf.obj.title=title;isf.obj.alt=title;if(isf.type!='none')
{isf.length=parseInt(duration,10);isf.resolution=parseInt(resolution,10);isf.clock=setInterval('isf.swapfade()',isf.length/isf.resolution);}
else
{isf.obj.src=isf.src;}}};isf.swapfade=function()
{if(isf.obj.complete){if(isf.fade){isf.count=isf.count*0.7;}else{isf.count=isf.count*(1/0.7);}
if(isf.count<(1/isf.resolution))
{clearInterval(isf.clock);isf.clock=null;isf.obj.src=isf.src;isf.obj.width=isf.width;isf.obj.height=isf.height;isf.fade=false;isf.clock=setInterval('isf.swapfade()',isf.length/isf.resolution);}
if(isf.count>(1-(1/isf.resolution)))
{clearInterval(isf.clock);isf.clock=null;isf.fade=true;isf.count=1;}
switch(isf.type)
{case'ie':isf.obj.filters.alpha.opacity=isf.count*100;break;case'khtml':isf.obj.style.KhtmlOpacity=isf.count;break;case'moz':isf.obj.style.MozOpacity=(isf.count==1?0.9999999:isf.count);break;default:isf.obj.style.opacity=(isf.count==1?0.9999999:isf.count);}}};function hideId(id){if(document.getElementById){var element=document.getElementById(id);if(element){element.style.display='none';}}}
function showId(id){if(document.getElementById){var element=document.getElementById(id);if(element){element.style.display='block';}}}
function precedent(){if(currentId>0){currentId=currentId-1;afficherImage(currentId);}}
function suivant(){if(currentId+1<tabPhotos.length){currentId=currentId+1;afficherImage(currentId);}}
function afficherImage(i){if(i>=0&&i<tabPhotos.length){currentId=i;if(i==0){hideId('precedent');}else{showId('precedent');changerLien('lien_precedent',tabPhotos[i-1][4]);}
if(i==tabPhotos.length-1){hideId('suivant');}else{showId('suivant');changerLien('lien_suivant',tabPhotos[i+1][4]);}
var image=tabPhotos[i];changerImage(image[0],image[1],image[2],image[3]);}}
function changerImage(fichier,hauteur,largeur,description){if(document.getElementById){var image=document.getElementById('photo');if(image){imageLoaded=false;swapfade(image,fichier,hauteur,largeur,description,1000,20);}
var lienImage=document.getElementById('lien_image');if(lienImage){lienImage.href=fichier;}
var texteImage=document.getElementById('descriptionText');if(texteImage){texteImage.innerHTML='<p>'+description+'</p>';}}}
function onLoadImgGalerie(){imageLoaded=true;}
function changerLien(id,url){if(document.getElementById){var lien=document.getElementById(id);if(lien){lien.href=url;}}}
compteur=0;currentTimer=1;elements=new Array();stopElipse=false;function initElipse(){var container=document.getElementById('photosTournantes');var blocListe=document.getElementById('listephotos');var newnode=document.createElement("span");container.style.height='350px';container.style.position='relative';elements=ajouterElementsPhotos(blocListe,container);newnode.setAttribute('id','text');container.appendChild(newnode);newnode.style.width=container.offsetWidth+'px';newnode.style.textAlign='center';newnode.style.position='absolute';newnode.style.top=Math.round(container.offsetHeight/2-40)+'px';newnode.style.left='0px';tourner(1);}
function tourner(val){if(!stopElipse&&val==currentTimer){var container=document.getElementById('photosTournantes');var x=container.offsetWidth-90;var y=container.offsetHeight-120;var espace=150/elements.length;for(i=0;i<elements.length;i++){position(elements[i],compteur+espace*i,x,y);}
compteur++;setTimeout('tourner('+val+')',80);}}
function position(element,val,x,y){var o=val/150*(Math.PI*2);var coefX=(Math.cos(o)+1)/2;var coefY=(Math.sin(o)+1)/2;var coef=(coefY+1)/2;var newX=coefX*x+20;var newY=coefY*y+20;var width=Math.round(coef*element[2]);var height=Math.round(coef*element[3]);var zindex=Math.round(coefY*100);element[0].style.left=newX+'px';element[0].style.top=newY+'px';element[0].style.zIndex=zindex;element[1].style.width=width+'px';element[1].style.height=height+'px';}
function ajouterElementsPhotos(blocPhotos,container){var node=blocPhotos.firstChild;elements=new Array();while(node){if(node.tagName&&node.tagName=="A"){var newNode=document.createElement('a');newNode.setAttribute('href',node.href);container.appendChild(newNode);newNode.style.position='absolute';var tab=new Array();tab[0]=newNode;var texte=node.textContent;newNode.setAttribute('onmouseover','survol(\''+node.textContent+'\')');newNode.setAttribute('onmouseout','finsurvol()');var child=node.firstChild;while(child){if(child.tagName){if(child.tagName=="IMG"){var newChild=document.createElement('img');newChild.setAttribute('src',child.src);newNode.appendChild(newChild);tab[1]=newChild;tab[2]=child.offsetWidth;tab[3]=child.offsetHeight;}}
child=child.nextSibling;}
elements.push(tab);}
node=node.nextSibling;}
return elements;}
function survol(texte){var text=document.getElementById('text');if(text){stopElipse=true;var node=document.createTextNode(texte);text.appendChild(node);}}
function finsurvol(){var text=document.getElementById('text');if(text){stopElipse=false;currentTimer++;tourner(currentTimer);var node=text.firstChild;while(node){var oldNode=node;node=node.nextSibling;text.removeChild(oldNode);}}}
