

	var popup_name;

	function open_popup(URL,wwid,wheigh)

	{

		var s_width = window.screen.width - 10

		var s_height = window.screen.height - 50



		if ((wwid) / (wheigh) > s_width / s_height)

			{

		 	var img_width = s_width;

		 	var img_height = (s_width *(wheigh) / (wwid)  ); 

			}

		else

			{

			var img_width = (s_height * (wwid)/ (wheigh) );

		 	var img_height = s_height; 

			}

		var option = "toolbar=no,scrollbars=yes,location=no,directories=no,menubar=no,resizable=yes,status=no,width="+img_width+",height="+img_height+",top=0,left=0";

	if (popup_name) popup_name.close();

		popup_name = window.open(URL, 'ZoomImage',option);

	}

	

	function open_popup_fixed(URL,wwid,wheigh)

	{

		var itop = ( window.screen.height - ( wheigh + 50 ) ) / 2

		var ileft = ( window.screen.width - ( wwid + 10) ) / 2

		if ( itop <= 0 ) itop = 0;

		if ( ileft <= 0 ) ileft = 0;

		
		var option = "toolbar=no,scrollbars=no,location=no,directories=no,menubar=no,resizable=no,status=no,width="+wwid+",height="+wheigh+",top="+itop+",left="+ileft;

	if (popup_name) popup_name.close();

		popup_name = window.open(URL, 'Gallery',option);

	}
	
	
function useNavigateurModerne() 
{ 
 
    if (navigator.appName.substring(0, 3) == "Mic") 
    { 
        valUseIE7 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)) ? true : false; 
        return valUseIE7; 
    } 
    else 
    { 
        return true; 
    } 
} 


function traitementPng4IE() 
{ 
    if (useNavigateurModerne() == false) 
    {    
        for (i=0; document.images.length>i; i++) 
        { 
            if (document.images[i].src.substring(document.images[i].src.length-3, document.images[i].src.length) == "png") 
            { 
                document.images[i].style.height = document.images[i].height + "px"; 
                document.images[i].style.width = document.images[i].width + "px"; 
                document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + document.images[i].src + ",sizingMethod='scale')"; 
                document.images[i].src = "_img/transparent.gif"; 
            } 
        } 
    } 
}



var x_pos;
var y_pos;
var move;
var Mouse_X;
var Mouse_Y;



