function formFocus(Field){
   eval("document.forms['mainsearch']." + Field + ".focus()");
   }


function IsUserSignedIn(ret_in,mode1){
  if (ret_in <= 0) {
    if (mode1 == 1){
    alert("Before finding another user you must first sign in.");
    }else{
    alert("Before submitting a business you must first sign in.");
    }
    return false
    }
}



function ExtendJS(ret_in,rschvar) {

//var blass = 'non3';
//if (document.getElementById) { alert('1')
//blass = document.forms["mainsearch"].schnam.value}
//else if(document.all) {alert('2');}
//else if(document.layers) {alert('3');}
//alert(blass)
//return true

      var foundone = 0;
      var foundname = 0;
      var foundtype = 0;
      var foundaddr = 0;
      if (TextAreaRequired('schnam')) {
         var schnamvar = document.forms["mainsearch"].schnam.value;
         foundone = 1;
         foundname = 1;
         if (!isAlphNumPlus(schnamvar, '.,&!-\'+$? :;')) {
           alert("The specified Business or Service contains invalid characters.");
           formFocus('schnam');
           return false;
           }
      }

//      if (TextAreaRequired('schtyp')) {
//         var schtypvar = document.forms["mainsearch"].schtyp.value;
//         foundone = 1;
//         foundtype = 1;
//         if (!isAlphNumPlus(schtypvar, '.,& -')) {
//           alert("The specified business type contains invalid characters.");
//           formFocus('schtyp');
//           return false
//           }
//      }

      if (TextAreaRequired('schadd')) {
        var schaddvar = document.forms["mainsearch"].schadd.value;
        foundone = 1;
        foundaddr = 1;
        if (!isAlphNumPlus(schaddvar, '.,?; :-\'&$@!%')) {
           alert("The specified Address, City, or Zip contains invalid characters.");
           formFocus('schadd');
           return false
        }
      }

//      var schcityValue = document.forms['mainsearch'].Cityval.options[document.forms['mainsearch'].Cityval.selectedIndex].text;
   //was comment out when other part of this paragraph was OK      var schcityValue = document.getElementById('Cityval').options[document.getElementById('Cityval').selectedIndex].text;
//      if (((foundname == 1)||(foundtype == 1))&&
//         ((!(schcityValue == 'New York, NY'))
//         &&(!(schcityValue == 'San Francisco, CA'))
//         &&(!(schcityValue == 'San Jose, CA'))
//         &&(!(schcityValue == 'Los Angeles, CA'))
//         &&(!(schcityValue == 'Denver, CO'))
//         &&(!(schcityValue == 'Chicago, IL'))
//         &&(!(schcityValue == 'Boston, MA'))
//         &&(!(schcityValue == 'Honolulu, HI'))
//         &&(!(schcityValue == 'Las Vegas, NV'))
//         &&(!(schcityValue == 'Washington, DC'))
//         &&(!(schcityValue == 'Tucson, AZ'))
//         &&(!(schcityValue == 'Gotham, NY'))
//         &&(!(schcityValue == 'Seattle, WA'))))
//         {
//          alert("Aside from data entered by Metrobot users, business" +"\n" + "listings for " + schcityValue + " are not currently available." + "\n" + "You may, however still access the map for this area.");
//         };


//was 8_25_05      if (foundone == 0) {
//          alert("You have not entered a search string.");
//          formFocus('schadd');
//          return false
//      }else{return true}

      if (foundone == 0) {
          alert("You have not entered a search string.");
          formFocus('schadd');
          return false
      }else{
            if (foundaddr == 0) {
                alert("You must enter an Address, a City/Sate, or a Zip Code.");
                formFocus('schadd');
                return false
            }else{return true}
           }





}







function isAlphNumPlus(str, plus)
{
  var len= str.length
  if (len==0)
    return false
  //else
  var p=0
  var ok= true
  var ch= ""
  while (ok && p<len)
  {
    ch= str.charAt(p)
    if (  ('A'<=ch && ch<='Z')
        ||('a'<=ch && ch<='z')
        ||('0'<=ch && ch<='9')
//        ||(ch==" ")
        ||(plus.indexOf(ch,0)>-1)
       )
      p++
    else
      ok= false
  }
  return ok
}


function TextAreaRequired(Field) {
//    var length = document.getElementById(Field).value.length;
  var length = eval("document.forms['mainsearch']." + Field
    + ".value.length");
  if (length === 0) {
    return false
  } else {
    return true
  }
}


function TextAreaRequired_WAS(Form,Field) {
  var length = eval("document." + Form + "." + Field
    + ".value.length");
  if (length == 0) {
    return false;
  } else {
    return true;
  }
}
