function submitQuoteInfo() {

	if (document.quoteform.q_Salute.value.length > 25){
	
		alert( "Salutation is too long." );
		
	}else if (document.quoteform.q_Salute.value.length == 0){
	
		alert( "Please enter your Salutation." );
	
	}else if (document.quoteform.q_firstname.value.length > 25){
	
		alert( "First name is too long." );
		
	}else if (document.quoteform.q_firstname.value.length == 0){
	
		alert( "Please enter your first name." );
	
	}else if (document.quoteform.q_lastname.value.length > 25){
	
		alert( "Last name is too long." );
		
	}else if (document.quoteform.q_lastname.value.length == 0){
	
		alert( "Please enter your last name." );

	}else if (document.quoteform.q_address1.value.length > 75){
	
		alert( "Address 1 is too long." );
		
	}else if (document.quoteform.q_address1.value.length == 0){
	
		alert( "Please enter Address 1." );

	}else if (document.quoteform.q_address2.value.length > 75){
	
		alert( "Address 2 is too long." );

	}else if (document.quoteform.q_city.value.length > 50){
	
		alert( "City/Town is too long." );
		
	}else if (document.quoteform.q_city.value.length == 0){
	
		alert( "Please enter your City/Town." );

	}else if (document.quoteform.q_state.value.length > 50){
	
		alert( "State is too long." );
		
	}else if (document.quoteform.q_state.value.length == 0){
	
		alert( "Please select your state." );

	}else if (document.quoteform.q_zip.value.length > 5){
	
		alert( "Zip is too long." );
		
	}else if (document.quoteform.q_zip.value.length == 0){
	
		alert( "Please enter your zip code." );

	}else if (validateZip(document.quoteform.q_zip.value) == false){
	
		alert( "Please enter a valid 5-digit zip code." );

	}else if (document.quoteform.q_phone.value.length > 12){
	
		alert( "Please enter a 10-digit phone number. Format: xxx-xxx-xxxx." );
		
	}else if (document.quoteform.q_phone.value.length == 0){
	
		alert( "Please enter a 10-digit phone number. Format: xxx-xxx-xxxx." );

	}else if (validatePhone(document.quoteform.q_phone.value) == false){
	
		alert( "Please enter a valid 10-digit phone number. Format: xxx-xxx-xxxx." );

	}else if (document.quoteform.q_email.value.length > 50){
	
		alert( "Email is too long." );

	}else if (document.quoteform.q_email.value.length > 0 && emailCheck(document.quoteform.q_email.value) == false){

			alert( "Please enter a valid email address." );

	}
//	else if (!(document.quoteform.q_phonetype[0].checked || document.quoteform.q_phonetype[1].checked || document.quoteform.q_phonetype[2].checked)){
//				alert( "Please choose the phone number location: Home, Work or Mobile" );
//	
//	}else if (document.quoteform.q_callhour.value.length > 2){
//
//		alert( "Best time to call hour is too long." );
//
//	}
	else if (document.quoteform.q_bestTime.value == ""){

		alert( "Please, best time to call cannot be left blank.");

	}
//	else if (document.quoteform.q_callminute.value == -1){
//
//		alert( "Please make a minute selection for the best time to call." );
//
//	}else if (document.quoteform.q_callhour.value != -1 && !(document.quoteform.q_callpreference[0].checked || document.quoteform.q_callpreference[1].checked)){
//		
//		alert( "Please choose the preferred time of day: AM or PM" );
//	
//	}
	else if (document.quoteform.q_mortgage.value.length > 0 && validateNumber(document.quoteform.q_mortgage.value) == false){
		
			alert( "Please enter a valid mortgage amount." );

	}else if (document.quoteform.q_mortgage.value.length > 8 ){
		
			alert( "Mortgage Amount is too long." );

	}else if (validateDOB(document.quoteform.q_borrowermonth.value, document.quoteform.q_borrowerday.value, document.quoteform.q_borroweryear.value)==false){
		
			alert( "Please enter a valid borrower date of birth." );
		
	}else if (document.quoteform.q_borrowerfeet.value.length > 0 && validateNumber(document.quoteform.q_borrowerfeet.value) == false){
	
			alert( "Please enter a valid number of feet for borrower." );

	}else if (document.quoteform.q_borrowerfeet.value.length > 1 ){
		
			alert( "Borrower Feet is too long." );
	
	}else if (document.quoteform.q_borrowerinches.value.length > 0 && validateNumber(document.quoteform.q_borrowerinches.value) == false){
		
			alert( "Please enter a valid number of inches for borrower." );

	}else if (document.quoteform.q_borrowerinches.value.length > 2 ){
		
			alert( "Borrower Inches is too long." );

	}else if (validateHeight(document.quoteform.q_borrowerfeet.value ,document.quoteform.q_borrowerinches.value)== false){
		alert( "Borrower Height must include feet and inches." );

	}else if (document.quoteform.q_borrowerweight.value.length > 0 && validateNumber(document.quoteform.q_borrowerweight.value) == false){
		
			alert( "Please enter a valid weight for borrower." );

	}else if (document.quoteform.q_borrowerweight.value.length > 4 ){
		
			alert( "Borrower Weight is too long." );
		
	}else if (document.quoteform.q_borroweroccupation.value.length > 50){
			alert( "Borrower Occupation is too long." );

	}else if (validateDOB(document.quoteform.q_spousemonth.value, document.quoteform.q_spouseday.value, document.quoteform.q_spouseyear.value) == false){
		
			alert( "Please enter a valid spouse/co-borrower date of birth." );
		
	}else if (document.quoteform.q_spousefeet.value.length > 0 && validateNumber(document.quoteform.q_spousefeet.value) == false){
		
			alert( "Please enter a valid number of feet for spouse/co-borrower." );

	}else if (document.quoteform.q_spousefeet.value.length > 1 ){
		
			alert( "Spouse feet is too long." );
		
	}else if (document.quoteform.q_spouseinches.value.length > 0 && validateNumber(document.quoteform.q_spouseinches.value) == false){
		
			alert( "Please enter a valid number of inches for spouse/co-borrower." );

	}else if (document.quoteform.q_spouseinches.value.length > 2 ){
		
			alert( "Spouse inches is too long." );

	}else if (validateHeight(document.quoteform.q_spousefeet.value ,document.quoteform.q_spouseinches.value)== false){
		alert( "Spouse Height must include feet and inches." );
		
	}else if (document.quoteform.q_spouseweight.value.length > 0 && validateNumber(document.quoteform.q_spouseweight.value) == false){
		
			alert( "Please enter a valid weight for spouse/co-borrower." );

	}else if (document.quoteform.q_spouseweight.value.length > 4 ){
		
			alert( "Spouse weight is too long." );
		
	}else if (document.quoteform.q_spouseoccupation.value.length > 50){
			alert( "Spouse Occupation is too long." );

	}else{

		//alert( "Quote Form is good." );
        document.quoteform.submit();
	}





}



