/*----------------------------------------------------------------
	This file contains common javascript routines use throughout WDB.
	 - Common variables used to determine browser version for layers
	 - A test function to display the version with an Alert box
	 - The function to build the correct layer display line
	 - A function to display the current date
	 
	Any or all of these functions can be included on any page by 
	inserting the following code in the <head> section of the page:
	
<script type="text/javascript" language=javascript src="JavaScript/TLOCommon.js">
<!-- hide script from old browsers
function setStyle() {
}

function showDate() {
}
//-->
</script>

	----------------------------------------------------------------*/
	
/*-------------------------------------
  (From webreference.com source)
  "document.all" works correctly for IE6
  "document.layers" works for Netscape4
  "document.getElementById()" tests for DOM
  "var" makes the variable global
 --------------------------------------*/
 
var ver				  = navigator.appVersion
var agent				= navigator.userAgent
var opera5			= this.agent.indexOf("Opera 5")>-1

var usesDOM			= (document.getElementById) ? true : false;
var usesALL			= (document.all) ? true : false;
var usesLayers	= (document.layers) ? true : false;

var IE4	= (usesALL && !usesDOM && !opera5) ? true : false;
var IE5	= (ver.indexOf("MSIE 5")>-1 && usesALL && usesDOM && !opera5) ? true : false;
var IE6	= (ver.indexOf("MSIE 6")>-1 && usesALL && usesDOM) ? true : false;
var IE7	= (ver.indexOf("MSIE 7")>-1 && usesALL && usesDOM) ? true : false;
var IE	= IE4||IE5||IE6||IE7
	
var MAC	= agent.indexOf("Mac")>-1

var NS4	= (usesLayers) ? true : false;
var NS6	= (usesDOM && !usesALL) ? true : false;

/*----------------------------------
 TEST - Use alert to display version
 -----------------------------------*/ 
function showVersion() {
	vers = IE4 ? "IE4" : IE5 ? "IE5" : IE6 ? "IE6" : NS4 ? "NS4" : NS6 ? "NS6" : MAC ? "MAC" : "Undefined";
	alert("Browser version is " + vers);
}

//showVersion();

/*------------------------------------------------------------
 Set the style for each effect selected.  "this.page" allows
 navigation for frames pages:
	if i = 1, then
 	divUses = setStyle("top.quote.","divUse"+i) returns
		"top.quote.document.all.divUse1.style"
 	 
 for navigation to current page only:
 	if l = "Roll", then
 	rollOver = setStyle("", "lnk"+l) returns
 		"document.all.lnkRoll.style"	 
 -------------------------------------------------------------*/ 
function setStyle(p,e) {

	this.page = p;
	this.element = e;
	
	switch (true) {
		case IE4:
		case IE5:
		case IE6:
		case IE7:
			this.rtnStyle = eval(this.page + "document.all." + this.element + ".style")       
			break
		case NS4:
			this.rtnStyle = eval(this.page + "document.layers." + this.element)
			break
		case NS6:
			this.rtnStyle = eval(this.page + "document.getElementById('" + this.element + "').style")
			break
		case MAC:
			break
	}	
	return this.rtnStyle	
}
/*----------------------------------------------------
  function showDate() - displays today's date
  Arrays start at 0, so to reference months by number,
   build 13 element array and start months at [1]...
  ----------------------------------------------------*/  
function showDate() {
	var months=new Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";

	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getFullYear();
	var year1=time.getYear();

	if (navigator.appName == "Netscape")
		year= year;
	if(navigator.appName.indexOf("WebTV") != -1) 
		year=year1;
	displayDate = lmonth + " " + date + ", " + year;

	document.write(displayDate);
}

function chgPage(pg) {
	top.location = pg;  //This changes the main page when button is released.
}