// sets default active tab
function setDefaultTab() {
	$('navProductsServices').className += " active";
}


// allows active tab to "stick" when hovered over
function setTabActions() {
	var i, x;
	var tabs = document.getElementsByClassName('tab');

	for(i = 0; i < tabs.length; i++) {
		var tab = tabs[i];
		tab.onmouseover = function() {
			for(x = 0; x < tabs.length; x++) {
				tabs[x].className = "tab";
			}
			this.className = "tab active";
		}
	}
}


// clears login inputs when clicked
function setLoginActions() {
	$('txtCustomerId').onclick = function() {
		if(this.value == "Customer ID") {
			this.value = '';
		}
	}
	$('txtPassword').onclick = function() {
		if(this.value == "Password") {
			this.value = '';
		}
	}
}


// vertically center advertisements
function centerAds() {
	var i;
	var ads = document.getElementsByClassName('logoAd');
	
	for(i = 0; i < ads.length; i++) {
		var ad = ads[i].childNodes[0];
		ad.style.marginTop = "-"+Math.ceil(ad.offsetHeight/2)+"px";
		ad.style.position = "absolute";
		ad.style.right = "0";
		ad.style.top = "50%";
	}
}


// creates striped table rows
function colorTableRows(tableClass) {
	var x, y;
	var tables = document.getElementsByClassName(tableClass);
	
	for(x = 0; x < tables.length; x++) {
		var tableBody = tables[x].getElementsByTagName('tbody')[0];
		var rows = tableBody.getElementsByTagName('tr');
		
		for(y = 0; y < rows.length; y++) {
			var row = rows[y];
			
			if(y % 2 == 0) {
				row.style.backgroundColor = "#fff";
			}
			else {
				row.style.backgroundColor = "#eee";
			}
		}
	}
}


// jump menu actions
function jumpMenu(theMenu) {
	if(theMenu.options[theMenu.selectedIndex].value != "") {
		window.location = theMenu.options[theMenu.selectedIndex].value;
	}
}


// initiate actions
window.onload = function() {
	setDefaultTab();
	setTabActions();
	setLoginActions();
	if(document.body.offsetHeight) { centerAds(); }
	// colorTableRows('courseList');
}
