
// gaia_map: creates a map object
var gaia_map = function() {
  var that;
  that = {
    change_region : function(id){
        $('#small_map_on_'+id).fadeIn(400).siblings().fadeOut(400);
    }
  };
  return that;
};

//  map: an instance of the gaia_map() object described above
var small_map = gaia_map();

//  small_map_over(small_map_over_id): changes the active region
//  on the map, if the user hovers over a link
//  for a long enough period of time.
var small_map_over = function(id){
    small_map.change_region(id);
}


// initialize_map: sets up the auto-rotator,
// and hook up the mouseover and mouseout events
// fot the regions to the map object.
var initialize_small_map = function(){
    
    //  make the mouseover event for each region
    //  be linked to the small_map_over($region) function
    $('[href *="gaiaglobal"]').mouseover(function(){
        small_map_over(1);
    });
    $('[href *="africa"]').mouseover(function(){
        small_map_over(2);
    });
    $('[href *="asia-pacific"]').mouseover(function(){
            small_map_over(3);
    });
    $('[href *="europe"]').mouseover(function(){
            small_map_over(4);
    });
    $('[href *="latinamericaandthecaribbean"]').mouseover(function(){
            small_map_over(5);
    });
    $('[href *="middleeastandnorthafrica"]').mouseover(function(){
            small_map_over(6);
    });
    $('[href *="usandcanada"]').mouseover(function(){
            small_map_over(7);
    });

 };
 
 //  Sanitize the environment
 //  and run the code when the browser loads!
jQuery(function($){
    if (!$.browser.msie) $('body').css('opacity', 0.9999);
    initialize_small_map();
});
