$(document).ready(function(){
	
	if(sPage === 'home'){
		$('#header').animate({ 'opacity': 1, 'top': '0px' }, 800);
	}
	else{
		$('#header').css({ 'opacity': 1, 'top': '0px' });
	}
	
	
	$('#nav').find('li').children('a').hover(
		function(){ $(this).parent('li').addClass('hover'); },
		function(){ $(this).parent('li').removeClass('hover'); }
	);

	$('#'+sPage).addClass('selected');
	
	$('#'+sPage+'_slogan').show();	
	
	
	$('.portfolio_image').children('a').hover(
		function(){ 
			$(this).children('img').fadeIn(300);
		},
		function(){ 
			$(this).children('img').fadeOut(300);
		}
	);
	
	if(sPage === 'about' || sPage === 'services' || sPage === 'work' || sPage === 'clients' || sPage === 'contact'){
		$('#hpquotes').hide();
	}
	else{
		$('#hpquotes').show();
	}
	
	
	$('.info_icon').click(function(){
		$(this).parent('h3').next('.portfolio_image').children('.overlay').fadeToggle();
	});
	$('.close_button').click(function(){
		$(this).parent('.overlay').fadeOut();								  
	});
	
	
	$(".single_image").fancybox({
		onStart: resetWorkImages,
		onComplete: resetWorkImages,
		onClose: resetWorkImages
	});
		
	
});

function resetWorkImages(){
	$('.portfolio_image').find('a').find('img').attr('style', '');
}

function showNextQuote(){
	var currentQuote = $('#hpquotes').children('.selected');
	var nextQuote = currentQuote.next();
	
	if(!nextQuote.length || !currentQuote.length){
		nextQuote = $('#hpquotes').children('img').first();
	}
	
	nextQuote.addClass('selected').fadeIn().siblings().removeClass('selected').hide();
}
