// JavaScript Document
function captchaRefresh(){
	window.document.getElementById('captcha_img').src = "captcha/captcha.php?width=154&height=50&characters=5&tmt="+Math.random();
}

function Trim(trstr){
	trstr = LTrim(trstr);
	return RTrim(trstr);
}

var eol = '\r\n';
function RTrim(trstr){
	while(trstr.charAt((trstr.length -1))==" " || trstr.charAt((trstr.length -1)) == eol){
		trstr = trstr.substring(0,trstr.length-1);
	}
	return trstr;
}

function LTrim(trstr){
	while(trstr.charAt(0)==" " || trstr.charAt((trstr.length -1)) == eol){
		trstr = trstr.replace(trstr.charAt(0),"");
	}
	return trstr;
}

function validateForm(){
	var f = window.document.form;
	//validate name
	if(Trim(f.name.value) == ''){
		alert('Please complete the name field');
		f.name.focus();
		return false;
	}
	
	//validate email
	if(Trim(f.email.value) == ''){
		alert('Please complete the email field');
		f.email.focus();
		return false;
	}
	
	//validate address
	if(Trim(f.address.value) == ''){
		alert('Please complete the address field');
		f.address.focus();
		return false;
	}
	
	//validate city
	if(Trim(f.city.value) == ''){
		alert('Please complete the city field');
		f.city.focus();
		return false;
	}
	
	//validate state
	if(Trim(f.state.value) == ''){
		alert('Please complete the state field');
		f.state.focus();
		return false;
	}
	
	//validate zip
	if(Trim(f.zip.value) == ''){
		alert('Please complete the zip field');
		f.zip.focus();
		return false;
	}
	
	//validate day phone
	if(Trim(f.day_phone.value) == ''){
		alert('Please complete the day phone field');
		f.day_phone.focus();
		return false;
	}
	
	//validate Captcha
	if(Trim(f.security_code.value) == ''){
		alert('Please enter the verification code');
		f.day_phone.focus();
		return false;
	}
}