var Widgets = {
    loadedClass: 'widget-load',

    loadAll: function() {
        $('.'+this.loadedClass).each(function(){
            widget = $(this);
            widget.load(widget.attr('title'));
        });
    },

    togglePropertyHistory: function() {
        historyList = $('.viewed-properties div.item-content');
        anchor = historyList.next('a');

        if ( anchor.hasClass('hide')) {
            // Now this block is open for viewing, hide last elements
            historyList.find('li:gt(1)').hide();

            // Set up new link state
            anchor.text(Lang._('Show all'));
            anchor.removeClass('hide');

        } else {
            // Now this block is close for viewing, expand all elements
            historyList.find('li:gt(1)').show();

            // Set up new lin state
            anchor.text(Lang._('Hide'));
            anchor.addClass('hide');
        }
    },

    toggleHistory: function() {
        historyList = $('.prev-searches div.item-content');
        anchor = historyList.next('a');

        items =  historyList.find('li:gt(1)');
        if ( anchor.hasClass('hide')) {
            // Now this block is open for viewing, hide last elements
            items.hide();

            // Set up new link state
            anchor.text(Lang._('Show all'));
            anchor.removeClass('hide');

        } else {
            // Now this block is close for viewing, expand all elements
            items.show();

            // Set up new lin state
            anchor.text(Lang._('Hide'));
            anchor.addClass('hide');
        }
    }
};
