function ValidateForm(theForm)
{


// validate email value 
  if (theForm.txEmail.value == "")
  {
    alert("Please enter your e-mail address.");
    theForm.txEmail.focus();
    return (false);
  }

  if (!checkEmail(theForm.txEmail.value))
  {
    theForm.txEmail.select();
    theForm.txEmail.focus();
		return (false);
	}
//--------------------------------------------

//validate phone
    if(theForm.txtPhone.value =="")
    {
        alert("Please enter a phone number.");
        theForm.txtPhone.focus();
        return(false);
    }

// validate password
  if (theForm.txPwd.value == "")
  {
    alert("Please enter a password.");
    theForm.txPwd.focus();
    return (false);
  }

  if (theForm.txPwd.value.length < 6)
  {
    alert("Your password must be at least 6 characters long.");
    theForm.txPwd.select();
    theForm.txPwd.focus();
    return (false);
  }

  // verify password  
  if (theForm.txPwd.value != theForm.txVPwd.value)
  {
    alert("Please verify your password in the \"Verify Password\" field.");
    theForm.txVPwd.select();
    theForm.txVPwd.focus();
    return (false);
  }
  
  

//------------------------------------------


// validate specialty

/*  if (theForm.SpeID.selectedIndex == 0)
  {
    alert("Please select one of the \"Specialty\" options.");
    theForm.SpeID.focus();
    return (false);
  }

  if (theForm.SpeID[theForm.SpeID.selectedIndex].value == "46")
  {
    if (theForm.txSpeOther.value == "")
    {
    alert("Please enter other specialty.");
    theForm.txSpeOther.focus();
    return (false);
    }
  } */


  if (theForm.ProfID.selectedIndex == 0)
  {
    alert("Please select one of the \"Profession\" options.");
    theForm.ProfID.focus();
    return (false);
  }
  
    if(theForm.val.value == "1" && theForm.txtMedicalSchool.value == "")
    {
        alert("Please enter a medical school.");
        theForm.txtMedicalSchool.focus();
        return(false);
    }
    
    if(theForm.val.value == "1" && theForm.txtGraduation.value == "")
    {
        alert("Please enter a graduation year.");
        theForm.txtGraduation.focus();
        return(false);
    }



// validate first name
  if (theForm.txFName.value == "")
  {
    alert("Please enter your first name.");
    theForm.txFName.focus();
    return (false);
  }

  if (!checkChar(theForm.txFName.value))
  {
    alert("Please enter only alphabet characters in the \"First Name\" field.");
    theForm.txFName.select();
    theForm.txFName.focus();
    return (false);
  }


// validate last name
  if (theForm.txLName.value == "")
  {
    alert("Please enter your last name.");
    theForm.txLName.focus();
    return (false);
  }

  if (!checkChar(theForm.txLName.value))
  {
    alert("Please enter only alphabet characters in the \"Last Name\" field.");
    theForm.txLName.select();
    theForm.txLName.focus();
    return (false);
  }
// validate zipcode
  if (theForm.txZip.value == "")
  {
    alert("Please enter your Zip Code.");
    theForm.txZip.focus();
    return (false);
  }

  if (!checkChar(theForm.txZip.value))
  {
    alert("Please enter only alphanumeric characters in the \"Zip Code\" field.");
    theForm.txZip.select();
    theForm.txZip.focus();
    return (false);
  }
   if(!checkYear(theForm.txtGraduation.value))
    {
        alert("Please enter only numbers for the graduation year.");
        theForm.txtGraduation.focus();
        return(false);
    }

  if (theForm.SpeID[theForm.SpeID.selectedIndex].value == "46")
	theForm.txSpe.value = theForm.txSpeOther.value;
  else
	theForm.txSpe.value = theForm.SpeID[theForm.SpeID.selectedIndex].text;

	theForm.txProf.value = theForm.ProfID[theForm.ProfID.selectedIndex].text;
//-------------------------------------
// if everything is ok...
  return (true);
} //end of function
// ####################################################################################################



