$(function(){
    /**
     * ***********************************************************************
     *     colorisation dynamique du tableau
     *     colorize plugin
     * ***********************************************************************
    **/
    $('.cal').colorize({ hover:'column', ignoreHeaders:true, banColumns:[0,$('.cal tr:eq(2)').find('td,th').size()-1]} );


    /**
     * ***********************************************************************
     *     colorisation dynamique du tableau
     *     tablehover plugin
     * ***********************************************************************
    **/
   /*
    $('.cal').tableHover({
        colClass: 'hoverColor',
        headRows: true,
        footRows: true,
        headCols: true,
        footCols: true
    });
    */


    /**
     * ***********************************************************************
     *     PROBLEME : DECALE LES CELLULES SOUS IE + NE FONCTIONNE PAS
     *     simple columns highlight
     *     using colgroups
     * ***********************************************************************
    **/
    //$(".cal tbody td").hover(
    //function(){
    //    var col = $(this.parentNode.childNodes).index(this);
    //    $($(".cal col")[col]).addClass("hoverColor");
    //},
    //function(){
    //    var col = $(this.parentNode.childNodes).index(this);
    //    $($(".cal col")[col]).removeClass("hoverColor");
    //
    //});


    /**
     * ***********************************************************************
     *     PROBLEME : RAME UN MAX SOUS IE
     *     simple columns highlight
     *     using columnhover plugin
     * ***********************************************************************
    **/
    //$('.cal').columnHover({eachCell:true, hoverClass:'hoverColor'});



/*
    altColor: '#ECF6FC',
    bgColor: '#fff',
    hoverColor: '#BCD4EC',
    hiliteColor: 'yellow',
*/



    /** 
     * ***********************************************************************
     *     TOOLTIPS BALLOONS - FROM A.TITLE
     * transformer le TITLE des liens en tooltip
     * @param livetip, classe du tooltip définie dans le css
     * ***********************************************************************
    **/
    $('<div id="livetip"></div>').hide().appendTo('body');
    var tipTitle = '';
    $('.cal tbody td a').bind('mouseover', function(event) {
      var $link = $(event.target).closest('a');
      if ($link.length) {
        var link = $link[0];

        tipTitle = link.title;
        link.title = '';
        $('#livetip')
        .css({
          top: event.pageY + 12,
          left: event.pageX + 12
        })
        .html('<div>' + tipTitle + '</div>')
        //.html('<div class="tt">' + tipTitle + '</div><div>' + link.href + '</div>')
        .show();
      }
    }).bind('mouseout', function(event) {
      var $link = $(event.target).closest('a');
      if ($link.length) {
        $link.attr('title', tipTitle);
        $('#livetip').hide();
      }
    });

});
