function resize() {

 var pageHeight = 0, pageWidth = 0; scrollTop = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    pageWidth = window.innerWidth;
    pageHeight = window.innerHeight;
    scrollTop = document.body.scrollTop;
    scrollLeft = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    pageWidth = document.documentElement.clientWidth;
    pageHeight = document.documentElement.clientHeight;
    scrollTop = document.documentElement.scrollTop;
    scrollLeft = document.documentElement.scrollLeft;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    pageWidth = document.body.clientWidth;
    pageHeight = document.body.clientHeight;
    scrollTop = document.body.scrollTop;
    scrollLeft = document.body.scrollLeft;
  }

//h1 = document.getElementById("contener").offsetHeight + document.getElementById("contener").scrollHeight;
h1 = document.getElementById("frontpanel").clientHeight;
h1 = h1 + 20;
h2 = pageHeight - 20 - 130 - 275 - 5 + scrollTop;
h = h1 > h2 ? h1 : h2;
document.getElementById("backpanel").style.height = h;

}

function zoom_tech(n) {
 for (i=1; i<=5; i++) {
  if (i==n) { 
   document.getElementById("zoom"+i).style.display = "block";
  }
  else {
   document.getElementById("zoom"+i).style.display = "none";
  }
 }
}

function closegallery() {
 
 document.getElementById("masque").style.display = "none";
 document.getElementById("zoomfront").style.display = "none";
 document.getElementById("zoomback").style.display = "none";
 document.getElementById("zoomfront_fla").style.display = "none";
 document.getElementById("zoomback_fla").style.display = "none";
 document.getElementById("boutonnext").style.display = "none";
 document.getElementById("boutonprev").style.display = "none";

}

function popupFlash(flanumber,bufferlength,repeat) {

 var pageWidth = 0, pageHeight = 0, scrollTop = 0, scrollLeft = 0, totalWidth = 0, totalHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    pageWidth = window.innerWidth;
    pageHeight = window.innerHeight;
    scrollTop = document.body.scrollTop;
    scrollLeft = document.body.scrollLeft;
    totalHeight = window.innerHeight + window.scrollMaxY;
    totalWidth = window.innerWidth + window.scrollMaxX;
    
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    pageWidth = document.documentElement.clientWidth;
    pageHeight = document.documentElement.clientHeight;
    scrollTop = document.documentElement.scrollTop;
    scrollLeft = document.documentElement.scrollLeft;
    totalHeight = document.documentElement.scrollHeight;
    totalWidth = document.documentElement.scrollWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    pageWidth = document.body.clientWidth;
    pageHeight = document.body.clientHeight;
    scrollTop = document.body.scrollTop;
    scrollLeft = document.body.scrollLeft;
    totalHeight = document.body.scrollHeight;
    totalWidth = document.body.scrollWidth;
  }

 width = 499;
 height = 331;

 thetop = (pageHeight - height) / 2 + scrollTop;
 theleft = (pageWidth - width) / 2 + scrollLeft;
 
 
 document.getElementById("masque").style.height = totalHeight;
 document.getElementById("masque").style.width = totalWidth;
 document.getElementById("masque").style.top = 0;
 document.getElementById("masque").style.left = 0;
 document.getElementById("masque").style.display = "block";

 document.getElementById("zoomfront_fla").style.top = thetop;
 document.getElementById("zoomfront_fla").style.left = theleft;
 document.getElementById("zoomfront_fla").style.display = "block";
 

 document.getElementById("zoomback_fla").style.top = thetop + 10;
 document.getElementById("zoomback_fla").style.left = theleft + 11;
 document.getElementById("zoomback_fla").style.display = "block";

// document.getElementById("closer").style.top = ((pageHeight - height) / 2) - 20;
// document.getElementById("closer").style.left = ((pageWidth - width) / 2) + width - 100;
// document.getElementById("closer").style.display = "block";

// document.getElementById("flashbig").value = "media/galerie_animations/" + theflash;
// document.getElementById("flashbig1").src = "media/galerie_animations/" + theflash;

/* codefla = "<object align=\"middle\" height=\"270\" width=\"480\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"><param value=\"sameDomain\" name=\"allowScriptAccess\"><param id=\"flashbig\" value=\"media/galerie_animations/"+theflash+"\" name=\"movie\"><param value=\"high\" name=\"quality\"><param value=\"#ffffff\" name=\"bgcolor\">"
   +"<embed id=\"flashbig1\" src=\"media/galerie_animations/"+theflash+"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" allowScriptAccess=\"sameDomain\" align=\"middle\" name=\"questions\" height=\"270\" width=\"480\" bgcolor=\"#ffffff\" quality=\"high\"></embed>"
   +"</object>";
*/

 codefla = "<embed src=\"../media/galerie_animations/mediaplayer.swf\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" width=\"480\" height=\"270\" allowfullscreen=\"false\" flashvars=\"bufferlength="+bufferlength+"&displayheight=270&file=animation_3D_"+flanumber+".flv&height=270&image=../media/galerie_animations/preview_animation_3D_"+flanumber+".jpg&width=480&overstretch=none&showdigits=false&showicons=false"+(repeat?"&repeat=true":"")+"\" />";

 document.getElementById("zoomback_fla").innerHTML = codefla;
}



