function login() {
	
	var username = $("#username").val();
	var pass = $("#pass").val();
	
	var errorMessage = "";
	var error = false;
	
	/** check if user name is filled in **/
	if (username.length == 0) {
		$('#username').css("borderColor", '#E30088');
		$("#username").focus();
		errorMessage += "** Please enter your username.<br>";
		error = true;
	}
	else {
		$('#username').css("borderColor", '#E0E0E0');
	}
	
	/** check for password **/
	if( pass.length == 0 ) {
		$('#pass').css("borderColor", '#E30088');
		$("#pass").focus();
		errorMessage += "** Please enter your password.<br>";
		error = true;
	}
	else {
		$('#pass').css("borderColor", '#E0E0E0');
	}
	
	if( error ) {
		$('#error').html(errorMessage).fadeIn();
	}
	else {
		
		$('#error').hide();
		var _data = "f=login&u="+username+"&p="+pass+"&";
		
		/** send email **/
		$.ajax({
	        type: "POST",
	        url: "/assets/php/classes/access.class.php",
			data:_data,
	        success: function(result) {
				
				if( parseInt(result) > -1 ) {
					window.location = '/clients';
				}
				else {
					
					switch( result ) {
						case "brute":
							window.location = '/fail';
							break;
						case "username":
							$("#error").html("The username you entered does not belong to any account. Make sure that it is typed correctly.");
							$('#username').css("borderColor", '#E30088');
							break;
						case "password":
							$("#error").html("The password you entered is incorrect. Passwords are case sensitive. Please try again.");
							break;
						default:
							$("#error").html(result);
							break;
					}
					
				}
					
				$("#pass").val("");
				$("#error").fadeIn();
				
			},
	        error: function(request,status,errorThrown) {
	        	$("#error").html("** It appears an error occured while running login scripts.<br />We apologize for the inconvenience. Please try again later.");
				$("#error").fadeIn();
	        }
	    });
		
	}
	
	return false;
	
}
