$(document).ready(function() {
	// must do scroll-pane first
	$('.scroll-pane').jScrollPane({scrollbarWidth:14, arrowSize:14, showArrows:true, scrollbarMargin: 10});
	$('.prev').addClass('prev-disabled');
	$('.next').addClass('next-disabled');
	$('.slides').cycle({
		timeout: 0,
		speed: 750,
		fx: 'scrollHorz',
		next: '.next',
		prev: '.prev',
		nowrap: 1,
		sync: 1,
		startingSlide: Number( window.location.hash.slice(1) ),
		before: function(currSlideElement, nextSlideElement, options, forwardFlag) {
			window.location.hash = "#"+ $(nextSlideElement).index();		
			// first
			if ( ( $(nextSlideElement).prev().attr('class') == undefined ) ) {$('.prev').addClass('prev-disabled');} else {$('.prev').removeClass('prev-disabled');}
			// last
			if ( ( $(nextSlideElement).next().attr('class') == undefined ) ) {$('.next').addClass('next-disabled');} else {$('.next').removeClass('next-disabled');}
		}
	});
	if ( $('body#intro').length > 0 ) {
		$('.timeline').css("background-position", "0 -230px");
		$('.timeline').clearQueue().delay(750).animate({top:"440px"},500);
	} else {
	}
	$('.XXXtimeline').mouseenter(function() {$('.timeline').clearQueue().animate({top:"440px"},500);
	});
	$('.XXXtimeline').mouseleave(function() {$('.timeline').delay(750).animate({top:"645px"},500);
	});
	$('.timeline').click(function() {
		if ( $('.timeline').css('top') != "440px" ) {
			$('.timeline').css("background-position", "0 -230px");
			$('.timeline').clearQueue().animate({top:"440px"},500);
		} else {
			$('.timeline').css("background-position", "0 0");
			$('.timeline').clearQueue().animate({top:"645px"},500);
		}
	});
	$('li#nav-timeline a').toggle(function() {
		$('.timeline').css("background-position", "0 -230px");
		$('.timeline').clearQueue().animate({top:"440px"},500);
	}, function () {
		$('.timeline').css("background-position", "0 0");
		$('.timeline').clearQueue().animate({top:"645px"},500);		
	});
	$('div.timeline > ul > li').each(function(i) {
		// alert( $(this).attr('id') );
		$(this).css('left', MathUtils.map( $(this).attr('id'), 1835, 2020, 37, 1185 ) - 62 + 'px');
		$(this).css('top', MathUtils.lerp( 35, 185, ((i%4)/4)) + 'px');
	});
	$('div.artists-artist ul').makeacolumnlists({cols: 5, colWidth: 175, equalHeight: false, startN: 1});
	$(function(){VideoJS.setup();});
});

