$.ui.widget.subclass('ui.popupWidgetBase', {
        
    _init: function() {

        var mc = this;

        $(this.element).find(".close-action").click(function( event ) {
            event.preventDefault();
            mc.hide();
        });

    },
    _setTitle: function( title ) {
        $(this.element).find("h1.title").text( title );
    },
    hide: function() {
        //
        // Skjuler svart gjennomsiktig teppe bak
        this._hideCurtain();

        $(this.element).slideUp("fast");
    },
    show: function() {
        this._show( true );
    },
    _show: function( scroll ) {
        var mc = this;

        $(this.element).slideDown("fast", function(){
            //
            // Viser svart gjennomsiktig teppe bak
            mc._showCurtain();
            if( !scroll ) return ;
            $('html, body').animate({
                scrollTop: $(mc.element).offset().top-50
            }, 750);
        });

    },
    _showCurtain: function() {

       var height = $(document).height();
       
        // Vi kan alltid juster høyden
       $(this.element).prev().css('height', height ).show();

//        if( ! $("body").children(".popup-widget-curtain:visible").length ) {
//            $(this.element).prev().show();
//        }
    },
    _hideCurtain: function() {
        $(this.element).prev().hide();
//        if( $("body").children(".popup-widget:visible").length < 2 ) {
//            $("body").children(".popup-widget-curtain:visible").hide();
//        }
    }
});
$.extend($.ui.popupWidgetBase, {
    defaults: {
        offset: 0,
        feedViewerElement: null,
        feedFullElement: null,
        toolTipPosiotion: {
             tooltip: 'rightTop',
             target: 'leftTop'
        },
        fetchLimit: 5,
        removable: false
    }
});

