$(document).ready(
	function() {
		$('#castViewBackground').css('display', 'none').fadeTo(0, 0);
		$('#castView').css('display', 'none');
		
		$('.castViewTarget').each(function() {
			$(this).css('cursor', 'pointer').click(function() {
				var target = $(this).attr('id').split('detailCast_')[1];
				
				$('#castView').load('./detail/' + target + '.html', function() {
					var leftOffset = ($(document).width() / 2) - ($(this).width() / 2);
					$(this).css({left:leftOffset + 'px'});
					
					$('#btnUpr').css('cursor', 'pointer').click(closeCastView);
					$('#btnBtm').css('cursor', 'pointer').click(closeCastView);
					
					$('#castViewBackground').css('display', 'block').fadeTo(300, 0.8);
					$(this).fadeIn(400);
				});
			})
		});
	}
);

var trace = function(target) {
	console.log(target);
}

var closeCastView = function() {
	$('#castViewBackground').fadeOut(300, function() {$('#castViewBackground').css('display', 'none');});
	$('#castView').fadeOut(400);
}