var submitcount=0;

function validateCaps(field)
 {
var valid = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only whole numbers and capital letters are accepted for the Account Number field!");
field.focus();
field.select();

return(false);
   }
}

function Check()
{


var account=window.document.mail_form.account.value;
var name=window.document.mail_form.name.value;
var address=window.document.mail_form.address.value;
var homephone=window.document.mail_form.homephone.value;
var password=window.document.mail_form.password.value;
var password1=window.document.mail_form.password1.value;
var dd = window.document.mail_form.dd.value;
var mm = window.document.mail_form.mm.value;
var yy = window.document.mail_form.yy.value;
var email = window.document.mail_form.email.value;


var atsign = email.indexOf("@");
var username = email.substring(0,atsign);

var dot = email.indexOf(".");
var isp = email.substring(atsign,dot);
var tld = email.substring(dot,email.length);


if (account =="")
{
alert("Please enter your Account Number");
window.document.mail_form.account.focus();
return(false);
}

else if (name == "")
{
alert("Please enter your Name");
window.document.mail_form.name.focus();
return (false);
}

else if (address == "")
{
alert("Please enter your Address");
window.document.mail_form.address.focus();
return (false);
}

else if (dd == "")
{
alert("Please enter your Day of Birth");
window.document.mail_form.dd.focus();
return (false);
}

else if (mm == "")
{
alert("Please enter your Month of Birth");
window.document.mail_form.mm.focus();
return (false);
}

else if (yy == "")
{
alert("Please enter your Year of Birth");
window.document.mail_form.yy.focus();
return (false);
}

else if (homephone == "")
{
alert("Please enter your Phone Number");
window.document.mail_form.homephone.focus();
return (false);
}

else if (email == "")
{
 if (atsign == -1)
{
alert("Please enter a VALID Email address");
window.document.mail_form.email.focus();
return (false);
}

else if (dot == -1)
{
alert("Please enter a VALID Email address");
window.document.mail_form.email.focus();
return (false);
}

else if (isp.length == 1)
{
alert("Please enter a VALID Email address");
window.document.mail_form.email.focus();
return (false);
}
}

else if (password == "")
{
alert ("Please enter a password");
window.document.mail_form.password.focus();
return (false);
}

else if (password1 == "")
{
alert ("Please confirm your password");
window.document.mail_form.password1.focus();
return (false);
}

else if (password1 != password)
{
alert ("The passwords you entered do not match, please try again");
window.document.mail_form.password.value="";
window.document.mail_form.password1.value="";
window.document.mail_form.password.focus();
return (false);
}


else if  (submitcount == 0)
      {
      submitcount++;
      return true;
      }
else
      {
      alert("This form has already been submitted.  Thanks!");
      return false;
      }


return (true);
}
