function check_form(t) {
   var s = document.getElementById("st").value;
   if (s && t) {
      return true;
   }
   document.myform.first_name.value = trim (document.myform.first_name.value, " ");
   if (!document.myform.first_name.value) {
      alert ("Please enter Conveyancer's First Name.");
      document.myform.first_name.focus();
      return false;
   } 

   document.myform.last_name.value = trim (document.myform.last_name.value, " ");
   if (!document.myform.last_name.value) {
      alert ("Please enter Conveyancer's Last Name.");
      document.myform.last_name.focus();
      return false;
   } 

   document.myform.email.value = trim (document.myform.email.value, " ");
   if (!document.myform.email.value) {
      alert ("Please enter Email.");
      document.myform.email.focus();
      return false;
   }
   else {
	  var str = document.myform.email.value;
      var at = "@";
	  var dot = ".";
	  var lat = str.indexOf(at);
	  var lstr = str.length;
	  var ldot = str.indexOf(dot); 

	  if (str.indexOf(at)==-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

	  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr || str.indexOf(at)==lstr - 1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.indexOf(dot)==lstr - 1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(at,(lat+1))!=-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(dot,(lat+2))==-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }
		
      if (str.indexOf(" ")!=-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }
   }

   if (!t) {
   document.myform.firm_name.value = trim (document.myform.firm_name.value, " ");
   if (!document.myform.firm_name.value) {
      alert ("Please enter Law Firm's Name.");
      document.myform.firm_name.focus();
      return false;
   } 

   document.myform.firm_address.value = trim (document.myform.firm_address.value, " ");
   if (!document.myform.firm_address.value) {
      alert ("Please enter Law Firm's Address.");
      document.myform.firm_address.focus();
      return false;
   } 

   document.myform.home_phone.value = trim (document.myform.home_phone.value, " ");
   if (!document.myform.home_phone.value) {
      alert ("Please enter Phone Number.");
      document.myform.home_phone.focus();
      return false;
   } 

   document.myform.fax.value = trim (document.myform.fax.value, " ");
   if (!document.myform.fax.value) {
      alert ("Please enter Fax Number.");
      document.myform.fax.focus();
      return false;
   } 

   document.myform.vendor_first_name.value = trim (document.myform.vendor_first_name.value, " ");
   if (!document.myform.vendor_first_name.value) {
      alert ("Please enter Vendor's First Name.");
      document.myform.vendor_first_name.focus();
      return false;
   } 

   document.myform.vendor_last_name.value = trim (document.myform.vendor_last_name.value, " ");
   if (!document.myform.vendor_last_name.value) {
      alert ("Please enter Vendor's Last Name.");
      document.myform.vendor_last_name.focus();
      return false;
   } 

   document.myform.joint_vendor_first_name.value = trim (document.myform.joint_vendor_first_name.value, " ");
   if (!document.myform.joint_vendor_first_name.value) {
      alert ("Please enter Joint Vendor's First Name.");
      document.myform.joint_vendor_first_name.focus();
      return false;
   } 

   document.myform.joint_vendor_last_name.value = trim (document.myform.joint_vendor_last_name.value, " ");
   if (!document.myform.joint_vendor_last_name.value) {
      alert ("Please enter Joint Vendor's Last Name.");
      document.myform.joint_vendor_last_name.focus();
      return false;
   } 

   document.myform.strata_plan_num.value = trim (document.myform.strata_plan_num.value, " ");
   if (!document.myform.strata_plan_num.value) {
      alert ("Please enter Strata Plan No.");
      document.myform.strata_plan_num.focus();
      return false;
   } 

   document.myform.strata_lot_num.value = trim (document.myform.strata_lot_num.value, " ");
   if (!document.myform.strata_lot_num.value) {
      alert ("Please enter Strata Lot No.");
      document.myform.strata_lot_num.focus();
      return false;
   } 

   document.myform.district_lot_num.value = trim (document.myform.district_lot_num.value, " ");
   if (!document.myform.district_lot_num.value) {
      alert ("Please enter District Lot No.");
      document.myform.district_lot_num.focus();
      return false;
   } 

   document.myform.unit_num.value = trim (document.myform.unit_num.value, " ");
   if (!document.myform.unit_num.value) {
      alert ("Please enter Unit No.");
      document.myform.unit_num.focus();
      return false;
   } 

   document.myform.pid_num.value = trim (document.myform.pid_num.value, " ");
   if (!document.myform.pid_num.value) {
      alert ("Please enter P.I.D. No.");
      document.myform.pid_num.focus();
      return false;
   } 

   document.myform.purchaser_first_name.value = trim (document.myform.purchaser_first_name.value, " ");
   if (!document.myform.purchaser_first_name.value) {
      alert ("Please enter Purchaser's First Name.");
      document.myform.purchaser_first_name.focus();
      return false;
   } 

   document.myform.purchaser_last_name.value = trim (document.myform.purchaser_last_name.value, " ");
   if (!document.myform.purchaser_last_name.value) {
      alert ("Please enter Purchaser's Last Name.");
      document.myform.purchaser_last_name.focus();
      return false;
   } 

   document.myform.joint_owner_first_name.value = trim (document.myform.joint_owner_first_name.value, " ");
   if (!document.myform.joint_owner_first_name.value) {
      alert ("Please enter Joint Owner's First Name.");
      document.myform.joint_owner_first_name.focus();
      return false;
   } 

   document.myform.joint_owner_last_name.value = trim (document.myform.joint_owner_last_name.value, " ");
   if (!document.myform.joint_owner_last_name.value) {
      alert ("Please enter Joint Owner's Last Name.");
      document.myform.joint_owner_last_name.focus();
      return false;
   } 

   document.myform.purchaser_home_phone.value = trim (document.myform.purchaser_home_phone.value, " ");
   if (!document.myform.purchaser_home_phone.value) {
      alert ("Please enter Purchaser's Home Phone Number.");
      document.myform.purchaser_home_phone.focus();
      return false;
   } 

   document.myform.purchaser_work_phone.value = trim (document.myform.purchaser_work_phone.value, " ");
   if (!document.myform.purchaser_work_phone.value) {
      alert ("Please enter Purchaser's Work Phone Number.");
      document.myform.purchaser_work_phone.focus();
      return false;
   } 

   if (document.myform.owner_occupied_2.checked == true) {
      document.myform.address.value = trim (document.myform.address.value, " ");
      if (!document.myform.address.value) {
         alert ("Please enter Purchaser's full Mailing Address.");
         document.myform.address.focus();
         return false;
      } 
   }

   document.myform.bank_name.value = trim (document.myform.bank_name.value, " ");
   if (!document.myform.bank_name.value) {
      alert ("Please enter Bank / Mortgage Company.");
      document.myform.bank_name.focus();
      return false;
   } 

   document.myform.branch.value = trim (document.myform.branch.value, " ");
   if (!document.myform.branch.value) {
      alert ("Please enter Branch.");
      document.myform.branch.focus();
      return false;
   } 

   document.myform.branch_address.value = trim (document.myform.branch_address.value, " ");
   if (!document.myform.branch_address.value) {
      alert ("Please enter Branch Address.");
      document.myform.branch_address.focus();
      return false;
   } 

   document.myform.completion_date.value = trim (document.myform.completion_date.value, " ");
   if (!document.myform.completion_date.value) {
      alert ("Please enter Completion Date.");
      document.myform.completion_date.focus();
      return false;
   } 
   }
   return true;
}

