$(document).ready(function(){
	if($('a.lightbox').length > 0)
		$('a.lightbox').lightBox();	

	if($('#inside .paper .content').length > 0)
		$('#inside .paper .content').cycle({fx: 'fade', timeout: 7000, cleartype: false, cleartypeNoBg: true});

	$('#cast .name, #cast .character').hover(
		function(e){
			var image = $(this).parent('.wrapper').find('.image_holder');
			if($(this).hasClass('name')) {
				image.css('background-position', 'center -270px');
			} else {
				image.css('background-position', 'center -20px');
			}
			var url = $(this).attr('rel');
			var id = $(this).parent('.wrapper').parent('div').attr('id').replace('cast', '');
			setContent(url, id+'_'+$(this).attr('class').replace('png', ''));
			var scroll = $('#cast'+id+'_'+$(this).attr('class').replace('png', ''));
			var top = 40;
			if($(this).hasClass('character')) {
				top = 300;
			}
			var top = e.pageY - $('#cast').height() - top;
			scroll.css('top', top);
			scroll.fadeIn();
			$(this).attr('class', $(this).attr('class')+'_hover');
		}, 
		function(){
			$('.scroll').stop(true, true);
			$('.scroll .content').stop(true, true);
			var id = $(this).parent('.wrapper').parent('div').attr('id').replace('cast', '');
			$(this).attr('class', $(this).attr('class').replace('_hover', ''));
			var scroll = $('#cast'+id+'_'+$(this).attr('class').replace('png', ''));
			scroll.hide();
                }
	);
});


function setContent(url, id) {
 	$.post(
        	url,
        	function(data) {
			$('#cast'+id+' .content').html(data);
        	}
        );
}
