/* Mouse overs for items on maps */
/* NacreData L.L.C. devin@nacredata.com */

/* How to add a new mouse-over map:
*
* 1. Add the new img tag immediately below the existing one in index-hover.php
*
* 2. Create an entry in map_styles.css and position the small image with the 
*    "left" and "top" attributes, adding "display: none" last to hide it
*
* 3. Add a new line in the "hide" function on the "NacreData" object in this 
*    file, identical to the others except for the new #id
*
* 4. Create a new "show_" function in the NacreData object, again copying the 
*    existing code except for a new funcion name and new #id
*
* 5. Add a new pair of mouseover bindings in the "$" function (the jQuery
*    "ready" function) for the area to activate the new image and for the 
*    image itself to capture and discard ("swallow") mouseover events on the 
*    new image to avoid flicker. 
*/

var NacreData = window.NacreData = {
  hide: function(event) { 
    $("#crm").css("display","none"); 
    $("#hazy").css("display","none"); 
    $("#prenter").css("display","none"); 
    
    event.stopPropagation();
  },
  hide_others: function(myid) {
    $("*#map_wrapper").children().not('*#'+myid).not("*#base_map").css("display","none"); 
  },
  swallow: function(event) { event.stopPropagation(); },
  show_crm: function(event) { NacreData.hide_others('crm'); $("#crm").css("display","block"); event.stopPropagation(); },
  show_hazy: function(event) {  NacreData.hide_others('hazy'); $("#hazy").css("display","block"); event.stopPropagation(); },
  show_prenter: function(event) {  NacreData.hide_others('prenter'); $("#prenter").css("display","block"); event.stopPropagation(); },
  images: new Array( "/map_project/images/crm-hover.jpg", 
  "/map_project/images/shumate-hover.jpg",
    "/map_project/images/moth-hover.jpg", 
    "/map_project/images/prenter_comm-hover.jpg",
    "/map_project/images/mtr4-hover.jpg", 
    "/map_project/images/WindTurbine_WebSmall-hover.jpg",
    "/map_project/images/maps/ajax-loader.gif"
    )
};

$( function() { 

  $("#map_wrapper").bind('mouseover',NacreData.hide);

  $("#crm_area").bind('mouseover',NacreData.show_crm);
  $("#crm").bind("mouseover",NacreData.swallow);

  $("#hazy_area").bind('mouseover',NacreData.show_hazy);
  $("#hazy").bind("mouseover",NacreData.swallow);
  
  $("#prenter_area").bind('mouseover',NacreData.show_prenter);
  $("#prenter").bind("mouseover",NacreData.swallow);
  
  /* New code to preload right bar images */
  
  for(var i = 0; i<NacreData.images.length; i++) {
    jQuery("<img>").attr("src", NacreData.images[i]);
  }


} );


