<!-- E-mail Validation -->
function eValid(emailAddress) {

		var at="@";
		var dot=".";
		var lat=emailAddress.indexOf(at);
		var elength=emailAddress.length;
		var ldot=emailAddress.indexOf(dot);
		if (emailAddress.indexOf(at)==-1){
		   alert("Please enter a valid e-mail address.");
		   return false;
		}

		if (emailAddress.indexOf(at)==-1 || emailAddress.indexOf(at)==0 || emailAddress.indexOf(at)==elength){
		   alert("Please enter a valid e-mail address.");
		   return false;
		}

		if (emailAddress.indexOf(dot)==-1 || emailAddress.indexOf(dot)==0 || emailAddress.indexOf(dot)==elength){
		    alert("Please enter a valid e-mail address.");
		    return false;
		}

		 if (emailAddress.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid e-mail address.");
		    return false;
		 }

		 if (emailAddress.substring(lat-1,lat)==dot || emailAddress.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid e-mail address.");
		    return false;
		 }

		 if (emailAddress.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid e-mail address.");
		    return false;
		 }
		
		 if (emailAddress.indexOf(" ")!=-1){
		    alert("Please enter a valid e-mail address.");
		    return false;
		 }

 		 return true					
	}


<!--- FORM VALIDATION -->
function validate_required(field,alerttxt){
with (field)
{	
if (value==null||value=="")
  {alert(alerttxt);return false;}	
else {return true;}
}
}




function validateForm(thisform)
{
with(thisform)
{
if(validate_required(FirstName,"Please enter your first name.")==false)
  {FirstName.focus();return false;}  
else if(validate_required(LastName,"Please enter your last name.")==false)
  {LastName.focus();return false;}  
else if(validate_required(zip,"Please enter your Zip code.")==false)
  {zip.focus();return false;}
else if(validate_required(phone,"Please enter your phone number.")==false)
  {phone.focus();return false;} 
else if(validate_required(code,"Please enter your contest code.")==false)
  {code.focus();return false;}
  else
  {var myForm = document.forms['EmailForm'];
var formElements = myForm.elements;
var taglength = formElements.length;
	var checked_count = 0;
	var msg = "Please choose at least one newsletter list to join.";


	for (i=0;i<taglength;i++){
		if(formElements[i].checked)
			++checked_count;
	}
	if(checked_count < 1) {
		alert(msg);
		return false;
		
	} else {
			return eValid(document.getElementById('emailAddress').value)}
		
		//return true;
		//document.getElementById('emvForm').submit();
	}
}
}


 /*

function checkboxValid()
{	

	var choices = 0;
	for (counter = 0; counter < EmailForm.checkbox.length; counter++)
	{
		alert("sdf");
	// If a checkbox has been selected it will return true
	// (If not it will return false)
	if (EmailForm.checkbox[counter].checked)
	{ choices = choices + 1; }
	}
	
	if (choices < 1 )
	{
	// If there were less then selections made display an alert box
	alert("Please choose at least one category.")
	return (false);
	}
	
	if(EmailForm.checkbox[0].checked){
	document.getElementById('category1').value = "Fiction  ";}
	else{document.getElementById('category1').value = "";}
	
	if(EmailForm.checkbox[1].checked){
	document.getElementById('category2').value = "kidsbooks  ";}
	else{document.getElementById('category2').value = "";}
	
	if(EmailForm.checkbox[2].checked){
	document.getElementById('category3').value = "churchresources  ";}
	else{document.getElementById('category3').value = "";}
	
	if(EmailForm.checkbox[3].checked){
	document.getElementById('category4').value = "womensinterest  ";}
	else{document.getElementById('category4').value = "";}
	
	if(EmailForm.checkbox[4].checked){
	document.getElementById('category5').value = "mensinterests  ";}
	else{document.getElementById('category5').value = "";}
	
       if(EmailForm.checkbox[5].checked){
	document.getElementById('category6').value = "marriage  ";}
	else{document.getElementById('category6').value = "";}
	
	if(document.getElementById('emailAddress').value != null){
	return eValid(document.getElementById('emailAddress').value)}
		
	return (true);
}
*/

