
schedule("window", initTableHighlights);




function initTableHighlights()
{
	var tables = document.getElementsByTagName("table");
	
	for (var i = 0; i < tables.length; i++)
	{
		if (tables[i].className.match(/(^| )highlightRow( |$)/))
		{
			var tbody = tables[i].getElementsByTagName("tbody")[0];
			var trs = tbody.getElementsByTagName("tr");
			
			for (var k = 0; k < trs.length; k++)
			{
				trs[k].onmouseover = mouseoverTr;
				trs[k].onmouseout = mouseoutTr;
				
				var anchor = trs[k].getElementsByTagName("a")[0];
				
				if (anchor != null)
				{
					addClass(trs[k], "clickable");
					
					trs[k].onclick = clickTr;
				}
			}
		}
	}
	
	return true;
};






function mouseoverTr()
{
	addClass(this, "hover");
	
	return true;
};




function mouseoutTr()
{
	removeClass(this, "hover");
	
	return true;
};




function clickTr()
{
	var anchors = this.getElementsByTagName("a"); // Store all anchors within this TR
	var theAnchor = null;													// store anchor
	
	// Determine if one of the anchors has target="_blank", store if it does
	for (var x = 0; x < anchors.length; x++) {
		var tempAnchor = anchors[x];
		if (tempAnchor.getAttribute("target") == "_blank") {
			theAnchor = tempAnchor;
		}
	}

	// If target="_blank" was NOT found then theAnchor is null
	if (theAnchor == null) {
		theAnchor = this.getElementsByTagName("a")[0];
		window.location = theAnchor.href;
	} else {
		window.open(theAnchor.href);
	}
	
	return false;
};
