



var colorOffLight = '#fff';
var colorOffDark = '#fafbf5';
var colorOver = '#e8eadd';
var colorCurrent = '#fff';
var theTables = new Array;
var cellCollection = new Array;
var c = 0;

function setAllRowColors(){
	var j = 0;
	var allTables = document.getElementsByTagName('tbody');
	for (var i=0;i<allTables.length;i++) {
		if (allTables[i].className.indexOf('altrows') != -1) {
			theTables[j] = allTables[i];
			setTheRowColors(theTables[j]);
			j++;
		}
	}
	cellEvents();
}

function setTheRowColors(theTable){
	theRows = theTable.getElementsByTagName('tr');
	for (var i=0;i<theRows.length;i++) {
		for (var j=0;j<theRows[i].childNodes.length;j++) {
			if (theRows[i].childNodes[j].nodeName == 'TD') {
				theRows[i].childNodes[j].style.backgroundColor = i%2 ? colorOffLight : colorOffDark;
			}
		}
	}
}

function getLink(currentCell,action) {
	var siblingCells = currentCell.parentNode.childNodes;
	if (action == 'over') currentCell.style.cursor = 'pointer';
	for (var i=0;i<siblingCells.length;i++) {
		if (siblingCells[i].className == 'col_name') {
			var nameCell = siblingCells[i];
			for (var j=0;j<nameCell.childNodes.length;j++){
				if (nameCell.childNodes[j].nodeName == 'A') {
					switch(action){
						case 'click': return nameCell.childNodes[j].href; break;
						case 'over': nameCell.childNodes[j].style.color = '#000'; break;
						case 'out': nameCell.childNodes[j].style.color = '#234F70'; break;
					}
				}
			}
		}
	}
}

function cellEvents(){
	var parentRow;
	for (var i=0;i<theTables.length;i++) {
		if (theTables[i].className.indexOf('hiliterow') != -1) {
			theCells = theTables[i].getElementsByTagName('td');
			for (var j=0;j<theCells.length;j++) {
				theCells[j].onmouseover = function() {
					parentRow = this.parentNode;
					collectCells(parentRow,this,'on');
					getLink(this,'over');
					this.style.cursor = 'pointer';
				}
				theCells[j].onmouseout = function() {
					parentRow = this.parentNode;
					collectCells(parentRow,this,'off');
					setTheRowColors(parentRow.parentNode);
					getLink(this,'out');
				}
				
			}
		}
	}
}

function collectCells(theRow,theCell,state) {
	var theTable;
	var theRows;
	var siblingCells = new Array;
	siblingCells = theRow.childNodes;
	for (var i=0;i<siblingCells.length;i++) {
		if (siblingCells[i].nodeName == 'TD') {
			cellCollection[c] = siblingCells[i];
			theTable = theRow.parentNode;
			if (theTable.className.indexOf('hilitecol') != -1) {
				if (cellCollection[c] == theCell) {
					c++;
					theRows = theTable.getElementsByTagName('tr');
					for (var j=0;j<theRows.length;j++) {
						if ((theCell.className.indexOf('col_name') == -1) && (theCell.className.indexOf('col_symbol') == -1)) {
							cellCollection[c] = theRows[j].childNodes[i];
							c++;
						}
					}
				}
				else c++;
			}
			else c++;
		}
	}
	for ( var k=0 ; k<cellCollection.length ; k++ ) {
		cellCollection[k].style.backgroundColor = (state == 'on' ? colorOver : colorOffLight);
	}
	if ((state == 'on') && (theCell.className.indexOf('col_name') == -1) && (theCell.className.indexOf('col_symbol') == -1) && (theTable.className.indexOf('hilitecol') != -1)) {
		theCell.style.backgroundColor = colorCurrent;
	}	
	cellCollection.length = 0;
	c = 0;
}



window.onload=function(){
	setAllRowColors();
	
}
