// ==UserScript==
// @name            Highlight Hatena Graph Table Header
// @namespace       http://espion.just-size.jp/archives/05/136155838.html
// @description     Highlight Hatena Graph Table Header
// @include         http://graph.hatena.ne.jp/*/edit*
// ==/UserScript==
//
// $Id: HighlightHatenaGraphTableHeader.user.js 710 2006-02-21 13:31:06Z takayama $

(
function() {

   function main() {
      var obj = new highlightTable({table: (document.getElementsByTagName('table'))[1]});
      obj.set();
   }

   function addEvent(elm, type, event) {
      if(elm.addEventListener) elm.addEventListener(type, event, false);
      else elm.attachEvent('on'+type, event);
   }

   function highlightTable(param) {
      for(var p in param)
         this[p] = param[p];
   }

   highlightTable.prototype.set = function() {
      var table = this.table;

      for(var i in table.rows) {
         for(var f in table.rows[i].cells) {
            var elm = table.rows[i].cells[f];
            if(!elm.style) continue;

            addEvent(elm, 'mouseover', this.coloring(i, f, this.color||'#EEEEAA'));
            addEvent(elm, 'mouseout',  this.coloring(i, f));
         }
      }
   }

   highlightTable.prototype.coloring = function(i, f, color) {
      var elm   = this.table.rows[i].cells[f];
      var row   = this.table.rows[1].cells[f];
      var cell  = this.table.rows[i].cells[0];

      return function(e) {
         elm.style.backgroundColor  = color||'';
         row.style.backgroundColor  = color||'';
         cell.style.backgroundColor = color||'';
      }
   }

   main();
}

)();


