/////////////////////////////////////////////////////
// Highlight table row.
// newElement could be any element nested inside the table
// highlightColor is the color of the highlight
/////////////////////////////////////////////////////
var prevRow = null;
var prevCell = null;
var tbName; // class name of table 

function highlightTableRow(myElement)
{
  // To get the node to the row (ie: the <TR> element), 
  // we need to traverse the parent nodes until we get a row element (TR)
  // Netscape has a weird node (if the mouse is over a text object, then there's no tagName
  while (myElement && ((myElement.tagName && myElement.tagName!="TR" && myElement.tagName!="tr") || !myElement.tagName))
  {
    myElement=myElement.parentNode;
  }

if(!myElement)
{
	prevRow.className="unhighlightedRow";
}	
	
  if (!myElement || (myElement && myElement.id && myElement.className=="rowHeader"))
    return;

  if ((myElement.parentNode.parentNode.className != tbName) && tbName != null)
  {//alert(tbName);
  	return;
  }

  if (myElement)
  {
    var tableRow=myElement;
	tableRow.className="highlightedRow";
	prevRow = tableRow;   
  }
}

function highlightTableCell(myElement)
{
  // To get the node to the row (ie: the <TR> element), 
  // we need to traverse the parent nodes until we get a row element (TR)
  // Netscape has a weird node (if the mouse is over a text object, then there's no tagName
  while (myElement && ((myElement.tagName && myElement.tagName!="SPAN" && myElement.tagName!="span") || !myElement.tagName))
  {
    myElement=myElement.parentNode;
  }

if(!myElement)
{
	prevCell.style.border="2px solid white";
	document.getElementById('selection').innerHTML = 'SELECT A STALLION';
}	
	
  if (!myElement || (myElement && myElement.id))
    return;

  if ((myElement.parentNode.parentNode.className != tbName) && tbName != null)
  {//alert(tbName);
  	return;
  }

  if (myElement)
  {
    var tableCell=myElement;
	tableCell.style.border="2px solid #990000";
	prevCell = tableCell;   
	document.getElementById('selection').innerHTML = tableCell.title;
  }
}

function trackTableHighlight(mEvent)
{

  if (!mEvent)
    mEvent=window.event;
		
  // Internet Explorer
  if (mEvent.srcElement)
  {
    highlightTableRow( mEvent.srcElement);
  }
  // Netscape and Firefox
  else if (mEvent.target)
  {
    highlightTableRow( mEvent.target);		
  }
}

function trackTableHighlightCell(mEvent)
{

  if (!mEvent)
    mEvent=window.event;
		
  // Internet Explorer
  if (mEvent.srcElement)
  {
    highlightTableCell( mEvent.srcElement);
  }
  // Netscape and Firefox
  else if (mEvent.target)
  {
    highlightTableCell( mEvent.target);		
  }
}
