
$(document).ready(function() {

        //using ajax submit

       var v = jQuery('#frm').bind('invalid-form.validate', function() {
               $('#notif-box').html('Please correct/complete all required fields marked in red!');
        }).validate({
                errorContainer: $('#notif-box'),
                errorElement: 'p',
                errorClass: 'errorBox',

                submitHandler: function(form) {
                        jQuery(form).ajaxSubmit({
                                //target: '#notification',
                                //dataType:  'json',
                                beforeSubmit:   showPre,
                                success:       showResponse  // post-submit callback
                        });
                }
        });

        function showPre(){
            $('#notification').show();
        }
        function showResponse(data){
                if (data.indexOf('true')>=0){
                    data = 'Successfully shared!';
                }

                $('#notification').html(data);
                $('#notification').show();

                 setTimeout(function() {
                    $('#notification').hide()
                    $('#notification').html('Sharing...');
                    $('.div.sharePopup').hide();
                    $('#frm')[0].reset();

                }, 2000);
        }

        var v2 = jQuery('#frm2').bind('invalid-form.validate', function() {
               $('#notif-box').html('Please correct/complete all required fields marked in red!');
        }).validate({
                errorContainer: $('#notif-box'),
                errorElement: 'p',
                errorClass: 'errorBox',

                submitHandler: function(form) {
                        jQuery(form).ajaxSubmit({
                                //target: '#notification',
                                //dataType:  'json',
                                beforeSubmit:   showPre2,
                                success:       showResponse2  // post-submit callback
                        });
                }
        });

        function showPre2(){
            $('#notification2').show();
        }
        function showResponse2(data){
                if (data.indexOf('true')>=0){
                    data = 'Successfully shared!';
                }

                $('#notification2').html(data);
                $('#notification2').show();

                 setTimeout(function() {
                    $('#notification2').hide()
                    $('#notification2').html('Sharing...');
                    $('.div.sharePopup').hide();
                    $('#frm2')[0].reset();

                }, 2000);
        }


         var subV = jQuery('#subFrm').bind('invalid-form.validate', function() {
               //something
        }).validate({
                //errorContainer: $('#fEmail'),
               // errorElement: 'p',
               // errorClass: 'errorBox',

                submitHandler: function(form) {
                        jQuery(form).ajaxSubmit({
                                beforeSubmit:   showPreSub,
                                success:       showResponseSub  // post-submit callback
                        });
                }
        });

        function showPreSub(){
            $('#fEmail').val('Sending...');
        }
        function showResponseSub(data){
                $('#fEmail').val(data);
        }
});

