(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.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);

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImagesArray = function(arr) {
    var args_len = arr.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arr[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);

$(document).ready(function () {
	var imageList = [];
	$('a[rel=external]').attr({'target':'_blank'});
	$('img.mo').each(function () {
		var normal = $(this).attr('src');
		var rollover = normal.replace(/(\..*?)$/, '-mo$1');
		imageList.push(normal);
		imageList.push(rollover);
		$(this).mouseenter(function () {
			$(this).attr('src', rollover);
		});
		$(this).mouseleave(function () {
			$(this).attr('src', normal);
		});
	});
	$('a.expand').click(function (event) {
		event.stopPropagation();
		$(this).next('.expandable').toggle("fast");
		$(this).hide();
		return false;
	});
	$('.menu li', '.submenu li').hover(
		function () {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
		}
	);
	$('#logo').click(function () {
		location.href='/';
	});
	jQuery.preLoadImagesArray(imageList);
});

