// JavaScript Document

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("topnav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}

function alternateRowColors() {
	var classNameOne = 'table1';
	var classNameTwo = 'table2';
	var classNameThree = 'table3';
	var classNameFour = 'table4';
	var rowcolor = '#e4eed0';
	var rows, arow;
	var tables = document.getElementsByTagName("table");
	var rowCount = 2;
	
	for(var k=0; k<tables.length; k++) {
		//dump(tables.item(i).className + " " + tables.item(i).nodeName + "\n");
		if(tables.item(k).className == classNameOne) {
			atable = tables.item(k);
			rows = atable.getElementsByTagName("tr");
			for(var j=0;j<rows.length;j++) {
				arow = rows.item(j);
				if(arow.nodeName == "TR") {
					if(rowCount % 2) {
						arow.style.backgroundColor = rowcolor;
					} else {
						// default case
					}
					rowCount++;
				}
			}
			rowCount = 0;
		}
		
	  var rowCount = 2;
		if(tables.item(k).className == classNameTwo) {
			atable = tables.item(k);
			rows = atable.getElementsByTagName("tr");
			for(var jj=0;jj<rows.length;jj++) {
				arow = rows.item(jj);
				if(arow.nodeName == "TR") {
					if(rowCount % 2) {
						arow.style.backgroundColor = rowcolor;
					} else {
						// default case
					}
					rowCount++;
				}
			}
			rowCount = 0;
		} 
		
	  var rowCount = 2;
		if(tables.item(k).className == classNameThree) {
			atable = tables.item(k);
			rows = atable.getElementsByTagName("tr");
			for(var jj=0;jj<rows.length;jj++) {
				arow = rows.item(jj);
				if(arow.nodeName == "TR") {
					if(rowCount % 2) {
						arow.style.backgroundColor = rowcolor;
					} else {
						// default case
					}
					rowCount++;
				}
			}
			rowCount = 0;
		} 
		
	  var rowCount = 2;
		if(tables.item(k).className == classNameFour) {
			atable = tables.item(k);
			rows = atable.getElementsByTagName("tr");
			for(var jj=0;jj<rows.length;jj++) {
				arow = rows.item(jj);
				if(arow.nodeName == "TR") {
					if(rowCount % 2) {
						arow.style.backgroundColor = rowcolor;
					} else {
						// default case
					}
					rowCount++;
				}
			}
			rowCount = 0;
		} 
		
	} //end main For Loop
	
}

swapHeader = function() {   //swap the header image on each load page load
	var numimages=8;
	rndimg = new Array("images/layout/headers/header_1.jpg", "images/layout/headers/header_2.jpg", "images/layout/headers/header_2.jpg", "images/layout/headers/header_3.jpg", "images/layout/headers/header_4.jpg", "images/layout/headers/header_5.jpg", "images/layout/headers/header_2.jpg", "images/layout/headers/header_5.jpg"); 
	x=(Math.floor(Math.random()*numimages));
	randomimage=(rndimg[x]);
	document.getElementById("pageheader").style.backgroundImage = "url("+ randomimage +")"; 
}

function init() {
	startList();
	alternateRowColors();
	swapHeader();
}

window.onload=init;
