var pop;
var maxH=screen.availHeight-32; // pour la barre de titre et la bordure
var maxW=screen.availWidth-10;  // pour la bordure
var IE = (window.innerWidth) ? 0 : 1;
//var NS4 = (document.getElementById) ? 0 : 1; // déjà fait

function sscrl(on)
{
 if (NS4) return
 with (pop.document.body) {
  if (on) style.overflow='auto';
  else style.overflow='hidden';
  }
}

function zoom()
{
 sh(pop.document.getElementById('l'),0)
 with (pop.img) {
  if (pop.force) {
     height=''
     style.height='auto';
     pop.force=pop.f2=0;
     }
  else {
     pop.force=pop.f2=1;
     var h=height||clientHeight;
     style.height='';
     height=h;
     }
  }
 imagePopup1(pop.img)
}

function sh(e,s)
{
 with(e.style){
  if (s) {
     opacity=1;
     filter='alpha(opacity=100)';
     }
  else {
     opacity=0;
     filter='alpha(opacity=0)';
     }
  }
}


function imagePopup1(url,w,h,force)
{

function setinnersize(w,h,maxW,maxH)
{
 var r=0;

 if (h>maxH) { // hauteur
  h=maxH;    // on réduit au maximum disponible
  w=w+16;    // on ajoute la taille de l'ascenseur
  r=1;
  }
 if (w>maxW) { // largeur
  w=maxW;h=h+16;
  if (h>maxH) { h=maxH; }
  r=1;
  }
 x=w;y=h;
 return r
}

function resize()
{
 function inner()
 {
  with (pop.document.body) {
   pop.innerWidth=offsetWidth-4;
   pop.innerHeight=offsetHeight-4;
   }
 }

 if (IE) inner();

 with(pop){
  if (x!=innerWidth || y!=innerHeight) {
     resizeBy(x-innerWidth,y-innerHeight);
     if (IE) inner();
     }

  if(x>innerWidth)maxW=innerWidth;
  if(y>innerHeight)maxH=innerHeight-32;
  }
}

var x,y,height='',localjs='',style='';

if (typeof(url)!="object") {
 var f2=0;
 if (force) {
  if (h>maxH) {
   height=' height="'+maxH+'"';
   w=Math.round((w*maxH)/h);
   h=maxH;
   f2=1;
   }
  }
 
 localjs='<script type="text/javascript">var force='+force+',f2='+f2+'</script>';
 var of=setinnersize(w,h,maxW,maxH),op=pop?!pop.closed:0;
 
 if(of)style=' style="overflow:auto;"';
 else style=' style="overflow:hidden;"';

 pop = window.open('','bdimg','width='+x+',height='+y+',scrollbars=yes,resizable=yes,left=0,screenX=0,top=0,screenY=0');
 if(op)resize();

 pop.document.open();
 if(NS4)pop.document.write('<html>'+localjs+'<title>&nbsp;</title><body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"><a href="javascript:window.close();"><img title="Cliquer pour fermer" border="0" src="'+url+'" '+height+' onload="opener.imagePopup1(this);"></a></body></html>');
 else	pop.document.write('<html><head>'+localjs+'<title>&nbsp;</title><meta http-equiv="imagetoolbar" content="no">'
   +'<style>#l {position:absolute;top:15px;right:15px;opacity:0;filter:alpha(opacity=0);-moz-outline:none;outline:none;} #l * {border:none;}</style>'
   +'</head><body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"'+style+'>'
   +'<img title="Cliquer pour fermer" border="0" src="'+url+'" '+height+' onload="opener.imagePopup1(this);" onclick="window.close()" style="cursor:pointer;">'
   +((of || f2)?'<a href="javascript:opener.zoom()" id="l" onmouseover="opener.sh(this,1)" onmouseout="opener.sh(this,0)">'
   +'<!--[if IE 6]><img src="/s.gif" title="zoomer" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/loupe.png\',sizingMethod=\'image\');"><![endif]>'
   +'<!--[if gt IE 6]>--><img src="/loupe.png" title="zoomer"><!--<![endif]--></a>':'')
   +'</body></html>');
 pop.document.close();
 pop.focus();
 }
else {

 pop.img=url;
 x=url.width||url.clientWidth; y=url.height||url.clientHeight;
 if (pop.force) {	// pas d'overflow ?
  if (y>maxH) {
   x=Math.round((x*maxH)/y);
   y=maxH;	// redim pop
   url.height=y;// redim image pop
   pop.f2=1;
   }
 }
 var s=setinnersize(x,y,maxW,maxH),l
 if (!s && !pop.f2 && !NS4 && (l=pop.document.getElementById('l'))) l.style.visibility='hidden'
 resize();
 sscrl(s);
}

}
