<!-- 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(blog,"Please enter the url of your blog.")==false)
  {blog.focus();return false;}
else if(validate_required(address,"Please enter your address.")==false)
  {address.focus();return false;}
else if(validate_required(city,"Please enter your City.")==false)
  {city.focus();return false;}
else if(validate_required(state,"Please choose your State.")==false)
  {state.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{return checkboxValid();}
}
}

function checkboxValid()
{	
	var choices = 0;
	var EmailForm = document.getElementById('EmailForm');
	for (counter = 0; counter < EmailForm.checkbox.length; counter++)
	{
	// 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('Facebook').value = "Facebook  ";}
	else{document.getElementById('Facebook').value = "";}
	
	if(EmailForm.checkbox[1].checked){
	document.getElementById('Twitter').value = "Twitter  ";}
	else{document.getElementById('Twitter').value = "";}
	
	if(EmailForm.checkbox[2].checked){
	document.getElementById('AFriend').value = "A Friend  ";}
	else{document.getElementById('AFriend').value = "";}
	
	if(EmailForm.checkbox[3].checked){
	document.getElementById('ABlog').value = "A Blog  ";}
	else{document.getElementById('ABlog').value = "";}
	
	if(EmailForm.checkbox[4].checked){
	document.getElementById('MBatterson').value = "MBatterson  ";}
	else{document.getElementById('MBatterson').value = "";}
	
	if(EmailForm.checkbox[5].checked){
	document.getElementById('Other').value = "Other";}
	else{document.getElementById('Other').value = "";}
	
	if(EmailForm.checkbox[6].checked){
	document.getElementById('category1').value = "Fiction  ";}
	else{document.getElementById('category1').value = "";}
	
	if(EmailForm.checkbox[7].checked){
	document.getElementById('category2').value = "Christian Living/Devotionals  ";}
	else{document.getElementById('category2').value = "";}
	
	if(EmailForm.checkbox[8].checked){
	document.getElementById('category3').value = "Family/Parenting  ";}
	else{document.getElementById('category3').value = "";}
	
	if(EmailForm.checkbox[9].checked){
	document.getElementById('category4').value = "Relationships  ";}
	else{document.getElementById('category4').value = "";}
	
	if(EmailForm.checkbox[10].checked){
	document.getElementById('category5').value = "Social Issues  ";}
	else{document.getElementById('category5').value = "";}
	
	
	if(document.getElementById('emailAddress').value != null){
	return eValid(document.getElementById('emailAddress').value)}
		
	return (true);
}
