function montreAppercu(){
  var objFondLight = document.getElementById('filter').style.display = 'block';
  var objAppercu = document.getElementById('box').style.display = 'block';
}
function affiche_div_img(num){
  var max = document.getElementById("nb_div_img").value ;    
  for(var i=0;i<=max;i++){
    if(i==num) eval("document.getElementById('img_"+i+"').style.display = 'block'") ;
    else eval("document.getElementById('img_"+i+"').style.display = 'none'") ;
  }
}

function getPageSize(){
  var xScroll, yScroll;
  if (window.innerHeight && window.scrollMaxY) {	
    xScroll = document.body.scrollWidth;
	yScroll = window.innerHeight + window.scrollMaxY;
  }
  else if (document.body.scrollHeight > document.body.offsetHeight){ 
    xScroll = document.body.scrollWidth;
	yScroll = document.body.scrollHeight;
  }
  else {
    xScroll = document.body.offsetWidth;
	yScroll = document.body.offsetHeight;
  }
  var windowWidth, windowHeight;
  if (self.innerHeight) {	
    windowWidth = self.innerWidth;
	windowHeight = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) {
    windowWidth = document.documentElement.clientWidth;
	windowHeight = document.documentElement.clientHeight;
  }
  else if (document.body) { 
    windowWidth = document.body.clientWidth;
	windowHeight = document.body.clientHeight;
  }	
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  }
  else { 
    pageHeight = yScroll;
  }
  if(xScroll < windowWidth){	
    pageWidth = windowWidth;
  }
  else {
    pageWidth = xScroll;
  }
  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
  return arrayPageSize;
}
      
function getPageScroll(){
  var yScroll;
  if (self.pageYOffset) {
    yScroll = self.pageYOffset;
  }
  else if (document.documentElement && document.documentElement.scrollTop){	 
    yScroll = document.documentElement.scrollTop;
  }
  else if (document.body) {// Tout autres qu'Explorers
    yScroll = document.body.scrollTop;
  }
  arrayPageScroll = new Array('',yScroll) 
  return arrayPageScroll;
}




function initialisation(){
  
  var objBody = document.getElementsByTagName("body").item(0);
  
  
  var objAppercu = document.getElementById('box') ;
  if(objAppercu){
    var objFondLight = document.getElementById('filter');
    var arrayPageSize = getPageSize();
    var arrayPageScroll = getPageScroll();
    objBody.insertBefore(objFondLight, objBody.firstChild);  // on définit overlay comme premier enfant de body
    objBody.insertBefore(objAppercu, objFondLight.nextSibling);  // je le met juste apres overlay
    objFondLight.style.width = (arrayPageSize[2] + 'px');
    objFondLight.style.height = (arrayPageSize[1] + 'px');
    objFondLight.style.top = '0' ;
    objFondLight.style.left = '0' ;
  }
}

function addLoadEvent(func){	
  var oldonload = window.onload;
  if (typeof window.onload != 'function'){
    window.onload = func;
  }
  else {
    window.onload = function(){
	  oldonload();
	  func();
      }
  }
}

addLoadEvent(initialisation);
