/*
'	ML 08/25/99 Added preLoadImages function to preload navbar mouseover images
'	EBS 11/3/99 Added Brattli code for stationary object placement, intended for use
'	in assessment window.
'	EBS 12/21/99 Added LivePerson connection function
'	EBS 1/31/00 Added routine to load Knowledgebase search results into separate window.
'	MTT 3/6/00 Changed enterLivePerson function to be compatible with LivePerson 3.0 (to be uploaded on Saturday, 3/11/00)
'	MTT 4/20/00	Changed enterLivePerson function to comply with Element K
'
'	For Welcome.ZDU, this includes browser capabilities detection,
'	image rollover and preload routines, window spawn routines,
'	and routines for stationary placement of objects relative to
'	the bottom of the user's screen.
'
'	Image rollover/preload, browser capabilities detection, and window
'	management routines are copyright 1999 Ziff-Davis Inc. 
'	Stationary object placement routines are copyright 1998, 1999
'	Thomas Bratti (http://www.bratta.com/).
'
'	Filename formulation for image rollovers:
'	Names will be formed like this ('category' is the name of the
'	functional category):
'
'	[category]			ID of the top-level menu	topViewReports
'						entry on top menu bar
'	[category]			NAME of the image for the 	imgtopViewReports
'						top-level menu
'	[strImgName]Off.gif	filename for "off"-state	imgtopViewReportsOff.gif
'	[strImgName]On.gif		filename for "on"-state		imgtopViewReportsOn.gif
'	[strImgName]Open.gif	filename for "open"-state	imgtopViewReportsOpen.gif
'	dropmenu[strImgName]	ID of the dropmenu layer	dropmenuViewReports
'
'	NOTE: The case of the 'category' string should not be changed 
'	when adding to the front and back.
'	NOTE: The image name must be specified with the NAME attribute
'	in the IMG tag -- do NOT use the ID attribute!
'
*/

var strEchoVal

var blnNonCSSP;
var blnBrowserDOM;
var blnCanDoRollover;

var intBrowserVer;
var strVisible;
var strHidden;
var strLastmenuClosedImgSrc;
var strOpenmenu;
var strMenuState;
var strLayer;

// CONDITIONAL document.write() OF STYLESHEET LINK
// REMOVED DUE TO IE3 INCOMPATABILITY & GENERAL
// USELESSNESS.

// check browser version to trap version 3 & below
// (not being used at this time, but may be...)
intBrowserVer = parseInt(navigator.appVersion)
if (intBrowserVer >= 4) {
	blnBrowserDOM = true;
} else {
	blnBrowserDOM = false;
}

// check for DOM version & set variables accordingly
if (document.layers) {		// NN4+ DOM
	blnCanDoRollover = true;
	blnNonCSSP = false;
	strVisible = 'show';
	strHidden = 'hide';
} else if (document.all) {	// IE4+ DOM
	blnCanDoRollover = true;
	blnNonCSSP = false;
	strVisible = 'visible';
	strHidden = 'hidden';
} else if (document.images) {	// NN3
	blnCanDoRollover = true;
	blnNonCSSP = true;
	strVisible = 'visible';
	strHidden = 'hide';
	blnBrowserDOM = true;
} else {
	blnCanDoRollover = false;
	blnNonCSSP = true;
	strVisible = 'visible';
	strHidden = 'hidden';
	blnBrowserDOM = false;
}

// toggles visibility of modality legend, etc.
function toggleMenu(strMenu) {
	// assign objects, strMenu is the id of the span
	if ((document.all) && (!blnNonCSSP)) {
		objMenuLayerPath = document.all(strMenu).style;
	}
	else if (document.layers) {
		objMenuLayerPath = document.layers[strMenu];
	}
	
	if (document.all) {
		if (objMenuLayerPath.visibility == strHidden) {
			objMenuLayerPath.visibility = strVisible;
		}
		else if (objMenuLayerPath.visibility == "") {
			objMenuLayerPath.visibility = strVisible;
		}
		else {
			objMenuLayerPath.visibility = strHidden;
		}
	}
	else if (document.layers) {
		if (objMenuLayerPath.visibility == strHidden) {
			objMenuLayerPath.visibility = strVisible;
		}
		else if (objMenuLayerPath.visibility == "") {
			objMenuLayerPath.visibility = strVisible;
		}
		else {
			objMenuLayerPath.visibility = strHidden;
		}
	}
}


