function signup_type(value)
{
	if (value == 'station') {
		$('#signup_info').text('Radio Station Information');
		$('.artist_info, .label_info, .authorized_info').hide();
		$('.station_info').show();
	} else if (value == 'label') {
		$('#signup_info').text('Record Label Information');
		$('.artist_info, .station_info, .authorized_info').hide();
		$('.label_info').show();
	} else if (value == 'artist') {
		$('#signup_info').text('Artist Information');
		$('.label_info, .station_info, .authorized_info').hide();
		$('.artist_info').show();
	} else if (value == 'authorized') {
		$('#signup_info').text('Authorized Downloader Information');
		$('.label_info, .station_info, .artist_info').hide();
		$('.authorized_info').show();
	}
	$('#record_label').attr('disabled',false);
	$('#no_label').attr('checked',false);
}

function checkSignup()
{
	if (!$('#agree').attr('checked')) {
		alert('You have to agree to the terms and conditions.');
		return false;
	} else if ($('#signup_table input[name=password]').val() == '' ||
			$('#signup_table input[name=password]').val() != $('#signup_table input[name=confirm_password]').val()) {
		alert('Make sure you confirm your password.');
		return false;
	}
	return true;
}

function showFileUpload()
{
	$('.hidden').toggle();
}

function confirm_action(url)
{
	if (confirm("Do you really want to do this?")) { 
		window.location = url;
	}
}

function songCallback(track)
{
	$('.active').removeClass('active');
	$('#track_'+track).addClass('active');
	$.get('media.php',{
		action: 'listen',
		track: track
	});
}

function changeTrack(track)
{
	var player = document.getElementById('amrakplayer');
	player.gotoTrack(track);
}

function initDND(pageid) {
	$("#songtable").tableDnD({
	    onDragClass: "myDragClass",
	    onDrop: function(table, row) {
            var rows = jQuery('#songtable').find('tr');
            var debugStr = row.id.substring(6);
				oneback = 0;
				idx1=row.id.substring(6);
				idx2=idx1;
            for (var i=0; i<rows.length; i++) {
            	if(rows[i].id.substring(0,5)!="track_") {
            		oneback=1;
            	}
                if(rows[i].id==row.id) {
						idx2=(i-oneback);                
                }
            }
            if(idx1!=idx2) {
            	window.location='media.php?action=reorder&oldpos='+idx1+'&newpos='+idx2+'&pageid='+pageid;
            }
	    },
	    dragHandle: "dragHandle"
	});
}

$(document).ready(function()
{

	$(".edit_title").editable("page.php?action=update", {
		loadtype: 'POST',
		submit  : 'Save',
		cancel  : 'Cancel',
		type: 'text',
		callback: function() {window.location.reload()}
	});
		
   $("a.greybox").click(function(){
      var t = this.title || $(this).text() || this.href;
      GB_show(t,this.href,300,600);
   	return false;
   });

	jQuery(document).ready(function() {
		jQuery('a[rel*=facebox]').facebox() 
	});
});

