/*
function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

if (window.location.hash) 
{
	var songID = window.location.hash.substr(1);
	var userID = getQuerystring('userid');
	var url = "index.php?option=com_community&view=music&task=music&songid="+songID+"&userid="+userID;
	window.location.href = url;
}
*/

jQuery(document).ready(function() {
	jQuery('.thumbnail a:not(.active)').hover(function() {
		jQuery(this).addClass('active');
	}, function() {
		jQuery(this).removeClass('active');
	});
	
	//Slider
	jQuery("#slider").easySlider({
			auto: false, 
			continuous: false,
			numeric: false,
			prevText: '<img border="0" alt="arrow-left" src="/templates/songclash/images/arrow-left.png"/>',
			nextText: '<img border="0" alt="arrow-left" src="/templates/songclash/images/arrow-right.png"/>'
	});
	
	
	//Jewel Case click
	jQuery("a.album-thumbnail").click(function() {
		var albumID = jQuery(this).attr('href');
		var albumTitle = jQuery(this).find('span.a-name').html();
		var albumDesc = jQuery(this).find('span.a-desc').html();
		
		albumID = albumID.substr(1);
		
				
		jQuery("a.album-thumbnail").removeClass('selected');
		jQuery(this).addClass('selected');
		
		jQuery("#playlist tbody").hide();
		jQuery("#playlist #tbody-"+albumID).show();
		
		return false;
	});

});

function ajaxSong(songID) 
{
	jQuery("#song-overlay").show();
	jQuery(".song-block").load('/index.php?option=com_community&view=music&task=song&songid='+songID+' .song-container', function(data) {
		if(jQuery("body").hasClass('logged-in-yes')) {
			runSongFunctions();
		}
		
		runTweetConversion();
		jQuery("#song-overlay").hide();
	});
	jQuery(".wall-block").load('/index.php?option=com_community&view=music&task=song&songid='+songID+' .wall', function() {});
	
	jQuery("tr").removeClass('selected');
	jQuery("tr#song-"+songID).addClass('selected');
}