// Perform image rollover for menu images
function imgRolloverOneLayer(strImgName,strImgState,strLayerName) {
	// set the image name ...

	strImgSrc = '/images/' + strImgName + strImgState + '.gif';

	if (blnCanDoRollover) {
		// do the rollover....
		if ((document.images) && (!document.layers)) {
//			alert('executing IE4+/NN3 rollover');
			if (strLayerName == "divTop") {
				strImgName = strImgName + "Top";
			}
			imgLayerPath = document.images[strImgName];
//			alert(imgLayerPath.src);
		} else if (document.layers) {	// NN rollover behavior scripted here
//			alert('executing NN4.x rollover');
			objLayer = document.layers[strLayerName];
			imgLayerPath = objLayer.document.images[strImgName];
		}
		// NN3 is currently not showing mouseovers correctly;
		// it's being conditionalized out here until I can 
		// figure out why.
		if  (blnBrowserDOM) {
			imgLayerPath.src = strImgSrc;
		}
//		alert(imgLayerPath.src);
	}
}

// generic image rollover routine
// ([only] works for images not inside of positioned layers)
function imgRollover(strImgName,strImgState,strImgPath) {
	if (typeof strImgPath == 'undefined' || strImgPath == '') {
	    strImgPath = '/images/';
	}

	// set the image and menu ID & name variables...
	strOnImgSrc = strImgPath + strImgName + strImgState + '.gif';
	strOffImgSrc = strImgPath + strImgName + strImgState + '.gif';

	// do the toggle....
	if (document.images) {
		imgLayerPath = document.images[strImgName];
		if (strImgState == 'On') {
			imgLayerPath.src = strOnImgSrc;
		} else if ((strImgState == 'Off') | (strImgState == 'InCat')) {
			imgLayerPath.src = strOffImgSrc;
		}
	}
}

function preLoadImages() { //preloads mouseover images for navbars
//	alert('preload');
  if (document.images) {
    var imgFiles = preLoadImages.arguments;
    if (document.preLoadArray == null) document.preLoadArray = new Array();
    var i = document.preLoadArray.length;
    with (document) for (var j=0; j < imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#") {
      preLoadArray[i] = new Image;
      preLoadArray[i++].src = imgFiles[j];
    } 
  }
}


/* BEGIN OBJECT PLACEMENT CODE -- minor modifications have been made
to suit context. */

/*Set these values, gright for how much from the right you want the layer to go
and gbottom for how much from the bottom you want it*/

var gright=170
var gAbsRight=0
var gbottom=50

//Browsercheck
var n = (document.layers) ? 1:0;
var ie = (document.all) ? 1:0;

// set positioning values based on browser --
// can also be used later to set sizing values
if (n==1) {
	//
	gAbsRight=0
	gbottom=35
} else if (ie==1) {
	//
	gAbsRight=0
	gbottom=60
	// this should be further conditionalized to set gbottom=45 for IE4
} else {
	//
	gAbsRight=0
	gbottom=45
}

//strEchoVal = gAbsRight + ", " + gbottom;
//alert(strEchoVal)

