$(document).ready(function(){
$('#email').focus(function(){
this.tempValue1 = this.value;
this.value = '';
$('#email').addClass('focused');
});
$('#email').blur(function(){
if (this.value == '') {
this.value = this.tempValue1;
}
$('#email').removeClass('focused');
});
$('#name').focus(function(){
this.tempValue1 = this.value;
this.value = '';
$('#name').addClass('focused');
});
$('#name').blur(function(){
if (this.value == '') {
this.value = this.tempValue1;
}
$('#name').removeClass('focused');
});
});

var recaptcha = {
    register: function() {
        $('.recaptchaForm').submit(recaptcha.validate);
    },

    validate: function() {
        var challenge = $('#recaptcha_challenge_field').val();
        var response  = $('#recaptcha_response_field').val();
        var infoName  = new Array();
        $('.recaptchaInfo').each(function(x){
            infoName[x] = $('#'+this.id).attr('rel');
        });
        var infoValue  = new Array();
        $('.recaptchaInfo').each(function(y){
            infoValue[y] = $('#'+this.id).val();
        });
        var strNames  = infoName.join('+++');
        var strValues = infoValue.join('+++');
        $.post('default/contact/validate-recaptcha',
            { challenge_field: challenge, response_field: response },
            function(valid) {
                if(valid) {
                    $.post('default/contact/send', { names: strNames, values: strValues },
                        function(send) {
                            if(send) {
                                $(document).attr('location','default/contact/success');
                            }
                        }, 'json'
                    );
                } else {
                    $.jGrowl("Los datos de validación no son correctos.", { header: 'Alerta', life: 10000 });
                    Recaptcha.reload ();
                }
            }, 'json'
        );
        return false;
    }
}