jQuery(document).ready(function(){
 function validateCaptcha()
        {
            challengeField = jQuery("input#recaptcha_challenge_field").val();
            responseField = jQuery("input#recaptcha_response_field").val();
            //alert(challengeField);
            //alert(responseField);
            //return false;
            var html = jQuery.ajax({
            type: "POST",
            url: "http://www.vanitiesonsale.com/ajax.recaptcha.php",
            data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
            async: false
            }).responseText;
			alert(html);
            if (html == "success")
            {
                jQuery(".note-msg").html(" ");
                // Uncomment the following line in your application
                return true;
            }
            else
            {
				jQuery('#contactform').before('<span class="response"><div class="error-msg">Your captcha is incorrect. Please try again.</div></span>');
                Recaptcha.reload();
                return false;
            }
        }
jQuery('#contactform').submit(function(){
	
	var action = jQuery(this).attr('action');
	var $_SKIN_URL = "<?php echo $this->getSkinUrl();?>";
	jQuery('#submit')
		.before('<img src="'+$_SKIN_URL+'quickcontact/images/opc-ajax-loader.gif" class="loader" style="padding-right:10px;"/>')
        
		.attr('disabled','disabled');

    
	jQuery.post(action, jQuery('#contactform').serialize(true),
		function(data){
			jQuery('#contactform #submit').attr('disabled','');
			jQuery('.response').remove();
			jQuery('#contactform').before('<span class="response">'+data+'</span>');
			jQuery('.response').slideDown();
			if ( jQuery('.response').text().indexOf('Thank you') != -1 ) { 
				jQuery('#subject').val('');
				jQuery('#content').val('');
				return validateCaptcha();
			}
			jQuery('#contactform img.loader').fadeOut(500,function(){jQuery(this).remove()});
		}
	);

	return false;

});
});
