(function($) {
    $.slideContent = {
        defaults: {
            wrapper: '',
            content: '',
            slider: '#slider',
            handler: '#handler'
        }
    };
    
    $.fn.extend({
        slideContent: function(config)
        {
            var config = $.extend({}, $.slideContent.defaults, config);
            config.content = this.attr('id');
            config.wrapper = this.parent().attr('id');
            
            doSlide(config);
            
            return this;
        }
    });
    
    function doSlide(config) 
    {
        var slider = $(config.slider);
        var handler = $(config.handler);
        var wrapper = $('#'+config.wrapper);
        var content = $('#'+config.content);
        var handlerHeight;
        
        if((content.height() > wrapper.height()))
        {
            wrapper.css('overflow','hidden');
            slider.css('display','block');
            handlerHeight = (wrapper.height() * slider.height()) / content.height();
            handler.height(handlerHeight);
            handler.draggable(
            {
                containment: 'parent',
                drag: function(e, ui)
                {
                    var text_top = ((wrapper.height() - content.height()) * ui.position.top) / (slider.height() - handlerHeight);
                    content.css('top',text_top);
                }
            });
        }
    }
})(jQuery);
