<!--
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.2  

// this function can now be called with the first argument alone.
// 20040104 FI avec adhoqueries pr mozilla
// 20060111 FI  tag title for firefox
function JustSoPicWindow(imageName,alt,bgcolor,defaultWindowWidth,defaultWindowHeight) {

	if (defaultWindowWidth == undefined) { defaultWindowWidth =640;}
	if (defaultWindowHeight == undefined) { defaultWindowHeight=480;}
	defaultPosLeft=10;
	defaultPosTop=10;

	if ((bgcolor=="")||(bgcolor == undefined)) {bgcolor="#FFFFFF";}

	if (alt == undefined) {alt="Click to close";}

	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
	
	
	newWindow = window.open("vwd_justso.html","newWindow","resizable=1,width="+defaultWindowWidth+",height="+defaultWindowHeight+",left="+defaultPosLeft+",top="+defaultPosTop);
	newWindow.document.open("text/html","replace");
	newWindow.document.writeln('<html><head><title>'+alt+'</title>');
	newWindow.document.writeln('</head>');
	// FI 030619 :  onBlur="self.close()" deleted because not intuitive for the user 
	newWindow.document.writeln('<body OnLoad="ReSizeWindowToImage(' + "'" + alt + "'" + ')" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onClick="self.close()">');
	newWindow.document.writeln('<span id=image><img src="'+imageName+'" alt="' + alt + '" title="' + alt + '" name="TheImage" id="TheImage"></span>'); 
	newWindow.document.writeln('</body></html>');
	// ununderstandable error when doing this with IE *and* not locally :newWindow.document.write('<scr' + 'ipt src="vwd_justsopw2.js" language="javascript1.2" content-type="text/javascr'+'ipt"></scr');
	//									newWindow.document.writeln('ipt>');
	// So I have to write down the whole thing in a variable (cd infra) and insert it...
	newWindow.document.writeln('<scr' + 'ipt language="javascript1.2" content-type="text/javascript">' + TextOfJavaSript); 
	newWindow.document.writeln('</scr' + 'ipt>');
	

	newWindow.document.close();
	newWindow.focus();
	return(false);
	}
}



// this variable contains the source of code to be inserted in the new window
var TextOfJavaSript = '<!--\n\
// initial JustSoPicWindow was \n\
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.\n\
// version 3.0.2  \n\
// This script by FI 030619 \n\
\n\
var GlobalAltText;\n\
var fullImageSize=false;\n\
\n\
var ns4=document.layers?1:0\n\
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1\n\
var ns6=document.getElementById&&!document.all?1:0\n\
\n\
\n\
\n\
function ReSizeWindowToImage(alt) {\n\
// according to Netscape javascript 1.3 reference, we need \n\
// UniversalBrowserWrite privilege to set a window inner size under \n\
// 100x100\n\
// undef in IE (how surprising...) netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");    \n\
	GlobalAltText=alt;\n\
\n\
	var StartMenu=28 // size in pixel of the menu bar on bottom of Windows screen\n\
	var TitleBar=26 // size in pixel of the title bar of the window (plus bottom border)\n\
	var MozillaSideBar=0 // wasted side margin in Mozilla windows\n\
	if (ns6) {\n\
		TitleBar=40 \n\
		MozillaSideBar=8 // wasted side margin in Mozilla windows\n\
	}\n\
	\n\
	// note : the image tag must have a name=TheImage.\n\
	var MyImage=new Image();\n\
	MyImage.src=document.TheImage.src;\n\
\n\
	//Was the img src file found ?\n\
	if (!(MyImage.complete)) {\n\
		return(false);\n\
	}\n\
	\n\
	\n\
	// Would have been better using directly TheImage, but it sometimes image was not loaded when\n\
	// the body onload event was called. So... with the MyImage.src=TheImage.src, we make sure the is IS loaded\n\
	\n\
	imageWidth=MyImage.width;\n\
	imageHeight=MyImage.height;\n\
	\n\
	\n\
	var w = screen.width;\n\
	var h = screen.height;\n\
	var byFactor=1;\n\
\n\
	if (imageWidth>w){ // image too large ? let us reduce both width and height	\n\
	  byFactor = w / imageWidth;			\n\
	  imageWidth = w;\n\
	  imageHeight = imageHeight * byFactor;\n\
	}\n\
\n\
	var adj=StartMenu+TitleBar;\n\
\n\
	if (imageHeight>h-adj){ // image still too tall ? let us reduce both width and height	\n\
	  byFactor = (h-adj) / imageHeight;\n\
	  imageWidth = (imageWidth * byFactor);\n\
	  imageHeight = h-adj; \n\
	}\n\
\n\
	var posTop =  ((h-(imageHeight+adj))/2);\n\
 	var posLeft = ((w-imageWidth)/2);\n\
\n\
	posLeft = parseInt(posLeft);\n\
	posTop  = parseInt(posTop);\n\
	imageWidth =parseInt(imageWidth);\n\
	imageHeight=parseInt(imageHeight);\n\
	\n\
// move and resize the window	\n\
window.moveTo(posLeft,posTop);\n\
\n\
// resize picture when the initial picture is bigger than screen\n\
if (((imageWidth!=MyImage.width) || (imageHeight!=MyImage.height)) && (!fullImageSize)) {\n\
	window.resizeTo(imageWidth+MozillaSideBar,imageHeight+TitleBar);\n\
	var TextImgResized ="\\nInitial image " + TheImage.width + "x" + TheImage.height + " resized to " + imageWidth + "x" + imageHeight + "\\nPress any key for full size";\n\
	image.innerHTML="<img src=\\"" + TheImage.src + "\\" width=" + imageWidth + " height=" + imageHeight + " alt=\\"" + alt + TextImgResized + "\\" title=\\"" + alt + TextImgResized + "\\" name=\\"TheImage\\">";\n\
}\n\
else {\n\
	window.resizeTo(MyImage.width+MozillaSideBar,MyImage.height+TitleBar);\n\
	//alert("pleine taille FIFIFI" + fullImageSize);\n\
	var TextImgResized ="\\nImage " + TheImage.width + "x" + TheImage.height;\n\
	if ((imageWidth!=MyImage.width) || (imageHeight!=MyImage.height)) {\n\
		// full size asked by user, bigger than screen\n\
		// resize window to full screen\n\
		window.resizeTo(w,h-StartMenu);\n\
		window.moveTo(0,0);\n\
		// give opportunity to get back to reduced size\n\
		TextImgResized += "\\nPress any key for reduced size";\n\
		if (ie4) { // FIFIFI not really happy with this... \n\
			document.body.scroll="yes";\n\
		} else {\n\
			window.scrollbars.visible=true;\n\
		}\n\
	}\n\
	image.innerHTML="<img src=\\"" + TheImage.src + "\\" width=" + MyImage.width + " height=" + MyImage.height + " alt=\\"" + alt + TextImgResized + "\\" name=\\"TheImage\\">";\n\
}\n\
\n\
}\n\
\n\
\n\
\n\
\n\
\n\
if (ns4)\n\
document.captureEvents(Event.KEYPRESS)\n\
function ReSize(e){\n\
if (ns4||ns6){\n\
fullImageSize=!fullImageSize;\n\
ReSizeWindowToImage(GlobalAltText);\n\
//if (e.which==122)\n\
}\n\
else if (ie4){\n\
fullImageSize=!fullImageSize;\n\
ReSizeWindowToImage(GlobalAltText);\n\
//if (event.keyCode==122)\n\
}\n\
}\n\
document.onkeypress=ReSize\n\
\n\
//-->\n\
';
//-->