jQuery(function(){

	/* Audio Player */
	jQuery("#playlist").hide();

	jQuery("#now_playing").click(function() {

		jQuery("#playlist").slideToggle('slow');
		jQuery("#content_other div").toggle('slow');
		
	});

	jQuery(".track").click(function(e) {
	
		e.preventDefault();
		
		jQuery("#playlist").slideUp("slow");
		
		var song = jQuery(this).attr('href');
		var song_title = jQuery(this).text();
		
		jQuery("#now_playing").attr('href', song);
		jQuery("#now_playing").text(song_title);		
		
		if (threeSixtyPlayer.lastSound) {
			threeSixtyPlayer.lastSound.stop(); // may not be needed (but to be safe..) - indicate "stop" to UI..
			threeSixtyPlayer.lastSound.destruct(); // kill this sound, kill HTTP request etc.
			jQuery('.sm2-360ui').remove();
			jQuery('.sm2-360ui sm2_playing').remove();
			threeSixtyPlayer.init();
			threeSixtyPlayer.handleClick({target: document.getElementById(song)});
			threeSixtyPlayer.play();
		}
	
	});

	jQuery("#content_other").hover(function() {
		jQuery("#content_other div").fadeIn('fast');
		jQuery("#playlist").slideUp('slow');
	});
	
});
