function checkForm() {
	var position = document.getElementById("position").value;	
	var name = document.getElementById("name").value;
	var email = document.getElementById("email").value;
	var company = document.getElementById("company").value;
	var address = document.getElementById("address").value;
	var state = document.getElementById("state").value;
	var city = document.getElementById("city").value;
	var zip = document.getElementById("zip").value;
	var phone = document.getElementById("phone").value;
	var fax = document.getElementById("fax").value;
	var comments = document.getElementById("comments").value;
	if (position == "") {
		hideAllErrors();
		document.getElementById("positionError").style.display = "block";
		document.getElementById("position").select();
		document.getElementById("position").focus();
		return false;
	}
	if (name == "") {
		hideAllErrors();
		document.getElementById("nameError").style.display = "block";
		document.getElementById("name").select();
		document.getElementById("name").focus();
		return false;
	} if (email == "" || email.indexOf("@") == -1 || email.indexOf(".") == -1) {
		hideAllErrors();
		document.getElementById("emailError").style.display = "block";
		document.getElementById("email").select();
		document.getElementById("email").focus();
		return false;
	}if (company == "") {
		hideAllErrors();
		document.getElementById("companyError").style.display = "block";
		document.getElementById("company").select();
		document.getElementById("company").focus();
		return false;
	}if (address == "") {
		hideAllErrors();
		document.getElementById("addressError").style.display = "block";
		document.getElementById("address").select();
		document.getElementById("address").focus();
		return false;
	}if (state == "") {
		hideAllErrors();
		document.getElementById("stateError").style.display = "block";
		document.getElementById("state").select();
		document.getElementById("state").focus();
		return false;
	}if (city == "") {
		hideAllErrors();
		document.getElementById("cityError").style.display = "block";
		document.getElementById("city").select();
		document.getElementById("city").focus();
		return false;
	}if (zip == "") {
		hideAllErrors();
		document.getElementById("zipError").style.display = "block";
		document.getElementById("zip").select();
		document.getElementById("zip").focus();
		return false;
	}if (phone == "") {
		hideAllErrors();
		document.getElementById("phoneError").style.display = "block";
		document.getElementById("phone").select();
		document.getElementById("phone").focus();
		return false;
	}if (comments == "") {
		hideAllErrors();
		document.getElementById("commentsError").style.display = "block";
		document.getElementById("comments").select();
		document.getElementById("comments").focus();
		return false;
	}else {
	    hideAllErrors();
        document.getElementById("loading_gif").style.display = "block";
	    sendemail();
		return true;
		
	}
}
function hideAllErrors() {
	document.getElementById("positionError").style.display = "none";	
	document.getElementById("nameError").style.display = "none";
	document.getElementById("emailError").style.display = "none";
	document.getElementById("companyError").style.display = "none";
	document.getElementById("addressError").style.display = "none";
	document.getElementById("stateError").style.display = "none";
	document.getElementById("cityError").style.display = "none";
	document.getElementById("zipError").style.display = "none";
	document.getElementById("phoneError").style.display = "none";
	document.getElementById("commentsError").style.display = "none";
}

/* AJAX CALL*/
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		ro = new XMLHttpRequest();
	}
	return ro;
}
var http = createRequestObject();
function sendemail() {
    var position = document.employment_form.position.value;
	var name = document.employment_form.name.value;
	var email = document.employment_form.email.value;
	var company = document.employment_form.company.value;
	var address = document.employment_form.address.value;
	var state = document.employment_form.state.value;
	var city = document.employment_form.city.value;
	var zip = document.employment_form.zip.value;
	var phone = document.employment_form.phone.value;
	var fax = document.employment_form.fax.value;
	var comments = document.employment_form.comments.value;
	document.employment_form.send.disabled = true;
	document.employment_form.send.value = 'Sending....';
    http.open('get', 'js/employment_contact.php?position='+position+'&company='+company+'&name='+name+'&email='+email+'&address='+address+'&state='+state+'&city='+city+'&zip='+zip+'&fax='+fax+'&phone='+phone+'&comments='+comments+'&action=send');
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function handleResponse() {
	if (http.readyState == 4) {
		var response = http.responseText;
		var update = new Array();
		if (response.indexOf('|' != -1)) {
			update = response.split('|');
			document.getElementById(update[0]).innerHTML = update[1];
		}
	}
}
