(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.fn.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);

jQuery().preLoadImages('images/menu_home_hover.gif', 'images/menu_about_hover.gif', 'images/menu_mytalk_hover.gif', 'images/menu_services_hover.gif', 'images/menu_news_hover.gif', 'images/menu_contact_hover.gif');


$(document).ready(function(){

  //setting up the nav hovers
  $('#nav ul li').hover(
    function()  { 
      $('.main', this).addClass('hover');
      $('.wrpr:not(.disabled)', this).css('visibility','visible');
            
      // make dropdowns at least as wide as their li parent
      if ($('.wrpr ul', this).width() <= $(this).width()    ){
        $('.wrpr ul', this).css('width', ($(this).width() - 6) + 'px'); 
      }
    },
    
    function()  {
      $('a.main', this).removeClass('hover');
      $('.wrpr', this).css('visibility','hidden');
      
      }
  )

});
