var cache = [];
  

$(document).ready(function(){
	//image rollovers - NAVIGATION
	$("#submenu_items a img").hover(
		 function()	 {
		 	this.src = this.src.replace("_off","_on");
		 },
		 function()	 {
		 	this.src = this.src.replace("_on","_off");
		 }
	);
	
	$("#gallery").hide();
	
	//NAVIGATION CLICKS
	$('#showtimes').click(function() {
  		$("#content_text").load('showtimes.htm');
		$("#content_title").text("Showtimes");
		$("#gallery").hide();
	});
	$('#admission').click(function() {
  		$("#content_text").load('admission.htm');
		$("#content_title").text("Admission");
		$("#gallery").hide();
	});
	$('#gettingthere').click(function() {
  		$("#content_text").load('getting_there.htm');
		$("#content_title").text("Getting there");
		$("#gallery").hide();
	});
	$('#registration').click(function() {
  		$("#content_text").load('registration.htm');
		$("#content_title").text("Registration");
		$("#gallery").hide();
	});
	$('#contactus').click(function() {
  		$("#content_text").load('contact_us.htm');
		$("#content_title").text("Contact us");
		$("#gallery").hide();
	});
	$('#display').click(function() {
  		$("#content_text").load('display.htm');
		$("#content_title").text("Display your ride");
		$("#gallery").hide();
	});
	$('#display').click(function() {
  		$("#content_text").load('display.htm');
		$("#content_title").text("Display your ride");
		$("#gallery").hide();
	});
	$('#sponsors').click(function() {
  		$("#content_text").load('sponsors.htm');
		$("#content_title").text("Sponsors");
		$("#gallery").hide();
	});
	$('#tradelinks').click(function() {
  		$("#content_text").load('tradelinks.htm');
		$("#content_title").text("Tradelinks");
		$("#gallery").hide();
	});
	$('#winners').click(function() {
  		$("#content_text").load('winners.htm');
		$("#content_title").text("Winners");
		$("#gallery").hide();
	});
	
	$('#winahotrod').click(function() {
  		$("#content_text").load('win_a_hotrod.htm');
		$("#content_title").text("Win a hotrod");
		$("#gallery").hide();
	});
	
	
	/*$('#gallerybuttons p a').click(function() {
		//get ID of current button to load page
		var pagetoload = this.id + ".htm";
		alert(pagetoload);
		$("#content_text").load(pagetoload);
		$("#content_title").text("Gallery");	
		$("#gallery").show();	
	});*/
	

	jQuery.preLoadImages("admission_on.gif", "contact_us_on.gif", "display_on.gif", "getting_there_on.gif", "registration_on.gif", "showtimes_on.gif", "sponsors_on.gif", "tradelinks_on.gif", "");
	
});

function openGallery() {
  	$("#content_text").load('gallery.htm');
	$("#content_title").text("Gallery");	
	$("#gallery").show();	
}

function openAboutUs() {
  	$("#content_text").load('about_us.htm');
	$("#content_title").text("About us");
	$("#gallery").hide();
}

function openBlog() {
  	$("#content_text").load('blog.htm');
	$("#content_title").text("Blog");
	$("#gallery").hide();
}

// 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);
    }
  }

function loadGallery(whatOne) {
	//alert(whatOne);
	var pagename = whatOne.replace(".htm","");
	pagename = pagename.replace(".HTM","");
	pagename = pagename.replace("_"," ");
	pagename = pagename.toUpperCase();
		$("#content_text").load(whatOne);
		$("#content_title").text("Gallery - " + pagename);	
		$("#gallery").show();	
}