function submitLogin() {

	if (document.loginform.login_username.value.length > 20){
	
		alert( "Username is too long." );
		
	}else if (document.loginform.login_username.value.length == 0){
	
		alert( "Please enter your username." );
		
	}else if (document.loginform.login_password.value.length > 20){
	
		alert( "Password is too long." );
		
	}else if (document.loginform.login_password.value.length == 0){
	
		alert( "Please enter your password." );
		
	}//else if (document.loginform.login_password.value.length < 6){
	
		//alert( "Password is too short. Passwords must be at least 6 characters." );
	
	//}
	else{
        
        //alert( "Login Form is good." );
        document.loginform.submit();
	
	}

}

function submitMCLogin() {

	if (document.mcloginform.login_username.value.length > 20){
	
		alert( "Username is too long." );
		
	}else if (document.mcloginform.login_username.value.length == 0){
	
		alert( "Please enter your username." );
		
	}else if (document.mcloginform.login_password.value.length > 20){
	
		alert( "Password is too long." );
		
	}else if (document.mcloginform.login_password.value.length == 0){
	
		alert( "Please enter your password." );
		
	}else if (document.mcloginform.login_password.value.length < 6){
	
		alert( "Password is too short. Passwords must be at least 6 characters." );
	
	}else{
        
        //alert( "Login Form is good." );
        document.mcloginform.submit();
	
	}

}

