/*
	Fichiers des fonctions JavaScript
	Jean-Philippe BATTU 	jeanpba@free.fr
	pour Alain et Annie Charriere

	References			Date			Fonction
	ouvre_popup()			10/04/2005		Ouvre une popup en fonction de la taille de l'ecran
	enable_png_transparent_ie()	28/03/2006	Pour corriger la prise en compte des png transparents avec IE55 et suivants
*/

function 	ouvre_popup(page,arg,lx,ly) 
	{
	var AutoClose = false;
	var x=(screen.availWidth-lx)/2;
	var y=(screen.availHeight-ly)/2;
	var opt = arg + ",top=" + y + ",left=" + x ;
	window.open(page,'',opt);
	}

//tempsFermeture = 10;
// Fermer le PopUp après 10 de secondes?
// Mettre 0 pour ne pas fermer le PopUp
// Voir la difference entre screen.availWidth et screen.width sur : http://fr.selfhtml.org/javascript/objets/screen.htm
// ou sur http://aliasdmc.free.fr/coursjavas/cours_javascript86.html , la difference etant au niveau des barres de taches

function 	DisplayImage(url, width , height) 	
	{
	// var top = (screen.height - height) / 2;
	var top = ( screen.availHeight - height) / 2;
	// var left = (screen.width - width) / 2;
	var left = ( screen.availWidth - width) / 2;
	// suite a la remarque de Alain Schauber du 17/07/2005, les scrollbars dans les fenetres popup sont ici autorisees scrollbars=1
	pFenetre = "resizable=0, scrollbars=1, left=" + left + ",top=" + top + ",width=" + width + ",height=" + height;
	//toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=600, height=600, left=10, top=20
	preview = window.open( url , '', pFenetre);
	// setTimeout('top.close();', 10);
	//if (tempsFermeture) setTimeout("pub.close();", tempsFermeture*1000);
	}

function 	PopUp( pagename , x , y ) 
	{
	url = "affiche_popup.php?name=" + pagename + "&coordx=" + x + "&coordy=" + y ;
	width = x + 20 ; // largeur du PopUp en pixels
	height = y + 30 ; // hauteur du PopUp en pixels
	delay = 0; // temps en seconde avant l'ouverture du PopUp
	DisplayImage(url, width, height);
	// timer = setTimeout("Debute(url, width, height)", delay*1000);
	}

function        enable_png_transparent_ie()
   {
   for(var i=0; i<document.images.length; i++)
      {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "'" : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " :"title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle      
         var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
         img.outerHTML = strNewHTML
         i = i-1
         }
      }
   }

window.attachEvent("onload", enable_png_transparent_ie ) ;
