<!--
var lastClass = "";


// Returns the TD object that is currently selected
function FindSelectedOption( obj )
{
  var row = document.getElementById( "option_row_1" );
  var cols = row.getElementsByTagName("td");     // Get the collection of all the columns
  var selectedOption = 0;
  var index = 0;
  var found = false;

  while( index < cols.length && !found )
  {
    if( cols[index].className == "portfolio-option-selected" )
    {
      selectedOption = cols[index];
      found = true;
    }
    index++;
  }
  
  // If not found then maybe the selected item is in the second row
  if( !found )
  {
    row = document.getElementById( "option_row_2" );
    cols = row.getElementsByTagName("td");     // Get the collection of all the columns
    selectedOption = 0;
    index = 0;
    found = false;
  
    while( index < cols.length && !found )
    {
      if( cols[index].className == "portfolio-option-selected" )
      {
        selectedOption = cols[index];
        found = true;
      }
      index++;
    }
  }

  if( !found )  // If there isn't a selected row then return the row that was clicked
  {
    selectedOption = obj;
  }
  
  return selectedOption;
}



function OptionHighlight( obj )
{
  lastClass = obj.className;
  
  if( obj.className != "portfolio-option-selected" )  // If this is the selected option then don't highlight it
  {
    obj.className = "portfolio-option-over";          // Highlight the current option
  }
}



// Highlights an option
function OptionSelect( obj )
{
  var selectedOption = FindSelectedOption( obj );
  
  lastClass = "";                               // This forces OptionUnlight( this_option ) to set this_option's style to portfolio-option
  OptionUnlight( selectedOption );              // Unlight the selected option
  obj.className = "portfolio-option-selected";  // Mark current option as the selected option
  lastClass = obj.className;                    // Set the lastClass variable so that it will remain selected when the cursor moves away
  
  ShowPicture( obj );
}



// Unlights a row on the grid
function OptionUnlight( obj )
{
  if( lastClass != "" )
  {
    obj.className = lastClass;
  }
  else
  {
    obj.className = "portfolio-option";
  }
}



function ShowPicture( obj )
{
  var imageIndex = obj.id;
  var imageSource = document.getElementById( "image-" + imageIndex );
  var imageDest = document.getElementById( "image-display" );
  
  imageDest.innerHTML = imageSource.innerHTML;
}



function TopMenuHighlight( obj )
{
  obj.className = "top-menu-highlight";
}



function TopMenuUnlight( obj )
{
  obj.className = "top-menu-item";
}

//-->


