// JavaScript Document

function checkFields()
{
	try
	{
		var form = get("form")
		var numOfFields = form.length - 2       //Minus 1 becuase we dont care about the submit button
		var pass = true                         //Determins if form is valid
		var fHilight = 0                        //Which field to select first
		
		for(var i = 0; i < numOfFields; i++)    //Itterate through all of the fields to make sure that there is a value
		{
			if(form[i].value == "")
			{
				$("#" + form[i].id).animate({ backgroundColor: "#FFFF66" }, 1000);
				
				if(fHilight == 0)
				{
					form[i].focus()
					fHilight = 1
				}
				
				pass = false
			}
			else
			{
				try {$("#" + form[i].id).animate({ backgroundColor: "#FFFFFF" }, 1000);} catch(errr) {}
			}
		}
		
		
		if(pass)                               //Check to make sure that the email is valid
		{
			pass = checkmail(form.email)
			if(!pass)
			{
				get("error").innerHTML = "Please enter a valid email address"
				$("#" + form[4].id).animate({ backgroundColor: "#FFFF66" }, 1000);
				form[4].select()
			}
		}
	}
	catch(err) {}
	
	if(!pass)
	{$("#error").slideDown(1000);}
	
	return pass //Return pass which tells the form weather to continue or not
}

function checkmail(e)
{
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	return emailfilter.test(e.value)
}

function get(id)
{
	return document.getElementById(id)	
}