function add_user_details() {
		
	// validate and process form
	// first hide any error messages
	$('.error').hide();
	
	$("#display").html("");
	
	var category_id = $("input#category_id").val();
	
  	var spotify = $("input#spotify").val();
	if (spotify == "") {
  		$("input#spotify").val("REQUIRED FIELD");
  		$("input#spotify").focus();
  		return false;
	}
	
	var email = $("input#email").val();
		if (email == "") {
  		$("input#email").val("REQUIRED FIELD");
  		$("input#email").focus();
  		return false;
	}
	
	
	
	/* the minumum age you want to allow in */
	var min_age = 18;

	/* change "age_form" to whatever your form has for a name="..." */	
	var year = $("#year option:selected").text();
	var month = $("#month option:selected").text();
	var day = $("#day option:selected").text();
	
	if(year == 'Year' || month == 'Month' || day == 'Day') {
		
		alert("Please select your Date of Birth");
		return false;
	
	} else {

		var theirDate = new Date((eval(year) + min_age), eval(month) -1, day);
		var today = new Date;
	
		if ( (today.getTime() - theirDate.getTime()) < 0) {
			alert("You must be over 18 to enter this competition");
			return false;
		} 	
		
		var dataString = 'spotify='+ spotify + '&email=' + email + '&category_id=' + category_id;
		//alert (dataString);
		
		$.ajax({
	  		type: "POST",
	 		url: "scripts/add_song.php",
	 		data: dataString,
	 		dataType: 'html',
	  		success: function(html) {
	    		$("#display").append(html);
	    		$("#add_song_inner").fadeOut(1000);
	    		$("#display").fadeIn(1500);
	    		entered_comp = true;
	  		}
	 
	 	});
	 
		return false;
		
	}
    	
}


function reload_form() {
	
	$("#display").fadeOut(1000);
	$("input#spotify").val("");
	$("#add_song_inner").fadeIn(1500);
	$("input#spotify").focus();
	
}

function reload_form_error() {
	
	$("#display").fadeOut(1000);
	$("input#email").val("");
	$("#add_song_inner").fadeIn(1500);
	$("input#email").focus();
	
}

function reload_form_error_url() {

	$("#display").fadeOut(1000);
	$("input#spotify").val("");
	$("#add_song_inner").fadeIn(1500);
	$("input#spotify").focus();

}

function switch_category(number) {
	
	document.getElementById('track_lisitings').style.display = 'none';
	document.getElementById('track_lisitings').innerHTML = '';
	document.getElementById('track_listings_loading').style.display = 'block';
	
	$.ajax({
		url: 'scripts/switch_category.php?id='+number,
		type: 'POST',
		dataType: 'html',
		error: function(){
			alert('Error loading html document');
		},

		success: function(html){
			$("#track_lisitings").append(html);
			sentTimer = setTimeout("hideLoading()", 2000);
		}
	});

}

function hideLoading() {
	document.getElementById('track_listings_loading').style.display = 'none';
	$("#track_lisitings").fadeIn(1000);
	
}