document.domain = "wrangler.com.co";

function stopWranglerPlayer() {
	$("#jplayer").jPlayer("pause");
}

$(function () {
	var playlist = [
		{
			name: "THE HALL EFFECT - AIM AT ME",
			mp3: "http://www.wrangler.com.co/audio/aim-at-me.mp3",
			oga: "http://www.wrangler.com.co/audio/aim-at-me.ogg"
		},
		{
			name: "THE HALL EFFECT - APRIL",
			mp3: "http://www.wrangler.com.co/audio/april.mp3",
			oga: "http://www.wrangler.com.co/audio/april.ogg"
		},
		{
			name: "THE HALL EFFECT - BECOME",
			mp3: "http://www.wrangler.com.co/audio/become.mp3",
			oga: "http://www.wrangler.com.co/audio/become.ogg"
		},
		{
			name: "THE HALL EFFECT - HITMAN STORY",
			mp3: "http://www.wrangler.com.co/audio/hitman-story.mp3",
			oga: "http://www.wrangler.com.co/audio/hitman-story.ogg"
		},
		{
			name: "THE HALL EFFECT - SHINE",
			mp3: "http://www.wrangler.com.co/audio/shine.mp3",
			oga: "http://www.wrangler.com.co/audio/shine.ogg"
		},
		{
			name: "THE HALL EFFECT - UNPURE",
			mp3: "http://www.wrangler.com.co/audio/unpure.mp3",
			oga: "http://www.wrangler.com.co/audio/unpure.ogg"
		}
	];
	
	var current =  Math.round(Math.random() * 5.0);

	function playlistChange(index, play) {
		$("#jplayer").jPlayer("setMedia", playlist[current]);
		if (play)
			$("#jplayer").jPlayer("play");
		$("#jp_playlist").html(playlist[current].name);
	}

	$(".jp-next").click(function(){
		current = (current + 1 < playlist.length) ? current + 1 : 0;
		playlistChange(current, true);
	});
	$(".jp-previous").click(function(){
		current = (current - 1 >= 0) ? current - 1 : this.playlist.length - 1;
		playlistChange(current, true);
	});

	$("#jplayer").jPlayer({
		ready: function(){
			playlistChange(current, false);
		},
		ended: function(event) {
			current = (current + 1 < playlist.length) ? current + 1 : 0;
			playlistChange(current, true);
		},
		swfPath: "js/",
		supplied: "oga, mp3"
	});
	
	$(".cerrar").click(function(){
		$(".player-container").animate({'padding-left': '3000px'}, 1000);
		$(".abrir").fadeIn();
	});

	$(".abrir").click(function(){
		$(".player-container").animate({'padding-left': '0'}, 1000);
		$(".abrir").fadeOut();
	});

	$(".colorbox").colorbox({open:true, iframe:true, innerWidth:640, innerHeight:390, 
		onClosed:function() {
			$("#jplayer").jPlayer("play");
		}
	});
});
