﻿/*

syntax
javascript:FN_openWin("",'[image location]',[width],[height])
javascript:FN_openWin('moreviews/53/bg-mor_1.jpg&cat=3&scat=7&zone=9&item=53&mor=1',500,655)


*/


function FN_openWin(caption,baseDir,thisPage, preWidth, preHeight){

	addSpace=0;

	screenHeight=parseFloat(preHeight);
	if (caption!="") screenHeight+=15;
	myScrollBars=0;
	myWidth=parseFloat(preWidth)+addSpace;

	myX=(screen.width-myWidth) / 2 
	myY=0; 20 // compensate for mac/windows bars

	if (screen.height < 601){
		screenHeight=(screen.height-40)-myY;
		myScrollBars=0;
		//myWidth+=20;
	}



	myWidth+=25
	screenHeight+=45

	if ( navigator.userAgent.indexOf("MSIE 7.0")>-1 ){ 
		screenHeight+=0
	}

	myY=(screen.height-screenHeight)/2 // center on page

	//newPage="pop.php?image="+thisPage

	commands='menubar=0;toolbar=0,location=0,scrollbars='
	commands+=myScrollBars
	commands+=',width='
	commands+=myWidth
	commands+=',height='
	commands+=screenHeight
	commands+=',resizable=no'

	/*if (baseDir=="") {} else {
		NewWindow = window.open(baseDir+thisPage, "", commands)
	}*/
		NewWindow = window.open("", "", commands)
		documentText=windowHtml(baseDir+thisPage,preWidth,preHeight,caption)

		NewWindow.document.write(documentText);
		NewWindow.document.close();
	

	NewWindow.moveTo(myX,myY);
	NewWindow.focus();

}

function windowHtml(img,w,h,caption){
	html="";
		html+="<html><head><title>HJT : Photo Gallery</title>"
		html+="<link href=\"css/hjt.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />"
		html+="</head><body bgcolor=\"#663366\" leftmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" topmargin=\"0\" >"; //background=\""+img+"\"
		html+="<div class=\"popups\">";
		html+=caption
		html+="</div>";
			html+="<div id=\"popImgOut\"><div id=\"popImg\">";
				html+="<a href=javascript:window.close()>"
					html+="<img src=\""+img+"\" width=\""+w+"\" height=\""+h+"\" border=0 alt=\"click to close window\">";
						html+="</a>"
							html+="<br><br>";
								
									html+="</div></div></body></html>";	
	return html;
}