jQuery.preloadImages = function()
{
  //http://www.mattfarina.com/2007/02/01/preloading_images_with_jquery
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
function addLoadEvent(func) {
  //http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function nav_click_g(){
	$("#main").fadeOut("slow");
	setTimeout("window.location = 'gallery.php?a=g'",1000);
}
function nav_click_h(){
	$("#main").fadeOut("slow");
	setTimeout("window.location = 'gallery.php?a=h'",1000);
}
addLoadEvent(function() {
	$.preloadImages("images/greg_bernhardt_hover.jpg","images/hannah_sessions_hover.jpg");
	$("#blue_ledge_gallery").html('<img src="images/blue_ledge_gallery.jpg" alt="Blue Ledge Gallery" />');
	$("#goat").click(function(){nav_click_g();});
	$("#goat").css("cursor","pointer");
	$("#goat").html('<img src="images/goat.jpg" alt="Painting of a goat" />');
	$("#greg_bernhardt").click(function(){nav_click_g();});
	$("#greg_bernhardt").css("cursor","pointer");
	$("#greg_bernhardt").html('<img id="gb_img" src="images/greg_bernhardt.jpg" alt="Greg Bernhardt" />');
	$("#gb_img").hover(function(){this.src = this.src.replace(".jpg","_hover.jpg");},function(){this.src = this.src.replace("_hover.jpg",".jpg");});
	$("#bales").click(function(){nav_click_h();});
	$("#bales").css("cursor","pointer");
	$("#bales").html('<img src="images/bales.jpg" alt="Painting of bales of hay" />');
	$("#hannah_sessions").click(function(){nav_click_h();});
	$("#hannah_sessions").css("cursor","pointer");
	$("#hannah_sessions").html('<img id="hs_img" src="images/hannah_sessions.jpg" alt="Hannah Sessions" />');
	$("#hs_img").hover(function(){this.src = this.src.replace(".jpg","_hover.jpg");},function(){this.src = this.src.replace("_hover.jpg",".jpg");});
});
