function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateFormBuyers() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormBuyers.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    var reqNonCitizenField = false;
	if (val) {
	 nm=val.name;
	 if (nm=='visitor_name') nm='Your Name';
     //if (nm=='Wife_Husband') nm='Spouse\' Name';
     if (nm=='Home_Phone') nm='Home Phone';
     //if (nm=='FAX') nm='Fax';
     if (nm=='email') nm='Email';
     if (nm=='Office_Phone') nm='Office Phone-w/ext';
     //if (nm=='When_to_visit_Florida') nm='Approximate date you will visit Florida';
     //if (nm=='When_to_move_to_Florida') nm='Approximate date to move to Florida';
     //if (nm=='Where_to_relocate_in_Florida') nm='Area of Relocation';
     //if (nm=='How_long_have_you_been_looking') nm='Time Looking';
     //if (nm=='Timetable') nm='Time Table';
     //if (nm=='Hobbies_Interests') nm='Hobbies and Interests';
     //if (document.Buyers_Form.US_citizen[0].checked) {
	   //if (nm=='Country_of_Citizenship') reqNonCitizenField = true;
	   //if (nm=='Attorney_name') reqNonCitizenField = true;
       //if (nm=='Attorney_Address') reqNonCitizenField = true;
       //if (nm=='Attorney_City') reqNonCitizenField = true;
	   //if (nm=='Attorney_State') reqNonCitizenField = true;
       //if (nm=='Attorney_City') reqNonCitizenField = true;
       //if (nm=='Attorney_Zip') reqNonCitizenField = true;
	   //if (nm=='Attorney_Phone') reqNonCitizenField = true;
	   //if (nm=='Attorney_email') reqNonCitizenField = true;
	   //if (nm=='Accountant_name') reqNonCitizenField = true;
	   //if (nm=='Accountant_Address') reqNonCitizenField = true;
	   //if (nm=='Accountant_City') reqNonCitizenField = true;
	   //if (nm=='Accountant_State') reqNonCitizenField = true;
	   //if (nm=='Accountant_Zip') reqNonCitizenField = true;
	   //if (nm=='Accountant_Phone') reqNonCitizenField = true;
	   //if (nm=='Accountant_email') reqNonCitizenField = true;
	 }
	 //if (nm=='Country_of_Citizenship') nm='Country of Citizenship';
	 //if (nm=='Attorney_name') nm='Attorney Name';
     //if (nm=='Attorney_Address') nm='Attorney Address';
     //if (nm=='Attorney_City') nm='Attorney City';
	 //if (nm=='Attorney_State') nm='Attorney State';
     //if (nm=='Attorney_City') nm='Attorney City';
     //if (nm=='Attorney_Zip') nm='Attorney Zip';
	 //if (nm=='Attorney_Phone') nm='Attorney Phone';
	 //if (nm=='Attorney_email') nm='Attorney Email';
	 //if (nm=='Accountant_name') nm='Accountant name';
	 //if (nm=='Accountant_Address') nm='Accountant Address';
	 //if (nm=='Accountant_City') nm='Accountant City';
	 //if (nm=='Accountant_State') nm='Accountant State';
	 //if (nm=='Accountant_Zip') nm='Accountant Zip';
	 //if (nm=='Accountant_Phone') nm='Accountant Phone';
	 //if (nm=='Accountant_email') nm='Accountant Email';
     //if (nm=='Available_DownPayment') nm='Available Down payment';
     //if (nm=='Co_Investor_available_Down_Payment') nm='Co-Investor Available Down Payment';
     //if (nm=='Target_Annual_Income_Before_Debt_Service') nm='Target Annual Income Before Debt Service';
     //if (nm=='Need_to_sell_current_business') nm='Need to Sell Current Business';
     //if (nm=='Business_Background') nm='Business Background';
     //if (nm=='textarea') nm='Listing Number';
     //if (nm=='Businesses_that_would_be_considered') nm='Businesses Considered';
     //if (nm=='Businesses_that_would_NOT_be_considered') nm='Businesses NOT Considered';

	 if ((val=val.value)!="") {
	    if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R' && reqNonCitizenField == false) errors += '- '+nm+' is required.\n';
	 }
  }
  //if (document.Buyers_Form.US_citizen[0].checked == false && document.Buyers_Form.US_citizen[1].checked == false) errors += '- Citizenship is required.\n';
  //if (document.Buyers_Form.Need_to_sell_current_business[0].checked == false && document.Buyers_Form.Need_to_sell_current_business[1].checked == false) errors += '- Need to Sell Current Business is required.\n';
  //if (document.Buyers_Form.Need_to_sell_current_residence[0].checked == false && document.Buyers_Form.Need_to_sell_current_residence[1].checked == false) errors += '- Need to Sell Current Residence is required.\n';  
  //if (document.Buyers_Form.Working_with_other_Business_Brokers[0].checked == false && document.Buyers_Form.Working_with_other_Business_Brokers[1].checked == false) errors += '- Working with Other Business Brokers is required.\n';  
  if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_validateFormSellers() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormSellers.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
	if (val) {
	 nm=val.name;
	 if (nm=='visitor_name') nm='Your Name';
     //if (nm=='Spouses_Name') nm='Spouse\' Name';
     if (nm=='Home_Phone') nm='Home Phone';
     //if (nm=='FAX') nm='Fax';
     if (nm=='EMail') nm='Email';
     //if (nm=='Business_name') nm='Business Name';
     //if (nm=='Business_address') nm='Business Address';
     //if (nm=='Business_City') nm='Business City';
     //if (nm=='Business_State') nm='Business State';
     //if (nm=='Business_Zip') nm='Business Zip';
     //if (nm=='Business_Phone') nm='Business Phone';
     //if (nm=='Business_FAX') nm='Business Fax';
     //if (nm=='Long_established') nm='Time Since Established';
     //if (nm=='owned_business') nm='Time Since Owned';
	 if ((val=val.value)!="") {
	    if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';
	 }
  }
  if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}