
function LTrim(str)
{  var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
       var j=0, i = s.length;
       while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
              j++;
       s = s.substring(j, i);
   }
return s;
}
function RTrim(str)
{  var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
       var i = s.length - 1;       
       while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
              i--;
       s = s.substring(0, i+1);
   }
return s;
}
function Trim(str)  { return RTrim(LTrim(str)); }

function Validate(theForm) {
	 if ((theForm.CommunityService.checked==false))
{
   alert("Por favor, marque para indicar que esta de acuerdo con dedicar 4 horas de servicio en la comunidad y que se hará responsable de su transporte.");
   theForm.CommunityService.focus();
   return (false);
}
	if (Trim(theForm.BoysGirlsClub.value) == "")
  {
    alert("Por favor, entre el nombre del “Boys & Girls Club.”");
    theForm.BoysGirlsClub.focus();
    return (false);
  }
   if (Trim(theForm.ClubDirector.value) == "")
  {
    alert("Por favor, entre el nombre del Director del Club/CPOe.");
    theForm.ClubDirector.focus();
    return (false);
 }
    if (Trim(theForm.MemberName.value) == "")
  {
    alert("Por favor, entre el Nombre del Miembro del Club ");
    theForm.MemberName.focus();
    return (false);
 }
    if (Trim(theForm.Phone.value) == "")
  {
    alert("Por favor, entre su número de teléfono.");
    theForm.Phone.focus();
    return (false);
 }
   var checkOK = "0123456789-()";
	var checkStr = theForm.Phone.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
				if (j == checkOK.length) {
					allValid = false;
					break;
				}
	}
	if (!allValid) {
		alert("Por Favor, entre solo caracteres numéricos para el camp telefónico.");
		theForm.Phone.focus();
		return (false);
	}
   if (Trim(theForm.Email.value) == "")
  {
    alert("Por favor, entre su dirección de correo electrónico.");
    theForm.Email.focus();
    return (false);
  }

	var checkStr = theForm.Email.value;
	var ch = checkStr.indexOf('@');

	if (ch==0 || ch==-1) {
		alert("Por favor, entre una dirección de correo electrónico válida.");
		theForm.Email.focus();
		return (false);
	}
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzfSOZsozYÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789-@.-_'";
	var checkStr = theForm.Email.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
				if (j == checkOK.length) {
					allValid = false;
					break;
				}
	}
	if (!allValid) {
		alert("Por Favor, entre solo letras, caracteres numéricos y los siguientes símbolos \"@.-_'\" para el campo \"correo electrónico\".");
		theForm.Email.focus();
		return (false);
	}
    if (Trim(theForm.Address.value) == "")
  {
    alert("Por favor, entre su Dirección de Domicilio.");
    theForm.Address.focus();
    return (false);
 }
    if (Trim(theForm.City.value) == "")
  {
    alert("Por favor, entre su ciudad.");
    theForm.City.focus();
    return (false);
 }
    if (Trim(theForm.State.value) == "")
  {
    alert("Por favor seleccione su estado.");
    theForm.State.focus();
    return (false);
 }
    if (Trim(theForm.Zip.value) == "")
  {
    alert("Por favor, entre su código postal.");
    theForm.Zip.focus();
    return (false);
 } 
  if (((Trim(theForm.Comments.value) == "") && (Trim(theForm.AttachedFile.value) == "")))
  {
    alert("Por favor, escriba la historia de su familia o adjunte un documento.");
    theForm.Comments.focus();
    return (false);
  } 
	

return (true);
}


