// JavaScript Document
if(window.addEvent){addEvent(window, "load", colorTables);}


function colorTable(tableID,color1,color2,color3,doHand,spareFirst,singleCols){
	myTable=Array();
	rowCount=-2;
	cellCount=0;
	if(spareFirst){rowCount=-2;}
	//theTable=document.getElementById(tableID);
	theTable=tableID;
	myTable["t"]=theTable;
	for(i in theTable.rows){
		rowCount++;
		tr=theTable.rows[i];
		myTable[tr.rowIndex]=[];
		cellCount--;
			for(o in tr.cells){
			cellCount++;
			td=tr.cells[o];
			myTable[tr.rowIndex].push(td);
			if(td.style){
				
				if(td.style){
					if(!singleCols){d=i;}
					else{d=cellCount;}
					
					td.parent=theTable;
					td.ind=rowCount;
					if(d%2){
						td.style.backgroundColor=color2; 
						if(doHand){
						td.style.cursor='pointer';}
						if(color3!=""){
						td.onmouseover=function(){
							highlightCells(this,color3);
							}
						td.onmouseout=function(){
							highlightCells(this,color2);
							}
						
						}}
					
					else{
						td.style.backgroundColor=color1; 
						if(doHand){
						td.style.cursor='pointer';}
						if(color3!=""){
						td.onmouseover=function(){
							highlightCells(this,color3);
							}
						td.onmouseout=function(){
							highlightCells(this,color1);
							}
							
						}}
					}
				}
			}
		}
	}	
	


function highlightCells(callerr,color){
	if(callerr.parent.getAttribute("singleCols")){
		callerr.style.backgroundColor=color;
		}
		
	else{	
	
	
	if(document.all){tr=callerr.parent.rows[callerr.ind];}
	else{tr=callerr.parent.rows[callerr.ind+1];}
	 for(i in tr.cells){
		 	if(tr.cells[i].style){
			tr.cells[i].style.backgroundColor=color;
		 }}
	}}

function applyTDstyle(theTable,cssClass,noTitle){
	theTable.border=1;
	theTable.className=cssClass;
	for(i=0; i<theTable.rows.length;i++){
		tr=theTable.rows[i];
			for(o in tr.cells){
				td=tr.cells[o];
				td.className=cssClass;
				if(i==0 && !noTitle){td.className=cssClass+"Title";}
			}}
}


function colorTables(){
	var obejcts = document.getElementsByTagName("table");
	for (ti=0;ti<obejcts.length;ti++) {
	t = obejcts[ti];
	var noTitle=t.getAttribute("noTitle");
	var singleCols=t.getAttribute("singleCols");
	
	if (t.nodeName == "TABLE" && t.getAttribute("colorme")) {
		if(t.getAttribute("colorme")=="grey"){
			colorTable(t,"#585858","#3c3c3c","#242424",1,noTitle,singleCols);
			}
		else if(t.getAttribute("colorme")=="greyNoHover"){colorTable(t,"#585858","#3c3c3c","",0,1,singleCols); useStyle="grey";}
		//if(!isset(useStyle)){useStyle=useStyle="grey";}
		applyTDstyle(t,"grey",noTitle);
        }
    }
}