function init() {
	setInterval("rotImg();",5000);
	return true;
}

function validateForm() {
	var fError = false;
	var tdError = document.getElementById('tdError');
	var rFields = new Array(6);
	rFields[0] = document.getElementById('txtName');
	rFields[1] = document.getElementById('txtAddress');
	rFields[2] = document.getElementById('txtEmail');
	rFields[3] = document.getElementById('txtCity');
	rFields[4] = document.getElementById('txtState');
	rFields[5] = document.getElementById('txtZip');

	for(f in rFields) {
		if(rFields[f].value == '') {
			fError = true;
			rFields[f].className = 'error';
		} else {
			rFields[f].className = '';
		}
	}

	if(fError == false) {
		var qString = '?';
		qString += 'txtName='+document.getElementById('txtName').value;
		qString += '&txtAddress='+document.getElementById('txtAddress').value;
		qString += '&txtAddress2='+document.getElementById('txtAddress2').value;
		qString += '&txtCity='+document.getElementById('txtCity').value;
		qString += '&txtState='+document.getElementById('txtState').value;
		qString += '&txtZip='+document.getElementById('txtZip').value;
		qString += '&txtPhone1='+document.getElementById('txtPhone1').value;
		qString += '&txtPhone2='+document.getElementById('txtPhone2').value;
		qString += '&txtFax='+document.getElementById('txtFax').value;
		qString += '&txtEmail='+document.getElementById('txtEmail').value;
		qString += '&txtComment='+document.getElementById('txtComment').value;
		qString += '&request='+document.getElementById('request').value;

		var AJAX = zXmlHttp.createRequest();
		AJAX.open("get", "php/form.php"+qString, true);
		AJAX.onreadystatechange = function() {
			if(AJAX.readyState == 4) {
				if(AJAX.status == 200) {
					if(/Thank.*/.test(AJAX.responseText)) {
						tdError.innerHTML = AJAX.responseText;
					} else {
						tdError.innerHTML = 'There was an error processing your request, please contact us by phone.';
					}
					document.form1.reset();
				}
			} else {
				//tdError.innerHTML = AJAX.statusText;
			}
		};
		AJAX.send(null);
	} else {
		tdError.innerHTML = 'There are errors in this form, please correct the fields marked in <span class="req">red</span>.';
		return true;
	}
}

function rotImg() {
	var imgList = new Array(10);
	imgList[0] = 'http://www.sohac.com/img/comfort.jpg';
	imgList[1] = 'http://www.sohac.com/img/SOH1.jpg';
	imgList[2] = 'http://www.sohac.com/img/SOH2.jpg';
	imgList[3] = 'http://www.sohac.com/img/SOH3.jpg';
	imgList[4] = 'http://www.sohac.com/img/SOH4.jpg';
	imgList[5] = 'http://www.sohac.com/img/SOH5.jpg';
	imgList[6] = 'http://www.sohac.com/img/SOH6.jpg';
	imgList[7] = 'http://www.sohac.com/img/SOH7.jpg';
	imgList[8] = 'http://www.sohac.com/img/SOH8.jpg';
	imgList[9] = 'http://www.sohac.com/img/SOH9.jpg';
	for(foo in imgList) {
		if(document.getElementById('rotImg').src == imgList[foo]) var nImg = (parseInt(foo) + 1);
	}
	if(nImg > 9) nImg = 0;
	document.getElementById('rotImg').src = imgList[nImg];
}