function check_form2() {
   document.myform.first_name.value = trim (document.myform.first_name.value, " ");
   if (!document.myform.first_name.value) {
      alert ("Please enter First Name.");
      document.myform.first_name.focus();
      return false;
   } 

   document.myform.last_name.value = trim (document.myform.last_name.value, " ");
   if (!document.myform.last_name.value) {
      alert ("Please enter Last Name.");
      document.myform.last_name.focus();
      return false;
   } 

   document.myform.owner_first_name.value = trim (document.myform.owner_first_name.value, " ");
   if (!document.myform.owner_first_name.value) {
      alert ("Please enter Owner's First Name.");
      document.myform.owner_first_name.focus();
      return false;
   } 

   document.myform.owner_last_name.value = trim (document.myform.owner_last_name.value, " ");
   if (!document.myform.owner_last_name.value) {
      alert ("Please enter Owner's Last Name.");
      document.myform.owner_last_name.focus();
      return false;
   } 

   document.myform.joint_owner_first_name.value = trim (document.myform.joint_owner_first_name.value, " ");
   if (!document.myform.joint_owner_first_name.value) {
      alert ("Please enter Joint Owner's First Name.");
      document.myform.joint_owner_first_name.focus();
      return false;
   } 

   document.myform.joint_owner_last_name.value = trim (document.myform.joint_owner_last_name.value, " ");
   if (!document.myform.joint_owner_last_name.value) {
      alert ("Please enter Joint Owner's Last Name.");
      document.myform.joint_owner_last_name.focus();
      return false;
   } 

   document.myform.strata_plan_num.value = trim (document.myform.strata_plan_num.value, " ");
   if (!document.myform.strata_plan_num.value) {
      alert ("Please enter Strata Plan No.");
      document.myform.strata_plan_num.focus();
      return false;
   } 

   document.myform.strata_lot_num.value = trim (document.myform.strata_lot_num.value, " ");
   if (!document.myform.strata_lot_num.value) {
      alert ("Please enter Strata Lot No.");
      document.myform.strata_lot_num.focus();
      return false;
   } 

   document.myform.unit_num.value = trim (document.myform.unit_num.value, " ");
   if (!document.myform.unit_num.value) {
      alert ("Please enter Unit No.");
      document.myform.unit_num.focus();
      return false;
   } 

   document.myform.email.value = trim (document.myform.email.value, " ");
   if (!document.myform.email.value) {
      alert ("Please enter Email.");
      document.myform.email.focus();
      return false;
   }
   else {
	  var str = document.myform.email.value;
      var at = "@";
	  var dot = ".";
	  var lat = str.indexOf(at);
	  var lstr = str.length;
	  var ldot = str.indexOf(dot); 

	  if (str.indexOf(at)==-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

	  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr || str.indexOf(at)==lstr - 1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.indexOf(dot)==lstr - 1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(at,(lat+1))!=-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(dot,(lat+2))==-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }
		
      if (str.indexOf(" ")!=-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }
   }

   document.myform.home_phone.value = trim (document.myform.home_phone.value, " ");
   if (!document.myform.home_phone.value) {
      alert ("Please enter Phone Number.");
      document.myform.home_phone.focus();
      return false;
   } 

   var r = document.getElementById ("agreement.2");
   if (r.checked == true) {
      alert ("You must agree to the owner declaration in order to continue.");
	  r.focus();
	  return false;
   }
   return true;
}

