/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var popupWindow = null;
var popupSettings = null;
function NewWindow(mypage, myname, w, h, scrl, pos, resiz) {
	yesorno = function(val) { pattern = /t(rue)?|y(es)?|1/i; return pattern.test(val) ? 'yes' : 'no' }
	var wMax = (screen.width) ? (screen.width) : 1024, hMax = (screen.height) ? (screen.height) : 768;
	var x = 0, y = 0;
	if (typeof myname != "string") myname = "Popup-" + Math.random();
	w = w || 640;
	h = h || 480;
	scrl = yesorno(scrl);
	resiz = yesorno(resiz);
	w = Math.min(w, wMax - 20);
	h = Math.min(h, hMax - 40);
	if (pos == "random") {
		x = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100;
		y = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100;
	}
	else if (pos == "center") {
		x = (screen.width) ? (screen.width - w) / 2 : 100;
		y =(screen.height) ? (screen.height -h ) / 2 : 100;
	}
	settings = 'width=' + w + ',height=' + h + ',top=' + y + ',left=' + x + ',scrollbars=' + scrl + ',resizable=' + resiz;
	settings += ',location=no,directories=no,status=no,menubar=no,toolbar=no';
	if (popupWindow && !popupWindow.closed)
		popupWindow.close();
	popupWindow = window.open(mypage, myname, settings);
	popupSettings = settings;
	popupWindow.focus();
}