function submitQuoteVerify(){

}

function submitAgentInquiry() {

	if (document.agentinquiryform.u_fullname.value.length > 50){
	
		alert( "Your full name is too long." );
		
	}else if (document.agentinquiryform.u_fullname.value.length == 0){
	
		alert( "Please enter your full name." );
		
	}else if (document.agentinquiryform.u_address1.value.length > 75){
	
		alert( "Address 1 is too long." );
		
	}else if (document.agentinquiryform.u_address1.value.length == 0){
	
		alert( "Please enter Address 1." );

	//}else if (document.agentinquiryform.u_address2.value.length > 75){
	
		//alert( "Address 2 is too long." );

	}else if (document.agentinquiryform.u_city.value.length > 50){
	
		alert( "City/Town is too long." );
		
	}else if (document.agentinquiryform.u_city.value.length == 0){
	
		alert( "Please enter your City/Town." );

	}else if (document.agentinquiryform.u_state.value.length > 2){
	
		alert( "State is too long." );
		
	}else if (document.agentinquiryform.u_state.value.length == 0){
	
		alert( "Please enter your state." );

	}else if (document.agentinquiryform.u_zip.value.length > 5){
	
		alert( "Zip is too long." );
		
	}else if (document.agentinquiryform.u_zip.value.length == 0){
	
		alert( "Please enter your zip code." );

	}else if (validateZip(document.agentinquiryform.u_zip.value) == false){
	
		alert( "Please enter a valid 5-digit zip code." );

	//}else if (document.agentinquiryform.u_phone.value.length > 14){
	
		//alert( "Please enter a 10-digit phone number. Format: 1-xxx-xxx-xxxx." );
	
	//}//else if (document.agentinquiryform.u_phone.value.length == 0){
	
		//alert( "Please enter the your daytime phone number. Format: 1-xxx-xxx-xxxx." );
		
	//}//else if (validatePhone(document.agentinquiryform.u_phone.value) == false){
	
		//alert( "Please enter a valid 10-digit daytime phone number. Format: xxx-xxx-xxxx." );

	//}else if (document.agentinquiryform.u_cell.value.length > 14){
	
	//	alert( "Please enter a 10-digit cell phone number. Format: 1-xxx-xxx-xxxx." );
	
	
	//}else if (validatePhone(document.agentinquiryform.u_cell.value) == false){
	
	//	alert( "Please enter a valid 10-digit cell phone number. Format: 1-xxx-xxx-xxxx." );
	
	
	
	
	}else if (document.agentinquiryform.u_email.value.length > 50){
	
		alert( "Email is too long." );
		
	}else if (document.agentinquiryform.u_email.value == ""){
	alert("Please enter a value for the \"email\" field.");
	document.agentinquiryform.u_email.focus();
	return (false);
	}
	var checkEmail = "@.";
	var checkStr = document.agentinquiryform.u_email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkEmail.length;  j++)
		{
		if (ch == checkEmail.charAt(j) && ch == "@")
		EmailAt = true;
		if (ch == checkEmail.charAt(j) && ch == ".")
		EmailPeriod = true;
		  if (EmailAt && EmailPeriod)
		break;
      	  if (j == checkEmail.length)
		break;
		}
		if (EmailAt && EmailPeriod)
		{
			EmailValid = true
			break;
		}
	}
	if (!EmailValid)
	{
	alert("The \"Email\" field must contain an \"@\" and a \".\".");
	document.agentinquiryform.u_email.focus();
	return (false);
	}
	
	
	
	
	
		
	//}else if (document.agentinquiryform.u_email.value.length > 50){
