
// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
	if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
	{
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	}
	else if  (window.onload)
	{
		if (window.onload != SafeOnload)
		{
			gSafeOnload[0] = window.onload;
			window.onload = SafeOnload;
		}		
		gSafeOnload[gSafeOnload.length] = f;
	}
	else
		window.onload = f;
}
function SafeOnload()
{
	for (var i=0;i<gSafeOnload.length;i++)
		gSafeOnload[i]();
}

function OpenWindowCentered(url, key, w, h, useParentForMetrics, settings)
{
	if( useParentForMetrics )
	{
		sLeft = parseInt(isNaN(window.parent.screenX)?window.parent.screenLeft:window.parent.screenX);
		sTop = parseInt(isNaN(window.parent.screenY)?window.parent.screenTop:window.parent.screenY);
		myWidth = 0
		myHeight = 0;
	if( typeof( window.parent.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.parent.innerWidth;
		myHeight = window.parent.innerHeight;
	} else if( document.documentElement &&
		( parent.document.documentElement.clientWidth || parent.document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = parent.document.documentElement.clientWidth;
		myHeight = parent.document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = parent.document.body.clientWidth;
		myHeight = parent.document.body.clientHeight;
	}
	} else {
		sLeft = parseInt(isNaN(window.screenX)?window.screenLeft:window.screenX);
		sTop = parseInt(isNaN(window.screenY)?window.screenTop:window.screenY);
		myWidth = 0
		myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement &&
		( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	}
		LeftPosition = (myWidth) ? (myWidth-w)/2 + sLeft : 0;
		TopPosition = (myHeight) ? (myHeight-h)/2 - 32 + sTop : 0;
		if( settings == '' || settings == null ) settings = 'menubar=no,scrollbars=no,statusbar=no';
		settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',' + settings;
		newwin = window.open( url, key, settings );
		if( LeftPosition < 0 || TopPosition < 0 ) newwin.moveTo(LeftPosition, TopPosition);
		return newwin;
}
