$.fn.clearForm = function() {
  return this.each(function() {
	var type = this.type, tag = this.tagName.toLowerCase();
	if (tag == 'form')
	  return $(':input',this).clearForm();
	if (type == 'text' || type == 'password' || tag == 'textarea')
	  this.value = '';
	else if (type == 'checkbox' || type == 'radio')
	  this.checked = false;
	else if (tag == 'select')
	  this.selectedIndex = -1;
  });
};

function validateContactRequest() {

	if($("#log_name").val()==""){
		alert("Please enter your name");
		$("#log_name").focus();
		return false;
	}
	if($("#log_email").val()==""){
		alert("Please enter your email address");
		$("#log_email").focus();
		return false;
	} else {
		var email_pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/i;
		if(!email_pattern.test($("#log_email").val())) {
			alert("Please provide a valid email address.");
			$("#log_email").val('');
			$("#log_email").focus();
			return false;
		}
	}
	if($("#log_phone").val()==""){
		alert("Please enter your phone number");
		$("#log_phone").focus();
		return false;
	}
	return true;

}