var Timer;var Timer2;var Timer3;var xxx; var pas;var sui2;var tabimg;var sens=1;var srcaccu;var cotaccu=1

function nu(st){  //enleve le px à une coordonnée
return(parseInt(st.substr(0,st.length-2)));
}

function decx(th,x,longtotale,ta){ //decale un div de x pixel horizontalement
th.style.left=Math.max(Math.min((eval(nu(th.style.left))+Math.round(x)),0),-longtotale+ta)+"px";
document.getElementById('curstyl').style.left=-nu(th.style.left)*660/(longtotale-660)+4;
}

function scrollx2(th,x,longtotale,ta){ //decale un div de x pixel horizontalement
if (longtotale>ta){
document.getElementById(th).style.left=Math.max(Math.min((eval(nu(document.getElementById(th).style.left))+Math.round(x)),0),-longtotale+ta)+"px";
sui2='scrollx2(\''+th+'\','+x+','+longtotale+','+ta+')';
Timer3=setTimeout(sui2,1);}
document.getElementById('curstyl').style.left=-nu(document.getElementById(th).style.left)*660/(longtotale-660)+4;
}

function lanx(th,x,sens,lt,ta){ //decale un div de x pixel horizontalement pour x grand lt=longueur totale de la bande ta= taille de la partie visible de la bande
  decx(th,pas*sens,lt,ta);
  if (xxx<x) {
      xxx=xxx+pas;var sui='lanx('+th.id+','+x+','+sens+','+lt+','+ta+')';
      if (xxx>(x-pas*(pas+1)/2)) if (pas>1) pas-=1; //pas*(pas+1)/2= somme des entiers de 1 à pas .
      Timer=setTimeout(sui,1); } 
  else {clearTimeout(Timer);}  
 }
 
function move(th,x,lt,ta) {sens=1;xxx=0; pas=20; //th=objet div  x=nb de pixel à décaler la bande lt=longueur totale de la bande ta= taille de la partie visible de la bande
  a=nu(th.style.left);
  rest=a+lt-ta; 
  if (x<0) {x=Math.min(-x,rest);sens=-1}
  else x=Math.min(x,-a);
  if ((xxx==0)&& (lt>ta) )  lanx(th,x,sens,lt,ta) ;//setTimeout('lanx('+th.id+','+x+','+sens+','+lt+','+ta+')',1);//
  }

function affichevig(ii){  //rend visibles les vignettes chargées par le bandeur.php
  for (var i=0;i<ii;i++) {st="vig"+i;document.getElementById(st).style.display="block"; }
  }
  
function popup(popUpDivVar){ // ouvre un popup sur fond noir
		//DOM compliant
   scrolly = document.body.scrollTop; scrollx = document.body.scrollLeft;
   dimx=document.body.scrollWidth; dimy=document.body.scrollHeight;   

   if ( window.innerWidth ) {
    //Netscape compliant
    scrolly = window.pageYOffset; scrollx = window.pageXOffset;
    dimx=window.innerWidth; dimy=window.innerHeight;
    docw=document.Width;  doch=document.Height;
  } 
    else if( document.documentElement ) {
    //IE6 standards compliant mode
    scrolly = document.body.scrollTop; scrollx = document.body.scrollLeft;
    dimx=document.body.clientWidth; dimy=document.body.clientHeight;
    docw=document.body.scrollWidth;  doch=document.body.scrollHeight;
  } 
     docw=document.body.scrollWidth;  doch=document.body.scrollHeight;
     
  document.getElementById(popUpDivVar).style.top =	(scrolly + dimy/2 - (nu(document.getElementById(popUpDivVar).style.height))/2 )+'px';
  document.getElementById(popUpDivVar).style.left =	(scrollx + dimx/2 - (nu(document.getElementById(popUpDivVar).style.width))/2 )+'px';
	
  document.getElementById('blanket').style.width=docw;
	document.getElementById('blanket').style.height=doch;
	document.getElementById('xx').style.top=nu(document.getElementById(popUpDivVar).style.top)+20+'px'  ;
	document.getElementById('xx').style.left=nu(document.getElementById(popUpDivVar).style.left)+nu(document.getElementById(popUpDivVar).style.width)+20 +'px' ;
	document.getElementById('blanket').style.display = 'block';
  document.getElementById(popUpDivVar).style.display = 'block';
 }

function poppic(sf) { // popup d'image simple
  var content="<center><img src='"+sf+"' height=100%>";
  document.getElementById('popUppic').innerHTML=content;
  popup('popUppic');
}

function popband(sf) { //popup d'un bandeau
 var content="bandeur.php?sf="+sf;
 if (typeof XMLHttpRequest == "undefined") {
  XMLHttpRequest = function() {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
      catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
      catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP"); }
      catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); }
      catch(e) {}
    throw new Error("This browser does not support XMLHttpRequest.");
  };
}
    req = new XMLHttpRequest();
    req.open('GET', content, false);
    req.send(null);
    content = req.responseText;
  document.getElementById('popUpband').innerHTML=content;
  popup('popUpband');
}


