function validateOnSubmit(theform)
{
 if(theform.vusername.value.length==0)
 {
  alert("Please Enter Your Username");
  theform.vusername.focus();
  return false;
  }
  if(theform.vpassword.value.length==0)
  {
  alert("Please Enter Your Password");
  theform.vpassword.focus();
  return false;
  }
 }
 
function validateFormOnSubmit(theForm) 
{
var reason1 = "";
var reason2 = "";
var reason3 = "";
var reason4 = "";
var reason5 = "";
var reason6 = "";
var reason7 = "";
var reason8 = "";
var reason9 = "";
var reason10 ="";
var reason11 = "";
var reason12 ="";
var reason13 ="";

var reason15 ="";
var reason16 ="";
var reason17 ="";
var reason18 ="";



	reason17 += validateNoSpace(theForm.vsitename);
	if (reason17 != "") 
	{
    alert("Please remove all spaces from the URL");
    return false;
    }
    reason18 += validateURL(theForm.vsitename);
	if (reason18 != "") 
	{
    alert("Please enter more than 3 characters for your URL");
    return false;
    }
	reason1 += validateEmpty(theForm.vfirstname);
	if (reason1 != "") 
	{
    alert("Please Enter First name");
//	theForm.firstname.focus();
    return false;
    }
	reason2 += validateEmpty(theForm.vlastname);
	if (reason2 != "") 
	{
    alert("Please Enter Last name");
//	theForm.lastname.focus();
    return false;
    }
	reason3 += validateEmpty(theForm.vusername);
	if (reason3 != "") 
	{
    alert("Please Enter User Name");
//	theForm.email.focus();
    return false;
    }
	if (!validateRadio(theForm.male_or_female)) 
	{
    alert("Please Enter Your sex. this is required so your pronoun default is set properly on your site");
    return false;
    }
	reason15 += validateEmpty(theForm.college);
	if (reason15 != "") 
	{
    alert("Please Enter Your College of Osteopathic Medicine");
    return false;
    }
	reason16 += validateEmpty(theForm.specialties);
	if (reason16 != "") 
	{
    alert("Please Enter the Specialties");
    return false;
    }
	reason4 += validateEmail(theForm.vemail);
	if (reason4 != "") 
	{
    alert("Please Enter Valid E-mail");
//	theForm.email.focus();
    return false;
    }
	
	reason5 += validateEmpty(theForm.vaddress);
	if (reason5!= "") 
	{
    alert("Please enter the Address");
//	theForm.cpassword.focus();
    return false;
    }
	
	reason6 += validateEmpty(theForm.vcity);
	if (reason6 != "") 
	{
    alert("Please Enter city");
//	theForm.city.focus();
    return false;
    }
	
	reason7+= validateEmpty(theForm.vstate);
	if (reason7 != "") 
	{
    alert("Please Enter State");
//	theForm.password.focus();
    return false;
    }
	
	reason8 += validateEmpty(theForm.vzip);
	if (reason8 != "") 
	{
    alert("Please Enter Zipcode");
//	theForm.phone.focus();
    return false;
    }
	
	reason9 += validateEmpty(theForm.vphone);
	if (reason9 != "") 
	{
    alert("Please Enter Phone number");
//	theForm.phone.focus();
    return false;
    }
	reason10 += validateEmpty(theForm.vpassword);
	if (reason10 != "") 
	{
    alert("Please Enter Password");
//	theForm.phone.focus();
    return false;
    }
	reason11 += validateEmpty(theForm.vpasswordrepeat);
	if (reason11 != "") 
	{
    alert("Please Re-enter Password");
//	theForm.phone.focus();
    return false;
    }
	reason12 += validatecomparision(theForm.vpassword,theForm.vpasswordrepeat);
	if (reason12 != "") 
	{
    alert("Password Mismatch");
	theForm.vpasswordrepeat.focus();
    return false;
    }
	reason13 += validateEmpty(theForm.vsitename);
	if (reason13 != "") 
	{
    alert("Please Enter Your site name");
    return false;
    }
//	alert(theForm.tos.checked);
	if(theForm.tos.checked!=true)
	{
	 alert('You must accept the Privacy policies of this site!');
	 return false;
	}
	if(theForm.acofp.checked!=true)
	{
	 alert('You must be a member of the American College of Osteopathic Family Physicians.  Join online at www.acofp.org or call 800-323-0794 !');
	 return false;
	}
  return true;
}
function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0)
	{
        fld.style.background = '#F0F0F0';
		fld.focus();
        error = "The required field has not been filled in.\n"
    } 
	else {
        fld.style.background = 'White';
    }
    return error;  
}

function validateURL(fld) {
	var error = "";
	
	if (fld.value.length < 4)
	{
	 	error = "Please enter more than 3 characters for your URL";
     }

   return error;
}

function validateNoSpace(fld) {
	var error = "";
	
	if (fld.value.length > 0)
	{
	 for (i = 0; i < fld.value.length; i++) 
      { 
      Char = fld.value.charAt(i); 

      if (Char == ' ') 
         {
         	error = "Please remove all spaces from URL";
         }
      }
     }

   return error;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function validateEmail(fld) {
    var error = "";
	var emailfmt= /^\w+([.-]\w+)*@\w+([.-]\w+)*\.\w{2,8}$/;
	if(!emailfmt.test(fld.value))
    {
        fld.style.background = '#F0F0F0'; 
        error = "Please enter Valid Email address.\n";
		fld.focus();
		
    }else {
        fld.style.background = 'White';
	
    }
   return error;
}
function validateRadio(fld){
	var n=0;
	for(i=0;i<fld.length;i++){
		if(fld[i].checked){
			n++;
		}
	}
	if(n) return true;
	else return false;		
}
function validatecomparision(fld,fld2)
{
    var error = "";
    if (fld.value == "" || fld2.value == "")
		{
        fld.style.background = '#F0F0F0';
		error = "You didn't enter a password or confirm password.\n";
        } 
	else if (fld.value!=fld2.value) 
	 {
        fld.style.background = '#F0F0F0'; 
		fld2.style.background = '#F0F0F0'; 
		error = "Please enter Same Value for both.\n";
     }
	else 
	{
        fld.style.background = 'White';
	}
   return error;
}