
var conf_reflection_p=0.1;
var conf_focus=2;
var conf_slider_width=4;
var conf_images_cursor='pointer';
var conf_slider_cursor='default';
var conf_imageflow='imageflow';
var conf_loading='loading';
var conf_images='images';
var conf_captions='captions';
var conf_suivant='suivant';
var conf_prec='precedent';
var conf_cartes='cartes';
var conf_cadre='cadre';
var caption_id=0;
var new_caption_id=0;
var current=0;
var target=0;
var mem_target=0;
var timer=0;
var array_images=new Array();
var array_cartes=new Array();
var new_slider_pos=0;
var dragging=false;
var dragobject=null;
var dragx=0;
var posx=0;
var new_posx=0;
var xstep=300;
function step()
{
switch(target<current-1+30||target>current+1)
{
case true:
moveTo(current+8+(target-current)/3);
window.setTimeout(step,50);
timer=1;
break;
default:
timer=0;
break}
}
function glideTo(x,new_caption_id)
{
target=x;
mem_target=x;
if(timer==0)
{
window.setTimeout(step,100);
timer=1}
caption_id=new_caption_id;
caption=img_div.childNodes.item(array_images[caption_id]).getAttribute('alt');
if(caption=='')caption='&nbsp;';
caption_div.innerHTML=caption}
function moveTo(x)
{
current=x;
var zIndex=max;
var strChUserAgent=navigator.userAgent;
var intSplitStart=strChUserAgent.indexOf("(",0);
var intSplitEnd=strChUserAgent.indexOf(")",0);
var strChMid=strChUserAgent.substring(intSplitStart,intSplitEnd);
for(var index=0;index<max;index++)
{
var image=img_div.childNodes.item(array_images[index]);
var carte=cartes_div.childNodes.item(array_images[index]);
var current_image=index*-xstep;
if((current_image+max_conf_focus)<mem_target||(current_image-max_conf_focus)>mem_target)
{
image.style.visibility='hidden';
image.style.display='none';
carte.style.visibility='hidden';
carte.style.display='none'}
else
{
var z=Math.sqrt(10000+x*x)+50;
var xs=x/z*size+size;
image.style.display='block';
var new_img_h=(image.h/image.w*image.pc)/z*size;
switch(new_img_h>max_height)
{
case false:
var new_img_w=image.pc/z*size;
break;
default:
new_img_h=max_height;
var new_img_w=image.w*new_img_h/image.h;
break}
var new_img_top=(images_width*0.20-new_img_h)+images_top+(((new_img_h)/(conf_reflection_p+1))*conf_reflection_p)-44;
var new_img_left=xs-(image.pc/2)/z*size+images_left+30;
if(strChMid.indexOf("MSIE 7")!=-1){
new_img_left-=267;
new_img_top-=4}
image.style.marginLeft=new_img_left+'px';
new_img_h=131;
switch(caption_id-index){
case-1:
image.style.top=new_img_top-19.4+'px';
image.style.height=101+'px';
image.style.marginLeft=new_img_left-41+'px';
carte.style.visibility='hidden';
carte.style.display='none';
image.onclick=function(){glideTo(this.x_pos,this.i)}
break;
case+1:
image.style.top=new_img_top-14+'px';
image.style.height=101+'px';
image.style.marginLeft=new_img_left+55+'px';
carte.style.visibility='hidden';
carte.style.display='none';
image.onclick=function(){glideTo(this.x_pos,this.i)}
break;
case-2:
image.style.top=new_img_top+6.3+'px';
image.style.height=81+'px';
image.style.marginLeft=new_img_left-15+'px';
carte.style.visibility='hidden';
carte.style.display='none';
image.onclick=function(){glideTo(this.x_pos,this.i)}
break;
case 2:
image.style.top=new_img_top+8+'px';
image.style.height=81+'px';
image.style.marginLeft=new_img_left+35+'px';
carte.style.visibility='hidden';
carte.style.display='none';
image.onclick=function(){glideTo(this.x_pos,this.i)}
break;
case 0:
image.style.top=new_img_top+'px';
image.style.height=new_img_h+'px';
carte.style.visibility='visible';
carte.style.display='block';
image.onclick=function(){image_onclick(caption_id,index)}
image.onclick=function(){window.location.href=(img_div.childNodes.item(array_images[caption_id])).getAttribute('longdesc')}
break;
default:
image.style.top=new_img_top+'px';
image.style.height=new_img_h+'px';
carte.style.visibility='hidden';
break}
image.style.visibility='visible';
switch(x<0)
{
case true:
zIndex++;
break;
default:
zIndex=zIndex-1;
break}
switch(image.i==caption_id)
{
case false:
break;
default:
zIndex=zIndex+1;
document.getElementById("affichage").src=image.getAttribute('name');
document.getElementById("affichage").longdesc=image.getAttribute('longdesc');
document.getElementById("affichage").title=image.getAttribute('title');
break}
image.style.zIndex=zIndex}
x+=xstep}
}
function image_onclick(caption,index){
if(caption==index){
window.location.href=(img_div.childNodes.item(array_images[caption])).getAttribute('longdesc')}
else
{
glideTo(this.x_pos,caption)}
}
function refresh(onload)
{
imageflow_div=document.getElementById(conf_imageflow);
img_div=document.getElementById(conf_images);
prec_div=document.getElementById(conf_prec);
suiv_div=document.getElementById(conf_suivant);
cartes_div=document.getElementById(conf_cartes);
cadre_div=document.getElementById(conf_cadre);
caption_div=document.getElementById(conf_captions);
images_width=img_div.offsetWidth;
images_top=imageflow_div.offsetTop;
images_left=imageflow_div.offsetLeft;
max_conf_focus=conf_focus*xstep;
size=images_width*0.37;
max_height=images_width*0.25;
imageflow_div.style.height=max_height+'px';
img_div.style.height=(images_width*0.338)-100+'px';
caption_div.style.width=images_width+'px';
max=img_div.childNodes.length;
var i=0;
for(var index=0;index<max;index++)
{
var image=img_div.childNodes.item(index);
var carte=cartes_div.childNodes.item(index);
if(image.nodeType==1)
{
array_images[i]=index;
array_cartes[i]=index;
carte.style.visibility='hidden';
carte.style.display='block';
image.x_pos=(-i*xstep);
image.onclick=function(){glideTo(this.x_pos,this.i)}
image.i=i;
if(onload==true)
{
image.w=image.width;
image.h=image.height}
switch((image.w+1)>(image.h/(conf_reflection_p+1)))
{
case true:
image.pc=118;
break;
default:
image.pc=100;
break}
document.getElementById("affichage").src=image.getAttribute('name');
document.getElementById("affichage").longdesc=image.getAttribute('longdesc');
var url_click=""+image.getAttribute('longdesc');
document.getElementById("affichage").title=image.getAttribute('title');
image.ondblclick=function(){
document.getElementById("affichage").src=this.src;document.getElementById("affichage").type="image/jpeg"}
image.style.cursor=conf_images_cursor;
i++}
}
max=array_images.length;
prec_div.onclick=function(){handle(1)}
suiv_div.onclick=function(){handle(-1)}
if(onload==true){
handle(-2)}
}
function goTo(indice){
glideTo(-indice*xstep,indice)}
function show(id)
{
var element=document.getElementById(id);
element.style.visibility='visible'}
function hide(id)
{
var element=document.getElementById(id);
element.style.visibility='hidden';
element.style.display='none'}
window.onload=function()
{
if(document.getElementById(conf_imageflow))
{
hide(conf_loading);
show(conf_cadre);
show(conf_prec);
show(conf_suivant);
refresh(true);
show(conf_images)}
}
window.onresize=function()
{
if(document.getElementById(conf_imageflow))refresh(false)}
function handle(delta)
{
var nbr_img=array_images.length;
var change=false;
switch(delta>0)
{
case true:
if(caption_id>=1)
{
target=target+xstep;
new_caption_id=caption_id-1;
change=true}
break;
default:
if(caption_id<(max-1))
{
target=target-(-delta)*xstep;
new_caption_id=caption_id+(-delta);
change=true}
break}
if(change==true)
{
glideTo(target,new_caption_id)}
}
function getKeyCode(event)
{
event=event||window.event;
return event.keyCode}
document.onkeydown=function(event)
{
var charCode=getKeyCode(event);
switch(charCode)
{
case 39:
handle(-1);
break;
case 37:
handle(1);
break}
}

