// JavaScript Document
function formCheck()
{
	var strName = document.getElementById('Name').value
	var strAddress = document.getElementById('Address').value
	var strCity = document.getElementById('City').value
	var strState = document.getElementById('State').value
	var strZip = document.getElementById('Zip').value
	var strPhone = document.getElementById('Phone').value
	var strEmail = document.getElementById('Email').value

	if(!isAlphabet(strName))
	{
		alert('Enter only letters for your name.')
		return false
	}

	if(!isAlphaNumeric(strAddress))
	{
		alert('Enter only letters and numbers for the address.')
		return false
	}

	if(!isAlphaNumeric(strCity))
	{
		alert('Enter only letters and numbers for the city.')
		return false
	}

	if(!isAlphabet(strState) || strState.length != 2)
	{
		alert('Please enter a valid state code')
		return false
	}
	
	if(!isZip(strZip))
	{
		alert('Please only numbers with a dash for the zip.')
		return false
	}
	
	if(!isPhone(strPhone))
	{
		alert('[0-9] (, ), -, . are the only valid charcters for the phone field.')
		return false
	}
	
	if(!isValidEmail(strEmail))
	{
		alert('The supplied email is invalid.')
		return false
	}
	
	return true

}

function isValidEmail(strString)
{
	var alphaExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;

	if(strString.match(alphaExp)){
		return true;
	}else{
		return false;
	}
}

function isAlphabet(strString)
{
	var alphaExp = /^[a-zA-Z\ \.]+$/;
	if(strString.match(alphaExp)){
		return true;
	}else{
		return false;
	}
}

function isAlphaNumeric(strString)
{
	var alphaExp = /^[0-9a-zA-Z\ \.]+$/;
	if(strString.match(alphaExp)){
		return true;
	}else{
		return false;
	}
}

function isZip(strString)
{
	var alphaExp = /^[0-9\-]+$/;
	if(strString.match(alphaExp)){
		return true;
	}else{
		return false;
	}
}

function isPhone(strString)
{
	var alphaExp = /^[0-9\-\.\(\)]+$/;
	if(strString.match(alphaExp)){
		return true;
	}else{
		return false;
	}
}

