// Temporary JavaScript Document for Business Table

function addBusinessTableListeners(){
	var tds = document.getElementsByTagName("td");
	for(var i=0; i<tds.length; i++){
		addEventFunc(tds[i], "mouseover", highlightBusinessTD, false);
		addEventFunc(tds[i], "mouseout", unhighlightBusinessTD, false);
	}
}


function highlightBusinessTD(e){
	if (!e) var e = window.event;	
	var tgt = e.target || e.srcElement;
	
	if(tgt.parentNode.parentNode.parentNode){
		if(tgt.parentNode.parentNode.parentNode.className == "business-table"){
			var otherTDs = tgt.parentNode.getElementsByTagName("td");
			for(var i=0; i<otherTDs.length; i++){
				otherTDs[i].style.backgroundColor = "#E7B5AE";
			}
		}
	}
}

function unhighlightBusinessTD(e){
	if (!e) var e = window.event;	
	var tgt = e.target || e.srcElement;
	
	if(tgt.parentNode.parentNode.parentNode){
		if(tgt.parentNode.parentNode.parentNode.className == "business-table"){
			var otherTDs = tgt.parentNode.getElementsByTagName("td");
			for(var i=0; i<otherTDs.length; i++){
				if(otherTDs[i].className.indexOf("even") != -1){
					otherTDs[i].style.backgroundColor = "#EDEDE1";
				} else if(otherTDs[i].className.indexOf("odd") != -1){
					otherTDs[i].style.backgroundColor = "#E4E4D8";
				}
			}
		}
	}
}

window.addEvent('domready', function() { addBusinessTableListeners(); });