$(document).ready(function(){
    /* ****************************** */
    /*    Call Now image hover effect */
    /* ****************************** */
    var imgSrc = "/images/phone_us.gif";
    var hoverImgSrc = "/images/phone_us_hover.gif";
    // Preload the "Call now!" hover image
    $.preloadImages(hoverImgSrc);
    // Now bind the image swap to the mouseover and mouseout events
// NH 3 Aug 09 - not ready for popup yet    
//    $("#callnow").hover(
//        function(){
            // What to do when the mouse goes over
//            $(this).attr("src",hoverImgSrc)
//                    .css("cursor","pointer");
//        },
//        function() {
            // What to do when the mouse leaves again
//            $(this).attr("src",imgSrc);
//        }
//    );
    // Hide the bottom part of the image ("CALL NOW!") when the office is closed
    // NOTE: the HIDECALLNOW variable is set in the template_default.php file.
    //   (These scenarios are checked: blackout dates, weekends, and off-hours)
    if (HIDECALLNOW) {
        // Wrap the image in a div which hides the overflow through CSS (shorter height, overlflow=hidden)
        $("#callnow").wrap("<div id='callnowWrap'></div>");
    }
    /* **************************************************************** */
    /*  Listen for Esc keypress when GreyBox is open.                */
    /*      1. Check if there are any anchor tags with rel='gb_*'
    /*      2. Close window if Esc key is pressed                              */
    /* **************************************************************** */
    /*if ($("a[rel^='gb_']").length) {
        $(document).keypress(function (e) {
            if (e.keyCode == 27) { // Esc
                 GB_hide();
                 // de-focus (blur) the clicked anchor so the dotted border disappears (Firefox)
                 $("a[rel^='gb_']").blur();
            }
        });
        // Whenever a GreyBox is opened, add the text '(Esc)' to the window titlebar beside the word 'Close'
        $("a[rel^='gb_']").click(function(e) {
            // Wait 100ms to make sure the GreyBox window is loaded
            setTimeout(function() {   $("td.close span").append(" (Esc)");   } , 100)
        });
    }*/
    
});

/* ************************************************************ */
/*                          Plugins                             */
/* ************************************************************ */
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}