jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

function UpdateHeight()
{
	var height = $("div#content").height() + 80;
	$("#middle").height(height);
}

function PrepareMenu()
{
	$("div.menuitem:not(.selected)").hover(function() {
		var id = $(this).attr("id").substring(5);
		$(this).css("background-image", "url(\"images/button_"+id+"_hover.png\")");
	}, function() {
    var id = $(this).attr("id").substring(5);
		$(this).css("background-image", "url(\"images/button_"+id+".png\")");
	});
}

$(document).ready(function() {
    PrepareMenu();
		UpdateHeight();
		$(document).load(UpdateHeight);
    $(window).resize(UpdateHeight);
  });

$.preloadImages("images/button_home_hover.png", "images/button_about_hover.png",
  "images/button_contact_hover.png", "images/button_faqs_hover.png",
  "images/button_mysteries_hover.png", "images/button_private_hover.png",
  "images/button_shows_hover.png", "images/button_testimonials_hover.png");
