nn4 = (document.layers) ? true : false;
ie4 = (document.all) ? true : false;
dom = (document.createTextNode)? true : false;
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));

function popupWindow(fileUrl, winW, winH, winN, scrollB) {
	var winWidth = (winW)? winW : 740;
	var winHeight = (winH)? winH : 520;
	var winName = (winN)? winN : 'popupWin'
	var scrollBars = (scrollB)? scrollB : 'auto'
	
	if (nn4 || ie4 || dom || is_ie) {
		var w = screen.width - (is_ie ? 35 : 0);
		var h = !is_ie ? screen.height : get_ie_h();
		//alert(w + 'x' + h + '--' + screen.availHeight);
		if (w < winWidth + 50) { winWidth = w - 50; scrollbars = 'yes' }
		if (h < winHeight + 100) { winHeight = h - 100; scrollbars = 'yes' }
		posX = Math.round((w - winWidth) / 2);
		posY = Math.round((h - winHeight) / 2);
		posCode = ((nn4 || dom) && !is_ie)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;
		//alert(winWidth + ' x ' + winHeight);
		//alert(posCode);
	} else {
		posCode = "";
	}
	var popupWin = window.open(fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=no,resizable=no,width=" + winWidth + ",height=" + winHeight + "," + posCode);
	if (popupWin) popupWin.focus();
}

function get_ie_h() { return get_doc_scroll()[1] + get_doc_size()[1] - 35; };
function get_doc_scroll(){var x=0,y=0;if(typeof(window.pageYOffset)=='number'){y=window.pageYOffset;x=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){y=document.body.scrollTop;x=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){y=document.documentElement.scrollTop;x=document.documentElement.scrollLeft;};return [x,y];};function get_doc_size(){var A,doc_w;if (typeof(window.innerWidth)=='number'){doc_w=window.innerWidth;A=window.innerHeight;}else if (document.documentElement&&document.documentElement.clientWidth&&document.documentElement.clientHeight){A=document.documentElement.clientHeight;doc_w=document.documentElement.clientWidth;}else if (self.innerWidth){A=self.innerHeight;doc_w=self.innerWidth;}else if (document.body){A=document.body.clientHeight;doc_w=document.body.clientWidth;};return new Array(doc_w,A);}