$(document).ready(function () {
    
    $("#newsletter-reg-trigger").click(function(event){
        event.stopPropagation();
        $(this).siblings('.newsletter-reg').fadeToggle();
        return false;
    })
    
    $('#register-newsletter').submit(function(){
        var data = $(this).serialize();
        $.post(
            $(this).attr('data-submit-url'),
            data,
            function(result) {
                if(result.status == '1') {
                    $('.bottom-mess.success').fadeIn();
                    $('.newsletter-reg').hide();
                    $('#register-newsletter')[0].reset();
                    setTimeout(function() { $('.bottom-mess.success').fadeOut(); }, 5000);                    

                }else{
                    $('.bottom-mess.fail').fadeIn();
                    setTimeout(function() { $('.bottom-mess.fail').fadeOut(); }, 5000);
                }
            },
            "json"
        );
        return false;
    });
    
    $('.bottom-mess.success').hide();    
    $('.bottom-mess.fail').hide();    

});
