var listID = "topNav";
var timer;
var target;

window.onload = function() {
	
	// Ensure this browser supports the DOM
	if (document.getElementById) {
		enableMenus(listID);
		stripeTablesInClass("Striped_Table",false);
	}
}

// Deploy XHTML dropdown menus. Scripting is used only to trigger the
// mouse event for the <li> tag, which does not support the :hover
// pseudoclass in IE. All other presentation is handled exclusively
// by CSS. Structure is a simple unordered list of links.

function enableMenus(listID) {
	var nav = document.getElementById(listID);
		
		for (var i=0; i<nav.childNodes.length; i++) {
			node = nav.childNodes[i];
			if (node.nodeName == "LI") {
				
				node.onmouseover = function() {
					clearTimeout(timer);
					this.className = this.className ? this.className : "over";		
					with (this.parentNode) {
						for (var j=0; j<childNodes.length; j++) {
							if (childNodes[j].nodeName == "LI" && childNodes[j] != this) {
								childNodes[j].className = childNodes[j].className == "current" ? "current" : "";
							}
						}
					}
				}
				
				// Introduce a slight delay before triggering the mouseout
				// event. This makes the menus easier to navigate.
				
	  			node.onmouseout = function() {
					target = this;
	  				timer = setTimeout("target.className = target.className == 'current' ? 'current' : ''",250);
				}
				
			}
		}
}

function stripeTablesInClass(targetClass,includeHeadings) {

		// Look for tables in the given CSS class and shade alternating rows
		
		// Color definitions
		var evenColor = "#fff";
		var oddColor = "#eee";
		
		var tables = document.getElementsByTagName("table");
		
		for (var i=0; i<tables.length; i++) {
			if (tables[i].className == targetClass) {
				var tbody = tables[i].firstChild;
				if (tbody.hasChildNodes()) {
					for (j=0; j<tbody.childNodes.length; j++) {
						var tr = tbody.childNodes[j];
						if (tr.nodeName.toLowerCase() == "tr" && !tr.className) {
							for (k=0; k<tr.childNodes.length; k++) {
								var td = tr.childNodes[k];
								if ((td.nodeName.toLowerCase() == "td" || (includeHeadings && td.nodeName.toLowerCase() == "th")) && (!td.className || td.className=="center")) {
									td.style.background = j/2 == parseInt((j/2).toString()) ? evenColor : oddColor;
								}
							}
						}
					}
				}
			}
		}
}


function fade(objID,targetAlpha,step,direction) {
	
	var obj = document.getElementById(objID);
	
	obj.style.opacity = direction == "up" ? parseFloat(obj.style.opacity) + step : parseFloat(obj.style.opacity) - step;
	obj.style.filter = "alpha(opacity:"+ (parseFloat(obj.style.opacity)*100) + ")";
	
	if ((direction == "up" && obj.style.opacity < targetAlpha) || (direction == "down" && obj.style.opacity > targetAlpha)) {
		setTimeout("fade('"+objID+"', 1, 0.1, 'up')", 20);
	}
}

function show(objID) {	
	var obj = document.getElementById(objID);
	
	obj.style.opacity = 0;
	obj.style.filter = "alpha(opacity:0)";
	obj.style.display = "block";
	
	setTimeout("fade('"+objID+"', 1, 0.1, 'up')", 20);
}

function hide(objID) {
	document.getElementById(objID).style.display = "none";
}