(function(jQuery) {
jQuery.fn.fadeInSequence = function(fadeInTime, timeBetween)
{
	//Default Values
	timeBetween = typeof(timeBetween) == 'undefined' ? 0 : timeBetween;
	 fadeInTime = typeof(fadeInTime) == 'undefined' ? 500 : fadeInTime;

	//The amount of remaining time until the animation is complete.
	//Initially set to the value of the entire animation duration.
	var remainingTime = jQuery(this).size() * (fadeInTime+timeBetween);

	var i=0; //Counter
	return jQuery(this).each(function()
	{
		//Wait until previous element has finished fading and timeBetween has elapsed
		jQuery(this).delay(i++*(fadeInTime+timeBetween));

		//Decrement remainingTime
		remainingTime -= (fadeInTime+timeBetween);

		if(jQuery(this).css('display') == 'none')
		{
			jQuery(this).fadeIn(fadeInTime);
		}
		else //If hidden by other means such as opacity: 0
		{
			jQuery(this).animate({'opacity' : 1}, fadeInTime);
		}

		//Delay until the animation is over to fill up the queue.
		jQuery(this).delay(remainingTime+timeBetween);

	});	

};

})(jQuery);




$(function () {
			$(".parts, .looks,.problems").hide();  
	$(".parts, .looks,.problems, .staffs, .officeimg").fadeInSequence(700);   
		
			// SUBMENU ANIMATION	

$('.photos a').append('<div class="gloss">Enlarge</div>');
var configHover = {    
     over: overNav, // function = onMouseOver callback (REQUIRED)    
     timeout: 0, // number = milliseconds delay before onMouseOut    
     out: outNav // function = onMouseOut callback (REQUIRED)    
};

function overNav() {
	$(this).children('.sub-menu').slideDown();
}
		
function outNav() {
	$(this).children('.sub-menu').slideUp();
	
	
}


		$('.sub-menu').hide();	
		$("#nav li").hoverIntent(configHover);



$('.button').hover( function (){
							  
						$(this).fadeTo('medium',.74);	  
							  },
							  function(){
				   $(this).fadeTo('medium',1);	 
				   
				   
							  });
// RETAINER CURRENT	
$(".slidedata").find("li:not(:first)").each(function(i) {
     $(this).hide();
   });
	
 $('#options li:first').addClass('current');

	$('#options li a').click(function(evt) {
					$('#options .current').removeClass("current");
			 		$(this).parent().addClass('current');
					var clicked = $(this).attr('href');
					var clicked2 = clicked.replace('#','.')
					$('.slidedata li').fadeOut(1000).hide();
					$('.slidedata ' + clicked).fadeIn(1400); 
					$('.slidedata ' + clicked2).fadeIn(1400);  
					evt.preventDefault();




 
 
});
	
	
		$('a[rel=modal]').fancybox({
	
		'overlayColor': '#333',
		'overlayOpacity' : 0.7
	});
			});
		


		
Cufon.replace('h1,h3,#nav li a:not(#nav li li a)',{'hover':true}); // Requires a selector engine for IE 6-7, see above

// SPAM EMAIL FIX  

    $('a.email').each(function(i) {
        var text = $(this).text();
        var address = text.replace(" at ", "@");
        $(this).attr('href', 'mailto:' + address);
            $(this).text(address);
        });


// SMOOTH ANCHOR LINKING
$("a.top").click(function(evt1) {
  $("html").animate({ scrollTop: 0 }, "medium");

  return false;
  evt1.preventDefault();
});








