
/*
 * Minimal theme for the Captcha
 */
var RecaptchaOptions = {
	theme: 'clean'
};

/* 
 * validateCaptcha
 * Partial AJAX Validation for the form
 */
function validateCaptcha() {	
	challengeField = $("input#recaptcha_challenge_field").val();
	responseField = $("input#recaptcha_response_field").val();

	var html = $.ajax({
		type: "POST",
		url: "includes/process.php",
		data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
		async: false
	}).responseText;
	
	
	if(html == "success")
	{
		$("#captchaStatus").html("");
		// Check to make sure all the required fields are filled in.
		var name = $("#nameInput").val();
		var company = $("#companyInput").val();
		var description = $("#descriptionInput").val();
		var phone = $("#phoneInput").val();
		var email = $("#emailInput").val();
		var message = $("#messageInput").val();
		
		if (name == "") 
		{
			Recaptcha.reload();
			$("#nameInput").focus();
			$("#nameError").html("Name is a required field");
			
			return false;
		}
		
		if (email == "") 
		{
			Recaptcha.reload();
			$("#emailInput").focus();
			$("#emailError").html("Email is a required field");
			
			return false;
		}
		
		if (message == "") 
		{
			Recaptcha.reload();
			$("#messageInput").focus();
			$("#messageError").html("Message is a required field");
			
			return false;
		}
		
	
		var dataString = 'name=' + name + '&company=' + company + '&description=' + description + '&phone=' + phone + '&email=' + email + '&message=' + message;
		
		//alert(dataString);
		
		// /*
		$.ajax({
			type: "POST",
			cache: false,
			url: "includes/sendEmail.php",
			data: dataString,
			success: function(html) {
				$('#contactForm').html(html)
				.hide()
				.fadeIn(1500, function() {
					$('#message').append("<img id='checkmark' src='images/check.png' />");
				});
			}
		}); 
		// */
		
		return false;
		}
	else
	{
		// On Captcha failure we'll tell the user what is wrong then reload a new captcha and focus it.
		$("#captchaStatus").html("Your captcha is incorrect. Please try again");
		Recaptcha.reload();
		return false;
	}
}