function popupLayer(theimage) {

 var pageWidth = 0, pageHeight = 0, scrollTop = 0, scrollLeft = 0, totalWidth = 0; totalHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    pageWidth = window.innerWidth;
    pageHeight = window.innerHeight;
    scrollTop = document.body.scrollTop;
    scrollLeft = document.body.scrollLeft;
    totalHeight = window.innerHeight + window.scrollMaxY;
    totalWidth = window.innerWidth + window.scrollMaxX;
    
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    pageWidth = document.documentElement.clientWidth;
    pageHeight = document.documentElement.clientHeight;
    scrollTop = document.documentElement.scrollTop;
    scrollLeft = document.documentElement.scrollLeft;
    totalHeight = document.documentElement.scrollHeight;
    totalWidth = document.documentElement.scrollWidth;
 
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    pageWidth = document.body.clientWidth;
    pageHeight = document.body.clientHeight;
    scrollTop = document.body.scrollTop;
    scrollLeft = document.body.scrollLeft;
    totalHeight = document.body.scrollHeight;
    totalWidth =  document.body.scrollWidth;
  }

 width = 639;
 height = 526;

 thetop = (pageHeight - height) / 2 + scrollTop;
 theleft = (pageWidth - width) / 2 + scrollLeft;
 
 
// document.getElementById("masque").style.height = pageHeight + scrollTop;
// document.getElementById("masque").style.width = pageWidth + scrollLeft; 
 document.getElementById("masque").style.height = totalHeight;
 document.getElementById("masque").style.width = totalWidth;
 document.getElementById("masque").style.top = 0;
 document.getElementById("masque").style.left = 0;
 document.getElementById("masque").style.display = "block";

 document.getElementById("zoomfront").style.top = thetop;
 document.getElementById("zoomfront").style.left = theleft;
 document.getElementById("zoomfront").style.display = "block";
 

 document.getElementById("zoomback").style.top = thetop + 10;
 document.getElementById("zoomback").style.left = theleft + 11;
 document.getElementById("zoomback").style.display = "block";

 document.getElementById("boutonprev").style.top = thetop + 10 + 0;
 document.getElementById("boutonprev").style.left = theleft + 11;

 document.getElementById("boutonnext").style.top = thetop + 10 + 0;
 document.getElementById("boutonnext").style.left = theleft + width - 78;


// document.getElementById("closer").style.top = ((pageHeight - height) / 2) - 20;
// document.getElementById("closer").style.left = ((pageWidth - width) / 2) + width - 100;
// document.getElementById("closer").style.display = "block";

 updateImage(theimage);

}




function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
 doc = xmlHttp.responseXML;
 next = doc.getElementsByTagName('next')[0].firstChild.data;
 previous = doc.getElementsByTagName('previous')[0].firstChild.data;

 if (next != "none") {
  document.getElementById("boutonnext").style.display = "block";
  document.getElementById("liennext").href = "javascript:updateImage('"+next+"')";
 }
 else { 
  document.getElementById("boutonnext").style.display = "none";
  document.getElementById("liennext").href = "#";
 }

 if (previous != "none") {
  document.getElementById("boutonprev").style.display = "block";
  document.getElementById("lienprev").href = "javascript:updateImage('"+previous+"')";
 }
 else {
  document.getElementById("boutonprev").style.display = "none";
  document.getElementById("lienprev").href = "#";
 }
 
} 
} 

function getHttpObject() {
        if (window.ActiveXObject) {
                return new ActiveXObject("Microsoft.XMLHTTP")
        }
        if (window.XMLHttpRequest) {
                return new XMLHttpRequest();
        }
        return false;
}

function updateImage(theimage) {
 document.getElementById("galeriebig").src = "../media/galerie_images/" + theimage;

 xmlHttp=getHttpObject()
 if (xmlHttp==null)
 {
 alert ("Votre navigateur ne supporte pas cette fonctionnalit&eacute;")
 return
 } 
 var url="../navigation_galerie.php?current="+theimage;
 xmlHttp.onreadystatechange=stateChanged 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
}




