function init(){
//  alert("Init has started")
  document.form1.bankrup_yrs.value="N/A";  // Added 5/31 12:20p mpl   //
  document.form1.credit[0].checked=false;
  document.form1.credit[1].checked=false;
  document.form1.credit[2].checked=false;
  document.form1.co_type[0].checked=false;
  document.form1.co_type[1].checked=false;
  document.form1.co_type[2].checked=false;
  document.form1.co_type[3].checked=false;
  document.form1.co_type[4].checked=false;
  document.form1.co_type[5].checked=false;

return true;

//Commented out at 6:30p 5/31 mpl since it started filling in after I entered 
//      the root dir '/' in front of the images in 'testapp5mpl0.html'

//  document.form1.co_name.value="co_name";
// return true;
//  document.form1.co_phone.value="co_phone";
//  document.form1.co_fax.value="co_fax";
//  document.form1.co_address.value="co_address";
//  document.form1.co_fed_id.value="co_fed_id";
//  document.form1.co_inc.value="co_inc";
//  document.form1.co_city.value="co_city";
//  document.form1.co_state.value="co_state";
//  document.form1.co_zip.value="co_zip";
//  document.form1.co_type[0].checked=true;
//  document.form1.co_years.value="co_years";
// return true;
  
//  document.form1.own1.value="own1";
//  document.form1.own1_title.value="own1_title";
//  document.form1.own1_address.value="own1_address";
//  document.form1.own1_email.value="own1_email@email.com";
//  document.form1.own1_city.value="own1_city";
//  document.form1.own1_state.value="own1_state";
//  document.form1.own1_zip.value="own1_zip";
//  document.form1.own1_ss.value="own1_ss";
//  document.form1.own1_percent.value="own1_percent";
  
//  document.form1.own1_home_phone.value="own1_home_phone";
//  document.form1.own1_biz_phone.value="own1_biz_phone";
//  document.form1.own1_alt_phone.value="own1_alt_phone";
  
//  document.form1.credit.value="credit"; //Added 5/31 12:00p mpl //
//  document.form1.bankrup_yrs.value="bank";  //  "   //
//  document.form1.credit[0].checked=true;   //  "   //
 
//  document.form1.eq1_make.value="eq1_make";
//  document.form1.eq1_model.value="eq1_model";
//  document.form1.eq1_year.value="eq1_year";
//  document.form1.eq1_notes.value="eq1_notes";
//  document.form1.eq1_vin.value="eq1_vin";
//  document.form1.eq1_price.value="eq1_price";
   
//  document.form1.mt_eq1_make.value="mt_eq1_make";
//  document.form1.mt_eq1_model.value="mt_eq1_model";
//  document.form1.mt_eq1_year.value="mt_eq1_year";
//  document.form1.mt_eq1_body.value="mt_eq1_body";
//  document.form1.mt_eq1_serial.value="mt_eq1_serial";
//  document.form1.mt_eq1_quantity.value="mt_eq1_quantity";
   
//  document.form1.eq_loc[0].checked=true;
//  document.form1.eq_address.value="eq_address";
//  document.form1.eq_city.value="eq_city";
//  document.form1.eq_state.value="eq_state";
//  document.form1.eq_zip.value="eq_zip";
   
//  document.form1.seller.value="seller";
//  document.form1.seller_contact.value="seller_contact";
//  document.form1.seller_address.value="seller_address";
//  document.form1.seller_phone.value="seller_phone";
//  document.form1.seller_city.value="seller_city";
//  document.form1.seller_state.value="seller_state";
//  document.form1.seller_zip.value="seller_zip";

//  document.form1.comments.value="comments";


}
function validate(){
//  alert("start validate")
//  document.form1.co_name.value="Test app";
//  return true;

	if(document.form1.co_name.value == ""){
		 alert("Please enter the Company Name.");
		 document.getElementById("co_name").focus();
		 return false;
	}

//This condition can be deleted when we switch to requiring more fields.  5/31 11:45a mpl //
	if(document.form1.co_phone.value == "" && document.form1.own1_email.value == ""){
		 alert("Please enter the Business Phone or an E-mail Address.");
		 document.getElementById("co_phone").focus();
		 return false;
	}
//This 'return true;' is temp so not all the fields are required. 5/31 11:45a mpl //	
return true;	
	
	if(document.form1.co_phone.value == ""){
		 alert("Please enter the Business Phone.");
		 document.getElementById("co_phone").focus();
		 return false;
	}	
	if(document.form1.co_fax.value == ""){
		 alert("Please enter the Business Fax.");
		 document.getElementById("co_fax").focus();
		 return false;
	}
	if(document.form1.co_address.value == ""){
		 alert("Please enter the Physical Address.");
		 document.getElementById("co_address").focus();
		 return false;
	}
	if(document.form1.co_fed_id.value == ""){
		 alert("Please enter the Federal I.D. Number.");
		 document.getElementById("co_fed_id").focus();
		 return false;
	}
	if(document.form1.co_inc.value == ""){
		 alert("Please enter the Date of Incorporation/Organization.");
		 document.getElementById("co_inc").focus();
		 return false;
	}
	if(document.form1.co_city.value == ""){
		 alert("Please enter the City.");
		 document.getElementById("co_city").focus();
		 return false;
	}
	if(document.form1.co_state.value == ""){
		 alert("Please enter the State.");
		 document.getElementById("co_state").focus();
		 return false;
	}
	if(document.form1.co_zip.value == ""){
		 alert("Please enter the Zip Code.");
		 document.getElementById("co_zip").focus();
		 return false;
	}
	if(!(document.form1.co_type[0].checked || document.form1.co_type[1].checked || document.form1.co_type[2].checked || document.form1.co_type[3].checked || document.form1.co_type[4].checked || document.form1.co_type[5].checked)){
		 alert("Please enter the Type of Business.");
		 document.getElementById("co_fed_id").focus();
		 return false;
	}
	if(document.form1.co_years.value == ""){
		 alert("Please enter the Years Under Same Ownership.");
		 document.getElementById("co_years").focus();
		 return false;
	}
	if(document.form1.own1.value == ""){
		 alert("Please enter the name of the Primary Contact.");
		 document.getElementById("own1").focus();
		 return false;
	}
	if(document.form1.own1_title.value == ""){
		 alert("Please enter the Primary Contact's Title.");
		 document.getElementById("own1_title").focus();
		 return false;
	}
	if(document.form1.own1_address.value == ""){
		 alert("Please enter the Home Address.");
		 document.getElementById("own1_address").focus();
		 return false;
	}	
	if(document.form1.own1_email.value == ""){
		 alert("Please enter the E-mail Address.");
		 document.getElementById("own1_email").focus();
		 return false;
	}else{
		if(!emailCheck(document.form1.own1_email.value)){
			document.getElementById("own1_email").focus();
		 	return false;
		}
	}
	if(document.form1.own1_city.value == ""){
		 alert("Please enter the Owner's City.");
		 document.getElementById("own1_city").focus();
		 return false;
	}
	if(document.form1.own1_state.value == ""){
		 alert("Please enter the Owner's State.");
		 document.getElementById("own1_state").focus();
		 return false;
	}
	if(document.form1.own1_zip.value == ""){
		 alert("Please enter the Owner's Zip Code.");
		 document.getElementById("own1_zip").focus();
		 return false;
	}
	if(document.form1.own1_ss.value == ""){
		 alert("Please enter the SSN.");
		 document.getElementById("own1_ss").focus();
		 return false;
	}
	if(document.form1.own1_percent.value == ""){
		 alert("Please enter the Ownership Percentage.");
		 document.getElementById("own1_percent").focus();
		 return false;
	}
	if(document.form1.own1_home_phone.value == ""){
		 alert("Please enter the Home Phone.");
		 document.getElementById("own1_home_phone").focus();
		 return false;
	}
	if(document.form1.own1_biz_phone.value == ""){
		 alert("Please enter the Business Phone.");
		 document.getElementById("own1_biz_phone").focus();
		 return false;
	}
// Credit Score and Bankruptcy conditions have not been tested for use.  5/31 12:05p mpl //
	if(!(document.form1.credit[0].checked || document.form1.credit[1].checked || document.form1.credit[2].checked)){
		 alert("Please enter Credit Score range.");
		 document.getElementById("own1_home_phone").focus();
		 return false;
	}
	if(document.bankrup_yrs.value == ""){
		 alert("Please enter the year the bankruptcy was dismissed.");
		 document.getElementById("bankrup_yrs").focus();
		 return false;
	}
	
	
	
	
//	if(document.form1.eq1_cab.value == ""){
//		 alert("Please enter the Cab & Chassis");
//		 document.getElementById("eq1_cab").focus();
//		 return false;
//	}
	if(document.form1.eq1_make.value == ""){
		 alert("Please enter the MAKE.");
		 document.getElementById("eq1_make").focus();
		 return false;
	}
	if(document.form1.eq1_model.value == ""){
		 alert("Please enter the MODEL.");
		 document.getElementById("eq1_model").focus();
		 return false;
	}
	if(document.form1.eq1_year.value == ""){
		 alert("Please enter the YEAR.");
		 document.getElementById("eq1_year").focus();
		 return false;
	}
	if(document.form1.eq1_price.value == ""){
		 alert("Please enter the Price.");
		 document.getElementById("eq1_price").focus();
		 return false;
	}
	if(!(document.form1.eq_loc[0].checked || document.form1.eq_loc[1].checked || document.form1.eq_loc[2].checked)){
		 alert("Please enter the Location where equipment will be based.");
		 return false;
	}
	if(document.form1.eq_loc[2].checked){
			if(document.form1.eq_address.value == ""){
				 alert("Please enter the Address of the Equipment.");
				 document.getElementById("eq_address").focus();
				 return false;
			}
			if(document.form1.eq_city.value == ""){
				 alert("Please enter the City of the Equipment.");
				 document.getElementById("eq_city").focus();
				 return false;
			}
			if(document.form1.eq_state.value == ""){
				 alert("Please enter the State of the Equipment.");
				 document.getElementById("eq_state").focus();
				 return false;
			}
			if(document.form1.eq_zip.value == ""){
				 alert("Please enter the Zip Code of the Equipment.");
				 document.getElementById("eq_zip").focus();
				 return false;
			}
	}
	if(document.form1.seller.value == ""){
		 alert("Please enter the Equipment Seller.");
		 document.getElementById("seller").focus();
		 return false;
	}
	if(document.form1.seller_contact.value == ""){
		 alert("Please enter the Equipment Seller Contact.");
		 document.getElementById("seller_contact").focus();
		 return false;
	}
	if(document.form1.seller_address.value == ""){
		 alert("Please enter the Seller's Address.");
		 document.getElementById("seller_address").focus();
		 return false;
	}
	if(document.form1.seller_phone.value == ""){
		 alert("Please enter the Seller's Phone.");
		 document.getElementById("seller_phone").focus();
		 return false;
	}
	if(document.form1.seller_city.value == ""){
		 alert("Please enter the Seller's City.");
		 document.getElementById("seller_city").focus();
		 return false;
	}
	if(document.form1.seller_state.value == ""){
		 alert("Please enter the Seller's State.");
		 document.getElementById("seller_state").focus();
		 return false;
	}
	if(document.form1.seller_zip.value == ""){
		 alert("Please enter the Seller's Zip Code.");
		 document.getElementById("seller_zip").focus();
		 return false;
	}
	// As of 5/31 11:40a mpl //
//		if(document.form1.comments.value == ""){
//		 alert("Please use the comments box to tell us about your company's needs.");
//		 document.form1.comments.focus();
//		 return false;
//	}

return true;
}
function emailCheck (emailStr) {
	if (emailStr.length==0)
	{
		return true;
	}
/* 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]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The email address 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("The email address doesn't seem to be valid.")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The email address doesn't seem to be valid.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */


/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
   // the address must end in a two letter or three letter word.
   alert("The email address doesn't seem to be valid.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="The email address doesn't seem to be valid."
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}


//  This function is not currently being used.  mpl 6/06 //
//-->
function validate1(){
  alert("start validate1")
//  document.form1.co_name.value="Test app";
//  return true;

	if(document.form1.co_name.value == "" && document.form1.own1.value == ""  && document.form1.seller.value == "" && document.form1.seller_contact.value == ""){
		 alert("Please enter a Name");
		 document.getElementById("co_name").focus();
		 return false;
	}
	if(document.form1.co_phone.value == "" && document.form1.own1_home_phone.value == "" && document.form1.own1_biz_phone.value == "" && document.form1.seller_phone.value == "" && document.form1.own1_email.value == "" && !emailCheck(document.form1.own1_email.value)){
		 alert("Please enter a Phone Number");
		 document.getElementById("co_phone").focus();
		 return false;
	}
	//if(document.form1.own1.value == ""){
	//	 alert("Please enter the name of the Primary Contact");
	//	 document.getElementById("own1").focus();
	//	 return false;
	//}
	//if(document.form1.own1_home_phone.value == ""){
	//	 alert("Please enter the Home Phone");
	//	 document.getElementById("own1_home_phone").focus();
	//	 return false;
	//}
	//if(document.form1.own1_biz_phone.value == ""){
	//	 alert("Please enter the Business Phone");
	//	 document.getElementById("own1_biz_phone").focus();
	//	 return false;
	//}
	//if(document.form1.own1_email.value == ""){
	//	 alert("Please enter the E-mail Address");
	//	 document.getElementById("own1_email").focus();
	//	 return false;
	//}else{
	//	if(!emailCheck(document.form1.own1_email.value)){
	//		document.getElementById("own1_email").focus();
	//	 	return false;
	//	}
	//}
	//if(document.form1.seller.value == ""){
	//	 alert("Please enter the Equipment Seller");
	//	 document.getElementById("seller").focus();
	//	 return false;
	//}
	//if(document.form1.seller_contact.value == ""){
	//	 alert("Please enter the Equipment Seller Contact");
	//	 document.getElementById("seller_contact").focus();
	//	 return false;
	//}
	//if(document.form1.seller_phone.value == ""){
	//	 alert("Please enter the Phone");
	//	 document.getElementById("seller_phone").focus();
	//	 return false;
	//}

return true;
}
