$(document).ready(function()
{
    // kick-off the map highlighter plugin
    $('.map').maphilight(
    {
        fillOpacity: 0.5,
        stroke:      false
    });
    
    // listen for clicks on the map, show/hide tooltips
    $("area").click(function()
    {
       $("div.map-tooltip").fadeOut("fast");
       $(this).next("div.map-tooltip:first").fadeIn("fast");
       return false;
    });
    
    // close tooltip link (inside tooltip itself)
    $("a.close-tooltip").click(function()
    {
       $(this).parents( 'div.map-tooltip:first' ).fadeOut("fast");
    });
       
    // bind the map events to the text links below it so they
    // perform the same actions as if the mouse were over the map.
    $("ul#map-locations a").hover(
        function()
        {
            $("area." + $(this).closest("li").attr('class')).trigger('mouseover');
        },
        function()
        {
           $("area." + $(this).closest("li").attr('class')).trigger('mouseout');
        }
    );
    
    $("ul#map-locations a").click(function()
    {
        $("area." + $(this).closest("li").attr('class')).trigger('click');
        return false;
    });
});
