<!--

function ltrim(s)

{

  var str = "";

	var i, j;

  if((s != null) && (s.length > 0))

	{

	  i=0;

	  while(i < s.length && isSpace(s.charAt(i))) { i++; }

	  for(j=i; j<s.length; j++) { str += s.charAt(j); }

	}

	return str;

}



function rtrim(s)

{

  var str = "";

	var i, j;

  if((s != null) && (s.length > 0))

	{

    i = s.length - 1;

	  while(i > 0 && isSpace(s.charAt(i))) { i--; }

	  for(j=0; j<=i; j++) { str += s.charAt(j); }

	}

		return str;

}



function lrtrim(s)

{

  var str = "";

	str = ltrim(s);

	str = rtrim(str);

	return str;

}



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)

{

  var contentPass = /^[A-Za-z0-9_\.\-\@]+$/;

  

  TheFullName = fm.FullName.value;

  TheFullName = TheFullName.replace(/'/g,"");

  TheFullName = TheFullName.replace(/"/g,"");

  TheFullName = lrtrim(TheFullName); 

  if(isEmpty(TheFullName))

    return (warning(fm.FullName,"Please enter your full name."));

  fm.FullName.value = TheFullName;

  

  ThePhone = fm.Phone.value;

  ThePhone = ThePhone.replace(/'/g,"");

  ThePhone = ThePhone.replace(/"/g,"");

  ThePhone = lrtrim(ThePhone);

  if(isEmpty(ThePhone))

    return (warning(fm.Phone,"Please enter your phone number."));

  fm.Phone.value = ThePhone;

  

  TheFax = fm.Fax.value;

  TheFax = TheFax.replace(/'/g,"");

  TheFax = TheFax.replace(/"/g,"");

  TheFax = lrtrim(TheFax); 

  if(TheFax.length < 1 ){ fm.Fax.value = "N/A"; }



  TheEmail = fm.Email.value;

  if(!isEmail(TheEmail))

    return (warning(fm.Email,"Email address is empty or invalid"));

	

  TheAddress = fm.Address.value;

  TheAddress = TheAddress.replace(/'/g,"");

  TheAddress = TheAddress.replace(/"/g,"");

  TheAddress = lrtrim(TheAddress);

  if(TheAddress.length < 1 ){ fm.Address.value = "N/A"; }

  

  TheCity = fm.City.value;

  TheCity = TheCity.replace(/'/g,"");

  TheCity = TheCity.replace(/"/g,"");

  TheCity = lrtrim(TheCity);

  if(TheCity.length < 1 ){ fm.City.value = "N/A"; }

  

  TheState = fm.State.value;

  TheState = TheState.replace(/'/g,"");

  TheState = TheState.replace(/"/g,"");

  TheState = lrtrim(TheState);

  if(TheState.length < 1 ){ fm.State.value = "N/A"; }

  

  TheZip = fm.Zip.value;

  TheZip = TheZip.replace(/'/g,"");

  TheZip = TheZip.replace(/"/g,"");

  TheZip = lrtrim(TheZip);

  if(TheZip.length < 1 ){ fm.Zip.value = "N/A"; }

  

  TheCountry = fm.Country.value;

  TheCountry = TheCountry.replace(/'/g,"");

  TheCountry = TheCountry.replace(/"/g,"");

  TheCountry = lrtrim(TheCountry);

  if(TheCountry.length < 1 ){ fm.Country.value = "N/A"; }

  

  TheComments = fm.Comments.value;

  TheComments = TheComments.replace(/'/g,"");

  TheComments = TheComments.replace(/"/g,"");

  TheComments = lrtrim(TheComments);

  if(TheComments.length < 1 ){ fm.Comments.value = "N/A"; }

  

  return true;

}

function isValidSignupForm(fm)

{

  var contentPass = /^[A-Za-z0-9_\.\-\@]+$/; 

  TheFullName = fm.FullName.value;

  TheFullName = TheFullName.replace(/'/g,"");

  TheFullName = TheFullName.replace(/"/g,"");

  TheFullName = lrtrim(TheFullName); 

  if(isEmpty(TheFullName))

    return (warning(fm.FullName,"Please enter your full name."));

  fm.FullName.value = TheFullName;

  TheEmail = fm.Email.value;

  if(!isEmail(TheEmail))

    return (warning(fm.Email,"Email address is empty or invalid"));

  return true;

}

//-->



