function login(thisForm) {
	var returnVal = true;
	try {
		//set JavascriptEnabled to 1 to indicate to the processing page that it is called through AJAX
		thisForm.AJAX.value = '1';

		var postContent = '';
		var element;
		for (var i = 0; i < thisForm.elements.length; i++)
		{
			element = thisForm.elements[i];
			if(element.name) {
				postContent = postContent + ((postContent != '') ? '&': '?');
				postContent = postContent + element.name + '=' + escape(getElementValue(element));
			}
		}
		// alert(thisForm.action);
// alert(postContent);
		var loginResult = loadXMLDoc(thisForm.action, false, postContent);
// alert(loginResult);
		var successfulLogin = eval(loginResult.toLowerCase());
		
		if(successfulLogin)
			//alert(unescape(thisForm.redirectToAfterLogin.value));	
			//return
			location.replace(unescape(thisForm.redirectToAfterLogin.value));
		else
			{
				//alert('Invalid username or password. Please try again.');
				showWarningMessage('login_OldUser_Warning', 'No record of this email address is in our system or invalid password. Please re-enter the correct email address and password below.');
			
			}
		//returnVal = false;
	} catch(e) {
		alert("Error:\n" + e.description);
	}
	//if there was any errors:
	
	//set JavascriptEnabled to 0 to indicate to the processing page that it is being called normally
	thisForm.AJAX.value = '0';
return false;
	//submit the form normally
	return returnVal;
}

function createnewuser(thisForm){
	sEmail = thisForm.NewCustomerEmail.value;
	if(!isEmailAddress(sEmail)){
		showWarningMessage('login_NewUser_Warning', 'You have entered an invalid address. Please re-enter your correct email address.');
		return false;
	}
	else
		{	
			var postContent = 'ajaxaction=CheckUniqueEmail&emailaddress=' + sEmail;
			var ajaxURL = document.getElementById('ajaxURL').value;
			var checkEmailResult = loadXMLDoc(ajaxURL, false, postContent);
			if(checkEmailResult == 'False'){
				var sMsg = 'The Email address you entered is already registered. Please login on the right to continue. If you can\'t remember you password, please use the "Forgot Your Password?" feature.';
				showWarningMessage('login_NewUser_Warning', sMsg);
				return false;
			}
			
		}
	return true;
}

function forgotpassword(thisForm){
	sEmail = thisForm.email.value;
	if(!isEmailAddress(sEmail)){
		showWarningMessage('login_ForgotPassword_Warning', 'You have entered an invalid address. Please re-enter your correct email address.');
		return false;
	}

	return true;
}

function isEmailAddress(sValue) {
	var pattern=/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$/;
	return (sValue.match(pattern));
}