////////////////////////////////////////////////////////////////////
//
// This file contains Javascript functions dealing with tables.
//
////////////////////////////////////////////////////////////////////


  
/*******************************************************************************
 * 
 * Data recovery functions.
 *
 * The following functions may be used to recover information about or the data
 * contained within table cells or rows. 
 *
 ******************************************************************************/

// this function is needed to work around a bug in IE related to element attributes
function hasClass (obj) {
    var result = false;
    if (obj.getAttributeNode("class") != null) {
        result = obj.getAttributeNode("class").value;
    }
    return result;
} 

/*******************************************************************************
 *
 * getCellContents
 *
 * Recovers the contents of a cell
 *
 ******************************************************************************/

function getCellContents(tableID, row, cell)
{
   return getCellValue(tableID.rows[row].cells[cell]);
}

/////////////////////////////////////////////////////////////////
//
// getRowClass
//
// Returns whether a row has the required class.
//
///////////////////////////////////////////////////////////////// 

function getRowClass (curTable, row, classType) {
   return hasClass(curTable.rows[row]) === classType;
}

function getCellValue(cellOrId) 
{
   var cell; 
   if(typeof cellOrId == 'string')
   { 
      cell = document.all ? document.all[cellOrId] : document.getElementById(cellOrId);
   }
   else
   {
      cell = cellOrId;
   }
   
   if (document.all)
   {
      return cell.innerText;
   }
   else 
   {
      cell.normalize();
      if (cell.firstChild.nodeType == 3)
      {
         return cell.firstChild.nodeValue;
      }
      else if (cell.firstChild.nodeType == 1)
      {
         return cell.firstChild.firstChild.nodeValue;
      }
      else 
      {
         return '';
      }
   }
}



////////////////////////////////////////////////////////////////
//
// dayToDays
//
// Converts the time in milliseconds to the number of days
// since the epoch.
//
////////////////////////////////////////////////////////////////
function dayToDays(inTime)
{
   return inTime.getTime() / (1000 * 60 * 60 * 24);
}



// Fire up the message on loading the page.
//addEvent(window, 'load', stripeTables, false);

// End of file
 

