//if the browser has JS turned on, set html class name to "hasJS"
document.documentElement.className += "hasJS";

// ATTACH EVENT HANDLERS
/* override onload */
addEvent(window, 'load', function() {
 		doStandardsCompliantExternalLinks(); //external-links.js
		enableClearDefault(); //clear-default.js
		tableStripes();//stripe the tables
		tableSelection();//on hover, change the table row
		}
); 
//Start striped table rows
function tableStripes() {
	if(!document.getElementsByTagName) return false;
	if(!document.getElementsByTagName("table")) return false;//check for tables

	var tables = document.getElementsByTagName("table");
	for(i=0; i < tables.length; i++) {
		if(tables[i].id == "addnewuser" || tables[i].id == "newproject" || tables[i].id == "changepassword") continue;
		var odd = false;//set var odd to true.
		var rows = tables[i].getElementsByTagName("tr");//grab all rows in selected table
		for(j=0; j < rows.length; j++) {
			var theClass = rows[j].className;
			if(theClass == "userdata") continue;
			if(odd == true) {
				rows[j].style.backgroundColor = "#F0F0F0";
				odd = false;
			} else {
				odd = true;
			}
		}
	}
}
function tableSelection() {
	if(!document.getElementsByTagName) return false;
	if(!document.getElementsByTagName("table")) return false;//check for tables
	
	var tablesHover = document.getElementsByTagName("table");//grab tables
	for (i=0; i < tablesHover.length; i++) {//used extra for to allow scipping of tables, else would usuall just grab rows.
		if(tablesHover[i].id == "addnewuser" || tablesHover[i].id == "newproject" || tablesHover[i].id == "editprojects") continue;
		var rowsHover = tablesHover[i].getElementsByTagName("tr");//grab the rows
		
		for(j=0; j < rowsHover.length; j++) {
			if(rowsHover[j] == rowsHover[0]) continue;//skip the first row (header)
			var theClass = rowsHover[j].className;
			if(theClass == "userdata") continue;//skip the user data.
			rowsHover[j].onmouseover = function() {
				bgColor = this.style.backgroundColor;//grab the original background color(this is a global var)
				this.style.backgroundColor = "#F6DCBC";
				}
			rowsHover[j].onmouseout = function() {
				this.style.backgroundColor = bgColor;
			}
		}
	}
}
function addClass(element, value) {
	if(!element.className) {
		element.className = value;
	} else {
		newClassName = element.className;
		newClassName+= " ";
		newClassName+= value;
		element.className = newClassName;
	}
}
