function validate() {
	return runScripts();
}

function runScripts() {
	return  ( 
			CheckNull(document.form1.First_Name, "First Name") &&
			CheckNull(document.form1.Last_Name, "Last Name") &&
			CheckNull(document.form1.Email, "E-mail") && 
			CheckEmail(document.form1.Email) &&
			CheckValidPhoneNumber() &&
			otherNumber() &&
			CheckQuestions()
		)
	}
	
/********************** START CHECK PHONE NUMBER ******************************/
function CheckValidPhoneNumber() {
	var theErrorMessage = "Please enter a valid phone number.\r\n\r\n";
	var theErrorIndex = 0;
	var theAreaCode = document.form1.Area_Daytime_Phone.value;
	var theExchange = document.form1.Prefix_Daytime_Phone.value;
	var thePhoneNumber = theAreaCode + theExchange + document.form1.Suffix_Daytime_Phone.value;
	
	/* Check Phone Number fields for Nulls */
	if ((theAreaCode == null) || (theAreaCode == "")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Please enter a valid area code.\r\n";
		}
	if ((theExchange == null) || (theExchange == "")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Please enter a valid exchange number.\r\n";
		}
	if ((document.form1.Suffix_Daytime_Phone.value == null) || (document.form1.Suffix_Daytime_Phone.value == "")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Please enter a valid number.\r\n";
		}
	/* Check 1st character in area code */
	if ((theAreaCode.slice(0,1) == "0") || (theAreaCode.slice(0,1) == "1")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". The first digit of your area code should not be 0 or 1.\r\n";
		}
	/* Check for repeating digits in area code */
	if ((theAreaCode == "222") || (theAreaCode == "333") || (theAreaCode == "444") || (theAreaCode == "555") || (theAreaCode == "666") || (theAreaCode == "777") || (theAreaCode == "999")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Area code " + theAreaCode + " is invalid.\r\n";
		}
	/* Check exchange for 555 */
	if (theExchange == "555") {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Exchange number 555 is invalid.\r\n";
		}
	/* Check for 10 digits in phone number */
	if (thePhoneNumber.length != 10) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Your phone number must contain 10 digits.\r\n";
		}
		
	if (theErrorMessage != "Please enter a valid phone number.\r\n\r\n") {
		alert(theErrorMessage);
		document.form1.Area_Daytime_Phone.value = "";
		document.form1.Prefix_Daytime_Phone.value = "";
		document.form1.Suffix_Daytime_Phone.value = "";
		document.form1.Area_Daytime_Phone.focus();
		return false;
		}
	else {
		return true;
		}
	}
/********************** END CHECK PHONE NUMBER ******************************/

/********************** END CHECK PHONE NUMBER ******************************/

function otherNumber() {
	var Area_Evening_Phone = document.form1.Area_Evening_Phone.value;
	var Prefix_Evening_Phone = document.form1.Prefix_Evening_Phone.value;
	var Suffix_Evening_Phone = document.form1.Suffix_Evening_Phone.value;

if (((Area_Evening_Phone == "") || (Area_Evening_Phone == null)) && 
    ((Prefix_Evening_Phone == "") || (Prefix_Evening_Phone == null)) && 
    ((Suffix_Evening_Phone == "") || (Suffix_Evening_Phone == null))) 
{
  return true;
}
else {
  if (CheckOtherValidPhoneNumber()) {
	return true;
  }
  else {
    return false;
  }
}

}

function CheckOtherValidPhoneNumber() {
	var theErrorMessage = "Please enter a valid phone number.\r\n\r\n";
	var theErrorIndex = 0;
	var theAreaCode = document.form1.Area_Evening_Phone.value;
	var theExchange = document.form1.Prefix_Evening_Phone.value;
	var thePhoneNumber = theAreaCode + theExchange + document.form1.Suffix_Evening_Phone.value;
	
	/* Check Phone Number fields for Nulls */
	if ((theAreaCode == null) || (theAreaCode == "")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Please enter a valid area code.\r\n";
		}
	if ((theExchange == null) || (theExchange == "")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Please enter a valid exchange number.\r\n";
		}
	if ((document.form1.Prefix_Evening_Phone.value == null) || (document.form1.Prefix_Evening_Phone.value == "")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Please enter a valid exchange number.\r\n";
		}
	/* Check 1st character in area code */
	if ((theAreaCode.slice(0,1) == "0") || (theAreaCode.slice(0,1) == "1")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". The first digit of your area code should not be 0 or 1.\r\n";
		}
	/* Check for repeating digits in area code */
	if ((theAreaCode == "222") || (theAreaCode == "333") || (theAreaCode == "444") || (theAreaCode == "555") || (theAreaCode == "666") || (theAreaCode == "777") || (theAreaCode == "999")) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Area code " + theAreaCode + " is invalid.\r\n";
		}
	/* Check exchange for 555 */
	if (theExchange == "555") {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Exchange number 555 is invalid.\r\n";
		}
	/* Check for 10 digits in phone number */
	if (thePhoneNumber.length != 10) {
		theErrorIndex++;
		theErrorMessage = theErrorMessage + theErrorIndex + ". Your phone number must contain 10 digits.\r\n";
		}
		
	if (theErrorMessage != "Please enter a valid phone number.\r\n\r\n") {
		alert(theErrorMessage);
		document.form1.Area_Evening_Phone.value = "";
		document.form1.Prefix_Evening_Phone.value = "";
		document.form1.Suffix_Evening_Phone.value = "";
		document.form1.Area_Evening_Phone.focus();
		return false;
		}
	else {
		return true;
		}
	}
/********************** END CHECK PHONE NUMBER ******************************/

