
function submit_login()
{
	var login_attempt 	= readCookie	('login_attempt');
	login_attempt 		= parseInt		(login_attempt);
	
	if(login_attempt == 4)
	{
		// captcha validation
		return;
	}
	
	email 	= document.getElementById("login_text").value;
	passwd 	= document.getElementById("password_text").value;
	
	if(email == "")
	{
		alert("An AllenPort account email address must be entered.");
	}
	else if(email.indexOf('@') == -1)
	{
		alert("The address is not a valid email address. It does not contain a \"@\".");
	}
	else if(passwd == "")
	{
		alert("A password must be entered.");
	}
	else if(!checkMailId(email) || !checkpasswd(passwd))
	{
		alert("Invalid email address or password.");
	}
	else {
		
		// check if we need remember the user
		if ($('#remember_me_check').attr("checked")) {
			// save cookie (expires after 7 days)
			$.cookie		('user_name_remind', email, { expires: 7 });
		} else {
			// remove cookie
			$.cookie		('user_name_remind', null);
		}
		
		
		// authenticate
		Authenticate	(email, passwd);
	}  
}


///////////////////////////////////////////////////////////
// function called when user clicks log off button
///////////////////////////////////////////////////////////
function logOff()
{
	window.location	= 'core/logout.php';
}

function logIn()
{
	window.location = 'index.php?login=true';
}
