/**
* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/
function initEmail()
{
	var email = document.getElementById('email');
	if(email.value == 'enter email address')
	{
		email.value = '';
	}
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
		   //alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.getElementById('email');
	
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Invalid E-mail Address");
		return false
	}
	if (echeck(emailID.value)==false)
	{
		alert("Invalid E-mail Address");
		return false
	}
	return true
 }

function trySubmit()
{
	var result = ValidateForm();
	if(result)
	{
		document.form1.submit();
	}
	else
	{
	}
}


function ValidateBigForm()
{
	var error = "";

	var nameFirst = document.getElementById('First_Name');
	if(nameFirst.value.length == 0)
	{
		error += "First Name is blank.\n";
	}
	var nameLast = document.getElementById('Last_Name');
	if(nameLast.value.length == 0)
	{
		error += "Last Name is blank.\n";
	}
	/*
	var address = document.getElementById('Address');
	if(address.value.length == 0)
	{
		error += "Address is blank.\n";
	}
	*/
	/*
	var city = document.getElementById('City');
	if(city.value.length == 0)
	{
		error += "City is blank.\n";
	}
	*/
	var birthMonth = document.getElementById('Birth_Month');
	if(birthMonth.options[birthMonth.selectedIndex].value < 1)
	{
		error += "Please select a birth month.\n";
	}
	var birthYear = document.getElementById('Birth_Year');
	if(birthYear.options[birthYear.selectedIndex].value < 1)
	{
		error += "Please select a birth year.\n";
	}
	
	var spouse = document.getElementById('Spouse_First_Name');
	if(spouse.value.length > 0)
	{
		var spBirthMonth = document.getElementById('Spouse_Birth_Month');
		if(spBirthMonth.options[spBirthMonth.selectedIndex].value < 1)
		{
			error += "Please select a birth month for your spouse.\n";
		}
		var spBirthYear = document.getElementById('Spouse_Birth_Year');
		if(spBirthYear.options[spBirthYear.selectedIndex].value < 1)
		{
			error += "Please select a birth year for your spouse.\n";
		}
	}

	var state = document.getElementById('State');
	if(state.options[state.selectedIndex].value.length == 0)
	{
		error += "Please select a state.\n";
	}
	var zip = document.getElementById('Zip');
	if(zip.value.length == 0)
	{
		error += "Zip Code is blank.\n";
	}
	var email = document.getElementById('EmailBig');
	if(!echeck(email.value))
	{
		error += "Email Address is not valid.\n";
	}
	/*
	var telephone = document.getElementById('Telephone');
	if(telephone.value.length == 0)
	{
		error += "Telephone is blank.\n";
	}
	*/
	var county = document.getElementById('County');
	if(county.value.length == 0)
	{
		error += "County is blank.\n";
	}

	if(error != "")
	{
		alert("There was a problem submitting the form.\n\n" + error);
		return false;
	}
	else
	{
		return true;
	}
}

function trySubmitBigForm()
{
	var result = ValidateBigForm();
	if(result)
	{
		document.formBig.submit();
	}
}