function go_lfm()
		{
			$('#inputarea').addClass('rounded_red');
			$('#inputarea').removeClass('rounded_green');
			$('#text_input').addClass('band_input_red');
			$('#text_input').removeClass('band_input_green');
			$('#addmore').hide();
			$('.band_input_green_additional').hide();
		}
		
		function go_sfy()
		{
			$('#inputarea').removeClass('rounded_red');
			$('#inputarea').addClass('rounded_green');
			$('#text_input').removeClass('band_input_red');
			$('#text_input').addClass('band_input_green');
			$('#addmore').show();
			$('.band_input_green_additional').show();
		}

		$(window).scroll(function(e){ 
		  $el = $('#listen'); 
		  if ($(this).scrollTop() > 195 && $el.css('position') != 'fixed'){ 
			$('#listen').css({'position': 'fixed', 'top': '0px'}); 
		  }
		  if ($(this).scrollTop() < 195 && $el.css('position') != 'relative'){ 
			$('#listen').css({'position': 'relative', 'top': '0px'}); 
		  } 
		});


	function selectText()
	{
		if (document.selection)
		{
			var div = document.body.createTextRange();

			div.moveToElementText(document.getElementById("divid"));
			div.select();
		}
		else
		{
			var div = document.createRange();

			div.setStartBefore(document.getElementById("divid"));
			div.setEndAfter(document.getElementById("divid")) ;

			window.getSelection().addRange(div);
		}
	}
//	var clip = new ZeroClipboard.Client();
	$(document).ready(function(){
		$("tr:odd").addClass("odd");
		if (($("#lfm_rad").attr('checked') == true) || location.hash == '#lastfm')
		{
			$("#lfm_rad").attr('checked', 'checked');
			updatelabel('lfm_id');
		}
	});
	
	
	function updateTextbox()
	{
		var cliptext = '';
		$('tr').each(function(item) {
		
				var tracktext = this.getAttribute('tracklink');
				if (tracktext != null)
				{
					cliptext = cliptext + ' ' + tracktext;
				}
		});
		document.getElementById('tracks_textbox').innerHTML = cliptext;
		document.getElementById('divid').innerHTML = '                                                                  '+cliptext;
	}
	
	function removeElement(divid) {
	  var elm = document.getElementById(divid);
	  var thisartist = document.getElementById(divid + '_artist').firstChild.innerHTML;
	  var parentelm = elm.parentNode;
	  parentelm.removeChild(elm);
//	  clip.reposition();
	  $("tr").removeClass("odd");
	  $("tr:odd").addClass("odd");
	  updateTextbox();
	  var plidval = document.getElementById('plid').value;
	  $.post("less.php", { remove_name: thisartist, plid:plidval},
			  function(data){
//				alert(data); 
			  }, "html");
	}
	
	function extendPlaylist(divid)
	{
		$('html').css('cursor', 'wait');
		var artists_list = '';
		$('.rowartist').each(function(item) {
			var artisttext = this.firstChild.innerHTML;
			if (artisttext != null)
			{
				artists_list = artists_list + '|' + artisttext;
			}
	});
	//alert(artists_list);
		var plidval = document.getElementById('plid').value;
		$.post("/playlist/more.php", { extend_name: document.getElementById(divid + '_artist').firstChild.innerHTML, current_artists:artists_list, plid:plidval},
			  function(data){
//				alert(data); 
				drawTracks(data);
			  }, "html");
	}
	
	function extendOriginalPlaylist()
	{
		var seedartist = $('#seedartist_span').html();
		$('html').css('cursor', 'wait');
		var artists_list = '';
		$('.rowartist').each(function(item) {
			var artisttext = this.firstChild.innerHTML;
			if (artisttext != null)
			{
				artists_list = artists_list + '|' + artisttext;
			}
	});
	//alert(artists_list);
		//extend_name = document.getElementById(divid + '_artist').firstChild.innerHTML);
		var plidval = document.getElementById('plid').value;
		$.post("/playlist/more.php", { extend_name: seedartist, current_artists:artists_list, ext:'1', plid:plidval},
			  function(data){
//				alert(data); 
				drawTracks(data);
			  }, "html");
	}
	
	function drawTracks(data)
	{
		if (data != '')
		{
			$("#trackstable").append(data);
//			clip.reposition();
			$("tr").removeClass("odd");
			$("tr:odd").addClass("odd");
		}
		else
		{
			alert('Couldn\'t find any additional suggestions for that artist');
		}
		$('html').css('cursor', 'default');
		updateTextbox();
	}
	
	function updatelabel(val)
	{
		if (val=='lfm_id')
		{
			go_lfm();
			$("#lfm_opt").show();
		}
		else
		{
			go_sfy();
			$("#inputlabel").html('Enter a band or artist: ');
			$("#lfm_opt").hide();
		}
	}
	function pop_pl(str)
	{
		go_sfy();
		$('#art_rad').attr('checked', true);
		$('#text_input').val(str);
	}