<!--

function isEmpty(s)

{ return ((s == null) || (s.length == 0)); }

function isSpace(c)

{ return ((c == "\n") || (c == " ") || (c == "\b") || (c == "\t")); }

function isWhiteSpace(s)

{

  for(i=0; i<s.length; i++)

    if(!isSpace(s.charAt(i))) return false;

  return true;

}

function warning(f,s)

{

  f.focus();

  f.select();

  alert(s);

  return false;

}

function isEmail(email)

{

  if(isEmpty(email)) return false;

  if(isWhiteSpace(email)) return false;

  invalidChars = " /:,;";

  for(i=0; i<invalidChars.length; i++)

  {

    badChar = invalidChars.charAt(i);

    if(email.indexOf(badChar,0) > -1) return false; 

  }

  atPos = email.indexOf("@",1);

  if(atPos == -1) return false; 

  if(email.indexOf("@",atPos+1) > -1) return false; 

  periodPos = email.indexOf(".",atPos);

  if(periodPos == -1) return false; 

  if(periodPos+3 > email.length) return false; 

  return true;

}

function isValidContactForm(fm)

{
  TheName = fm.Name.value;
  TheAddress = fm.Address.value;
  TheCity = fm.City.value;
  TheState = fm.State.value;
  TheCountry = fm.Country.value;
  zipcode = fm.zipcode.value;
  ThePhone = fm.Phone.value;
  TheEmail = fm.Email.value;
  Comments = fm.Comments.value;

  if(isEmpty(TheName))
    return (warning(fm.Name,"Please enter your  name."));
  if(isEmpty(TheAddress))
    return (warning(fm.Address,"Please enter your address."));
  if(isEmpty(TheCity))
    return (warning(fm.City,"Please enter your city."));	
  if(!isEmail(TheEmail))
    return (warning(fm.Email,"Email address is empty or invalid"));

  if(isEmpty(Comments))
    return (warning(fm.Comments,"Please give us your questions or comments."));
  return true;
}

function isValidRequestForm(fm)

{
  TheName = fm.name.value;
  TheAddress = fm.address.value;
  TheEmail = fm.email.value;
  TheQuestions = fm.questions.value;

  if(isEmpty(TheName))
    return (warning(fm.name,"Please enter your  name."));
  if(isEmpty(TheAddress))
    return (warning(fm.address,"Please enter your address."));	
  if(!isEmail(TheEmail))
    return (warning(fm.email,"Email address is empty or invalid"));

  if(isEmpty(TheQuestions))
    return (warning(fm.questions,"Please give us your questions or comments."));
  return true;
}

function isContactOk(fm)

{
  var email, first;
  email = fm.email.value;
  fm.firstvalue = fm.first.value.replace(/'/g,"");
  fm.first.value = fm.first.value.replace(/"/g,"");
  first = fm.first.value;
  if(isEmpty(first)) return (warning(fm.first,"Please enter First Name."));
  fm.last.value = fm.last.value.replace(/'/g,"");
  fm.last.value = fm.last.value.replace(/"/g,"");
  last = fm.last.value;
  if(isEmpty(last)) return (warning(fm.last,"Please enter Last Name."));
  fm.address.value = fm.address.value.replace(/'/g,"");
  fm.address.value = fm.address.value.replace(/"/g,"");
  address = fm.address.value;
  if(isEmpty(address)) return (warning(fm.address,"Please enter address."));
  fm.city.value = fm.city.value.replace(/'/g,"");
  fm.city.value = fm.city.value.replace(/"/g,"");
  city = fm.city.value;
  if(isEmpty(city)) return (warning(fm.city,"Please enter city."));
  fm.phone.value = fm.phone.value.replace(/'/g,"");
  fm.phone.value = fm.phone.value.replace(/"/g,"");
  if(isEmpty(fm.phone.value)) return (warning(fm.phone,"Please enter your phone number."));
  fm.country.value = fm.country.value.replace(/'/g,"");
  fm.country.value = fm.country.value.replace(/"/g,"");
  country = fm.country.value;
  if(isEmpty(country)) return (warning(fm.country,"Please enter country."));
  if(!isEmail(email)) return (warning(fm.email,"Invalid Email. Please enter again."));
  fm.comments.value = fm.comments.value.replace(/'/g,"");
  fm.comments.value = fm.comments.value.replace(/"/g,"");
  if(isEmpty(fm.comments.value)) return (warning(fm.comments,"Please enter your comments."));
  return true;
}
//-->
