$(document).ready(function() {
	// portfolio caption hover
	$('.p_item a').hover(function() {
		$(this).children('.p_caption').animate({
			opacity: '1.0',
			filter: ''
		}, 500);
	}, function() {
		$(this).children('.p_caption').animate({
			opacity: '0.0',
			filter: ''
		}, 500);
	});
	
});


// home page animations
function homePage() {
	$('#logo').animate({
		opacity: 1,
		marginTop: '0px',
		filter: ''
	}, 1000, function() {
		$('#feeds').animate({
			opacity: 1,
			filter: ''
		}, 1000);
		$('#signup').animate({
			opacity: 1,
			filter: ''
		}, 1000);
	});
}

// bio page animations
function bioPage() {

	// bio tabs
	$('#biocontent .tabs a').click(function() {
		if ($(this).hasClass('sel')) {
			//
		} else {
			resetTabs();
			var $content = $(this).attr('rel');
			$(this).addClass('sel');
			$('#'+ $content).addClass('active');
			return false;
		}
	});

	$('#bio_bubble').animate({
		opacity: 1,
		filter: ''
	}, 1000);
	
	$('#jhrotate ul li').each(function(e) {
		$(this).animate({filter:''});
	});
}

// bio reset tabs
function resetTabs() {
	$('#biocontent .tabs a').removeClass('sel');
	$('#biocontent .content').removeClass('active');
}

// portfolio page
function portfolioPage() {

	// build out the masonry
	$('#portfolio_list').masonry({
		singleMode: true,
		columnWidth: 250,
		itemSelector: '.p_item',
		isAnimated: true,
		animate: true,
		resizeable: true,
		saveOptions: true,
		animationOptions: {
			duration: '1000',
			queue: false
		}
	});

	// apply inner shadow to all the elements
	$('#portfolio_list .p_item a').each(function() {
		var width = $(this).children('img').width();
		var height = $(this).children('img').height();
		$(this).children('.p_shadow').css({height: height+'px', width: width+'px'});
	});
	
	// apply inner shadow to nav elements
	$('.p_nav ul li a').each(function() {
		var width = $(this).children('img').width();
		var height = $(this).children('img').height();
		$(this).children('.shadow').css({height: height+'px', width: width+'px'});
	});
	
	// fade in all elements
	$('#portfolio_list .p_item').delay(1000).animate({opacity: '1.0', filter: ''}, 500)
}
