﻿$.fn.extend({

  tableRowHighlighte: function(option) {

    var table = $(this);
    var tableRows = table.find('tbody tr');
    var tableRowsOdd = table.find('tbody tr:odd');
    var tableRowsEven = table.find('tbody tr:even');

    tableRowsEven.css({ 'background-color': '#EFEFEF' });

    if (option != 'onlyAlter') {
      tableRows.click(function(event) {
        tableRows.removeClass('selected');
        $(this).addClass('selected');
        //$(this).toggleClass('selected');
        $(this).css({ 'background-color': '#3875d7' });
      });

      tableRows.mouseover(function(event) {

        tableRowsOdd.not('.selected').css({ 'background-color': '' });
        tableRowsEven.not('.selected').css({ 'background-color': '#EFEFEF' });

        if ($(this).hasClass('selected') == false)
          $(this).css({ 'background-color': '#FFD700' });
      });

      tableRows.mouseout(function(event) {
        tableRowsOdd.not('.selected').css({ 'background-color': '' });
        tableRowsEven.not('.selected').css({ 'background-color': '#EFEFEF' });
      });
    }
  
  }

});