function check_form3() {
   document.myform.first_name.value = trim (document.myform.first_name.value, " ");
   if (!document.myform.first_name.value) {
      alert ("Please enter First Name.");
      document.myform.first_name.focus();
      return false;
   } 

   document.myform.last_name.value = trim (document.myform.last_name.value, " ");
   if (!document.myform.last_name.value) {
      alert ("Please enter Last Name.");
      document.myform.last_name.focus();
      return false;
   } 

   document.myform.email.value = trim (document.myform.email.value, " ");
   if (!document.myform.email.value) {
      alert ("Please enter Email.");
      document.myform.email.focus();
      return false;
   }
   else {
	  var str = document.myform.email.value;
      var at = "@";
	  var dot = ".";
	  var lat = str.indexOf(at);
	  var lstr = str.length;
	  var ldot = str.indexOf(dot); 

	  if (str.indexOf(at)==-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

	  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr || str.indexOf(at)==lstr - 1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.indexOf(dot)==lstr - 1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(at,(lat+1))!=-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }

      if (str.indexOf(dot,(lat+2))==-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }
		
      if (str.indexOf(" ")!=-1){
	     alert("Please enter a Valid Email Address.");
		 document.myform.email.focus();
		 return false;
      }
   }

   document.myform.home_phone.value = trim (document.myform.home_phone.value, " ");
   if (!document.myform.home_phone.value) {
      alert ("Please enter Phone Number.");
      document.myform.home_phone.focus();
      return false;
   } 

   document.myform.agent_first_name.value = trim (document.myform.agent_first_name.value, " ");
   if (!document.myform.agent_first_name.value) {
      alert ("Please enter Listing Agent's First Name.");
      document.myform.agent_first_name.focus();
      return false;
   } 

   document.myform.agent_last_name.value = trim (document.myform.agent_last_name.value, " ");
   if (!document.myform.agent_last_name.value) {
      alert ("Please enter Listing Agent's Last Name.");
      document.myform.agent_last_name.focus();
      return false;
   } 

   document.myform.real_estate_company.value = trim (document.myform.real_estate_company.value, " ");
   if (!document.myform.real_estate_company.value) {
      alert ("Please enter Real Estate Company Name.");
      document.myform.real_estate_company.focus();
      return false;
   } 

   document.myform.company_address.value = trim (document.myform.company_address.value, " ");
   if (!document.myform.company_address.value) {
      alert ("Please enter Real Estate Company Address.");
      document.myform.company_address.focus();
      return false;
   } 

   document.myform.agent_phone.value = trim (document.myform.agent_phone.value, " ");
   if (!document.myform.agent_phone.value) {
      alert ("Please enter Listing Agent's Phone Number.");
      document.myform.agent_phone.focus();
      return false;
   } 

   document.myform.strata_plan_num.value = trim (document.myform.strata_plan_num.value, " ");
   if (!document.myform.strata_plan_num.value) {
      alert ("Please enter Strata Plan No.");
      document.myform.strata_plan_num.focus();
      return false;
   } 

   document.myform.strata_lot_num.value = trim (document.myform.strata_lot_num.value, " ");
   if (!document.myform.strata_lot_num.value) {
      alert ("Please enter Strata Lot No.");
      document.myform.strata_lot_num.focus();
      return false;
   } 

   document.myform.unit_num.value = trim (document.myform.unit_num.value, " ");
   if (!document.myform.unit_num.value) {
      alert ("Please enter Unit No.");
      document.myform.unit_num.focus();
      return false;
   } 

   document.myform.owner_first_name.value = trim (document.myform.owner_first_name.value, " ");
   if (!document.myform.owner_first_name.value) {
      alert ("Please enter Owner's First Name.");
      document.myform.owner_first_name.focus();
      return false;
   } 

   document.myform.owner_last_name.value = trim (document.myform.owner_last_name.value, " ");
   if (!document.myform.owner_last_name.value) {
      alert ("Please enter Owner's Last Name.");
      document.myform.owner_last_name.focus();
      return false;
   } 

   document.myform.joint_owner_first_name.value = trim (document.myform.joint_owner_first_name.value, " ");
   if (!document.myform.joint_owner_first_name.value) {
      alert ("Please enter Joint Owner's First Name.");
      document.myform.joint_owner_first_name.focus();
      return false;
   } 

   document.myform.joint_owner_last_name.value = trim (document.myform.joint_owner_last_name.value, " ");
   if (!document.myform.joint_owner_last_name.value) {
      alert ("Please enter Joint Owner's Last Name.");
      document.myform.joint_owner_last_name.focus();
      return false;
   } 

   return true;
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function resizeText(size) {
   document.body.style.fontSize = size + "px";
}

