// **********************************************************************************
// main.js
// Generic javascript functions
// **********************************************************************************

function clearBox ( obj ){
	obj.value = "";
}
// ************************************************************************************************

var blnClearNavSearch = true;

// **********************************************************************************
function gotoQuickLink( obj ) {
	top.document.location.href = obj.options[ obj.selectedIndex ].value
}
// **********************************************************************************
function clearFirstTimeTextInput( el ) {
	if( blnClearNavSearch ) {
		el.value = ""
		blnClearNavSearch = false
	}
}
// **********************************************************************************
function launchGlossary( term ) {
	var strHREF = "/glossary/index.htm?term=" + term
	var objWindow = window.open( strHREF, "Glossary", "height=250,width=460,status=yes,scrollbars=no,toolbar=no,resizable=yes" )
	objWindow.focus()
}
// **********************************************************************************
// Write Glossary link
// **********************************************************************************
function wgl( name ) {
	var searchName = name;
	strTitle = "title=\"Look up " +name+ " in our glossary of financial terms\""
	strHREF = "href=\"/glossary/index.htm#" + searchName + "\""
	strOnClick = "onClick=\"launchGlossary('" +searchName+ "'); return false;\""

	document.write( "<a " +strTitle+ " " +strHREF+ " " +strOnClick+ ">" +name+ "</a>"  )
}
// **********************************************************************************
function catchDBLClick() {
	if (boolAlreadySubmitted) {
		return false
	} else {
		// undefined/false
		boolAlreadySubmitted=true
		return true
	}
}
// **********************************************************************************
function openWindow( url, name, width, height, features ) {
	properties = "width=" +width+ ",height=" +height+ "," +features + ",resizable=yes"
	objWindow = window.open( url, name, properties )
	objWindow.focus();
}
// ******************************************************************
function openPopWin(windowURL, windowWidth, windowHeight, windowFeatures, windowLeft, windowTop) {
	var windowName = "popup";

	if (windowLeft=="cen") {
		windowLeft = (screen.width - windowWidth)/2 - 20;
	}
	windowTop =+ 20;

	var windowProperties = "width=" + windowWidth + ",height=" + windowHeight + "," + windowFeatures + ",left=" + windowLeft + ",top=" + windowTop;
	window.open(windowURL,windowName,windowProperties);
}
// **********************************************************************************
function writeOpenWindowBold( linkText, linkTitle, url, name, width, height, features, linkClass ) {
	str = "openWindow('" +url+ "', '" +name+ "'," +width+ "," +height+ ",'" +features+ "','" +linkClass+ "');return false;"

	document.write( "<a class=\"bold\" href=\"" +url+ "\" onClick=\"" +str+ "\" title=\"" +linkTitle+ "\" class=\"" +linkClass+ "\">" +linkText+ "<\/a>" )
}
// **********************************************************************************
// **********************************************************************************
function writeOpenWindow( linkText, linkTitle, url, name, width, height, features, linkClass ) {
	str = "openWindow('" +url+ "', '" +name+ "'," +width+ "," +height+ ",'" +features+ "','" +linkClass+ "');return false;"

	document.write( "<a href=\"" +url+ "\" onClick=\"" +str+ "\" title=\"" +linkTitle+ "\" class=\"" +linkClass+ "\">" +linkText+ "<\/a>" )
}
// **********************************************************************************
// **********************************************************************************
function writeOpenWindowButton( linkText, linkTitle, url, name, width, height, features ) {
	str = "openWindow('" +url+ "', '" +name+ "'," +width+ "," +height+ ",'" +features+ "');return false;"

	document.write( "<a href=\"" +url+ "\" onClick=\"" +str+ "\" title=\"" +linkTitle+ "\" class=\"textButton\">" +linkText+ "<\/a>" )
}
// **********************************************************************************
function writeCloseThisWindow() {
	document.write( "<a href=\"javascript:top.window.close();\" title=\"Close this window\">Close this window</a>" );
}
// **********************************************************************************
// Browser detection
function browserType() {
	var os = "Unknown";

	var agt=navigator.userAgent.toLowerCase();

	this.name = navigator.appName
	    this.major = parseInt(navigator.appVersion);
	    this.minor = parseFloat(navigator.appVersion);
	    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
	                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
	                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	    this.nav2 = (this.nav && (this.major == 2));
	    this.nav3 = (this.nav && (this.major == 3));
	    this.nav4 = (this.nav && (this.major == 4));
	    this.nav4up = (this.nav && (this.major >= 4));
	    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
	                          (agt.indexOf("; nav") != -1)) );
	    this.nav6 = (this.nav && (this.major == 5));
	    this.nav6up = (this.nav && (this.major >= 5));
	    this.gecko = (agt.indexOf('gecko') != -1);
	    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	    this.ie3    = (this.ie && (this.major < 4));
	    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
	    this.ie4up  = (this.ie  && (this.major >= 4));
	    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
	    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
	    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
	    this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
	    this.ie6up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
	    this.aol   = (agt.indexOf("aol") != -1);
	    this.aol3  = (this.aol && this.ie3);
	    this.aol4  = (this.aol && this.ie4);
	    this.aol5  = (agt.indexOf("aol 5") != -1);
	    this.aol6  = (agt.indexOf("aol 6") != -1);
	    this.opera = (agt.indexOf("opera") != -1);
	    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
	    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
	    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
	    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
	    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);
	    this.webtv = (agt.indexOf("webtv") != -1);
	    this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1));
	    this.AOLTV = this.TVNavigator;
	    this.hotjava = (agt.indexOf("hotjava") != -1);
	    this.hotjava3 = (this.hotjava && (this.major == 3));
	    this.hotjava3up = (this.hotjava && (this.major >= 3));
	    this.DOM = (document.getElementById ? true : false);
	this.screenWidth = window.screen.width
	this.screenHeight = window.screen.height
	this.java = navigator.javaEnabled()
	if(navigator.userAgent.indexOf('Win')!=-1) {
		if(navigator.userAgent.indexOf('95')!=-1) os = "Windows95"; 
		else if(navigator.userAgent.indexOf('98')!=-1) os = "Windows95"; 
		else if(navigator.userAgent.indexOf('Win')!=-1) os = "Windows3.1 or NT";
	}
	else if(navigator.userAgent.indexOf('Mac')!=-1) os = "Macintosh";
	this.os = os
}
objBrowser = new browserType();
// **********************************************************************************
