// variation on  JK Pop up image viewer script- By JavaScriptKit.com
// Visit JavaScript Kit (http://javascriptkit.com)
var windowtitle="Middle River Homestead and Cottages" ; //pop window title

// compensate size for css padding and other bits
var imgleftpad = 0;
var imgrightpad = 0;
var imgtoppad = 0;
var imgbottompad = 45;
var linkheight = 30;
var captionheight = 50;

//default values
var newwidth = 600;
var newheight = 300;

function isexist(obj){
return (typeof obj !="undefined")
}

function openImgWin(imgpath,  popheight,popwidth, alt){
	
	popwidth  = popwidth + imgleftpad + imgrightpad;
	popheight = popheight + imgtoppad + imgbottompad + linkheight + captionheight;

		function getpos(){
				xcoord=(isexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : isexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
				ycoord=(isexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : isexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
				if (window.opera){
						xcoord-=screenLeft
						ycoord-=screenTop
				}
		}

		getpos()
		var imgwin;
		var windowattributes='width='+popwidth+',height='+popheight+',resizable=yes,left='+xcoord+',top='+ycoord
		/*if (typeof imgwin=="undefined" || imgwin.closed)
			imgwin=window.open("","",windowattributes)
		else{*/
			// ? just do it all the time
			//newwidth  = popwidth + imgleftpad + imgrightpad;
			//newheight = popheight + imgtoppad + imgbottompad + linkheight + captionheight;
		
			
		//}
		//if(isexist(imgwin))imgwin.close();
		
		imgwin=window.open("imgwin","",windowattributes)
		imgwin.document.open()	
		//imgwin.resizeTo(newwidth, newheight)
		imgwin.resizeTo(popwidth, popheight)
		imgwin.document.write('<html><head><title>'+windowtitle+'</title><link rel="stylesheet" type="text/css" href="/common/css/viewer.css"></head><body onload="document.title=\''+ windowtitle + '\';" onblur="self.close()"><div align="center"><img id="po_img" name="po_img" src="'+imgpath+'" alt="' + alt + '" ><p>' + alt + '</p><img src="/images/logosmall.jpg" alt="Middle River" height="45" width="300" /><br /><a href="javascript:window.close()">close window</a></p></div></body></html>')
		imgwin.document.close()
		imgwin.focus()
		//
}
