function redirect() {
  window.location = "control_panel.php";
}
function Login() {
  var url = 'ajax/login.php';
  new Ajax.Request(
  	url, {
  		method: 'post',
  		parameters: Form.serialize('Login'),
  		onSuccess: function(transport) {
    		var notice = $('notice');
    		if (transport.responseText == 0) {
      			notice.update('<font color="#ff0000">Form Error(s)</font>');
      			Effect.Appear('notice');
    		}
    		if (transport.responseText == 1) {
      			Effect.Fade('Login');
      			notice.update('Login successful, redirecting to the control panel...<img src="images/loading.gif" alt="Loading" />');
      			Effect.Appear('notice');
      			setTimeout('redirect()', 5000);
    		}
    		if (transport.responseText == 2) { 
     			notice.update('<font color="#ff0000">Human Test Failed</font>');
      			Effect.Appear('notice');
      			alert('Human Test Failed');
				Recaptcha.reload();
    		}
    		if (transport.responseText == 3) { 
      			notice.update('<font color="#ff0000">Login Incorrect</font>');
      			Effect.Appear('notice');
      			alert('Login Incorrect');
    		}
    	}
  	}
  );
}
