﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />
$(document).ready(function() {

    // Regex for finding the links
    var patt = new RegExp("[^#]+$");

    // Bind behaviour to calendar links
    $("table#calendar a").bind("mouseenter", function() {
        var href = $(this).attr('href');
        var hashval = patt.exec(href);
        $("ul#events li.eventShow").hide();
        $("ul#events li#" + hashval).show();
    }).bind("mouseleave", function() {
        $("ul#events li.eventHide").hide();
        $("ul#events li.eventShow").show();
    });

    // Kill the mouseover on a click
    $("table#calendar a").click(function() {
        $("table#calendar a").unbind("mouseenter");
        $("table#calendar a").unbind("mouseleave");
        var href = $(this).attr('href');
        var hashval = patt.exec(href);
        $("ul#events li").hide();
        $("ul#events li#" + hashval).show();
        href = "#" + hashval;
        $(this).attr('href', href);
        return false;
    });

});