d = document;

window.onload = function(){
	prepareDropDowns();
	homeLinksHover();
	preparePopUps();
	stripeTables();
}

function prepareDropDowns(){
	var nav = d.getElementById('topNav');
	if (!nav) return;
	var navLi = nav.getElementsByTagName('li');
	for (i=0; i<navLi.length; i++){
	if(navLi[i].lastChild.nodeName=='UL'){
		liUL = navLi[i].lastChild;
		navLi[i].onmouseover=function(){this.className='hover';}
		navLi[i].onmouseout=function(){this.className=' ';}	
		}
	}
}

function homeLinksHover () {
	var homeLinks = d.getElementById('homeLinks');
	if (!homeLinks) {return}
	var span = homeLinks.getElementsByTagName('span');
	for (i=0; i<span.length; i++){
	span[i].onmouseover = function(){ this.className='hover'; this.style.cursor='pointer'; };
	span[i].onmouseout = function(){ this.className=' ' };
	span[i].onclick = function(){location = getLocation(this); };
	}
}

function getLocation(ele) {
var link = ele.getElementsByTagName('a');
var locat = link[0].href;
return locat;
}

function preparePopUps() {
	var content = document.getElementById('side');
	if (!content) return;
	var a = content.getElementsByTagName('a');
	if (a.length<1) {return false;}
	
	for (i=0; i < a.length; i++) {
	
		if (a[i].rel == 'popUp'){
		var link = a[i].getAttribute('href');
		a[i].onclick = function() {popUp(this.getAttribute('href')); return false;};
		}
	
	}
}

function popUp(link) {
	
	width = screen.availWidth;	
	width = width/2;
	width = width-375;
	
	height = screen.availHeight;
	height = height/2;
	height = height-275;

	newWin = window.open(link,"","width = 750, height = 550, resizable=1, scrollbars=1");
	newWin.moveTo(width,height);
}

function stripeTables() {
	var tables = d.getElementsByTagName('table');
	if (tables.length < 1) return;
	for (i = 0; i < tables.length; i++) {
		if (tables[i].className == "stripe") {
		stripe(tables[i]);
		}
	}

}

function stripe(table){
	var tr = table.getElementsByTagName('tr');
	var x = false;
	
	for (i=0; i < tr.length; i++) {
		if (x == true) { tr[i].className = "alt"; x = false; } else { x = true;}
	}
	
	for (i=0; i < tr.length; i++) {
		var td = tr[i].getElementsByTagName('td');
		var x = false;
		
		for (y=0; y < td.length; y++) {
		if (x == true) {td[y].className="alt"; x = false} else {x = true}
		}
	}
}
