function checkForm() {	
	var name = document.getElementById("name").value;
	var email = document.getElementById("email").value;
	var comments = document.getElementById("comments").value;
	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 (comments == "") {
		hideAllErrors();
		document.getElementById("commentsError").style.display = "block";
		document.getElementById("comments").select();
		document.getElementById("comments").focus();
		return false;
	}else {
	    hideAllErrors();
        document.getElementById("loading_gif2").style.display = "block";
	    sendemail();
		return true;
		
	}
}
function hideAllErrors() {
	document.getElementById("nameError").style.display = "none";
	document.getElementById("emailError").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 name = document.quick_form.name.value;
	var email = document.quick_form.email.value;
	var comments = document.quick_form.comments.value;
	document.quick_form.send.disabled = true;
	document.quick_form.send.value = 'Sending....';
    http.open('get', 'js/quick_contact.php?name='+name+'&email='+email+'&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];
		}
	}
}