function applyCufon() {
	var cufon = new Array(
			'.top-navi ul li',
			'.homepage-slideshow span.title',
			'a.box-title:not(.skip)',
			'.blog .entry h1',
			'.blog .entry h1 a',
			'.calendar .event h1',
			'.calendar .event h2',
			'.small-video h1',
			'a.more-videos',
			'.contact-us .grid_3 h2',
			'.artist .grid_3.border-right .inside h2',
			'.artist .grid_3.border-right .inside p a',
			'.artist h1',
			'.calendar-entry h1',
			'.calendar-entry h3',
			'.archive a.box-title span.text',
			'.comments h3',
			'.footer ul li a',
			'.artist .read-more a',
			'.cufon-video h1'
		);
	
	$.each(cufon, function(x, v) {
		var e = $(v);
		if( e ) {
			Cufon.replace( e, { hover: true } );
		}
	});
}

function calendarpage() {
	jQuery('.page-holder .inside').each(function() {
		var $pages = $(this).find('.page');

		// $pages.css('width', $(this).width());
		$pages.css('width', '220px');
		$(this).css('width', $pages.length*220 + 'px');
	});

	jQuery('.archive .page-holder').serialScroll({
		items: '.page',
		prev: '.archive a.box-title span.left-arrow',
		next: '.archive a.box-title span.right-arrow',
		duration: 400,
		start: 1,
		cycle: false,
		constant: false,
		onBefore: function( e, elem, $pane, $items, pos ) {
			var $title = jQuery('.archive a.box-title');
			$title.find('.text').html( $(elem).find('> h2').html() );
			Cufon.replace( $title );
		
			if( pos+1 >= $items.length ) {
				jQuery('.archive a.box-title span.right-arrow').hide();
				jQuery('.archive a.box-title span.left-arrow').show();
			} else if( pos == 0 ) {
				jQuery('.archive a.box-title span.left-arrow').hide();
				jQuery('.archive a.box-title span.right-arrow').show();
			} else {
				jQuery('.archive a.box-title span.left-arrow').show();
				jQuery('.archive a.box-title span.right-arrow').show();
			}
		}
	});

	jQuery('.archive .page-holder .inside').trigger('goto', [jQuery('.archive .page-holder .inside .page').index( jQuery('.archive .page-holder .inside .page.current') )] );
	
	if( jQuery('.archive .page').length == 1 ) {
		jQuery('.archive .left-arrow, .archive .right-arrow').hide();
	}
}

function homepage() {
	$('.homepage-slideshow .inside').cycle({
		fx: 'fade',
		before: function() {
			var $title = jQuery('.homepage-slideshow .overlay span.title');
			$title.html( $(this).find('img').attr('alt') );

			Cufon.replace( $title );
		},
		next:   '.homepage-slideshow .navi .next',
	  	prev:   '.homepage-slideshow .navi .prev',
		duration: 200,
		timeout: 5000
	});
	
	if( $player_ready ) {
		updateDisplay();
	}
	
	blog_captionroll();
	
	mp3_bind();
}

function blog_captionroll() {
	jQuery('.caption').each(function() {
		var $thecaption = $(this).find('.the-caption');
		// $thecaption.animate({'bottom': -1*$thecaption.height() });
		$thecaption.css('bottom', -1*$thecaption.height());
		
		$(this).hover(function() {
			var $thecaption = $(this).find('.the-caption');
			$thecaption.animate({'bottom': 0}, 200);
		}, function() {
			var $thecaption = $(this).find('.the-caption');
			$thecaption.animate({'bottom': -1*$thecaption.height()}, 200);
		});
	});
	
	jQuery('.homepage-slideshow').each(function() {
		var $overlay = $(this).find('.overlay');
		// $overlay.animate({'top': -1*$overlay.height() });
		$overlay.css('top', -1*$overlay.height() );
		
		$(this).hover(function() {
			var $overlay = $(this).find('.overlay');
			$overlay.animate({'top': 0}, 200);
		}, function() {
			var $overlay = $(this).find('.overlay');
			$overlay.animate({'top': -1*$overlay.height()}, 200);
		});
	})
}

$(document).ready(function() {
	applyCufon();
	$('.footer').localScroll({
		duration: 300,
	});
})