//Define the function for logging in
function login(){
	
	var email = $('#emailLogin').val();
	var psw   = $('#pswLogin').val();
	
	//Adding loading data	
	$('#login_response').html('Logging In...');
	//Use ajax to send the data to the php file
	$.post("login.php", { email:email, psw:psw },
	function(reset_result){
		if(reset_result == 1){
			$('#login_response').empty();
			$('#login_response').html('Login failed! Password\'s are case sensitive. Forgot your password? You can use the forgotten password form below to reset your password.');
			$('#forgotLogin').val('');
		}
		else if(reset_result == 2){
			window.location = "/admin/pending.php";
		}
		else if(reset_result == 3){
			window.location = "/admin/";
		}
	});
} 
//Define the function for sending a forgotten password
function forgot(){
	
	var emailaddress = $('#forgotLogin').val();
	
	//Adding loading data	
	$('#login_response').html('Resetting your password...');
	//Use ajax to send the data to the php file
	$.post("forgot-password.php", { forgotLogin:emailaddress },
	function(reset_result){
		if(reset_result == 1){
			$('#login_response').empty();
			$('#login_response').html('Your temporary password has been emailled to your Peppermint email address!');
			$('#forgotLogin').val('');
		}
		else if(reset_result == 2){
			$('#login_response').empty();
			$('#login_response').html('Your password could not be sent at this time! Please try again.');
		}
		else if(reset_result == 3){
			$('#login_response').empty();
			$('#login_response').html('A new password could not be created at this time! Please try again.!');
		}
		else if(reset_result == 4){
			$('#login_response').empty();
			$('#login_response').html('Please enter a valid Peppermint email address!');
		}
	});
} 
