var isDOM = (document.getElementById)? true : false;
var uAgent =  navigator.userAgent.toLowerCase();
var isIE = (window.showHelp) ? true : false;
var isOpera = (window.opera || uAgent.indexOf('opera') > - 1) ? true : false;
var isMac = (uAgent.indexOf( "mac" ) > -1) ? true : false;
var isSafari = (uAgent.indexOf("safari") > - 1) ? true : false;
var isMozilla = (uAgent.indexOf( "gecko" ) > -1 && !isSafari && !isOpera) ? true : false;
var MozVer = ( isMozilla ) ? parseFloat( uAgent.substring( uAgent.indexOf( "rv:" ) + 3, uAgent.indexOf( "rv:" ) + 7 ) ) : 0;

var scrWidth = screen.availWidth;
var scrHeight = screen.availHeight;

var newwin;

function openWnd(theURL) {
	var additional_appearance = "status=yes,resizable=1,scrollbars=yes,menubar=no,toolbar=no,location=no";

	if (openWnd.arguments[5] && (openWnd.arguments[5] != "")){
		additional_appearance = openWnd.arguments[5];
	}
	var width = (openWnd.arguments[1]) ? openWnd.arguments[1] : 500;
	var height = (openWnd.arguments[2]) ? openWnd.arguments[2] : 300;
	var type = (openWnd.arguments[3] == 'image') ? true : false;
	var wtitle = (openWnd.arguments[4]) ? openWnd.arguments[4] : 'Preview';
	var left = Math.round((scrWidth-width)/2);
	var top = Math.round((scrHeight-height)/2)-35;

	var kw = (isIE) ? 20 : 0;

	additional_appearance += ",width="+(width+kw);
	additional_appearance += ",height="+height;
	additional_appearance += ",top="+top;
	additional_appearance += ",left="+left;
	winname = 'pwindow';

	if ( newwin && !newwin.closed ){
		newwin.location.href = theURL;
		newwin.resizeTo(width,height);
		newwin.resizeBy(width-newwin.document.body.clientWidth,height-newwin.document.body.clientHeight);
	}else{
		newwin = window.open(theURL,winname,additional_appearance);
	}
	if ( type ){
		output = '<html><head><title>'+wtitle+'</title></head><body bgcolor="#ffffff" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><img src="'+theURL+'" width="'+width+'" height="'+height+'" border=0></body></html>';
		newwin.document.open();
		newwin.document.write(output);
		newwin.document.close();
	}

	newwin.focus();

	return newwin;
}

