var browser = new Object();
browser.version = parseInt(navigator.appVersion);
browser.isNavigator = false;
browser.isIE = false;
if (navigator.appName.indexOf("Netscape") != -1)
	browser.isNavigator = true;
else if (navigator.appName.indexOf("Microsoft") != -1)
	browser.isIE = true;

function PopupWindow(url, windowname, h, w, arg) 
{
	if (h == '') { h = '80%'; }
	if (w == '') { w = '95%'; }
	var sheight = new String(h);
	var swidth = new String(w);
	var l = 50;
	var t = 50;
	if (sheight.indexOf('%') >= 0)
	{
		h = sheight.replace(/\%/, '');
		h = window.screen.height * (h * 0.01);
		if (h > window.screen.height) { h = window.screen.height * 0.95; }
		t = (screen.height/2) - (h/2) - 50;
		if (t <= 0) t = 10;
	}
	else
	{
		t = (screen.height/2) - (h/2);
	}
	if (swidth.indexOf('%') >= 0)
	{
		w = swidth.replace(/\%/, '');
		w = window.screen.width * (w * 0.01);
		if (w > window.screen.width) { w = window.screen.width * 0.95; }
		l = ((screen.width/2)-(w/2));
		if (l <= 0) l = 10;
	}
	else
	{
		l = (screen.width/2) - (w/2);
	}
	if (arg == '') { arg = "scrollbars,resizable,status,menubar=no,toolbar=no"; }
	if (browser.isIE)
	{
		arg = "height=" + h + ",width=" + w + ",left=" + l + ",top=" + t + "," + arg;
		var popwin = window.open(url, windowname, arg);
	}
	else if (browser.isNavigator) 
	{
		arg = "scrollbars,resizable,status";
		arg = "height=" + h + ",width=" + w + ",screenX=" + ((screen.width/2)-(w/2)) + ",screenY=50," + arg;
		var popwin = window.open(url, windowname, arg);
	}
	else
		var popwin = window.open(url, windowname);

	popwin.focus();
	return true;
}
