function SendEMail()
{
	document.frmLogon.Doit.value = "EmailPassword";
	document.frmLogon.submit();
}

function ForceLength(objField, minLength, maxLength, strWarning)
{
	var strField = new String(objField.value);
	if ((strField.length > maxLength) || (strField.length < minLength))
	{
		alert(strWarning);
		return false;
	} else
		return true;
}

function CheckSpaces(objField,strWarning)
{
	var strField = new String(objField.value);
	if (strField.indexOf(" ") != -1)
	{
		objField.focus();
		alert(strWarning);
		return false;
	} else
		return true;
}

function IsValidEmail(fieldvalue)
{
	var testresults
	var str=fieldvalue
	//var filter=/^.+@.+\..{2,3}$/	
	var filter=/^[A-Z|a-z|0-9|\-|\_|\.]*[A-Z|a-z|0-9]+@[A-Z|a-z|0-9|\-]*[A-Z|a-z|0-9|\-|\.]*[A-Z|a-z|0-9]+\.[A-Z|a-z|0-9]{2,4}$/	

	if (str.indexOf(" ") != -1)
	{
		alert("Please do not include space(s) in your E-mail address");
		return false;
	}
	if (filter.test(str))
	{		
		testresults=true	
	}
	else
	{		
		alert("Please enter your E-mail address in the format shown below. \nJohn.Smith@AOL.com")		
		testresults=false		
	}			
	return (testresults)
}

function IsValidMatch(TheForm){
 var testresults
 if (TheForm.txtverifpass.value == TheForm.Password.value)
   {
    testresults=true
   }
  else{
    alert("You did not verify your Password correctly.  Please try again.");
    TheForm.txtverifpass.select();
    TheForm.txtverifpass.focus();
    testresults=false
  }
  	return (testresults)
 }
 
function txtPwdRmd_onblur(TheForm){
 if (document.frmLogonCreate.Password.value == "") return true;
 
 if (document.frmLogonCreate.txtPwdRmd.value == document.frmLogonCreate.Password.value)
	{
	 alert("Do not place your Password in your Password hint.");
     document.frmLogonCreate.txtPwdRmd.select();          
     document.frmLogonCreate.txtPwdRmd.focus(); 
	 return false;
    }
    else{
     return true;
     }
  }

function ValidateFormLogon(TheForm)
{
	if (TheForm.Email.value.length == 0)
	{
		alert("Please enter your E-mail address in the format shown below. \nJohn.Smith@AOL.com")		
		TheForm.Email.focus();
		return false;
	}
	if (!IsValidEmail(TheForm.Email.value))
	{
		TheForm.Email.focus();
		return false;
	}
	if (TheForm.Password.value.length == 0)
	{
		alert("Please enter your Password, then continue.");
		TheForm.Password.focus();
		return false;
	}  
	return true;
}

function ValidateSerial(TheForm)
{
	if (!ForceLength(TheForm.SerialNumber,26,26,"Please enter a Serial Number of appropriate length."))
	{
		TheForm.SerialNumber.select();
		TheForm.SerialNumber.focus();
		return false;
	} 
	if (TheForm.SerialNumber.value.length == 0)
	{
		alert("Please re-enter your Serial Number, then continue.");
		TheForm.SerialNumber.focus();
		return false;
	}
	return true;
}

