function refreshCaptcha()
{
	var img = document.images['captchaimg'];
	img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}

function checkForm(Form){
	if (Form.name.value == ""){
		alert("You must provide your name.")
		return false
	}
	if (Form.company.value == ""){
		alert("You must provide your company name.")
		return false
	}
	
	if(!ValidPhone(Form.phone.value)){
		return false
	}
	
	if (Form.email.value == ""){
		alert("You must provide an Email address.")
		return false
	}
	
	if (Form.city.value == ""){
		alert("You must provide the city where you are located.")
		return false
	}
	if (Form.state.value == ""){
		alert("You must provide the state where you are located.")
		return false
	}
	if (Form.category.value == ""){
		alert("You must provide the category you are interested in.")
		return false
	}
	if (Form.captcha.value == ""){
		alert("You must enter in the captcha.")
		return false
	}
	if (!validateEmail(Form.email.value)){
		alert("You must provide a valid Email address.")
		return false
	}
	
	return true
	
}

function validateEmail(emailAddress){
	atPos = emailAddress.indexOf("@",1)
	periodPos = emailAddress.indexOf(".",atPos)
	
	if (atPos == -1){
		return false
	}
	
	if (periodPos == -1){
		return false
	}
	
	if ((periodPos - atPos) < 3 ){
		return false
	}
	
	if ((emailAddress.length - periodPos) < 3){
		return false
	}
	
	return true

}

function ValidPhone(phone)
{
	var valid = "0123456789-";

		if(phone=="")
		{
		alert("You must provide your phone number.")
		return false
		}
		
		if(phone.length != 12)
		{
		alert("Invalid phone number. Format must be xxx-xxx-xxxx.")
		return false
		}
		
		
		for (var i=0; i < phone.length; i++)
		{
		temp = "" + phone.substring(i, i+1);
		
		
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your phone number. Format must be xxx-xxx-xxxx.")
			return false;
			}
		}
		
	
		return true
}
