
function iefixes(){
  $("ul.nav li:last-child").css({ "border-right-width":"1px" });
}


(function($){
  $.fn.tableStripe=function(){

    return this.each(function(){
      $(this).find("td").hover(rowHighlight,rowReset).hover(colHighlight,colReset);
    });

  };

  function colHighlight(){
    var my_index = $(this).parents("tr").children().index(this);
    var num_children = $(this).parents("tr").children().length;

    $(this).parents("table:first").find("tr").each(function(){
      if( $(this).children().length == num_children)
	$(this).children().eq(my_index).addClass("activecol");
    });
  }

  function colReset(){
    $(this).parents("table:first").find(".activecol").removeClass("activecol");
  }

  function rowHighlight(){
    $(this.parentNode).addClass("activerow");
  }

  function rowReset(){
    $(this.parentNode).removeClass("activerow");
  }

})(jQuery);


function initToolTips(){

  function showHelper(){
    var tooltip = $("#tooltip").length == 1 ? $("#tooltip") : $('<div></div>').attr('id','tooltip');
    tooltip.empty().hide();
    $("<div></div>").addClass('message').html( $(this).attr('title') ).appendTo(tooltip);
    $(document.body).prepend( tooltip.fadeIn("slow") );
    tooltip.css('top', $(this).offset().top - $(tooltip).outerHeight() + "px")
    if( parseInt( $(this).offset().left) > parseInt( $(document.body).outerWidth()/2) )
      tooltip.css('left',  $(this).offset().left + parseInt($(this).outerWidth()/2) - $(tooltip).outerWidth() + "px").addClass("onright");
    else
      tooltip.css('left',  $(this).offset().left + parseInt($(this).outerWidth()/2) + "px");
  }

  function hideHelper(){
    $("#tooltip").remove( );
  }

  $( "a[title]" ).mouseover( showHelper ).mouseout( hideHelper );

}

$(function(){
  $("#course_stats,#demographics,#general_stats").tableStripe();
});

$(initToolTips)

$(iefixes);

