/*
** RegionMap.js
*/
$(function() {

   var $links = $("div#regionMap a.region"),
       $sourceImages = $links.children("img"),
       arr = new Array($sourceImages.length);


   $sourceImages.each(function(i) {
      var $img = $(this);

      // Preload hover images
      arr[i] = new Image();
      arr[i].src = this.src.replace(/^(.*)(\.gif)$/ig, "$1.hover$2");
   
      // Add rollover events   
      $img.hover(function() {
         this.src = this.src.replace(/^(.*)(\.gif)$/ig, "$1.hover$2");   
      }, function() {
         this.src = this.src.replace(/^(.*)(\.hover)(\.gif)$/ig, "$1$3");   
      })      
   });



   $links.click(function(evt) {
      var cookieValue = $(this).getBookmark();
      evt.preventDefault();

      // These values must replicate those in Abl.PageMap.defaults
      Abl.Cookie.set("activeRegion", cookieValue, 60, "d");

      // Perform page routing based upon the (new) region cookie
      window.location = "/Default.aspx";
   });

});