//	
//		alert( "Email is too long." );
//		
//	}else if (document.agentinquiryform.u_email.value.length == 0){
//	
//		alert( "Please enter your Email Address." );
//
//	}else if (emailCheck(document.agentinquiryform.u_email.value) == false){
//		
//		alert( "Invalid Email Address." );
//		
//	
//	}
else{
        removeFormat() 
        //alert( "Login Form is good." );
        document.agentinquiryform.submit();
	
	}

}

function validatePhone(num) {
	var orignumber = new String(num);
	var regexp = /[^0123456789]/gi;
	var fixednumber = orignumber.replace(regexp,"");
	if (fixednumber.length != 10){
	   //alert(fixednumber.length +"   "+ fixednumber.toString());
	   return(false);
	}else{
	   return(true);
	}
}

function validateZip(num) {
	var orignumber = new String(num);
	var regexp = /[^0123456789]/gi;
	var fixednumber = orignumber.replace(regexp,"");
	if (fixednumber.length != 5){
	   //alert(fixednumber.length +"   "+ fixednumber.toString());
	   return(false);
	}else{
	   return(true);
	}
}

function validateNumber(num){
	if(/^\d+$/.test(num)){
		return true;
	}else{
		return false;
	}
}

function validateDOB(month, day, year){
	if(month == -1 && day == -1 && year == -1){
		return true;
	}else if (month > 0 && day > 0 && year > 0){
		return true;
	}else{
		return false;
	}
}

function validateHeight(feet, inches){
	if(feet.length > 0 && inches.length > 0){
		return true;
	}else if (feet.length == 0 && inches.length == 0){
		return true;
	}else{
		return false;
	}
}

function emailCheck (emailStr) {

/*
This script and many more are available free online at -->
The JavaScript Source!! http://javascript.internet.com -->

V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
Original:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
Changes:
 1.1.4: Fixed a bug where upper ASCII characters (i.e. accented letters
international characters) were allowed.

1.1.3: Added the restriction to only accept addresses ending in two
letters (interpreted to be a country code) or one of the known
TLDs (com, net, org, edu, int, mil, gov, arpa), including the
new ones (biz, aero, name, coop, info, pro, museum).  One can
easily update the list (if ICANN adds even more TLDs in the
future) by updating the knownDomsPat variable near the
top of the function.  Also, I added a variable at the top
of the function that determines whether or not TLDs should be
checked at all.  This is good if you are using this function
internally (i.e. intranet site) where hostnames don't have to 
conform to W3C standards and thus internal organization e-mail
addresses don't have to either.
Changed some of the logic so that the function will work properly
with Netscape 6.

1.1.2: Fixed a bug where trailing . in e-mail address was passing
(the bug is actually in the weak regexp engine of the browser; I
simplified the regexps to make it work).

1.1.1: Removed restriction that countries must be preceded by a domain,
so abc@host.uk is now legal.  However, there's still the 
restriction that an address must end in a two or three letter
word.

1.1: Rewrote most of the function to conform more closely to RFC 822.

1.0: Original  */

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

//alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
//alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
//alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

//alert("The username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
//alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
//alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
//alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
//alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

function removeFormat() 
{
	colname=document.agentinquiryform.u_phone
	if (colname.value.substr(0, 2) == "1-")
	{
		repColname=(colname.value.substr(2, colname.value.length));
	}
	else
	{
		repColname=colname.value
	}
	repColname=repColname.replace(/-/g, "")
	colname.value=repColname
	
	colname=document.agentinquiryform.u_cell
	if (colname.value.substr(0, 2) == "1-")
	{
		repColname=(colname.value.substr(2, colname.value.length));
	}
	else
	{
		repColname=colname.value
	}
	repColname=repColname.replace(/-/g, "")
	colname.value=repColname
}