	// récupère les dimensions de la fenêtre du navigateur
	function getWindowDim() { 
		var width 	= 0;
		var height 	= 0;
		if ( typeof(window.innerWidth) == 'number' ) {
			//Non-IE
			width 	= window.innerWidth;
			height 	= window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			width 	= document.documentElement.clientWidth;
			height 	= document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			width 	= document.body.clientWidth;
			height 	= document.body.clientHeight;
		};
		return [width, height];
	}	
	
  function popupopen(idpopup,urlpopup,idback,callback) {
   var xy=getWindowDim();
   var background,popup;
  
   if (Object.isUndefined(idpopup) || idpopup == null) {
        popup=$$('body').reduce().appendChild(Element('div',{id:'popupwindow'}));
        popupdestroy=true;
	   }
     else {
		popup=$(idpopup);
        popupdestroy=false;
	   }
   if (Object.isUndefined(idback) || idback == null) background=$$('body').reduce().appendChild(Element('div',{id:'popupbackground'}));
       else background=$(idback);
   if ((popup==null) || (background==null)) return false;
   if (urlpopup != null) {
	   new Ajax.Request(urlpopup, {method: 'get',
              onSuccess: function(transport) {$(idpopup).update(transport.responseText);   if (typeof(callback)=='function') callback();}
       });
      }
   var wh=popup.getDimensions();
   
   var lm=Math.floor(0.5*(xy[0]-wh.width));
   var tm=Math.floor(0.5*(xy[1]-wh.height));
   
   background.setStyle({position:'fixed',top:'0px',left:'0px',background:'#000',zIndex:999,width:xy[0]+'px',height:xy[1]+'px','margin-left':'0px','margin-top':'0px',display:'block',opacity:0.2});

   popup.setStyle({position:'fixed',top:tm+'px',left:lm+'px',zIndex:1000,display:'block'});
   popupwindow=popup;
   popupback=background;
   popupopened=true;
  }
  
  function popupclose()  {
	if (!popupopened) return;
    popupback.remove();
	if (popupdestroy) popupwindow.remove();
	else popupwindow.hide();
   }

// **************** un popup a partir d'une image ******************
  function popupimgopen(img) {
   var xy=getWindowDim();
   var lm=Math.floor(0.5*(xy[0]-img.width));
   var tm=Math.floor(0.5*(xy[1]-img.height));

   var popupwindow=$$('body').reduce().appendChild(Element('div',{id:'popupwindow'}));
   var background=$$('body').reduce().appendChild(Element('div',{id:'popupbackground'}));
	
 $('popupbackground').setStyle({position:'fixed',top:'0px',left:'0px',background:'#000',zIndex:999,width:xy[0]+'px',height:xy[1]+'px','margin-left':'0px','margin-top':'0px',display:'block',opacity:0.2});
 $('popupwindow').setStyle({position:'fixed',display:'block',width:img.width+'px',height:img.height+'px',top:tm+'px',left:lm+'px',zIndex:1000,cursor:'pointer'});
     $('popupwindow').setStyle({background:'url('+img.src+') no-repeat'});
	 $('popupwindow').observe('click',popupimgclose);
  }

  function popupimgclose() {
	$('popupwindow').remove();
	$('popupbackground').remove()
  }
  
var popupwindow, popupback, popupopened=false,popupdestroy;