var isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;


function popCenterWin(w,h,url){
	// width of the new window
	var wWidth = w;
	// height of the new window
	var wHeight = h;
	// window left position
	var posL = (window.screen.availWidth - wWidth) / 2;
	// window top position
	var posT = (window.screen.availHeight - wHeight) / 2;
	// see if extra param has passed in
	if(arguments.length==4){
		var extra = ',' + arguments[3];
	}else{
		var extra = "";
	}
	var newWin = window.open(url,"centreWindow",'width=' + wWidth + ',height=' + wHeight + ',top=' + posT + ',left=' + posL + extra);
	newWin.focus();
}


function exactImgWin(imgPath,w,h){
	// window width
	var winW = (!isMac) ? w : w - 15;
	// window height
	var winH = (!isMac) ? h : h - 15;
	// window left position
	var posL = (window.screen.availWidth - winW) / 2;
	// window top position
	var posT = (window.screen.availHeight - winH) / 2;
	// window content
	var winContent = '\n<html>\n<head>\n<title>jw-jones.com\' Gallery</title>\n</head>\n<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">\n<A HREF="javascript:window.close()"><img src="'+ imgPath +'" alt="Click To Close" border="0"></A>\n</body>\n</html>\n';
	// window params
	var winParams = 'width=' + winW + ',height=' + winH + ',top=' + posT + ',left=' + posL;
	// srollbars and resizable?
	if(arguments.length == 4){
		winParams += ',scrollbars=1,resizable=1';
	}
	// create an unique window name
	rn = new Date();
	winName = rn.getHours();
	winName = winName + '_' + rn.getMinutes();
	winName = winName + '_' + rn.getSeconds();
	// open window
	fotoWin = window.open('', winName, winParams);
	fotoWin.document.write(winContent)
	fotoWin.focus();
}