var ContactUs = {};
//var SERVER = "http://192.168.0.104/anahata";



$(document).ready(function (){

    ContactUs.validator();


//VillaType.onBlurDefaultPrice();
});



ContactUs.validator = function(){
    $('#button-contact').click(function(){
        var validator = $("#PageContactForm").validate({
            rules: {
                "firstname": {
                    required: true
                    
                },
                "lastname":{
                    required : true
                },
                "email" : {
                    required : true,
					email : true
                },
				"phone" : {
                    required : true
                }
            },
            errorElement: "div",
            errorPlacement: function(error, element) {
                    error.insertAfter(element);
                    
            }
        });

        
        validator.form();

        var challengeField = $("input#recaptcha_challenge_field").val();
        var responseField = $("input#recaptcha_response_field").val();
		var host = window.location.host+"/ontelstudio.com/";
        var test = $.ajax({
            type : "POST",
            url : "http://ontelstudio.com/get_captcha.php",
            data: ({
                recaptcha_challenge_field : challengeField,
                recaptcha_response_field: responseField
            }),
            dataType: "html",
            async: false

        }).responseText;


        if( (test.replace('^\s+|\s+$', '') == "True") && validator.form()){
            $("#PageContactForm").submit();
        }
        else{

            $(".errorRecaptcha").html("Please type the two words above.");
            Recaptcha.reload();
            return false;
        }
		
    });


}