function changeOpac(opacity, id) {
    
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

// coordonnée de souris
function WhereMouse( e ){
  var DocRef;    // Variable pour IE uniquement


  // L'événement est passée à la fonction
  // donc tous sauf IE…
  if( e){                     // Dans ce cas on obtient directement la position dans la page
    Mouse_X = e.pageX;
    Mouse_Y = e.pageY;
  }
  else{                      // Dans ce cas on obtient la position relative à la fenêtre d'affichage
    Mouse_X = event.clientX;
    Mouse_Y = event.clientY;


    //-- Il faut traiter le CAS des DOCTYPE sous IE
    if( document.documentElement && document.documentElement.clientWidth) // Donc DOCTYPE
      DocRef = document.documentElement;   // Dans ce cas c'est documentElement qui est réfèrence
    else
      DocRef = document.body;                    // Dans ce cas c'est body qui est réfèrence

    //-- On rajoute la position liée aux ScrollBars
    Mouse_X += DocRef.scrollLeft;
    Mouse_Y += DocRef.scrollTop;
  }
}




function get_top(id)
{
    var elem=document.getElementById(id);
    
    mytop = elem.offsetTop;
    tempEl = elem.offsetParent;
  	while (tempEl != null) 
  	   {
    		mytop += tempEl.offsetTop;
    		tempEl = tempEl.offsetParent;
    	 }
   
   return mytop;    
}

function get_left(id)
{
    var elem=document.getElementById(id);
    
    myleft = elem.offsetLeft;
    tempEl = elem.offsetParent;
  	while (tempEl != null) 
  	   {
    		myleft += tempEl.offsetLeft;
    		tempEl = tempEl.offsetParent;
    	 }
   
   return myleft;    
}

// gestion souris du carousel
function move_carousel(direction,id_carousel) // 
{
    var isRepeat;
    
    x = Mouse_X;
    y = Mouse_Y;

    
    // position et taille carousel
    
    var carousel=document.getElementById(id_carousel);
    mytop = carousel.offsetTop;
    tempEl = carousel.offsetParent;
  	while (tempEl != null) 
  	   {
    		mytop += tempEl.offsetTop - tempEl.scrollTop;
    		tempEl = tempEl.offsetParent;
    	 }
    myh= carousel.offsetHeight;
    myleft= carousel.offsetLeft;
    tempEl = carousel.offsetParent;
  	while (tempEl != null) 
  	   {
    		myleft += tempEl.offsetLeft;
    		tempEl = tempEl.offsetParent;
    	 }
    myw= carousel.offsetWidth;
    
    
    // Image sur souris
    
    var id_img=id_carousel+'_img';
    var img_mouse=document.getElementById(id_img);
    // opacité des Image sur souris
    changeOpac(60, id_img);//div_mouse
    
    //alert(myleft+" "+mytop );
    
    // si souris hors carousel on sort
    
    if (direction=='Y')
        myright=myleft+myw-25; // gestion scrollbar
    else
        myright=myleft+myw;
    if (direction=='X')
        mybot=mytop+myh-25; // gestion scrollbar
    else
        mybot=mytop+myh;    
    if ( x<myleft || x>(myright) || y<mytop || y> (mybot) )
      {
      clearTimeout(isRepeat); 
      img_mouse.style.display='none';//div_mouse
      return;
      }
      
   
     if (direction=='Y')   // Carousel VERTICAL  ---------------------------
      {
          // zone neutre = milieu de carousel
          zone_neutre = mytop + myh * 0.5;
          
          // calcul ecart souris / zone neutre
          ecart_px = y - zone_neutre;
          
          // bornes en %
          my_h1=70;
          my_h2=85;
          my_h3=95; // 90
          
         // déplacements en pixel
          d12=1;
          d23=2;
          d3=10;
          
          // delta y
          dy=  y - mytop;
          
          // ecart en %
          ecart= ecart_px * 100 / (myh * 0.5); 
          //alert("Ecart ="+ ecart);
          
          
          
          // Gestion déplacement carousel / souris
         
          dh =0;
             
          if (ecart>=my_h1 && ecart < my_h2 && carousel.scrollTop<carousel.scrollHeight - carousel.offsetHeight )  // 
            {
            carousel.scrollTop=carousel.scrollTop+ d12; 
            
            img_mouse.src="./_img/down_slow.png";
            dh= - ( img_mouse.offsetHeight + 10 ); 
            }
          
           if (ecart>=my_h2 && ecart < my_h3 && carousel.scrollTop<carousel.scrollHeight - carousel.offsetHeight)  // 
            {
            carousel.scrollTop=carousel.scrollTop+ d23; 
            
            img_mouse.src="./_img/down_normal.png";
            dh= - ( img_mouse.offsetHeight + 10 ); 
            }
           if (ecart>=my_h3 && carousel.scrollTop<carousel.scrollHeight - carousel.offsetHeight)  // 
            {
            carousel.scrollTop=carousel.scrollTop+ d3; 
            
            img_mouse.src="./_img/down_quick.png";
            dh= - ( img_mouse.offsetHeight + 10 ); 
            }
          if (ecart<=-my_h1  && ecart > -my_h2 && carousel.scrollTop>0)  // 
            {
            carousel.scrollTop=carousel.scrollTop- d12; 
            
            img_mouse.src="./_img/up_slow.png";
            dh=20;
            }
          if (ecart<=-my_h2 && ecart > -my_h3 && carousel.scrollTop>0)  // 
            {
            carousel.scrollTop=carousel.scrollTop- d23; 
            
            img_mouse.src="./_img/up_normal.png";
            dh=20;
            }
          if (ecart<= -my_h3 && carousel.scrollTop>0)   // 
            {
            carousel.scrollTop=carousel.scrollTop- d3; 
            
            img_mouse.src="./_img/up_quick.png";
            dh=20;
            }
          if ( (ecart> -my_h1  && ecart<my_h1) || dh==0 )  // on fait rien
            {
            clearTimeout(isRepeat); 
            img_mouse.style.display='none';//div_mouse
            img_mouse.src="./_img/neutre.png";
                       
            }
          else
            {//div_mouse
            if (navigator.appName=="Netscape")      // MOZILLA
                {
                
                img_mouse.style.top= dy + carousel.scrollTop + dh ;
                img_mouse.style.left= (myw / 2 ) - img_mouse.offsetWidth / 2 ;
                
                img_mouse.style.display='none';
                }
            else                                    // IE
                {
                img_mouse.style.top= dy + carousel.scrollTop + dh ;
                img_mouse.style.left= (myw / 2 ) - img_mouse.offsetWidth / 2 ;
                img_mouse.style.display='block';
                }
            }
      }
    else    // Carousel Horizontal ---------------------------------------
      {
          // zone neutre = milieu de carousel
          zone_neutre = myleft + myw * 0.5;
          
          // calcul ecart souris / zone neutre
          ecart_px = x-zone_neutre;
          
          // bornes en %
          my_w1=70;
          my_w2=85;
          my_w3=95; // 90
          
         // déplacements en pixel
          d12=1;
          d23=2;
          d3=10;
          
          // delta x sur images de souris
          dx=  x - myleft;
          
          // ecart en %
          ecart= ecart_px * 100 / (myw * 0.5); 
          
                  
          // Gestion déplacement carousel / souris
         
         dw =0;
             
          if (ecart>=my_w1 && ecart < my_w2 && carousel.scrollLeft<carousel.scrollWidth - carousel.offsetWidth)  // 
            {
            carousel.scrollLeft=carousel.scrollLeft+ d12; 
            
            img_mouse.src="./_img/right_slow.png";
            dw= - ( img_mouse.offsetWidth + 10 ); 
            }
          
           if (ecart>=my_w2 && ecart < my_w3 && carousel.scrollLeft<carousel.scrollWidth - carousel.offsetWidth)  // 
            {
            carousel.scrollLeft=carousel.scrollLeft+ d23; 
            
            img_mouse.src="./_img/right_normal.png";
            dw= - ( img_mouse.offsetWidth + 10 ); 
            }
           if (ecart>=my_w3 && carousel.scrollLeft<carousel.scrollWidth - carousel.offsetWidth)  // 
            {
            carousel.scrollLeft=carousel.scrollLeft+ d3; 
            
            img_mouse.src="./_img/right_quick.png";
            dw= - ( img_mouse.offsetWidth + 10 ); 
            }
          if (ecart<=-my_w1  && ecart > -my_w2  && carousel.scrollLeft>0 )  // 
            {
            carousel.scrollLeft=carousel.scrollLeft- d12; 
            
            img_mouse.src="./_img/left_slow.png";
            dw=20;
            }
          if (ecart<=-my_w2 && ecart > -my_w3 && carousel.scrollLeft>0)  // 
            {
            carousel.scrollLeft=carousel.scrollLeft- d23; 
            
            img_mouse.src="./_img/left_normal.png";
            dw=20;
            }
          if (ecart<= -my_w3  && carousel.scrollLeft>0)  // 
            {
            carousel.scrollLeft=carousel.scrollLeft - d3; 
            
            img_mouse.src="./_img/left_quick.png";
            dw=20;
            }
          if ( (ecart> -my_w1  && ecart<my_w1) || dw==0 )  // on fait rien
            {
            clearTimeout(isRepeat); 
            img_mouse.style.display='none';
            img_mouse.src="./_img/neutre.png";
            }
          else
            {
            if (navigator.appName=="Netscape")      // MOZILLA
                {
                
                img_mouse.style.top= mytop +( (myh / 2 ) - img_mouse.offsetHeight /2 ) ; 
                img_mouse.style.left= dx + carousel.scrollLeft + dw ;
                
                img_mouse.style.display='none';
                }
            else                                    // IE
                {
                img_mouse.style.top= (myh / 2 ) - img_mouse.offsetHeight /2 ; 
                img_mouse.style.left= dx + carousel.scrollLeft + dw ;
                
                img_mouse.style.display='block';
                }
            
            }
      }
    
    if (navigator.appName=="Netscape")      // MOZILLA
        tempo=150;
    else
        tempo=40;
        
    // on relance la function
    isRepeat = setTimeout("move_carousel('"+direction+"','"+id_carousel+"')",tempo);

}

function show_photo(URL)
{
var popup_name;

	var option = "toolbar=no,scrollbars=yes,location=no,directories=no,menubar=no,resizable=yes,status=no";


	if (popup_name) popup_name.close();

		popup_name = window.open(URL, 'Download',option);


}



// gere l'opacité du fond d'écran
function set_opacity()
{

    x = Mouse_X;
    y = Mouse_Y;

    
    // position et taille carousel
    
    var elem=document.getElementById("slide_opacity");
    mytop = elem.offsetTop;
    tempEl = elem.offsetParent;
  	while (tempEl != null) 
  	   {
    		mytop += tempEl.offsetTop;
    		tempEl = tempEl.offsetParent;
    	 }
    myh= elem.offsetHeight;
    /*
    myleft= elem.offsetLeft;
    tempEl = elem.offsetParent;
  	while (tempEl != null) 
  	   {
    		myleft += tempEl.offsetLeft;
    		tempEl = tempEl.offsetParent;
    	 }
    myw= elem.offsetWidth;
    */
    
    
    
    
    valeur= 100 - 100 * (y - mytop )/ myh;
    
    changeOpac(valeur, 'cadre') ;
    document.getElementById('cursor_slide_opacity').style.top= y - mytop;
    
   return valeur;
    
    
}


function animadiv(div1,xd,yd,wd,hd,st)
{


  // position de depart
  x1 = Mouse_X - 25 ;
  y1 = Mouse_Y - 10;
  x2= x1+ 50;
  y2= y1+ 20;
  
  // position destination
  y11=yd;
  x11=xd;
  y12=yd+hd;
  x12=xd+wd;
  


// delta x y
  dx1=(x11-x1);
  dy1=(y11-y1);
  dx2=(x12-x2);
  dy2=(y12-y2);
  


// calcul valeur du pas
  stx1=dx1/st;
  sty1=dy1/st;
  stx2=dx2/st;
  sty2=dy2/st;




  var elem=document.getElementById(div1);
  // depart
    elem.style.left=x1+'px';
    elem.style.top=y1+'px';
    elem.style.width=(x2-x1)+'px';
    elem.style.height=(y2-y1)+'px';
    elem.style.display='block';
  




 expand_div(x1,x2,y1,y2,stx1,stx2,sty1,sty2,st,div1);
  
}


function expand_div(x1,x2,y1,y2,stx1,stx2,sty1,sty2,st,div1,divanim)
{
 
  if (divanim==undefined)
      divanim='visio';
      
      
   //alert(divanim);
    
    x1=x1+stx1;
    x2=x2+stx2;
    y1=y1+sty1;
    y2=y2+sty2;
    
    var elem=document.getElementById(div1);
    elem.style.left=x1+'px';
    elem.style.top=y1+'px';
    elem.style.width=(x2-x1)+'px';
    elem.style.height=(y2-y1)+'px';
    elem.style.display='block';
    
    if (st<=0) // fin
      {
      elem.style.display='none';
      switch (divanim)
        {
        case 'visio':
          elem.innerHTML='';
          break;
        case 'photo':
          document.getElementById('img_photo').style.display='block';
          break;
        }
      
          
      document.getElementById(divanim).style.display='block';
      }
    else
      {
      st=st-1;
      
      setTimeout("expand_div("+x1+","+x2+","+y1+","+y2+","+stx1+","+stx2+","+sty1+","+sty2+","+st+",'"+div1+"','"+divanim+"')",1*st+5);
      }
   
    


}

function animphoto(div1,xd,yd,wd,hd,xa,ya,wa,ha,st)
{

  
  
  // position de depart
  x1 = xd ;
  y1 = yd;
  x2= xd+ wd;
  y2= yd+ hd;
  
  // position destination
  y11=ya;
  x11=xa;
  y12=ya+ha;
  x12=xa+wa;
  


// delta x y
  dx1=(x11-x1);
  dy1=(y11-y1);
  dx2=(x12-x2);
  dy2=(y12-y2);
  


// calcul valeur du pas
  stx1=dx1/st;
  sty1=dy1/st;
  stx2=dx2/st;
  sty2=dy2/st;




  var elem=document.getElementById(div1);
  // depart
    elem.style.left=x1+'px';
    elem.style.top=y1+'px';
    elem.style.width=(x2-x1)+'px';
    elem.style.height=(y2-y1)+'px';
    elem.style.display='block';
  




 expand_div(x1,x2,y1,y2,stx1,stx2,sty1,sty2,st,div1,'photo');
  
}

function bugIE()
{

if (navigator.appName == "Microsoft Internet Explorer")
 {
           
 document.getElementById('imgblue').width = 600;
 document.getElementById('imgedge').width = 600;
 }
 
 }
