function changeStateSelect(e)
{
	document.getElementById("selecttext").innerHTML = e[e.selectedIndex].innerHTML;	
}

function clearForm()
{
	var theForm = document.getElementById("contactform");
	var textArray = new Array();
	textArray.push(theForm.name);
	textArray.push(theForm.address);
	textArray.push(theForm.city);
	textArray.push(theForm.zip);
	textArray.push(theForm.phone);
	textArray.push(theForm.email);
	textArray.push(theForm.org);
	textArray.push(theForm.question);
	for (var i = 0; i < textArray.length; i++)
	{
		textArray[i].value = "";
		textArray[i].style.color = "black";
	}
	document.getElementById("state").selectedIndex = 0;
	document.getElementById("selecttext").innerHTML = "Select a State";
	document.getElementById("selecttext").style.color = "black";
}

function validateContactForm()
{
	var theForm = document.getElementById("contactform");
	var textArray = new Array();
	textArray.push(theForm.name);
	textArray.push(theForm.address);
	textArray.push(theForm.city);
	textArray.push(theForm.zip);
	textArray.push(theForm.phone);
	textArray.push(theForm.email);
	textArray.push(theForm.org);
	textArray.push(theForm.question);
	var emailRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var phoneRegExp = /^(\()?([0-9]{3})(\)|-)?([0-9]{3})(-)?([0-9]{4}|[0-9]{4})(\ ?)([xX]?([" "0-9]{1,5}))?$/;
	var zipRegExp = /^[0-9]{5}$/;
	var passVal = new Boolean(true);
	
	for (var i = 0; i < textArray.length; i++)
	{
		if (textArray[i].value == "" || textArray[i].value == "Please complete this field" )
		{
			textArray[i].value = "Please complete this field";
			textArray[i].style.color = "red";
			passVal = false;
		}
		if (textArray[i].name == 'email' && !emailRegExp.test(textArray[i].value))
		{
			passVal = false;
			textArray[i].value = "Please enter a valid email";
			textArray[i].style.color = "red";
		}
		if (textArray[i].name == 'phone' && !phoneRegExp.test(textArray[i].value))
		{
			passVal = false;
			textArray[i].value = "Please enter a valid phone number - (555)555-1234 (ext's ok)";
			textArray[i].style.color = "red";
		}
		if (textArray[i].name == 'zip' && !zipRegExp.test(textArray[i].value))
		{
			passVal = false;
			textArray[i].value = "Please enter a valid 5 digit zip code";
			textArray[i].style.color = "red";
		}
		textArray[i].onfocus = function() { this.style.color = "black"; };
	}
	document.getElementById("state").onfocus = function() { document.getElementById("selecttext").style.color = "black"; };
	
	if (document.getElementById("state").value == "")
	{
		passVal = false;
		document.getElementById("selecttext").style.color = "red";
	}
	
	if (passVal != true)
	{
		return false;
	}
	else {
		
		return true;
	}
}