
/* ============================================================================
 Dynamic Menu: This script is provided by Oregon State University.
 Created and enhanced by Central Web Services (CWS) http://oregonstate.edu/cws/
 Modified by Extended Campus (eCampus) http://ecampus.oregonstate.edu/
 This script is free to use provided these credits remain.
============================================================================ */
// Browser Compatibility Testing
//window.onerror = null; // Error Trapping
var omLyr = (document.layers)?1:0; // Legacy Navigator support, layers
var omAll = (document.all)?1:0; // Object model All support
var omID = (document.getElementById)?1:0; // Object model ID support

// Menu variables
var boxStart = 0;
var boxStay = null;
var onLayer;

if (omLyr) { // Legacy Navigator layer changer
	cssRef = "layer.";
	lyrRef = "document.layers";
	cssMod = "";
}
if (omAll) { // Object model layer changer
	cssRef = "layer.style.";
	lyrRef = "document.all";
	cssMod = ".style";
}

function showLayer(lyrName,shownOnMouse) 
{ // Display box	

	if (omLyr && !shownOnMouse) return;
	if (omID || omAll || omLyr) {
		if (boxStay != null) {
			clearTimeout(boxStay);
			hideLayer(onLayer);
		}
		if (omID || omAll) 
		{
			var layerElement = document.getElementById(lyrName);
			layerElement.style.visibility = "visible";
			onLayer = lyrName;	
			//alert(document.body.offsetHeight);
			//	x_top = (document.body.offsetHeight) / 2 - 320;				
				layerElement.style.top = 216;
			if (omAll) 
			{
				var setFocusElement;
				var elementID = "menu" + lyrName.charAt(3) + lyrName.charAt(4) + lyrName.charAt(5);
				//alert(elementID);
				setFocusElement = document.getElementById((elementID));
				setFocusElement.focus();
			}
		} else { // omLyr
			eval(lyrRef + "['" + lyrName + "']" + cssMod + ".visibility = \"visible\"");
			onLayer = lyrName;
		}
	} // End if omID, omAll, omLyr
}


function hideLayer(lyrName) { // Hide box
	if ((omID || omAll) && (boxStart == 0)) {
		var layerElement = document.getElementById(lyrName);
		layerElement.style.visibility = "hidden";
	} else if (omLyr && (boxStart == 0)) {
		eval(lyrRef + "['" + lyrName + "']" + cssMod + ".visibility = \"hidden\"");
	}
}

// Set defaults if undefined
if (boxDelay < 0.5) boxDelay = 1.5;
if (bdSize < 0) bdSize = 2;
if (dotWth < 0) bdSize = 20;
if (dotHgt < 0) bdSize = 20;

function boxTimer() { // Source mouseout delay
	//boxStay = setTimeout("btnOut()",boxDelay * 1000);
	boxStay = setTimeout("btnOut()",200);
}

function btnOut(lyrName) { // Source MouseOut
	if (boxStart == 0){hideLayer(onLayer);}
}

function boxOver() { // Box MouseOver image
	clearTimeout(boxStay);
	boxStart = 1;
}

function boxOut() { // Box MouseOut image
	boxStart = 0;
	boxStay = setTimeout("hideLayer(onLayer)", 1500);
}

function boxLink(title, url) { // Box elements
	this.title = title;
	this.url = url;
}


function boxGen(boxArray){ // Build the dynamic box
	var elmtName = boxArray.name;
	var boxWth;
	bdSize = 0;
	N = eval(boxArray + ".length")-1;
	// Finds the longest title length in order to determine box width
	var boxWth = eval(boxArray + ".tblWidth");
	n = "\<div id=\"" + eval(boxArray + '.id') + "\" style=\"visibility:hidden;position:absolute;\">\<table bgcolor=\"#000000\"";
	n += " border=\"" + bdSize + "\"";
	if (boxWth > 50) {
		n += " width=\"" + boxWth + "\"";
	} else {
		n += " width=\"150\"";
	}
	n += " cellspacing=\"0\" cellpadding=\"0\"";
	if (bdColor != "") n += " bordercolor=\"" + bdColor + "\"";
	if (bdLight != "") n += " bordercolorlight=\"" + bdLight + "\"";
	if (bdColor != "") n += " bordercolordark=\"" + bdDark + "\"";
	n += ">\<tr>\<td style=\"background-color:" + bdColor + "\">";
	n += "\<table border=\"0\" width=\"100%\" bgcolor=\"#3b6ca6\"";
	n += " cellspacing=\"0\" cellpadding=\"0\">\<tr>";
	n += "\<td class=\"bxlnk\"" + " width=\"100%\">";
	n += "\<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#000000\" bordercolor=\"#3b6ca6\">";
	for (var i = 0; i <= N; i++ ) 
	{ // Process box list
		n += "\<tr>\<td>&nbsp;</td>\<td>";
		var x1 = eval(boxArray + "[" + i + "].title");
		var x2 = eval(boxArray + "[" + i + "].url");
		var t1 = x2.toLowerCase().indexOf("http:\//");
		var t2 = x2.toLowerCase().indexOf(Host);
		if (x1 != "" && x2 == "") { // If item is a title
			//n += "\<h5 class=\"MenuHeading\">" + x1 + "\</h5>";
		} else if (x1 == "" && x2 != "") { // If item is a description
			n += x2 + "\<br />";
		} else { // If item is a link
			n += "\<a class=\"bxlnk\"";
			if (t1 == 0 && t2 != 0 && newWindow && window.open) { // If link is external
				n += " href=\"javascript:newWin('" + x2 + "');\"";
			} else { // If link is internal
				n += " href=\"" + x2 + "\"";
			}
			if (dotOvr != "") {
				n += " onmouseover=\"Chng('" + eval(boxArray + '.id') + "-" + i + "','1');boxOver('');\"";
				n += " onfocus=\"Chng('" + eval(boxArray + '.id') + "-" + i + "','1');boxOver('');\"";
				n += " onmouseout=\"Chng('" + eval(boxArray + '.id') + "-" + i + "','0');boxOut('');\"";
				if (i == N) {
					n += " onblur=\"Chng('" + eval(boxArray + '.id') + "-" + i + "','0');";
					n += "hideLayer('" + eval(boxArray + '.id') + "');\"";
				} else {
					n += " onblur=\"Chng('" + eval(boxArray + '.id') + "-" + i + "','0');boxOut('');\"";
				}
			} else {
				n += " onmouseover=\"boxOver('');\"";
				n += " onfocus=\"boxOver('');\"";
				n += " onmouseout=\"boxOut('');\"";
				if (i == N) {
					n += " onblur=\"hideLayer('" + eval(boxArray + '.id') + "');\"";
				} else {
					n += " onblur=\"boxOut('');\"";
				}
			}
			n += ">" + x1 + "\</a>\<br />";
		}
		n += "\</td>\</tr>";
	}

	n += "\</table>\</td>\</tr>\</table>\</td>\</tr>\</table>\</div>";
	return n;
}