/********************************************************************************
Constructing the ChangeText object
********************************************************************************/
function makeObj(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'
   	this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')							
	this.moveIt=b_moveIt;
}
function b_moveIt(x,y){
	this.x=x; this.y=y
   	this.css.left=this.x
	this.css.top=this.y
}
/********************************************************************************
Initilizing the page, getting height and width to moveto and calls the 
object constructor
********************************************************************************/
var pageWidth,pageHeight
function geoInit(){
	oTest=new makeObj('divBottom')
	pageWidth=(ie)?document.body.offsetWidth-4:innerWidth;
	pageHeight=(ie)?document.body.offsetHeight-2:innerHeight;
	checkIt()
	//sets the resize handler.
	onresize=resized
	if(ie) window.onscroll=checkIt;
}
/********************************************************************************
This function executes onscroll in ie and every 10 millisecond in ns
and checks if the user have scrolled, and if it has it moves the layer.
********************************************************************************/
function checkIt(){
	if(ie) {
		oTest.moveIt(gAbsRight,document.body.scrollTop+pageHeight-gbottom)
	} else if(n) {
		oTest.moveIt(gAbsRight, window.pageYOffset+pageHeight-gbottom)
		setTimeout('checkIt()',10)
	}
}

//Adds a onresize event handler to handle the resizing of the window.
function resized(){
	pageWidth=(ie)?document.body.offsetWidth-4:innerWidth;
	pageHeight=(ie)?document.body.offsetHeight-2:innerHeight;
	if(ie) checkIt()
}


//Calls the geoInit onload
//onload=geoInit;

/* END OF THIRD-PARTY CODE */

// puts focus on popup window if the browser supports it;
// initializes object placement routines.
function loadHelp() {
	if (document.images) {
		window.focus(this.window);
		if (ie || n) {
			// ADDED TO SUPPORT STATIONARY OBJECTS:
			oTest=new makeObj('divBottom')
			pageWidth=(ie)?document.body.offsetWidth-4:innerWidth;
			pageHeight=(ie)?document.body.offsetHeight-2:innerHeight;
			checkIt()
			//sets the resize handler.
			onresize=resized
			if(ie) window.onscroll=checkIt;
			// END OF STATIONARY OBJECT SUPPORT
		}
	} else {
		// do nothing
	}
//		alert();
}

// loads context-sensitive help in a new window
function popUp(strHelpPage) {
//	alert(strHelpPage);
	if (document.images) {
		window.open(strHelpPage, "help", "top=20,left=200,height=400,width=400,location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no");
	} else {
		window.location = strHelpPage;
	}
}

// loads knowledgebase search results in a new window
function popUpSearchResults(strURL,strWindowName,strFeatures) {
//	alert(strHelpPage);
	if (document.images) {
		self.name = 'Main';
		window.open(strURL,strWindowName,strFeatures);
	} else {
		window.location = strURL;
	}
}


/* BEGIN 3RD PARTY LIVEPERSON CONNECTION CODE */
// Following code has been modified for ZDU

/* --- OLD LIVEPERSON CODE
		function enterLivePerson(accountName, re, name) {
			window.name = "lp_parent";
			var url = "http://lp2.liveperson.com/enter.asp?user=" + accountName + "&RE=" + re + "&name=" + name;
			var hWnd = window.open(url,"live_person","width=300,height=350,resizable=yes,scrollbars=yes");
			if (hWnd != null) {
				if (hWnd.opener == null) {
					hWnd.opener = self;
					window.name = "home";
					hWnd.location.href=url;
				}
			}
		}
*/

// New Liveperson 3.0 code
function enterLivePerson(aname, gname, re, name) {
	window.name = "lp_parent";
	// var url = "http://lptest2.client.liveperson.net/user.asp?aname=" + aname + "&gname=" + gname + "&RE=" + re + "&name=" + name;
	var url = "http://elementk.client.liveperson.net/user.asp?aname=" + aname + "&gname=" + gname + "&RE=" + name + "&name=" + re;
	var hWnd = window.open(url,"live_person","width=300,height=350,resizable=yes,scrollbars=yes");
	if (hWnd != null) { if (hWnd.opener == null) { hWnd.opener = self; window.name = "home"; hWnd.location.href=url; } }
}

/* END 3RD PARTY LIVEPERSON CONNECTION CODE */

/* This function prevents the user from selecting a non-selectable
 * option in a select field.
 */
function skip_dummy_option(f_select) {
  if (f_select.options[f_select.selectedIndex].value == 'dummy') {
    f_select.selectedIndex = f_select.selectedIndex + 1;
  }
}
