// Common functions for all pages

var showing_pic = 0;
var fadeSpeedBg = 500;
var fadeSpeedIn = 400;
var fadeSpeedOut = 800;
var fadeOutDelay = 2000;
var scrollSpeed = 400;	 
 
// Load on ready for all pages
 $(document).ready(function(){
 
   // initial fadein's for bg and text (if exists)	 
   $("#bg_img").fadeTo(0,0);
   $("#loading").hide();
      
   if ($("#text_container").length) {
	   $("#text_container").hide();
	   $("#text_container").fadeIn(fadeSpeedBg);
   }
   
   // load function for main pic
   $("#bg_img").load(function(){
      // set the image hidden by default    
      $("#loading").fadeOut();
      $(this).fadeTo(fadeSpeedBg,1);
   });
   
   // populate main pic info on ready
   $("#bg_img").attr("src","content/portfolio/"+pics[showing_pic][0]);
   
   // catch menu links and fade out bg before next one
   $("#menu a").click(function(e){
		e.preventDefault();
		var linkLocation = this.href;
		if ($("#text_container").length) { $("#text_container").fadeTo(fadeSpeedBg, 0); }
		$("#bg_img").fadeTo(fadeSpeedBg, 0, function(){ window.location = linkLocation; });
	});
   
   // menu hover 
   $("#menu").hoverIntent({
	   over: function(){
		   		$(this).animate({left: "0px"},{queue: false, duration: fadeSpeedIn}); 
		   		$(this).data("visited",1);
	   	  	 }, 
	   timeout: fadeOutDelay,
	   out: function(){
		   $(this).animate({left: "-160px"},{queue: false, duration: fadeSpeedOut}); 
	   	  }
   });
  
    
   // end   
 }); 
 
