$(document).ready(function(){
	$('#check_mp').click(function() {
		var email = $('#email2').attr("value");
		if(email != "")
		{
			$('#mp_user_found').hide("slow");
			$('#mp_user_error').hide("slow");
			$('#mail_error').hide("slow");
			$.ajax({
				method: "get",url: "ajax/mp_user_exists.php",data: "email="+email,
				beforeSend: function(){$("#loading").css("visibility", "visible");
									   $('#check_mp').attr("disabled", "disabled");
									   $('#check_mp').attr("value", "Checking...");},
				complete: function(){ $("#loading").css("visibility", "hidden");
									  $('#check_mp').removeAttr("disabled");
									  $('#check_mp').attr("value", "Check");},
				success: function(result){ //result contains the data received from the Ajax call
					if(result=='1')
					{
						$('#mp_check_div').hide("slow");
						$('#mp_user_found').show("slow");
					}
					else if(result=='0')
					{
						$('#mp_user_error').show("slow");
					}
					else
					{
						$('#mail_error').show("slow");
					}
				}
				}); //close $.ajax(
		}
		else
		{
			alert("Please enter your e-mail address.");
		}
	});
	
});
