// This checks which browser we have;
var isNS = (navigator.appName.indexOf('Netscape') != -1);
var isIE = (navigator.appName.indexOf('Microsoft') != -1);
var hasDOM = (navigator.appVersion.indexOf('4.') != -1 ||
			  navigator.appVersion.indexOf('5.') != -1 ||
			  navigator.appVersion.indexOf('6.') != -1 )
//alert(navigator.appName);

function openWindowCentered(sSrc,name,windowX,windowY,width,height,sFeatures)
{
	/*
		This function opens a window centered on its parent.
		It performs its magic both in Netscape and IE.
	*/
	
	var xPropname = "";
	var yPropname = "";

	// check for a DOM-capable browser, if so use screen objects and set window position
	if (hasDOM)
	{
		//alert(navigator.appVersion);

		windowX = screen.availWidth/2;
		windowY = screen.availHeight/3;

		// IE and Netscape have different properties for window positioning		
		if (isIE)
		{
			xPropname = "left=";
			yPropname = "top=";
		}
		else if (isNS)
		{
			xPropname = "screenX=";
			yPropname = "screenY=";
		}
	}

	// compensates position values for the width and height of the window itself
	windowX = windowX - width/2;
	windowY = windowY - height/2;

	// a debugging-line to check the calculated screen position
	//alert ("windowX=" + windowX + "\nwindowY=" + windowY);
	
	sFeatures = xPropname + windowX + "," + yPropname + windowY + ",width=" + width + ",height=" + height + "," + sFeatures;
	
	// opens the window and gives it focus
	
	var newWin = window.open(sSrc,name,sFeatures);
	newWin.self.focus();

	// if (hasDOM) newWin.onload = resizeWindow(newWin,width,height);
}

function resizeWindow(newWin,width,height)
{
	var dWidth 	= 0;
	var dHeight = 0;

	// add the browserchrome to width + height
	// so we can use the resizeTo function later
	if (isIE)
	{
		dWidth  = width - newWin.clientWidth;
		dHeight = height - newWin.clientHeight;
	}
	else if (isNS)
	{
		dWidth  = width - newWin.innerWidth;
		dHeight = height - newWin.innerHeight;
	}
	// resize using new outerWidth and outerHeight values
	newWin.resizeBy(dWidth,dHeight);	
}
