	function validateEmailv2(email){
	// a very simple email validation checking. 
	// you can add more complex email checking if it helps 
		if(email.length <= 0) {
			return true;
		}
		var splitted = email.match("^(.+)@(.+)$");
		if(splitted == null) return false;
		if(splitted[1] != null ) {
			var regexp_user=/^\"?[\w-_\.]*\"?$/;
			if(splitted[1].match(regexp_user) == null) return false;
		}
		if(splitted[2] != null)	{
			var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
			if(splitted[2].match(regexp_domain) == null) {
				var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
				if(splitted[2].match(regexp_ip) == null) return false;
			}// if
			return true;
		}
		return false;
	}

	function checkContactForm() {
		if ((document.getElementById('fullname').value != '') && 
			(validateEmailv2(document.getElementById('email').value)) && 
			(document.getElementById('phone').value != '')) {
			return true;
		} else {
			return false;
		}
	}
	
	function makeContact() {
	  if (checkContactForm()) {
			var request = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
			request.open("POST", "makecontact.php", true);
			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			request.onreadystatechange = function(){
				if (request.readyState == 4){
					document.getElementById('fullname').value = '';
					document.getElementById('phone').value = '';
					document.getElementById('email').value = '';
					document.getElementById('message').value = '';
					alert(request.responseText);
				}
			};
			request.send("name=" + document.getElementById('fullname').value + "&email=" + document.getElementById('email').value + "&phone=" + document.getElementById('phone').value + "&message=" + encodeURI(document.getElementById('message').value));
		} else {
		  alert('Please complete each of the fields and ensure the email address is valid.');
		}	
		return false;
	}
