aFieldsReq = new Array(
										{'field':'email','len':'','blank':'N','func':'isValidEmail','erro':'E-mail invalid'},
										{'field':'password','len':'5','blank':'N','func':'','erro':'Password incorrect. '}
									);
var aErros = new Array();

doSignIn = function()
{
	d = document.FrmDetail;
	
	// Verifica erros
	if (checkFormErros())
		return doFormErros();

	$("bt_submit").disabled = true;
	$("bt_submit").value = "Signing in...";

	
	var signin = new ServerRequest();
  signin.onComplete = function (responseText, responseXML)
  {
      if(responseText == "") { $("bt_submit").disabled = false;	$("bt_submit").value = "Sign in"; return showErro("Blank response"); }
      var aResponse = eval( '(' + responseText + ')' );
      if (aResponse[0] == 1) { $("bt_submit").disabled = false;	$("bt_submit").value = "Sign in"; return showErro(aResponse[1]); }
      
      if ($("url").value != "")
      	location.replace($("url").value);
      else
      	location.replace("report.php");
  }
  signin.submit("ajax.php?action=doSignIn&"+getFormElements(d));
}

forgetPW = function()
{
	d = document.FrmDetail;
	
	// Verifica erros
	if (!$("email").value.isValidEmail())
		return showErro("Invalid email!\n\nPlease fill it at the 'email' field above!");

	var newkey = new ServerRequest();
  newkey.onComplete = function (responseText, responseXML)
  {
      if(responseText == "") { return showErro("Blank response"); }
      var aResponse = eval( '(' + responseText + ')' );
      if (aResponse[0] == 1) { return showErro(aResponse[1]); }

     	alert("Your password has been sent to " + $("email").value);
  }
  newkey.submit("ajax.php?action=doForgetPW&"+getFormElements(d));
}

