var form_valid 	= 7
var namef_valid = 1
var address_valid = 1
var city_res_valid = 1
var state_valid = 1
var zip_valid = 1
var phone_valid = 1
var email_valid = 1

function initform()
{
	document.VIOF_form.namef.focus()
}

function helpme(field)
{
	if (field == 'namef')
	alert("Please enter First and Last Name.\nIt must be longer than 5 characters.")
	if (field == 'address')
		alert("Please enter Mailing Address.\nIt must be longer than 5 characters.")
	if (field == 'city_res')
		alert("Please enter City of residence.\nIt must be logner than 3 characters.")
	if (field == 'state')
		alert("Please enter State of residence.\nAbbreviations are accepted.")
	if (field == 'zip')
		alert("Please enter Zip Code.\nIt must be 5 Digits.")
	if (field == 'phone')
		alert("Please enter Phone Number.\nArea Code must be included.")
	if (field == 'mailfrom')
		alert("Please enter E-mail Address.\nIt must be valid to receive the order.")
 
	if (field == 'fileselect')
		alert("Current is the list of current voters. Selecting Historical\nallows a selection of voters based upon past elections.")
	if (field == 'suspvoter')
		alert("Suspended voters are not elligible to\nvote, but were at one time.")
	if (field == 'precinct')
		alert("To sort the list via precinct, do so here.\nIf not, leave blank.")
	if (field == 'city_form')
		alert("To sort the list via city, do so here.\nIf not, leave blank.")
	if (field == 'school')
		alert("To sort the list via school districts, do so here.\nIf not, leave blank.")
	if (field == 'eledate')
		alert("To sort the list via past elections voted in,\ndo so here. If not, leave blank.")
	if (field == 'party')
		alert("To sort the list via party choices for primary\nelections, do so here. If not, leave blank.")
	if (field == 'moreinfo')
		alert("To add any additional information, do so here.")

	if (field == 'ophouse')
		alert("To list each household once in a physical file, select yes.")
	if (field == 'sort')
		alert("To sort the file by addresses or by last names, do so here.\nThe addresses are sorted alphabetically, not by city.")
	if (field == 'receive')
		alert("If order is mailed, payments must be received\nbefore the request is processed.")
	if (field == 'medium')
		alert("Price list\nCD ... $10\nE-mail ... $10\nLaser Labels ... $0.02 per label\nLoose Leaf Paper ... $5 fee, $0.10 per page")
	if (field == 'dformat')
		alert("If not sure which digital format to choose, Suggestion:\nMicrosoft Excel and dBase are the most versitile of the formats listed.")
}

function checklength(field, minlength)
{
	if (eval("document.VIOF_form."+field+".value.length") >= minlength)
	{
		var num = eval(field+"_valid")
		if (num == 1)
		{
			eval(field+"_valid = 0")
			form_valid -= 1
		}
	}
}

function checkemail()
{
	var maillength = document.VIOF_form.mailfrom.value.length
	var atlocation = document.VIOF_form.mailfrom.value.indexOf("@")
	if (atlocation >= 4)
	{
		if ((maillength-atlocation) >= 5)
		{
			if (email_valid == 1)
			{
				email_valid = 0
				form_valid -= 1
			}
		}
	}
}

function fliphistorical()
{
	if (document.VIOF_form.fileselect[0].checked)
	{
		document.getElementById('hist_hide_1').style.display = "none";
		document.getElementById('hist_hide_2').style.display = "none";
	}
	if (document.VIOF_form.fileselect[1].checked)
	{
		document.getElementById('hist_hide_1').style.display = "block";
		document.getElementById('hist_hide_2').style.display = "block";
	}
}

function flipformat()
{
	if (document.VIOF_form.medium[0].checked)
		document.getElementById('format_hide').style.display = "block";
	if (document.VIOF_form.medium[1].checked)
		document.getElementById('format_hide').style.display = "block";
	if (document.VIOF_form.medium[2].checked)
		document.getElementById('format_hide').style.display = "none";
	if (document.VIOF_form.medium[3].checked)
		document.getElementById('format_hide').style.display = "none";
}

function checkvalid()
{
	if (document.VIOF_form.affidavit[0].checked)
	{
		alert("Agreement to the affidavit must be made to submit the form.")
		return false
	}
	else
	{
		if (form_valid == 0)
		{
			return true
		}
		else
		{
			if (namef_valid == 1)
			{
				alert("Check the name field.")
				return false
			}
			if (address_valid == 1)
			{
				alert("Check the address field.")
				return false
			}
			if (city_res_valid == 1)
			{
				alert("Check the city field.")
				return false
			}
			if (state_valid == 1)
			{
				alert("Check the state field.")
				return false
			}
			if (zip_valid == 1)
			{
				alert("Check the zip field.")
				return false
			}
			if (phone_valid == 1)
			{
				alert("Check the phone field.")
				return false
			}
			if (email_valid == 1)
			{
				alert("Check the email field.")
				return false
			}
		}
	}
}