// Fonction pour afficher une image dans pop up qui se redimensionne automatiquement
/*
function popImage(chemin)
   {
   html = '<html> <head> <title>ImageMax</title> </head> <body TOPMARGIN="0" LEFTMARGIN="0" onBlur="top.close()">';
   html += '<IMG src="'+chemin+'" BORDER=0 NAME=ImageMax onLoad="window.resizeTo(document.ImageMax.width, document.ImageMax.height+50)" onmousedown="self.close();">';
   
   html += '</body></html>';
   popupImage = window.open('','_blank','toolbar=0, location=0, directories=0, menuBar=0, scrollbars=0, resizable=1');
   popupImage.document.open();
   popupImage.document.write(html);
   popupImage.document.close()
   };
*/
/*
Après avoir ouvert la fonction, on va écrire le contenu HTML de notre pop-up dans une variables, ici html.
 événement (onBlur) avec la méthode close permet de fermer la fenêtre lorsque l'on clique à coté.
Ensuite on va y inscrire l'image grace au paramètre chemin envoyé à la fonction. 
Au chargement de l'image, grâce à l'événement (onLoad), on va retailler la fênetre en utilisant la méthode resizeTo de l'objet window et les propriété width et height de l'image (ici ImageMax est le nom de l'élement <img>)
*/

// Fonction pour afficher une animation flash avec l'image dans pop up qui se redimensionne automatiquement
function popImage(chemin)
   {
	var pos_slash_fin = chemin.lastIndexOf("/"); 
	var nom = chemin.substring(pos_slash_fin+1,chemin.length);	
	var pos_slash_fin2 = chemin.lastIndexOf("/",pos_slash_fin-2); 
	var largeur = chemin.substring(pos_slash_fin2+1,pos_slash_fin);	
	var hauteur = 200;	
	var rep = "rep="+j_url+chemin.substring(1,pos_slash_fin+1);
	
	var chem_swf = j_url+"moteur/flash/anim/alpha00.swf";	
	var variables = "largeur="+largeur+"&amp;";
	variables += rep+"&amp;nb=1&amp;element0="+nom; 


   	html3 = '<html>';
	html3 += '<head>';
	html3 += '<title>Pop Image</title>';
		
	//html3 += '</head>';
	//html3 += '<body TOPMARGIN="0" LEFTMARGIN="0" onBlur="top.close()">';
	
	html3 += '<script language="javascript">';
	html3 += "function aff_anim(h){";
	//html3 += "document.write('</div>');";
	//html3 += 'var h=document.images["idimage"].height;';	
	html3 += "document.write('";
	//html3 = '<html>';
	html3 += '<head>';
	html3 += '<title>Pop Image</title>';	
	html3 += '</head>';
	//html3 += '<body TOPMARGIN="0" LEFTMARGIN="0">';
	html3 += '<body TOPMARGIN="0" LEFTMARGIN="0" onBlur="window.close()">';
	html3 += '<div onmousedown="window.close();">';
	html3 += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largeur+'" height="';
	html3 += "'+h+'";
	html3 += '" align="middle">';
	html3 += '<param name="allowScriptAccess" value="sameDomain" />';
	html3 += '<param name="movie" value="'+chem_swf+'" />';
	html3 += '<PARAM NAME="FlashVars" VALUE="hauteur=';
	html3 += "'+h+'";
	html3 += '&amp;'+variables+'">';
	html3 += '<param name="loop" value="false" />';
	html3 += '<param name="menu" value="false" />';
	html3 += '<param name="quality" value="high" />';
	html3 += '<param name="wmode" value="transparent" />';
	html3 += '<param name="bgcolor" value="#ffffff" />';
	html3 += '<PARAM NAME="Scale" VALUE="ExactFit" />';
	html3 += '<embed src="'+chem_swf+'" FlashVars="hauteur=';
	html3 += "'+h+'";
	html3 += '&amp;'+variables+'" loop="false" menu="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+largeur+'" height="';
	html3 += "'+h+'";
	html3 += '" scale="exactfit" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	html3 += '</object>';
	html3 += '</div>';
	
	html3 += "</body></html>');";
	//html3 += 'document.getElementById( "divimg" ).style.visibility ="hidden";document.getElementById( "divimg" ).style.display ="none";';
	html3 += '}';
	html3 += '</script>';	
	
	
	html3 += '</head>';
	html3 += '<body TOPMARGIN="0" LEFTMARGIN="0">';
		 
	html3 += '<div id="divimg" style="visibility:hidden">';
	html3 += '<IMG src="'+chemin+'" BORDER=0 NAME=ImageMax id="idimage" onLoad="window.resizeTo(document.ImageMax.width, document.ImageMax.height+50);aff_anim(document.ImageMax.height)">';
	html3 += '</div>';
	html3 += '</body>';
	html3 += '</html>';
	
 
   popupImage2 = window.open('','_blank','toolbar=0, location=0, directories=0, menuBar=0, scrollbars=0, resizable=no');
   popupImage2.document.open();
   popupImage2.document.write(html3);
   popupImage2.document.close()
};
