/*=====================================*\
|* Login
\*=====================================*/

$(function() {
	$("#loginButton").click(function() {
		$("#loginButton").hide();
		$("#login_loading").show();
		
		$.post("includes/process/login.php", $("#loginForm").serialize(), function(data) {
			if( data != "Success" ) {
				title = "Log In";
				
				switch(data) {
					case "Error1":
						text = "You must enter your Account Name and Password to log in.";
						break;
					
					case "Error2":
						text = "Your Account Name and Password must be between 2 and 16 characters.";
						break;
					
					case "Error3":
						text = "You are already logged in!";
						break;
					
					case "Error4":
						text = "The Account Name and/or Password you entered is incorrect.";
						break;
				}
				
				popupBox(title, text);
				
				$("#loginButton").show();
				$("#login_loading").hide();
			} else {
				window.location.href = window.location.href
			}
		});
		
		return false;
	});
});