function submitForm(form) {
	form = $(form);

	// validate each field
	var valid = true;

	form.find(".inputField, textarea").each(function() {
		var f = $(this);
		if (f.val().length < 3) {
		  alert(f.attr("name").replace("_", " ") + " field is empty");
		  f.get(0).focus();
		  valid = false;
		  return false;
		}
	});

	if (!valid) return false;

	form.fadeTo(400, 0.3);

	$.getJSON("/services/sendMail?" + form.serialize(), function(json) {
		form.fadeTo(400, 1);

		if (json.message) {
			form.find("div.error").html(json.message).show();

		} else {
			form.html(
				'<div class="box info">The form was successfully submitted. You will be contacted soon</div>'
			);
		}
	});

	return false;
}

