/* Copyright AshAlom.com 1997-2009. Licenced to Ash Alom. ashalom [AT] gmail [Dot COM]
**************************************************************************************/



function ProcessLogin(){
	var ErrorMSG = "";
	var FORM = eval("document.LoginForms");
	ColourLoginForm();
	if (ValidateeMail(FORM.eMail.value)==false){
		ColourLoginForm(FORM.eMail);
		ErrorMSG += "<li>Your login eMail address is invalid.</li>";
	}
	if (FORM.Password.value.length < 2){
		ColourLoginForm(FORM.Password);
		ErrorMSG += "<li>Please enter a valid password.</li>";
	}
	if(ErrorMSG){
		ShowErrorBox(ErrorMSG);
	}else{
		ShowErrorBox("", 1);
		FORM.SubmitButton.value="Logging in...";
		FORM.SubmitButton.disabled=true;
		document.getElementById("Throbber").style.visibility="visible";
		document.getElementById("Throbber").title="Please wait";
		FORM.Corona.value="Process";
		FORM.action="PROCESS_login.php";
		FORM.target="iFrame";
		setTimeout("document.LoginForms.submit();",1000);
	}
}

function ColourLoginForm(Feild){
	var FORM = eval("document.LoginForms");
	if(Feild){
		Feild.className="InputField_Error";
	}else{
		FORM.eMail.className="InputField";
		FORM.Password.className="InputField";
	}
}

function ShowErrorBox(Messages, Clear){
	if (Clear){
		document.getElementById("ErrorBox").innerHTML="";
		document.getElementById("ErrorBox").style.visibility="hidden";
	}else{
		document.getElementById("ErrorBox").innerHTML="<b>Unable to login.</b> Please fix the following errors:<ul>"+Messages+"</ul>";
		document.getElementById("ErrorBox").style.visibility="visible";
	}
}
