J.sidebar = {
    
    
    open_share_list : function () {
        $.get('/products/sidebar/share_wishlist_form/', {}, function(form_data) {
            Shadowbox.open({
                player:     'html',
                title:         '',
                content:     form_data,
                width:         380,
                height:        300
            },{
                overlayOpacity : .7,
                enableKeys: false,
                onFinish : function(inst) {
                    J.app.setup_input_labels($('#shadowbox_content'));
                    $('#share_wishlist_form').ajaxForm({ 
                        dataType : 'json',
                        success : function(data) {
                            if(data.success){
                                // close the lightbox
                                J.app.create_message(data.message);
                                Shadowbox.close();
                            }else{
                                J.app.display_form_errors(data.errors);
                            }
                        },
                        error : function (data) {
                            console.log('error:' +data);
                        }
                    });                    
                }
            });
        });        
    },

    open_newsletter_form : function () {
        $.get('/products/sidebar/newsletter_form/', {}, function(form_data) {
            Shadowbox.open({
                player:     'html',
                title:         '',
                content:     form_data,
                width:         380,
                height:        270
            },{
                overlayOpacity : .7,
                enableKeys: false,
                onFinish : function(inst) {
                    J.app.setup_input_labels($('#shadowbox_content'));
                    $('#newsletter_form').ajaxForm({
                        dataType : 'json',
                        success : function(data) {
                            if(data.success){
                                // close the lightbox
                                J.app.create_message(data.message);
                                Shadowbox.close();
                            }else{
                                J.app.display_form_errors(data.errors);
                            }
                        },
                        error : function (data) {
                            console.log('error:' +data);
                        }
                    });                    
                }
            });
        });        
    },

    open_price_request_form : function () {
        $.get('/products/sidebar/price_request_form/', {}, function(form_data) {
            Shadowbox.open({
                player:     'html',
                title:         '',
                content:     form_data,
                width:         380,
                height:        430
            },{
                overlayOpacity : .7,
                enableKeys: false,
                onFinish : function(inst) {
                    J.app.setup_input_labels($('#shadowbox_content'));
                    $('#price_request_form').ajaxForm({
                        dataType : 'json',
                        success : function(data) {
                            if(data.success){
                                // close the lightbox
                                J.app.create_message(data.message);
                                Shadowbox.close();
                            }else{
                                J.app.display_form_errors(data.errors);
                            }
                        },
                        error : function (data) {
                            console.log('error:' + data.message);
                        }
                    });                    
                }
            });
        });        
    },
    
    
    open_login_form : function () {
        $.get('/products/sidebar/login_form/', {}, function(form_data) {
            Shadowbox.open({
                player:     'html',
                title:         '',
                content:     form_data,
                width:         240,
                height:        230
            },{
                overlayOpacity : .7,
                enableKeys: false,
                onFinish : function(inst) {
                    J.app.setup_input_labels($('#shadowbox_content'));
                    // $('#price_request_form').ajaxForm({
                    //     dataType : 'json',
                    //     success : function(data) {
                    //         if(data.success){
                    //             // close the lightbox
                    //             J.app.create_message(data.message);
                    //             Shadowbox.close();
                    //         }else{
                    //             J.app.display_form_errors(data.errors);
                    //         }
                    //     },
                    //     error : function (data) {
                    //         console.log('error:' + data.message);
                    //     }
                    // });                    
                }
            });
        });        
    }
    
    
};