// variation on  JK Pop up image viewer script- By JavaScriptKit.com
// Visit JavaScript Kit (http://javascriptkit.com)
var windowtitle="Kangaroo Island" ; //pop window title

// compensate size for css padding and other bits
var imgleftpad = 0;
var imgrightpad = 0;
var imgtoppad = 0;
var imgbottompad = 0;
var linkheight = 30;
var captionheight = 20;

//default values
var newwidth = 600;
var newheight = 300;

function isexist(obj){
return (typeof obj !="undefined")
}

function openImgWin(imgpath,  popheight,popwidth, alt){

		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.document.write('<html><head><title>'+windowtitle+'</title><link rel="stylesheet" type="text/css" href="/core/css/viewer.css"></head><body onload="document.title=\''+ windowtitle + '\';" onblur="self.close()"><img id="po_img" name="po_img" src="'+imgpath+'" alt="' + alt + '" ><br><a href="javascript:window.close()">close window</a></body></html>')
		imgwin.document.close()
		imgwin.focus()
	
}