function ValidateProfile(theForm)
{

// validate email value 
  if (theForm.txEmail.value == "")
  {
    alert("Please enter your e-mail address.");
    theForm.txEmail.focus();
    return (false);
  }

  if (!checkChar(theForm.txEmail.value))
  {
    alert("Please enter only letter and digit characters and @ and . in the \"Email\" field.");
    theForm.txEmail.focus();
    return (false);
  }
  
  if (!checkEmail(theForm.txEmail.value))
  {
    theForm.txEmail.select();
    theForm.txEmail.focus();
		return (false);
  }

//--------------------------------------------


// validate password
  if (theForm.txPwd.value == "")
  {
    alert("Please enter a password.");
    theForm.txPwd.focus();
    return (false);
  }
  //validate phone
    if(theForm.txtPhone.value =="")
    {
        alert("Please enter a phone number.");
        theForm.txtPhone.focus();
        return(false);
    }
    
  if (theForm.txPwd.value.length < 6)
  {
    alert("Your password must be at least 6 characters long.");
    theForm.txPwd.select();
    theForm.txPwd.focus();
    return (false);
  }

  
// verify password  
  if (theForm.txPwd.value != theForm.txVPwd.value)
  {
    alert("Please verify your password in the \"Verify Password\" field.");
    theForm.txVPwd.select();
    theForm.txVPwd.focus();
    return (false);
  }
//------------------------------------------



// validate zipcode
  if (theForm.txZip.value == "")
  {
    alert("Please enter your Zip Code.");
    theForm.txZip.focus();
    return (false);
  }

  if (checkChar(theForm.txZip.value)== false)
  {
    alert("Please enter only alphanumeric characters in the \"Zip Code\" field.");
    theForm.txZip.select();
    theForm.txZip.focus();
    return (false);
  }
  
 if(theForm.val.value == "1" && theForm.txtMedicalSchool.value == "")
    {
        alert("Please enter a medical school.");
        theForm.txtMedicalSchool.focus();
        return(false);
 }
 if(theForm.val.value == "1" && theForm.txtGraduation.value == "")
    {
        alert("Please enter a graduation year.");
        theForm.txtGraduation.focus();
        return(false);
        
   }
 if(!checkYear(theForm.txtGraduation.value))
    {
        alert("Please enter only numbers for the graduation year.");
        theForm.txtGraduation.focus();
        return(false);
    }
 if (theForm.ProfID.selectedIndex == 0)
  {
    alert("Please select one of the \"Profession\" options.");
    theForm.ProfID.focus();
    return (false);
  }
    
    // validate first name
  if (theForm.txFName.value == "")
  {
    alert("Please enter your first name.");
    theForm.txFName.focus();
    return (false);
  }

  if (!checkChar(theForm.txFName.value))
  {
    alert("Please enter only alphabet characters in the \"First Name\" field.");
    theForm.txFName.select();
    theForm.txFName.focus();
    return (false);
  }


// validate last name
  if (theForm.txLName.value == "")
  {
    alert("Please enter your last name.");
    theForm.txLName.focus();
    return (false);
  }

  if (!checkChar(theForm.txLName.value))
  {
    alert("Please enter only alphabet characters in the \"Last Name\" field.");
    theForm.txLName.select();
    theForm.txLName.focus();
    return (false);
  }


//-------------------------------------
// if everything is ok...
  return (true);
} //end of function





// check input characters
function checkChar(chrValue) {
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@.";
  var checkStr = chrValue;
  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;
    }
  }

	return allValid;
} // end of function
// ####################################################################################################

  
function checkYear(chrYear){
    var strYear = "1234567890";
    var Year = chrYear;
    var allValid = true;
 
   for (i = 0;  i < Year.length;  i++)
   {
        ch = Year.charAt(i);
        for (j = 0;  j < strYear.length;  j++)
        {
            if (ch == strYear.charAt(j))
                break;
        }
        if (j == strYear.length)
             {
                 allValid = false;
                 break;
             }
    }
    return allValid;
}

// check email format
function checkEmail(email) {
		var first = email.indexOf("@")
		var last = email.indexOf(".")
		var email_num = email.length;

		if (first != -1) {                // check @ duplicate
			mail_str = email;
			mail_str = mail_str.substr(first+1);
			second = mail_str.indexOf("@");
			if (second != -1)	{
				alert("We are unable to recognize the e-mail address you entered. Please try entering your address again.");
				return false;
			}
		}

		if ((email.indexOf(" ")) != -1)	{
			alert ("\" space \" is not valid in email address.");
			return false;
		}

		if ((email.indexOf("/")) != -1)	{
			alert ("\" / \" is not valid in email address.");
			return false;
		}

		if ((email.indexOf(";")) != -1)	{
			alert ("\" ; \" is not valid in email address.");
			return false;
		}

		if ((email.indexOf(",")) != -1)	{
			alert ("\" , \" is not valid in email address.");
			return false;
		}

		if (email.search(/(\S+)@(\S+)\.(\S+)/) == -1) {
			alert("We are unable to recognize the e-mail address you entered. Please try entering your address again.");
			return false;
		}

		if (email.substring(0, 5) == "http:") {
			alert ("\" http: \" is not valid in email address.");
			return false;
		}

		if (email.lastIndexOf(".") == email_num-1) {
			alert ("\" . \" is not valid at the end of email address.");
			return false;
		}

	return true;
} // end of function
// ####################################################################################################



