$(document).ready(function(){

	 setHoverImgs();

	 $.preloadImages("../images/nav/contacthover.jpg", "../images/nav/homehover.jpg", "../images/nav/portfoliohover.jpg");

						   });

	 

/*functions */

   	function setHoverImgs() {

	//image hover code. changes out image.png src to imagehover.jpg

	//on mouse over to all images within specified area (#navbar)

	$('#nav img')

	    .mouseover(function(){

			var src = $(this).attr("src").match(/[^\.]+/) + "hover.png";

			$(this).attr("src", src);

							})

		.mouseout(function(){

			var src = $(this).attr("src").replace("hover", "");

			$(this).attr("src", src);

						   });

	}

    //preload the hover images so the user does not have to wait

	jQuery.preloadImages = function() {

      for(var i = 0; i<arguments.length; i++) {

         jQuery("<img>").attr("src", arguments[i]);

       }

    }