(function ($) {
// attach to jQuery
    $.extend({
        groupSlider: function (options) {
            var defaults = {
                maxRingTime: 100
            };
            options = $.extend({}, defaults, options);

            this.run = function () {

                $('#userMonitorToggleLink').click(function () {
                    setTimeout(function () {
                        $("#content .ringTimeSlider").each(function () {
                            $(this).rangeSlider('resize');
                        });
                    }, 350);
                });

                $("#content .ringTimeSlider").each(function () {
                    var slider = $(this);
                    slider.rangeSlider({
                        valueLabels: "hide",
                        durationIn: 500,
                        durationOut: 2000,
                        arrows: false,
                        step: 1,
                        bounds: {min: 0, max: options.maxRingTime},
                        defaultValues: {min: slider.prev().val(), max: slider.next().val()},
                        formatter: function (val) {
                            var value = Math.round(val * 5) / 5;
                            var decimal = value - Math.round(val);
                            var result = decimal === 0 ? value.toString() + ".0" : value.toString();
                            return result + ' sec.';
                        },
                        scales: [
                            // Primary scale
                            {
                                first: function (val) {
                                    return val;
                                },
                                next: function (val) {
                                    return val + 10;
                                },
                                stop: function (val) {
                                    return false;
                                },
                                label: function (val) {
                                    return val;
                                },
                                format: function (tickContainer, tickStart, tickEnd) {
                                    tickContainer.addClass("myCustomClass");
                                }
                            },
                            // Secondary scale
                            {
                                first: function (val) {
                                    return val;
                                },
                                next: function (val) {
                                    if (val % 10 === 9) {
                                        return val + 2;
                                    }
                                    return val + 1;
                                },
                                stop: function (val) {
                                    return false;
                                },
                                label: function () {
                                    return '';
                                }
                            }]
                    });
                });

                setTimeout(function () {
                    // Change options after slider creation
                    $("#content .ringTimeSlider").rangeSlider("option", "valueLabels", 'change');
                }, 2000);
            };
        }
    });
})(jQuery);