var PortletDraggable = function () {

    return {
        //main function to initiate the module
        init: function (elem, options) {

            if (!jQuery().sortable) {
                return;
            }
            var defaults = {
                connectWith: ".portlet",
                items: ".portlet",
                opacity: 0.8,
                coneHelperSize: true,
                placeholder: 'portlet-sortable-placeholder',
                forcePlaceholderSize: true,
                tolerance: "pointer",
                helper: "clone",
                tolerance: "pointer",
                forcePlaceholderSize: !0,
                helper: "clone",
                cancel: ".portlet-sortable-empty",
                revert: 250, // animation in milliseconds
                update: function(b, c) {
                    if (c.item.prev().hasClass("portlet-sortable-empty")) {
                        c.item.prev().before(c.item);
                    }
                }
            };

            options = $.extend(defaults, options);

            if (!elem) {
                elem = $("#sortable_portlets");
            }

            elem.sortable(options);
        }
    };
}();
