sfHover = function() {
var sfEls = document.getElementById("menu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
shadeRows = function(){
	var tables = document.getElementsByTagName("table");
	for (var l = 0; l<tables.length; l++){
	if (tables[l].className.indexOf("products") != -1){	
		var tbodyArr = tables[l].getElementsByTagName("tbody");
		var theadArr = tables[l].getElementsByTagName("thead");
		
		for (var s = 0; s <= theadArr.length-1; s++){
			theadArr[s].onclick = function(){
				var tbodyArr2 = this.parentNode.getElementsByTagName("tbody");
				//window.alert(tbodyArr2[0].className);
				//tbodyArr2[0].className = tbodyArr2[0].className.replace(new RegExp(" hidden\\b"), " shown");
				if (tbodyArr2[0].className.indexOf("hidden") != -1){
					tbodyArr2[0].className = " shown";
			    }else {
			    	tbodyArr2[0].className = " hidden";
			    }
				//window.alert(tbodyArr2[0].className);
			}
		}
		
		for (var n = 0; n<=tbodyArr.length-1; n++){
			tbodyArr[n].className += " hidden";
			var tabRows = tbodyArr[n].getElementsByTagName("tr");
		    //window.alert(tabRows.length);
			for (var x=0; x<tabRows.length; x++){
				if (x%2 == 0 && tabRows[x].className.indexOf("type") == -1){
					tabRows[x].className += " shaded";
				}
		tabRows[x].onmouseover = function(){
				if (this.className.indexOf("type") != -1 ){
						var tabCells = this.getElementsByTagName("td");
					for (var y = 0; y < tabCells.length; y++){
						tabCells[y].style.backgroundColor = "transparent";
					}
				}
				if (this.className.indexOf("shaded") != -1){
					var tabCells = this.getElementsByTagName("td");
				
				for (var y = 0; y < tabCells.length; y++){
					
					tabCells[y].style.backgroundColor = "#d1e0c2";
	
				} 
			} if(this.className.indexOf("fake") != -1){
				var tabCells = this.getElementsByTagName("td");
				
				for (var y = 0; y < tabCells.length; y++){
					
						tabCells[y].style.backgroundColor = "#d1e0c2";
			}
			}else{
				var tabCells = this.getElementsByTagName("td");
				for (var y = 0; y < tabCells.length; y++){
					tabCells[y].style.backgroundColor = "#d1e0c2";
				}
			}
			}
		tabRows[x].onmouseout = function(){
			if (this.className.indexOf("type") != -1){
				var tabCells = this.getElementsByTagName("td");
				for (var y = 0; y < tabCells.length; y++){
					tabCells[y].style.backgroundColor = "transparent";
				}
			}
			if (this.className.indexOf("shaded") != -1){
				
				var tabCells = this.getElementsByTagName("td");
				for (var y = 0; y < tabCells.length; y++){
					
						tabCells[y].style.backgroundColor = "#ffd999";
					
				} 
			}else{
				var tabCells = this.getElementsByTagName("td");
				for (var y = 0; y < tabCells.length; y++){
					tabCells[y].style.backgroundColor = "transparent"
				}
			}
		}
		
	}
	}
	}
}
}
expanders = function(){
	var expander = document.getElementById("expander");
	expander.onclick = function(){
		var tables = document.getElementsByTagName("table");
		for (var i = 0; i < tables.length; i++){
			if (tables[i].className.indexOf("products") != -1){
				var tableBody = tables[i].getElementsByTagName("tbody");
				if (tableBody[0].className.indexOf("hidden") != -1){
					tableBody[0].className = " shown";
					this.setAttribute ("src","gf/collapse.png");					
				} else {
					tableBody[0].className = tableBody[0].className.replace(new RegExp(" shown\\b"), " hidden");
					this.setAttribute("src", "gf/expand.png");
				}
			}
		}
	}
}

simpetest = function(obj){
	var clicked = 0;
	//var expander = document.getElementByName("expander");
	//expander.onclick = function(){
		if (obj.getAttribute("src") == "gf/expand.png"){
			obj.setAttribute ("src","gf/collapse.png");
			clicked = 1;
		}else{
			obj.setAttribute("src", "gf/expand.png");
			clicked = 0;
		}
		var tables = document.getElementsByTagName("table");
		for (var i = 0; i < tables.length; i++){
			if (tables[i].className.indexOf("products") != -1){
				var tableBody = tables[i].getElementsByTagName("tbody");
				if (clicked == 1){
					tableBody[0].className = " shown";
					//this.setAttribute ("src","gf/collapse.png");					
				} else {
					//tableBody[0].className = tableBody[0].className.replace(new RegExp(" shown\\b"), " hidden");
					tableBody[0].className = " hidden";
					//window.alert(tableBody[0].className);
					//this.setAttribute("src", "gf/expand.png");
				}
			}
		}
	//}
}

rewind = function(){
	window.alert(this.tagName);
}


if (window.attachEvent){
 window.attachEvent("onload", sfHover);
 window.attachEvent("onload", shadeRows);
 window.attachEvent("onload", expanders);
 }else{
 	window.onload = shadeRows;
 	//window.onload = expanders;
 	//var expander = document.getElementById("test");
 	//expander.onclick = rewind;
 	//window.onload = simpetest;
 }
 