function popflash(sf,xl,x) { // popup d'un flash
var tti=new Date(); st=tti.getTime();xl=xl+"?"+st;
  document.getElementById('popUpflash').style.width=x+"px";
  document.getElementById('popUpflash').style.height=x+"px";
  var cont='<object type="application/x-shockwave-flash" data="'+sf+'" width=100% height=100% align=top>';
  cont=cont+'<param name="FlashVars" value="datas='+xl+'"/>';
  cont=cont+'<param name="movie" value="'+sf+'" />';
  cont=cont+'<param name="wmode" value="transparent"/></object>';
  
  document.getElementById('popUpflash').innerHTML=cont;
  popup('popUpflash');
}

function popclose() { //ferme un popup
clearTimeout(Timer3);Timer3=null;clearTimeout(Timer2);Timer3=null;
if (popUppic.style.display != 'none') {
  if (popUpflash.style.display == 'none') {popUppic.style.display = 'none' ;blanket.style.display = 'none';} 
  else popUppic.style.display = 'none';}
else {popUpband.style.display = 'none' ; popUpflash.style.display = 'none' ;blanket.style.display = 'none';} 
}

function preload(st) {  //précharge les grosses images de bandeur.php
  document.getElementById("preloa").style.display='block';
	load(st); // st est la liste des urls des images à précharger
}
function FinPreload() {
	// FinPreload est appelée à la fin du préchargement pour déclencher une action
document.getElementById("bigp").src=tabimg[1].src;
	document.getElementById("bigg").style.display='block';
  document.getElementById("preloa").style.display='none';
  clearTimeout(Timer2);}

function load(st) {//précharge les grosses images de bandeur.php
st=st.replace(/!/g,'');
var reg=new RegExp("[ ,;]+", "g");
var tab=st.split(reg);
        if (document.images) {
                tabimg=new Array();
                tabimg.length=tab.length;
                for (var i=0;i<tab.length;i++) {
                        tabimg[i]=new Image();
                        tabimg[i].src=tab[i];}
                Verifie();}}
                
function Verifie() { // vérifie si les images à précharger ont fini d'être préchargées
        var ok=1;cpt=0;
        if (document.images) {
                for (var i=1;i<tabimg.length;i++) {
                        if (!(tabimg[i].complete)) {ok=0} else cpt+=1;
                }
                st = cpt+'/'+(tabimg.length-1);
            		document.getElementById("progress").innerHTML=st;}
        if (ok) {FinPreload()}
        else {Timer2=setTimeout("Verifie()",20)}
}

function inbul(st){ ///affiche une infobulle 
  bul=document.getElementById("bulle");
  bul.innerHTML=st;
 if (st!="") bul.style.display='inline';}
 
function outbul(){document.getElementById("bulle").style.display='none';} //rend invisible l'infobulle

function position(e)	{ //renvoie les coordonnées de la souris
  x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
	y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
//	window.status = "Souris X:"+x+" / Y:"+y;
  bul=document.getElementById("bulle");
  bul.style.left=x+15;  bul.style.top=y; 
}


function flip(){  // fait pivoter sur elle meme verticalement une image d'ID 'accu'
l=document.getElementById('accu').width+80;
h=document.getElementById('accu').height;
flipp(l,h);
}

function flipp(l,h){  // fait pivoter sur elle meme verticalement une image d'ID 'accu'
pas=4;
if ( document.getElementById('accu').width<(3*h/4)) pas=6;
if ( document.getElementById('accu').width<(h/2)) pas=8;
if ( document.getElementById('accu').width<(h/4)) pas=10;

if (sens==1) document.getElementById('accu').width-=pas;
if (sens==0) document.getElementById('accu').width+=pas;
if (document.getElementById('accu').width<=0) {
  if (cotaccu==1) {document.getElementById('accu').src='pics/accueil2.jpg';cotaccu=0;}
  else {document.getElementById('accu').src='pics/accueil1.jpg';cotaccu=1;}
  sens=0;
}
if (document.getElementById('accu').width>(l)) sens=1;
document.getElementById('accu').height=h;
st='flipp('+l+','+h+')';
setTimeout(st,30);
}



if(navigator.appName.substring(0,3) == "Net") document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = position;

var timeout=new Array();

function slide(){
setImgOpacity(0,"accu2");
document.getElementById("accu2").style.display="inline";
fader2();

}

var opa=100;
var step=2;
var image=1;
function setImgOpacity(opacity,id){
  var object=document.getElementById(id);
  object.style.opacity=(opacity/100);
  object.style.MozOpacity=(opacity/100);
  object.style.KhtmlOpacity=(opacity/100);
  object.style.filter="alpha(opacity="+opacity+")";}

function fader2(){
var speed=15;
var timer=0;

  if (opa==-30) {  document.getElementById("accu").src="diap/"+(image+1)+".jpg";image+=1;step=-step}
  if (opa==130) {  document.getElementById("accu2").src="diap/"+(image+1)+".jpg";image+=1;step=-step}
  if (image==12) image=0;
 
  opa=opa+step;
  setImgOpacity(opa,"accu");
  setImgOpacity(100-opa,"accu2");
  timeout=setTimeout("fader2()",(speed));
  
   }