/** Takes input from a contact field, sends an email to agent.
	email is defined in config file.
	*/
function contactForm(div) {
	
	var contactDiv = div;
	var button = div.find("input[type=button]");
	
	button.click(function() {
		name = contactDiv.find("input[name=name]").val();
		email = contactDiv.find("input[name=email]").val();
		comment = contactDiv.find("textarea").val();
		fullName = name.split(" ");
		url = window.location.href;
		
		if(name=="") {
			alert("Please enter your name");
			return null;
		}
		else if(fullName.length<2) {
			alert("Please enter your first and last name");
			return null;		
		}
		else if(email=="") {
			alert("Please enter your email");
			return null;
		}
		else if(comment=="") {
			alert("Please enter a message");
			return null;
		}

		$.ajax({
			type: "POST",
			url: "/includes/ajax/contactUs.php",
			data: "&name=" +name+"&email="+email+"&comment=" +comment+"&url="+url,
			//data: "&name=" +name+"&email="+email+"&comment=" +comment,
			success: function(){
				alert("Thanks! We'll get in touch with you as soon as possible.");
			}
	 	});
	});
	

	
}
