function createPopup()  {
    var div = document.createElement('div');
    div.setAttribute('id','background_popup');
    div.style.display = 'none';
    document.body.appendChild(div);
    setTrans('background_popup',0.6);
    
}

function showPopup() {
    
    var div = document.getElementById('background_popup');
    if(!div) {
        createPopup();
        div = document.getElementById('background_popup');
    }
    div.style.top = 0 + "px"; 
    div.style.left = 0 + "px"; 
    var area = getBodySize();
    div.style.width = area.largeur + 'px';
    div.style.height = area.hauteur + 'px';
    div.style.display = "block";
}

function hidePopup() {
    var div = document.getElementById('background_popup');
    if(div) {
    div.style.display = 'none';
    }
}


function getBodySize() {
  var area = new Object();
   
  area.hauteur = document.body.scrollHeight;
  area.largeur = document.body.scrollWidth;
//  alert(area.hauteur +'  ' + area.largeur);
  return area ;
}     



function getBodySize2() {
  var area = new Object();
  if (document.all)  {
         if(document.documentElement) {
            /*
            si le doctype est fourni IE place les propriete dans document.documentElement rien que pour embeter le peuple
            */ 
            var hauteur = document.documentElement.clientHeight;
            var largeur = document.documentElement.clientWidth;
         } else {
             /*
             si ie 5 ou ie 6 sans doc type 
             */
             var hauteur = document.body.clientHeight;
             var largeur = document.body.clientWidth;
         }
      } else {
          /*
          si c'est un un firefox like 
          */
         
          var hauteur = window.innerHeight;
          var largeur = window.innerWidth;
      }
      
      area.hauteur = hauteur;
      area.largeur = largeur;
      return area ;
}     

function getScreenArea() {
  var area = new Object();
  if (document.all)  {
         if(document.documentElement) {
            /*
            si le doctype est fourni IE place les propriete dans document.documentElement rien que pour embeter le peuple
            */ 
            var top = document.documentElement.scrollTop;
            var left = document.documentElement.scrollLeft;
            var hauteur = document.documentElement.clientHeight;
            var largeur = document.documentElement.clientWidth;
            
            
         } else {
             /*
             si ie 5 ou ie 6 sans doc type 
             */
             var top = document.body.scrollTop;
             var left = document.body.scrollLeft;
             var hauteur = document.body.clientHeight;
             var largeur = document.bodyt.clientWidth;
         }
      } else {
          /*
          si c'est un un firefox like 
          */
          var top = window.pageYOffset;
          var left = window.pageXOffset;
          var hauteur = window.innerHeight;
          var largeur = window.innerWidth;
      }
      area.top = top;
      area.left = left;
      area.hauteur = hauteur;
      area.largeur = largeur;
      
      return area ;
}     

function centerDiv(div_id) {
    
    var div = document.getElementById(div_id);
    /*
    la div doit etre visible pour pouvoir avoir ces dimensions
    */
    div.style.display = 'block';
    document.body.appendChild(div);
    var area = getScreenArea();
    var posy = (area.hauteur - parseInt(div.clientHeight)) / 2 + area.top; 
    var posx = (area.largeur - parseInt(div.clientWidth)) / 2 + area.left; 
    div.style.position = 'absolute';
    div.style.top = posy + "px"; 
    div.style.left = posx + "px"; 
    return div;
}



/*
To call this script, use something like (the number is a delay before it closes or 0 for no timed closing -
the true/false says if the window should close when they switch to another window):
<script type="text/javascript"><!--
//you can style this, but don't try to text-align it to the right, it will break the resizing effect
//keep it narrow, if it is wider than the image, the window will wrap to this width
//the makeright class tells the script to automatically align it to the right
var extraHTML = '<br><a href="javascript:window.close()" style="text-decoration:none;color:#777;background-color:#bbb;font-weight:bold;border-left:2px solid #000;" class="makeright">Close<\/a>';
//--></script>
<a href="me.jpg" onclick="return popImageExtra(this.href,'Site author',true,3000,extraHTML);">link</a>
*/

//really not important (the first two should be small for Opera's sake)
PositionX = 10;
PositionY = 10;
defaultWidth  = 600;
defaultHeight = 400;

//don't touch (except to modify the window contents)
function popImageExtra(imageURL,imageTitle,AutoClose,oTimeClose,extraHTML){
    AutoClose =false;
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function getRefToDivMod( divID, oDoc ) {\n'+
			'if( !oDoc ) { oDoc = document; }\n'+
			'if( document.layers ) {\n'+
			'if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {\n'+
			'for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {\n'+
			'y = getRefToDivNest(divID,oDoc.layers[x].document); }\n'+
			'return y; } }\n'+
			'if( document.getElementById ) { return oDoc.getElementById(divID); }\n'+
			'if( document.all ) { return oDoc.all[divID]; }\n'+
			'return document[divID];\n'+
		'}\n'+
		'function resizeWinTo() {\n'+
			'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
			'if( !document.images[0].height || window.doneAlready ) { return; }\n'+ //in case images are disabled
			'var oH = getRefToDivMod( \'myID\' ); if( !oH ) { return false; }\n'+
			'var oW = oH.clip ? oH.clip.width : oH.offsetWidth;\n'+
			'var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }\n'+
			'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
			'window.doneAlready = true;\n'+ //for Safari and Opera
			'var mH = screen.availHeight-130, mW = screen.availWidth-40;\n'+
			'if( oH > mH || oW > mW ) {\n'+
			'var hDif = oH - document.images[0].height;\n'+
			'var wDif = oW - document.images[0].width;\n'+
			'mH = mH - hDif; mW = mW - wDif;\n'+
			'mH = mH \/ document.images[0].height;\n'+
			'mW = mW \/ document.images[0].width;\n'+
			'var zoomFactor = ( mH < mW ) ? mH : mW;\n'+
			'oH = Math.floor( document.images[0].height * zoomFactor );\n'+
			'oW = Math.floor( document.images[0].width * zoomFactor );\n'+
			'document.images[0].height = oH;\n'+
			'document.images[0].width = oW;\n'+
			'oH += hDif; oW += wDif;\n'+
			'}\n'+
			'if(document.getElementsByTagName) {\n'+
				'for( var l = document.getElementsByTagName(\'a\'), x = 0; l[x]; x++ ) {\n'+
					'if(l[x].className==\'makeright\'&&!l[x].style.position){\n'+
						'l[x].style.position=\'relative\';\n'+
						'l[x].style.left=(document.images[0].width-(l[x].offsetWidth+l[x].offsetLeft))+\'px\';\n'+
			'}}}\n'+
			'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
			'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
			'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
			'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
			'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
			'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
			'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
			'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
			'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
			'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
			

		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(AutoClose?'"':'')+'>'+
		(document.layers?('<layer left="0" top="0" id="myID">'):('<div style="position:absolute;left:0px;top:0px;" id="myID">'))+
		'<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
		(extraHTML?extraHTML:'')+(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}
//			(oTimeClose?('window.setTimeout(\'window.close()\','+oTimeClose+');\n'):'')+
function popImageExtraVoid(imageURL,imageTitle,AutoClose,oTimeClose,extraHTML){
 // alert(imageURL);
  popImageExtra(imageURL,imageTitle,AutoClose,oTimeClose,extraHTML);
  return void(0)
}

function htmlPopup(URL,w,h) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+w+",height="+h+",left = "+((screen.width - w) /2) +",top = "+((screen.height -50 - h) /2)+"');");
}