$(document).ready(function(){
						   
	 $('#fbdiv').hide();
	 setHoverImgs();
	 $.preloadImages("../images/nav/contacthover.jpg", "../images/nav/homehover.jpg", "../images/nav/portfoliohover.jpg");
	 $.setFacebookPageDiv();
	 });
	 
/*functions */
   	function setHoverImgs() {
	//image hover code. changes out image.jpg src to imagehover.jpg
	//on mouse over to all images within specified area (#navbar)
	$('#headerlinks 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]);
       }
    }
	
	jQuery.setFacebookPageDiv = function() {
		
		var $fbbutton = $('.fbbutton');
		var $fbdiv = $('#fbdiv');
		
		$buttonPosition = $fbbutton.offset();
		$left = $buttonPosition.left + 50;
		$top = $buttonPosition.top + 50;
		
		$fbdiv.css({'position' : 'absolute', 'top' : $top + 'px', 'left' : $left + 'px'});
		
		$fbbutton.mouseover(function() {
							$fbdiv.show();
								 });
		$('#fbiframe').mouseout(function(){
							$fbdiv.hide();
							  });
		$(document).click(function(){
							$fbdiv.hide();
							  });
	}