// popup window auto dimensionnée
// --------------------------------------------
var popUpWin=0;

function PopupWin(titre, fichier,lien,titreimage) {
	var xp=100;
	var yp=20;
	// c'est un fichier html
	if( fichier.indexOf(".html") != -1 ) {
	     popUpWindowURL(fichier, 20, 40,700, 900);
		 return;
	}
	// c'est un fichier Flash
	else if ( fichier.indexOf(".swf") != -1 ) {
	    popUpWindowFLASH(fichier, 20, 40,820, 660);
	    return;

	}
	popUpWin=open("",'fichier','width=2,height=2,toolbar=no,scrollbars=yes,resizable=yes');
	popUpWin.moveTo(xp,yp);
	popUpWin.document.write("<HTML><HEAD>");
	popUpWin.document.write('<style type="text/css"><!-- .Arial12 {font-family: Arial, Helvetica, sans-serif; font-size: 12px}--></style>');
	popUpWin.document.write('<TITLE>'+titre+'</TITLE>');	
	popUpWin.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {window.resizeTo(document.images[0].width+40,document.images[0].height+140); self.focus();}");
		popUpWin.document.write("else { setTimeout('checksize()',600) } window.resizeTo(document.images[0].width+40,document.images[0].height+140); self.focus();}</"+"SCRIPT>");
	popUpWin.document.write("</HEAD>");
    popUpWin.document.write("<BODY   onload='checksize()' leftMargin=10 topMargin=10 marginwidth=0 marginheight=0 onBlur='self.focus'>");
	if(arguments.length > 2 && lien.length > 0) 
		popUpWin.document.write("<CENTER><A href='"+ lien +"' target='_blank'><IMG src='"+fichier+"' border=2 alt='"+titreimage+"'title='"+titreimage+"'></CENTER></A>");
	else
		popUpWin.document.write("<CENTER><IMG src='"+fichier+"' border=2 ></CENTER>");	
	popUpWin.document.write("<div align='center'><b><span class='Arial12'>"+titre+"</span></b></div><br>");
	popUpWin.document.write("<CENTER><INPUT TYPE=button value='Fermer la fenêtre / Close Window' onClick=window.close()></CENTER><br>");
	popUpWin.document.write("<style type='text/css'><!-- body { background-image: url(Ressources/Fonds/fond.jpg);}--></style>");
	popUpWin.document.write("</BODY></HTML>");
	popUpWin.focus();
	popUpWin.document.close();
}

// Window PopUp pour un URL .
function popUpWindowURL(URLStr, left, top, width, height)
{ 
  if(popUpWin){
     if(!popUpWin.closed) popUpWin.close();
  }

  if(width < 20) width = 800; if (height < 20 ) height = 600;
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
   popUpWin.focus();
}
// pour les diaporama flash
// ------------------------
function popUpWindowFLASH(diaporama1, left, top, width, height)
{ 
  if(popUpWin){
     if(!popUpWin.closed) popUpWin.close();
  }
  // composition nom de la page + nom du fichier swf
  // passage du nom en variable $_GET
  // -----------------------------------------------
  var urlswf= "Images/diaporamas/diaporama00.php?diapo="+diaporama1;//diaporama1;
  if(width < 20) width = 800; if (height < 20 ) height = 600;
  popUpWin = open(urlswf, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
   popUpWin.focus();
}



