document.all.Login.focus();

function ValidateEmail(emailValue, typeEmail)  {
   if (emailValue == "") {
      if (typeEmail == 0) return false
   } else  {
     if ((emailValue.indexOf('@') == -1) || (emailValue.indexOf('.') == -1)) return false
     for (i=0; i < emailValue.length; i++)  {
       charID = emailValue.charCodeAt(i)
       if (!((charID>=45 && charID <= 46) || (charID>=48 && charID<=57) || (charID>=64 && charID<=90) || (charID==95) || (charID>=97 && charID<=123)))
       {
               return false;
       }
     }
   }
  return true;
}

function ValidateLogin(loginValue)  {
  var charID;
 if (loginValue.length < 4) {
        return false;
  } else {
        for (i=0; i < loginValue.length; i++)
        {
                charID = loginValue.charCodeAt(i);
                if (!((charID>=48 && charID<=57) || (charID>=97 && charID<=122) || (charID>=65 && charID<=90) || charID==95))
                {
                        return false;
                }
        }
  }
  return true;
}

function customer_data_validator(theForm) {
    if (! ValidateEmail(theForm.Login.value,0)) {
      alert("Please enter your correct \"e-mail Address\" !\n (EXAMPLE:user@home.com)");
      theForm.Login.focus();
      return (false);
    }
    if (! ValidateLogin(theForm.password.value)) {
        alert("Please select your \"Password\" in allowed format!\n (Use only letters, numbers and \"_\" with at least 4 characters)");
        theForm.password.focus();
        return (false);
    }
    if (theForm.password.value != theForm.password2.value) {
        alert("Your \"Password\" and \"Confirmation\" are not the same, please re-enter.");
        theForm.password2.value="";
        theForm.password.focus();
        return (false);
    }
    if (theForm.contactname.value == "") {
        alert("Please enter your \"Name\".");
        theForm.contactname.focus();
        return (false);
    }

    if(theForm.DayPhone_i.value.length>10) {
      return (true);
    }

    // || isNaN(theForm.DayPhone.value)


    var re = new RegExp('-', "g");
    var re2= new RegExp(' ', "g");
    nv=theForm.DayPhone.value.replace(re,"");
    nv=nv.replace(re2,"");

    // alert("Old="+theForm.DayPhone.value+" new="+nv);
    // if (theForm.DayPhone.value.length < 7 ) 

    if (nv.length < 7 ) {
        alert("Please enter your 7 digit Day Phone.");
        theForm.DayPhone.focus();
        return (false);
    }

    if (theForm.DayPhone_p.value.length < 3 || isNaN(theForm.DayPhone_p.value)) {
        alert("Please enter your 3 digit Day Phone Area Code.");
        theForm.DayPhone_p.focus();
        return (false);
    }

    return (true);
}
