if(typeof console == 'undefined') { console = new Object(); console.log = function(){}; }

jQuery.fn.viewportOffset = function() {
    var offset = $(this).offset();
    
    return {
      left: offset.left - jQuery(window).scrollLeft(),
      top: offset.top - jQuery(window).scrollTop()
    };
};


// jQuery.fn.tooltip = function(text, title) {
//    title = (typeof title == 'undefined') ? 'Class Description' : title;

//    var $dialog = jQuery('<div></div>').html(text).dialog({
//        autoOpen: false,
//        draggable:  true,
//        position:  [this.viewportOffset().left+10,this.viewportOffset().top],
//        title: title
//    });

//    $dialog.dialog('open');

//    jQuery('.ui-dialog.ui-widget.ui-corner-all').mouseleave( function(event) {
//        $dialog.dialog('close');
//    });
// }


// Turning this block off but leaving in place for now to see which way the client goes on the scheduler descriptions - 10/25/2010 BV
//$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready (a little sooner that page load)
//  $('.schedDescrip').hide();
//  $('.slick-slidetoggle').click(function() {
//    $('.schedDescrip').slideToggle(400);
//    return false;
//  });
//});

//$(document).ready(function() {
//  $('#TUE').click(function() {
//    $('.schedDescrip').hide();
//    return false;
//  });
// });



//Set up events for showing the class description on mouseover
jQuery('table.schedule td a').each(function(idx) {
    //Disable clicks on class descriptions
    $(this).click( function(e) {
        e.preventDefault();
        return false;
    });

    //Find links with an href in the format "descriptions#<class_id>"
    var matches = this.href.match(/.*descriptions\#id(\d+)$/);
    if(matches){
        //Check to see if the class has a description
        if(jQuery('#description_'+matches[1]).val()) {
            jQuery(this).mouseover(function(e) {
                //Display description here
                jQuery(this).tooltip(jQuery('#description_'+matches[1]).val(), $(this).html());
            });
            jQuery(this).mouseout(function(e) {
                jQuery('#current-tooltip').hide();
            });
        }
    }
});


