$(document).ready(
	function() {
		$('#portfolioViewBg').css('display', 'none').fadeTo(0, 0);
		$('#portfolioView').css('display', 'none');
		
		$('.portfolioViewTarget').each(function() {
			$(this).css('cursor', 'pointer').click(function() {
				var target = $(this).attr('id').split('portfolio_')[1];
				
				$('#portfolioView').load(target + '.html', function() {
					var leftOffset = ($(document).width() / 2) - ($(this).width() / 2);
					$(this).css({left:leftOffset + 'px'});
					
					$('.closeBtn').css('cursor', 'pointer').click(closeCastView);
					
					$('#portfolioViewBg').css('display', 'block').fadeTo(300, 0.99);
					$(this).fadeIn(400);
				});
			})
		});
	}
);

var trace = function(target) {
	console.log(target);
}

var closeCastView = function() {
	$('#portfolioViewBg').fadeOut(300, function() {$('#portfolioViewBg').css('display', 'none');});
	$('#portfolioView').fadeOut(400);
}