function ValidateFormCreate(TheForm)
{
	if (TheForm.Email.value.length == 0)
	{
		alert("Please enter your E-mail address in the format shown below. \nJohn.Smith@AOL.com")		
		TheForm.Email.focus();
		return false;
	}
	if (!IsValidEmail(TheForm.Email.value))
	{
		TheForm.Email.focus();
		return false;
	}
	if (TheForm.Email.value != TheForm.txtverifemail.value)
	{
		alert("You did not retype your E-mail address correctly.  Please try again.");
		TheForm.txtverifemail.select();
		TheForm.txtverifemail.focus();
		return false;
	}
	
	if (!ForceLength(TheForm.Password,6,12,"Please enter a Password of appropriate length."))
	{
		TheForm.Password.select();
		TheForm.Password.focus();
		return false;
	} 
	if (!CheckSpaces(TheForm.Password,"Please do not include space(s) in your Password."))
	{
		return false;
	}
	if (TheForm.txtverifpass.value.length == 0)
	{
		alert("Please re-enter your Password, then continue.");
		TheForm.txtverifpass.select();
		TheForm.txtverifpass.focus();
		return false;
	}
	if (!IsValidMatch(TheForm))
	{
		TheForm.txtverifpass.focus();
		return false;
	} 
	var blnEmpty = true;
	strTmp = new String(TheForm.firstname.value)
	for (var i = 0; i < strTmp.length; i++)
	{
		if (strTmp.charAt(i) != ' ')
		{
			blnEmpty = false;
			break;
		}
	}
	if (blnEmpty == true)
	{
		alert("Please enter your name, then continue.");
		TheForm.firstname.focus();
		return false;
	}
	if (TheForm.firstname.value.length == 0)
	{
		alert("Please enter your name, then continue.");
		TheForm.firstname.focus();
		return false;
	} 
	blnEmpty = true;
	strTmp = new String(TheForm.lastname.value)
	for (var i = 0; i < strTmp.length; i++)
	{
		if (strTmp.charAt(i) != ' ')
		{
			blnEmpty = false;
			break;
		}
	}
	if (blnEmpty == true)
	{
		alert("Please enter your name, then continue.");
		TheForm.lastname.focus();
		return false;
	}
	if (TheForm.lastname.value.length == 0)
	{
		alert("Please enter your name, then continue.");
		TheForm.lastname.focus();
		return false;
	} 
	return true;
}

function ValidateAccountInfo(TheForm)
{
	if (TheForm.firstname.value.length == 0)
	{
		alert("Please enter your first name.")		
		TheForm.firstname.focus();
		return false;
	}
	if (TheForm.lastname.value.length == 0)
	{
		alert("Please enter your last name.")		
		TheForm.lastname.focus();
		return false;
	}
	if (TheForm.Phone.value.length == 0)
	{
		alert("Please enter your phone number.")		
		TheForm.Phone.focus();
		return false;
	}
	if (TheForm.Email.value.length == 0)
	{
		alert("Please enter your E-mail address in the format shown below. \nJohn.Smith@AOL.com")		
		TheForm.Email.focus();
		return false;
	}
	if (!IsValidEmail(TheForm.Email.value))
	{
		TheForm.Email.focus();
		return false;
	}
	if (TheForm.Saddr1.value.length == 0)
	{
		alert("Please enter your address.")		
		TheForm.Saddr1.focus();
		return false;
	}
	if (TheForm.Scity.value.length == 0)
	{
		alert("Please enter your city.")		
		TheForm.Scity.focus();
		return false;
	}
	if (TheForm.Cardnumber.value.length == 0)
	{
		alert("Please enter your Credit Card Number.")		
		TheForm.Cardnumber.focus();
		return false;
	}
	if (TheForm.Expmonth.value.length == 0)
	{
		alert("Please select Expiration Date.");
		TheForm.Expmonth.focus();
		return false;
	}
	if (TheForm.Expyear.value.length == 0)
	{
		alert("Please select Expiration Date.")		
		TheForm.Expyear.focus();
		return false;
	}
	var blnEmpty = true;
	strTmp = new String(TheForm.Bfirstname.value)
	for (var i = 0; i < strTmp.length; i++)
	{
		if (strTmp.charAt(i) != ' ')
		{
			blnEmpty = false;
			break;
		}
	}
	if (blnEmpty == true)
	{
		alert("Please enter your card holder name, then continue.");
		TheForm.Bfirstname.focus();
		return false;
	}
	blnEmpty = true;
	strTmp = new String(TheForm.Blastname.value)
	for (var i = 0; i < strTmp.length; i++)
	{
		if (strTmp.charAt(i) != ' ')
		{
			blnEmpty = false;
			break;
		}
	}
	if (blnEmpty == true)
	{
		alert("Please enter your card holder name, then continue.");
		TheForm.Blastname.focus();
		return false;
	}
	if (TheForm.Cardcode.value.length == 0)
	{
		alert("Please enter three- or four-digit Card Code on the back of your credit card (on front for AMEX).")
		TheForm.Cardcode.focus();
		return false;
	}

	return true;
}

