//------------ Global Variables -----------
var sWindowName = "";

//Use to center the new window:
var gWidth = 800;
var gHeight = 550;
var gscrollbars='yes';
var gTop = (screen.height / 2) - (gHeight/2);
var gLeft = (screen.width / 2) - (gWidth/2);

var windowFeatures ="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + gWidth + ",height=" + gHeight + ",top=" + gTop + ",left=" + gLeft;
var newWindow;
//------------ Browser Detection ----------
var browser = "";
var browsername = navigator.appName;
var browserversion = parseInt(navigator.appVersion);
var IsPrint = (window.print) ? 1 : 0;
var IsFrames = (window.frames)? 1 : 0;

if (browsername == "Netscape") {
    browser = "ns" + browserversion;
} else {
    if (browsername == "Microsoft Internet Explorer") {
        if (browserversion >= 4) {
            browser = "ie" + browserversion;
        } else {
            browser = "ie3";
        }
    }
}

//------------ Open New Window -------------
function openWindow( url, name, features)	{
	var newWindow;
	newWindow = window.open(url,name,features);

	if (newWindow != null)
	{
		if (newWindow.opener == null)
			newWindow.opener=self;
		if ((browser == "ns3","ns4") || (browser == "ie4"))
			newWindow.focus();
	}
}

/****************************
 * This function is simpler to use b/c only the url is needed.
 * However, it also gives a little more freedom with width & height. 
 * You can simply assign sWindowName, gHeight, & gWidth before calling this function.
 ****************************/
function openWindow2( url )
{
	var newWindow;
	var gTop = (screen.height / 2) - (gHeight/2);
	var gLeft = (screen.width / 2) - (gWidth/2);
	var windowFeatures ="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + gscrollbars + ",resizable=no,width=" + gWidth + ",height=" + gHeight + ",top=" + gTop + ",left=" + gLeft;

	newWindow = window.open(url, sWindowName, windowFeatures);
	
	if (newWindow != null)
	{
		if (newWindow.opener == null)
			newWindow.opener=self;
		if ((browser == "ns3","ns4") || (browser == "ie4"))
			newWindow.focus();
	}
	gscrollbars='yes';
	sWindowName="";
}


function closeWindow () {
	self.close ();
}


function KeepOnTop(){
	if ( browser != "ie3" )
		self.focus();
	}                                           

//------------ Print frame ----------
function PrintWindow(){
if ( self != top){
	if (IsPrint && IsFrames){
		if (browser != "ie3")
			parent.frames["wPrint"].focus();
		parent.frames["wPrint"].print();
		} else {
			alert("Your browser does not support automatic print.\nPlease click the print icon on your browser.");
			if (browser != "ie3")
				parent.frames["wPrint"].focus();
		}	
	}	
}


//---- Test Function ----
function OpenPrintWindow(strURL){
	//center the new window:
	var pWidth = 750;
	var pHeight = 400;
	var pTop = (screen.height / 2) - (pHeight/2);
	var pLeft = (screen.width / 2) - (pWidth/2);
	
	if (IsPrint && IsFrames){
		windowFeatures = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + pWidth + ",height=" + pHeight + ",top=" + pTop + ",left=" + pLeft;
	} else {
		windowFeatures = "toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + pWidth + ",height=" + pHeight + ",top=" + pTop + ",left=" + pLeft;
	}
	openWindow(strURL,'print',windowFeatures);
}

function seePage(thePage) {
	if (window.opener){
		window.opener.location.href = thePage;
	}
	window.close();
}



var OrigColor;
function ChgColor(color)
{
	OrigColor = window.event.srcElement.style.color;
	window.event.srcElement.style.color = color;
}

function RstColor()
{
	window.event.srcElement.style.color = OrigColor;
}



