$(document).ready(function() 
{ 

  //add highlighting to event table rows as cursor moves over
  $('#eventtbl tbody tr:[rowtype=evt]').hover(
   function()
   {
    $(this).addClass('highlightclick');
   },
   function()
   {
    $(this).removeClass('highlightclick');
   }
  );
  
  //add function when an event table row is clicked
	$('#eventtbl tbody tr:[rowtype=evt]').click(function(e) { 
		
		if ($(this).next('tr').is(':hidden')) {
			$(this).next('tr').show();
		} else {
			$(this).next('tr').hide();
		}

	});

  //add highlighting to race table rows as cursor moves over
  $('#eventtbl tbody tr:[rowtype=rac]').hover(
   function()
   {
    $(this).addClass('highlightclick');
   },
   function()
   {
    $(this).removeClass('highlightclick');
   }
  );

  //add function when a race table row is clicked
	$('#eventtbl tbody tr:[rowtype=rac]').click(function(e) { 
		
		//set input value
		$('#racid').attr('value',$(this).children('td:first').text());
		//submit form
		$('#racres').submit();
		
		e.stopPropagation(); 
		return false; 
	});
	
}); 