function ValidateContact(TheForm)
{
	var filter=/^[0-9]{4}$/
	
	if (TheForm.name.value.length == 0)
	{
		alert("Please enter your name.")		
		TheForm.name.focus();
		return false;
	}
	if (TheForm.email.value.length == 0)
	{
		alert("Please enter your E-mail address in the format shown below. \nJohn.Smith@AOL.com")		
		TheForm.email.focus();
		return false;
	}
	if (!IsValidEmail(TheForm.email.value))
	{
		TheForm.email.focus();
		return false;
	}
	if (TheForm.description.value.length == 0)
	{
		alert("Please enter your content.")		
		TheForm.description.focus();
		return false;
	}
	if (TheForm.verification.value.length < 4)
	{
		alert("Please enter verification code.")		
		TheForm.verification.focus();
		return false;
	}
	if (!filter.test(TheForm.verification.value))
	{
		alert("Verification Code must be numbers.")		
		TheForm.verification.focus();
		return false;
	}

	return true;
}

function ValidateComments(TheForm)
{
	var filter=/^[0-9]{4}$/
	
	if (TheForm.name.value.length == 0)
	{
		alert("Please enter your name.")		
		TheForm.name.focus();
		return false;
	}
	if (TheForm.email.value.length == 0)
	{
		alert("Please enter your E-mail address in the format shown below. \nJohn.Smith@AOL.com")		
		TheForm.email.focus();
		return false;
	}
	if (!IsValidEmail(TheForm.email.value))
	{
		TheForm.email.focus();
		return false;
	}
	if (TheForm.verification.value.length < 4)
	{
		alert("Please enter verification code.")		
		TheForm.verification.focus();
		return false;
	}
	if (!filter.test(TheForm.verification.value))
	{
		alert("Verification Code must be numbers.")		
		TheForm.verification.focus();
		return false;
	}

	return true;
}

function IsReservedTerm(fieldvalue)
{
	var testresults = false
	var str = fieldvalue
	str = str.toUpperCase( );
	
	if (str.indexOf("CUTEPDF") != -1 || str.indexOf("CUTE PDF") != -1)
	{
		alert("CutePDF is our trademark. Please do not include term CutePDF in your entering.");
		return true;
	}
	if (str.indexOf("ADOBE") != -1)
	{
		alert("ADOBE is trademark. Please do not include term ADOBE in your entering.");
		return true;
	}
	if (str.indexOf("ACROBAT") != -1)
	{
		alert("ACROBAT is trademark. Please do not include term ACROBAT in your entering.");
		return true;
	}
	return (testresults)
}

function ValidateCustomInfo(TheForm)
{
	if (!TheForm.Qty_CPrinter01.checked && !TheForm.Qty_CPrinter02.checked)
	{
		alert("Please select a package.")		
		TheForm.Qty_CPrinter01.focus();
		return false;
	}
	if (TheForm.PackageName.value.length == 0)
	{
		alert("Please specified the package name.")		
		TheForm.PackageName.focus();
		return false;
	}
	else
	{
		if (IsReservedTerm(TheForm.PackageName.value))
		{
			TheForm.PackageName.focus();
			return false;
		}
	}
	if (TheForm.Destination.value.length == 0)
	{
		alert("Please specified the destination folder.")		
		TheForm.Destination.focus();
		return false;
	}
	else
	{
		if (IsReservedTerm(TheForm.Destination.value))
		{
			TheForm.Destination.focus();
			return false;
		}
	}
	if (TheForm.ProgramFolder.value.length == 0)
	{
		alert("Please specified the program folder.")		
		TheForm.ProgramFolder.focus();
		return false;
	}
	else
	{
		if (IsReservedTerm(TheForm.ProgramFolder.value))
		{
			TheForm.ProgramFolder.focus();
			return false;
		}
	}
	if (TheForm.PrinterName.value.length == 0)
	{
		alert("Please specified the printer name.")		
		TheForm.PrinterName.focus();
		return false;
	}
	else
	{
		if (IsReservedTerm(TheForm.PrinterName.value))
		{
			TheForm.PrinterName.focus();
			return false;
		}
	}
	if (!TheForm.License.checked)
	{
		alert("Please accept our License Agreement.")		
		TheForm.License.focus();
		return false;
	}

	return true;
}