function CheckQuestions() 
	{
		if (document.form1.State.selectedIndex == "0")
			{
				alert("Please select a state");
				document.form1.State.focus();
				return false;
			}	
		if (document.form1.Best_Time_To_Call.selectedIndex == "0")
			{
				alert("Please select the best time we can call you");
				document.form1.Best_Time_To_Call.focus();
				return false;
			}	
		if (document.form1.Current_Legal_Problem_1.selectedIndex == "0")
			{
				alert("Please select your current legal problem");
				document.form1.Current_Legal_Problem_1.focus();
				return false;
			}

				
	}	

/**************** Radio Button Check ***********/

function CheckCredit() 
{ 
   if (document.form1.creditcard[0].checked == false) 
      {alert ("You must have a credit card or checking account.") 
      return false;}
      else 	{
	    return true			}
} 

/**************** End Radio Button Check ***********/
				 
	function CheckNull(boxName, Readable)	{
	  if (boxName.value == "")
	{  alert("You must enter something in the " + Readable + " box.")
		boxName.focus()
	    return false  }
	  else 	{
	    return true			}	}
	    


			 
	function CheckEmail(Email)  {
		 if (Email.value.indexOf("@") == -1)  
		 { alert("Your e-mail address needs to have an @ sign in it. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/**************** stop if AT is the first character ***********/
		 if (Email.value.indexOf("@") == 0)  
		 { alert("Your e-mail address can not start with an @ sign. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/* ************* look for the dot *************************** */
		 if (Email.value.indexOf(".") == -1)  
		 { alert("Your e-mail address needs to have a DOT in it. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else	
/****************************************************************/
/************** FORBIDDEN CHARACTERS ****************************/
/****************************************************************/
/************* stop if it has a comma ***************************/
		if  (Email.value.indexOf(",") != -1)  
		 { alert("Your e-mail address can not contain a comma. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else	
/************* stop if it has a semi colon **********************/
		if  (Email.value.indexOf(";") != -1)  
		 { alert("Your e-mail address can not contain a semi colon. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else	
/************* we are allowing tildes *****************************/
/************* stop if it has a space ***************************/
		if  (Email.value.indexOf(" ") != -1)  
		 { alert("Your e-mail address can not contain a space and there can be no spaces at the beginning or the end of the Email address. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else	
/***************** stop if it has  a ] *****************************/		 
		 if (Email.value.indexOf("]") != - 1)  
		 { alert("Your e-mail address can not contain a SQUARE BRACKET.  Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/***************** stop if it has  a [ *****************************/		 
		 if (Email.value.indexOf("[") != - 1)  
		 { alert("Your e-mail address can not contain a SQUARE BRACKET.  Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/*****************************************************************/
/****************** special AT and DOT stuff *********************/
/*****************************************************************/
/* *************** look for @ before the LAST dot *************** */
		var AtSpot = Email.value.indexOf("@")
		var lastDotSpot = Email.value.lastIndexOf(".")
		 if (lastDotSpot < AtSpot)  
		 { alert("Your e-mail address must have a DOT somewhere after the AT sign .  Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/***************** if it starts w a dot stop *************************/		 
		 var firstDotSpot = Email.value.indexOf(".")
		 if (firstDotSpot == 0)  
		 { alert("Your e-mail address can not start with a DOT.  Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/***************** if it ends w a dot stop ***************************/		 
		 var theLength = Email.value.length
		 if (lastDotSpot == theLength - 1)  
		 { alert("Your e-mail address can not end with a DOT.  Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/**************** look for 2 AT signs ********************************/		 
		 var lastAtSpot = Email.value.lastIndexOf("@")
		 if (AtSpot != lastAtSpot)  
		 { alert("Your e-mail address can not contain 2 @ signs. You may enter only one Email name.")
		   Email.focus()
		   return false   }
		 else	
/*********************************************************************/
/**************** characters it cant have after the AT ***************/
/*********************************************************************/
/***************** stop if it has a + after the AT *******************/		 
		 if (Email.value.lastIndexOf("+") > AtSpot)  
		 { alert("Your e-mail address can not have a PLUS SIGN there.  Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/***************** stop if it has a = after the AT *******************/		 
		 if (Email.value.lastIndexOf("=") > AtSpot)  
		 { alert("Your e-mail address can not have an EQUALS SIGN there.  Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   }
		 else	
/************* stop if it has an ampersand after the AT ************/
		 if (Email.value.lastIndexOf("&") > AtSpot)  
		 { alert("Your e-mail address can not contain an AND sign there. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else   
/************* stop if it has a slash after the AT *****************/
		 if (Email.value.lastIndexOf("/") > AtSpot)  
		 { alert("Your e-mail address can not contain a SLASH there. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else   
/************* stop if it has a pound sign after the AT *************/
		 if (Email.value.lastIndexOf("#") > AtSpot)  
		 { alert("Your e-mail address can not contain a POUND SIGN there. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else   
/************* stop if it has a ? after the AT **********************/
		 if (Email.value.lastIndexOf("?") > AtSpot)  
		 { alert("Your e-mail address can not contain a QUESTION MARK there. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else   
/************* stop if it has a ) after the AT *******************************/
		 if (Email.value.lastIndexOf(")") > AtSpot)  
		 { alert("Your e-mail address can not contain a RIGHT PARENS there. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else   
/************* stop if it has a ( after the AT *******************************/
		 if (Email.value.lastIndexOf("(") > AtSpot)  
		 { alert("Your e-mail address can not contain a LEFT PARENS there. Please enter a correct e-mail address so that we can get your information to you.")
		   Email.focus()
		   return false   } 
		 else   
/**************** guess it looks OK **********************************/
		 {
		   return true
		 			 }
		 			 }
