<!--
/////////////////////////////////////////////////////////////////////////////////////////////
//  
// Procedure:	frmLogin_onSubmit(objForm)
// Purpose: 	Validates the Contact form.
// Programmer:  the king
// Date:        may/2004
// inputs:      objForm. A form object.
// outputs:     True or false value depending whether there is no validation errors.
//
/////////////////////////////////////////////////////////////////////////////////////////////
function frmLogin_onSubmit(objForm) {

	var strMissingInfo = "";
			

	if (objForm.txtEmail.value == '' || objForm.txtEmail.value == 'Your Email Address') {
		strMissingInfo += '\n     -  Your email address';
		objForm.txtEmail.className = 'texterror';
	} else if (!IsEmail(objForm.txtEmail)) {
		strMissingInfo += '\n     -  A valid email address';
		objForm.txtEmail.className = 'texterror';
	} else {
		objForm.txtEmail.className = 'text';
	}

	if (objForm.txtPassword.value == '' || objForm.txtPassword.value == 'Your Password') {
		strMissingInfo += '\n     -  Your password';
		objForm.txtPassword.className = 'texterror';
	} else {
		objForm.txtPassword.className = 'text';
	}

	
					  
	if (strMissingInfo != "") 
	{
		strMissingInfo = "To login to the maxfactor club, you must enter:\n" +
						   "_____________________________________\n" +
		strMissingInfo + "\n_____________________________________" +
		"\n\nPlease re-enter and submit again!";
		alert(strMissingInfo);
		return false;
	}
	else {
		objForm.cmdSubmit.disabled = true;
		return true;
	}
}	

/////////////////////////////////////////////////////////////////////////////////////////////
//  
// Procedure:	frmTrade_onSubmit(objForm)
// Purpose: 	Validates the Contact form.
// Programmer:  the king
// Date:        may/2004
// inputs:      objForm. A form object.
// outputs:     True or false value depending whether there is no validation errors.
//
/////////////////////////////////////////////////////////////////////////////////////////////
function frmTrade_onSubmit(objForm) {

	var strMissingInfo = "";
	strMissingInfo += checkTextForNullValue(objForm.txtName, '\n     -  Your name', 'text', 'texterror');
	strMissingInfo += checkTextForEmailAddr(objForm.txtEmail, '\n     -  Your email', 'text', 'texterror');
	strMissingInfo += checkTextForNullValue(objForm.txtMessage, '\n     -  Your message', 'textarea', 'textareaerror');

	if (strMissingInfo != "") 
	{
		strMissingInfo = "To send your message, you must enter:\n" +
						   "_____________________________________\n" +
		strMissingInfo + "\n_____________________________________" +
		"\n\nPlease re-enter and submit again!";
		alert(strMissingInfo);
		return false;
	}
	else {
		objForm.cmdSubmit.disabled = true;
		return true;
	}
}	

function checkTextForNullValue(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
		
	if (objFormElement.value == '') {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}




function checkSelectForNullValue(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
	
	if (objFormElement.options[objFormElement.selectedIndex].value == '') {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}
function checkTextForEmailAddr(objFormElement, strErrorMsg, strClass, strClassError) {
	var rc;
		
	if (!IsEmail(objFormElement.value)) {
		objFormElement.className = strClassError;
		rc = strErrorMsg;
	} else {
		objFormElement.className = strClass;
		rc = '';
	}
	return rc;
}
function IsEmail(Expression)
	{
		if (Expression == null)
			return (false);

		var supported = 0;
		if (window.RegExp)
		{
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported) 
			return (Expression.indexOf(".") > 2) && (Expression.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(Expression) && r2.test(Expression));
	}
	//-->
