//
// Windows functions
//

/**
** Open a popup window centered on the page
**
**/
function openCenteredWindow(theURL,winName,height,width,features)
{
    var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt
    features = features + ",height=" + height
    features = features + ",width=" + width

    if(navigator.appName == "Microsoft Internet Explorer")
    {
        //screenY = document.body.offsetHeight
        screenY = window.screen.availHeight
        screenX = window.screen.availWidth
    }
    else
    { // Navigator coordinates
    //		screenY = window.outerHeight
    //		screenX = window.outerWidth
        // change made 3/16/01 to work with Netscape:
            screenY = screen.height;
            screenX = screen.width;
    }

    //alert("Navigator: " + navigator.appName + " , Screen X: " + screenX + " ,Screen Y: " + screenY + " , width: " + width + " , height: " + height );

    leftvar = (screenX - width) / 2
	rightvar = (screenY - height) / 2

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		leftprop = leftvar
		topprop = rightvar - 20
	}
	else
	{ // adjust Netscape coordinates for scrolling
		leftprop = (leftvar - pageXOffset)
		topprop = (rightvar - pageYOffset)
	}

    features = features + ",left=" + leftprop
    features = features + ",top=" + topprop

    //alert("Feature: " + features);

    window.open(theURL,winName,features);
}


function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
