jQuery(document).ready(function ($) {
        
    $.note.options.viewport = $.notecontroller.note_count;
    $.note.init();

});

(function ($) {
    
    //Extends jQuery's namespace
    $.note = {};
    
    //Default settings
    $.note.options = {
        viewport: ''
    };
    
    //Initialize the basket module
    //and binds the needed events
    $.note.init = function () {
        
        var width = 660;
        var position = 'fixed';
        
        if($.browser.msie && parseInt($.browser.version) == 6) {
            var width = width - 10;
            var position = 'absolute';
        }
          
        var modalConfig = {
            'position': position,
            'animationSpeed': 200,
            'width': width+'px',
            'textContainer': '<div>',
            'textClass': 'ajax_add_article_container'
        };
        var sliderConfig = {
            'headline': false,
            'navigation': false,
            'scrollSpeed': 800,
            'rotate': false,
            'width':630,
            'height': 210,
            'scrollWidth': 578,
            'containerCSS': {
                'margin': '0 0 15px 15px'
            }
        };
        
        $('a.addToNote').live('click', function (event) {
            event.preventDefault();
            $.ajax({
                'dataType': 'jsonp',
                'beforeSend': function() {
                    $.loadingIndicator.open();
                },
                'url': $(this).attr('href'),
                'success': function (result) {
                    $.loadingIndicator.close();
                    $.modal(result, '', modalConfig);
                    $('#lbOverlay').css('opacity', '0').show().fadeTo('fast', '0.3');
                    
                    $('.slider_modal').ajaxSlider('locale', sliderConfig);
                    
                    $('.modal .close').hide();
                    $.note.refreshDisplay();
                }
            })
        });
    };
    
    //Refreshs the note display
    $.note.refreshDisplay = function () {
        $.ajax({
            'dataType': 'jsonp',
            'url': $.note.options.viewport,
            'success': function (result) {
                $('.notecount').html(result);
            }
        })
    };
    
})(jQuery);
