$(function(){
	
	
	$('#flash .left img, #flash .right img').click(function(){
		$("#flash .left").animate({
			left: '-506px'
		}, 1500);
		
		$("#flash .right").animate({
			left: '1012px'
		}, 1500, function(){
			$('#flash').remove();
			$('#content-hider').delay(500).fadeTo('slow', 1);
		});
		
	});
	
	
	
	/****************************************************
	************* SCROLLPANE  *************
	****************************************************/
	$('.scroll-pane').jScrollPane();
	
	
	/****************************************************
	************* CAROUSELS *************
	****************************************************/
	
    $('#carousel').jCarouselLite({
        circular: true,
        auto: 3000,
        scroll: 1,
        mouseWheel: true,
        speed: 1000,
        visible: 4
    });

    $('#carouselvideo').jCarouselLite({
        circular: true,
        auto: 2500,
        scroll: 1,
        mouseWheel: true,
        speed: 1000,
        visible: 4
    });


	/****************************************************
	************* ROTATING PHOTOS AND VIDEOS *************
	****************************************************/
	$("a[rel^='prettyPhoto']").prettyPhoto();



	/****************************************************
	************* jPLAYER AUDIO PLAYER *************
	****************************************************/
		var playItem = 0;

		var myPlayList = [
		
			{name:"Lazy Man",mp3:"/tracks/uploads/06_Lazy_Man.mp3"},
		
			{name:"Pervert Song (Acousticide 2010)",mp3:"/tracks/uploads/Pervert_Song.mp3"},
		
			{name:"Sweet Lament (Acousticide 2010)",mp3:"/tracks/uploads/Sweet_Lament.mp3"},
		
			{name:"Space Invasion (Acousticide 2010)",mp3:"/tracks/uploads/Space_Inasion.mp3"},
		
			{name:"The Bastards (Sonic Rape 2010)",mp3:"/tracks/uploads/Bastards_Final.mp3"},
		
			{name:"Lucy Lucifer (Sonic Rape 2010)",mp3:"/tracks/uploads/Lucy_Final.mp3"},
		
			{name:"50% Immigrant - Handmade(2005)",mp3:"/tracks/uploads/1_50_Immigrant_Clepto-Hand_Made_2005.mp3"},
		
			{name:"Victory - Handmade(2005)",mp3:"/tracks/uploads/04_Victory.mp3"},
		
			{name:"Not Dead Yet (Sonic Rape 2010)",mp3:"/tracks/uploads/Longsong_Final.mp3"},
		
			{name:"Through the Night! (Kebab B-sides 2012)",mp3:"/tracks/uploads/through_the_night.mp3"}
			];

		// Local copy of jQuery selectors, for performance.
		var jpPlayTime = $("#jplayer_play_time");
		var jpTotalTime = $("#jplayer_total_time");

		$("#jquery_jplayer").jPlayer({
			ready: function() {
				displayPlayList();
				playListInit(false); // Parameter is a boolean for autoplay.
				
			},
			nativeSupport: true, oggSupport: false, swfPath: "/js/" 
		})
		.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
			jpPlayTime.text($.jPlayer.convertTime(playedTime));
			jpTotalTime.text($.jPlayer.convertTime(totalTime));
		})
		.jPlayer("onSoundComplete", function() {playListNext();});

		$("#jplayer_previous").click( function() {
			playListPrev();
			$(this).blur();
			return false;
		});

		$("#jplayer_next").click( function() {
			playListNext();
			$(this).blur();
			return false;
		});

		function displayPlayList() {
			$("#jplayer_playlist ul").empty();
			for (i=0; i < myPlayList.length; i++) {
				var listItem = (i == myPlayList.length-1) ? "<li class='jplayer_playlist_item_last'>" : "<li>";
				listItem += "<a href='#' id='jplayer_playlist_item_"+i+"' tabindex='1'>"+ myPlayList[i].name +"</a></li>";
				$("#jplayer_playlist ul").append(listItem);
				$("#jplayer_playlist_item_"+i).data( "index", i ).click( function() {
					var index = $(this).data("index");
					if (playItem != index) {
						playListChange( index );
					} else {$("#jquery_jplayer").jPlayer("play");}
					$(this).blur();
					return false;
				});
			}
		}

		function playListInit(autoplay) {
			if(autoplay) {
				playListChange( playItem );
			} else {
				playListConfig( playItem );
			}
		}

		function playListConfig( index ) {
			$("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current").parent().removeClass("jplayer_playlist_current");
			$("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current").parent().addClass("jplayer_playlist_current");
			playItem = index;
			$("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3);
		}

		function playListChange( index ) {
			playListConfig( index );
			$("#jquery_jplayer").jPlayer("play");
		}

		function playListNext() {
			var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0;
			playListChange( index );
		}

		function playListPrev() {
			var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1;
			playListChange( index );
		}
	});
