// JavaScript Document

var letters = new Array();
var output;
var valid = new Boolean();

function Randomizer()
{

for (x = 0; x < 26; x++) //Fills up the array with all the lower case chars
{
	letters[x] = String.fromCharCode(x + 97);
}

output = letters[Math.floor(Math.random() * 26)];

for (y = 0; y < 9; y++) //Fills output array with the random letters
{
	output +=  letters[Math.floor(Math.random() * 26)];
}
	
	document.getElementById('Validator').innerHTML=output;
}

function formProtect() {
	document.getElementById('botprotection').setAttribute('action','_gdForm/webformmailer.asp');
	valid = true;
}
function validateForm()
{
    valid = false;
    if ( document.getElementById('verify').value != output)
    {
        alert ( 'You must correctly type the text in the box to submit this form.' );
		document.getElementById('verify').value = '';
		document.getElementById('verify').focus();
		Randomizer();
		valid = false;
    }
	else if (document.getElementById('verify').value == output)
		{
			if (document.getElementById('Name').value == " " || document.getElementById('Name').value == "" || document.getElementById('Name').value == "First")
			{
				alert('Please fill out the First name field');
				valid = false;		
			}
			else if (document.getElementById('Last Name').value == " " || document.getElementById('Last Name').value == "" || document.getElementById('Last Name').value == "Last")
			{
				alert('Please fill out the Last Name field');
				valid = false;
			}
			else if (document.getElementById('Email').value == " " || document.getElementById('Email').value == "" || document.getElementById('Email').value == "you@yourdomain.com")
			{
				alert('Please fill out the Email field');
				valid = false;
			}
			else if(document.getElementById('Email').value != " ")
			{
				var temp = document.getElementById('Email').value;
				var Bool = new Boolean();
			for(a = 0; a < temp.length; a++)
			{
				if(temp.charAt(a) == "@")
				{
					Bool = true;
					a = temp.length;
				}
				else
					Bool = false;
			}
			if (Bool != true)
				{
					valid = false;
					alert("Please input a valid email address with an @ sign.");
				}
			}
			if(Bool == true){
			formProtect(); }
		}
    return valid;
}