<!--

// Call this to setup a mouse hover cell targeting
//pass the tbody object that you want to setup targeting on
//optionally pass the class for the target color (default to altrowcoloropt3)
//optionally pass the color of the target column color (default to #ccddee)
//optionally pass the number of "locked columns" which will not show the verticle targeting (default to 0)
//optionally pass the class for alternating rows (this will default to altrowcoloropt7)
function setHoverScript(tbody,targetRowClass,targetColumnColor,lockedColumns,altRowClass)



{
	
if (document.getElementById && document.createElement)

{ 

	//defaults for optional parameters
	if(targetRowClass == undefined) targetRowClass = "altrowcoloropt3";
	if(targetColumnColor == undefined) targetColumnColor = "#ccddee";
	if(lockedColumns == undefined) lockedColumns = 0;
	if(altRowClass == undefined) altRowClass = "altrowcoloropt7";

	var rowCount = 1;
	
	//get the rows in the table
	var rows = tbody.childNodes;
	for(var i = 0; i < rows.length; i++)
	{
		//only set script if this is an actual row
		if(rows[i].nodeType == 1)
		{
			rows[i].onmouseover = function(){shade(this, targetRowClass);}
			
			//remove one from the rowCount if this is not an alternating row.
			if(rows[i].className != '') rowCount--;
			
			//set the alternating row color if there is not already a class on this row
			if(rowCount%2==0 && rows[i].className == '')
			{
				rows[i].className=altRowClass;
			}
			
			//get cells in the row set the onmouse over script
			var cells = rows[i].childNodes;
			for(var x = 0; x < cells.length; x++)
			{
				//only set the script if this in an actual cell and the cell does not have a colspan > 1
				if(cells[x].nodeType == 1 && cells[x].colSpan == 1)
				{
					cells[x].onmouseover = function(){shadeCol(this, lockedColumns, targetColumnColor);}
				}
			}
			rowCount++;
		}
	}
}
}


//Shade the row and set the mouse out for that row.
function shade(row, targetRowClass)
{	
	if(!row.onmouseout)
	{
		var oldclass = row.className;
		row.onmouseout = function() {this.className=oldclass;}
	}
	row.className=targetRowClass;
}

//shade the cells and set the mouse out for the cells.
function shadeCol(cell,lockedColumns,targetColumnColor)
{
	var columnNum = getColIndex(cell);
	
	//dont shade the "locked" columns
	if(columnNum < lockedColumns) { 
		return 0;
	}
	//get the rows
	var rows = cell.parentNode.parentNode.childNodes;

	for(var i = 0; i < rows.length; i++)
   {
	   //only worry about the actual rows
		if(rows[i].nodeType == 1)
		{
			var shadeCell = getCellInRow(rows[i], columnNum);
			//if the cell has a colspan > 1 then we will ignore it as it is probably a subheading
			if(shadeCell != null && shadeCell.colSpan == 1)
			{
				//only set the onmouseout if it is not already set.
				if(!shadeCell.onmouseout)
				{
					//var oldclass = cell.style.backgroundColor;
					shadeCell.onmouseout = function() {unShadeCol(this,'');}
				}
				shadeCell.style.backgroundColor=targetColumnColor;
			}
		}
	 }
	 cell.style.backgroundColor="white";
}

//put the columns back to the normal color
function unShadeCol(cell, restoreClass)
{
	var columnNum = getColIndex(cell);
	
	//get the rows
	var rows = cell.parentNode.parentNode.childNodes;

	for(var i = 0; i < rows.length; i++)
	{
		//only worry about the actual rows
		if(rows[i].nodeType == 1)
		{
			var shadeCell = getCellInRow(rows[i], columnNum);
			if(shadeCell != null) shadeCell.style.backgroundColor=restoreClass;			
		}
	}
}

//will get the cell within a row givin an index
function getCellInRow(row, searchIndex)
{
	var cellsInRow = row.childNodes;
	var cellIndex = 1;
	
	//loop until we find the cell that we want
	for(var y = 0; y < cellsInRow.length; y++)
	{
		if(cellsInRow[y].nodeType == 1)
		{
			if(cellIndex == searchIndex)
			{
				return cellsInRow[y];
			}
			cellIndex++;
		}
	}
	//if we are here then we didnt find that index
	return null;
}

//will get the position of a cell within a row.
function getColIndex(cell)
{
   var row = cell.parentNode;
   var cellsInRow = row.childNodes
   var index = 1;
   for(var i = 0; i < cellsInRow.length; i++)
   {
	  if(cellsInRow[i] == cell)
	  {
		 return index;
	  }
	  //if it is a td then increment the index
	  //need to do this because firefox returns more than just tds in a table row.
	  if(cellsInRow[i].nodeType == 1)  index++;
   }
}



-->
