/*
  *  function called once the dom is ready to roll.
  *
  */
  
$(document).ready(function(){		
  
  /* add rollover functionality to the tab navigation */
  $('#tabNav li').hover(function() {
    $(this).addClass('hover');
  }, function() {
    $(this).removeClass('hover');
  });
  
  /* set up dropdown menu trigger for all browsers (not respected in IE when sitting on top of a flash object) */
  $('#overlay').click( function()
  { 
    toggleDropdown();
  });
  
  // rollup function
  /* no need for a rollup at this point
  $('#bottomBar').click( function()
  {
    // show the return-to-site link
    $('#bottomBarMenu').fadeToggle();
    $('#dropdownContainer').slideToggle("slow", function(){
      $('#underlay').fadeToggle();
      $('#displayContainerBackground').fadeToggle("slow");
    });
  });
  */
  
  
  /* dropdown functionality to add hover classes to menu items  and show overplayed pngs*/  
   $('.dropdownMenuItem').click(function(){

    // get the ID of the hovered element and use that ID to construct pointer to corresponding transparency class ID
    var curId = $(this).attr('id');
    var overlayElemId = '#overlay'+curId;
    
    // remove all hover classes from nav menu items then add it to the corresponding one
    $('.dropdownMenuItem').removeClass('hover');
    $(this).addClass("hover");
    
    // hide ALL transparency classes, then remove the one that corresponds to the hover
    $('.transparency').addClass('hidden');
    $(overlayElemId).removeClass('hidden');
  });
  
});

/*
  *  other inline functions
  *
  */
  
// define image preloads
var themePath = base_path + directory;
$.preloadImages(  "/img/content/dropdown/menu1_sprite.jpg", 
                  "/img/content/dropdown/menu3_sprite.jpg", 
                  "/img/content/dropdown/menu2_sprite.jpg", 
                  "/img/content/dropdown/menu4_sprite.jpg",
				  "/img/content/dropdown/menu5_sprite.jpg",
				  "/img/content/dropdown/menu6_sprite.jpg", 
                  "/img/content/dropdown/overlay1.png", 
                  "/img/content/dropdown/overlay2.png", 
                  "/img/content/dropdown/overlay3.png", 
                  "/img/content/dropdown/overlay4.png", 
                  "/img/content/dropdown/pacific_city_header.png",
                  "/img/content/dropdown/dropdown_bg.jpg",
                  "/img/layout/displayContainer_bg.jpg",
                  "/img/content/meetings_popup.jpg"
               );

// due to some IE6 flash strangeness, this function gets called
// directly from the flash
function toggleDropdown(){
  
  // since there is no 'returning' after the dropdown gets dropped, simply hide the toggle control -- averts issue with overlay over flash trigger in Safari.
  $('#overlay').hide();
  $('#underlay').hide();
  $('#displayContainerBackground').fadeToggle("slow",null,function()
    {
      // show the 'return to site' link
      //$('#bottomBarMenu').fadeToggle();
      $('#dropdownContainer').slideToggle("slow");
    });
    
}