(function($) {
  var cache = [];
  $.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(
    "/Img/navL2LnkOn.png", "/Img/navL2LnkOff.png", "/Img/navL2SxLnkOn.png", "/Img/navL2SxLnkOff.png", 
    "/Img/navL2BckS.png", "/Img/navL2BckM.png", "/Img/navL2BckL.png", 
    "/img/navL2TopS.png", "/Img/navL2BotS.png", "/img/navL2TopM.png", "/Img/navL2BotM.png", "/img/navL2TopL.png", "/Img/navL2BotL.png"
);

$(document).ready(function () {
	$('.navL1').each(function(index) {
		$(this).bind({
		  mouseenter: function() {
		  	closeAllMenuItems();
		  	// $('#nav0' + (index + 1) + 'L2').slideToggle('fast');
		  	//if(index == 0 || index == 4)
		  	    $('#nav0' + (index + 1) + 'L2').show();
		  }
		});
	});
		
	$('.menuL2ContainerS ul li a, .menuL2ContainerM ul li a, .menuL2ContainerL ul li a').each(function() {
		$(this).bind({
		  mouseenter: function() {
		  	$(this).parent().css('background-image', 'url(/Img/navL2LnkOn.png)');
		  },
		  mouseleave: function() {
		  	$(this).parent().css('background-image', 'url(/Img/navL2LnkOff.png)');
		  }
		});
	});

	$('.menuL2ItemS, .menuL2ItemM, .menuL2ItemL').each(function() {
		$(this).bind({
		 mouseleave: function() {
		  	closeMenuItem($(this));
		  }
		});
	});
	
	$('.menuL2SxContainer ul li a').each(function() {
		$(this).bind({
		  mouseenter: function() {
		  	$(this).parent().css('background-image', 'url(/Img/navL2SxLnkOn.png)');
		  },
		  mouseleave: function() {
		  	$(this).parent().css('background-image', 'url(/Img/navL2SxLnkOff.png)');
		  }
		});
	});
});

function closeAllMenuItems() {
	$('#nav01L2').hide();
	$('#nav02L2').hide();
	$('#nav03L2').hide();
	$('#nav04L2').hide();
	$('#nav05L2').hide();
	$('#nav06L2').hide();
}

function closeMenuItem(item) {
    item.hide();
}
