// eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(4($){$.J=$.J||{};$.J.9={7:{16:\'y\',m:11,1l:1y,1m:11,1i:w,c:w,d:w}};$.13.1K=4(12){F 7=$.1E({},$.J.9.7,12);p.1G(4(){$(p).17(\'1f\',1L 15($(p),7))});G p};$.13.1H=4(19){G $(p).17(\'1f\').X(19)};4 15($i,7){F W=p,$j=$i.t(".j"),$s=$i.t(".s"),$9=$i.t(".1I"),$L=$9.t(".1M"),$8=$9.t(".1N"),b=0,a=0,6=0,k=0,c=0,l=1,d=0,Y=0,n=0,D=0,A=7.16===\'x\',P="14"1C g.1w,r=A?"z":"1x",f=A?"1D":"1z";4 1t(){W.X();Z();G W}p.X=4(R){S=r.1T(0).26()+r.25(1).1O();b=$j[0][\'K\'+S];a=$s[0][\'22\'+S];2(b<=0)b=1;2(a<=0)a=1;k=b/a;c=7.c||b;d=h.I(c,h.H(0,(7.d||(c*k))));2(d<1d)d=1d;2(7.d){F x=c-d;2(x==0)x=1;l=(a-b)/x}v{l=a/c}2(k<1&&!D){23(R){1b"28":6=a-b;1a;1b"29":6=h.I(a-b,h.H(0,6));1a;27:6=1v(R,10)||0}}v{$9.1c()}1e()};4 1g(){2(k<1&&$9.18(":20")){$j.z($j.z()-10);$9.21();2(!n)n=$8.K()[f]}}4 1u(){2(k<1&&$9.18(":1S")){$j.z($j.z()+10);$9.1c()}}4 1e(){$8.e(f,6/(l==0?1:l));$s.e(f,-6);n=$8.K()[f];$9.e(r,c);$L.e(r,c);$8.e(r,d)}4 Z(){2(P){$j[0].14=4(5){2(1===5.O.1V){M(5.O[0]);5.1Z()}}}v{$8.u("1Y",M);$L.u("B",C)}2(7.m&&E.T){$i[0].T("1W",m,w);$i[0].T("24",m,w)}v 2(7.m){$i[0].1X=m}$i.1U(1g,1u)}4 M(5){n=A?5.1p:5.1h;Y=1v($8.e(f),10)||0;D=1;2(P){g.1k=4(5){5.1o();C(5.O[0])};g.1s=q}v{$(g).u("1j",C);$(g).u("B",q);$8.u("B",q)}}4 m(5){2(k<1){F o=5||E.5,1r=o.1q?o.1q/1P:-o.1R/3;6-=1r*7.1l;6=h.I((a-b),h.H(0,6));$8.e(f,6/(l==0?1:l));$s.e(f,-6);2(7.1m||(6!==(a-b)&&6!==0)){o=$.5.2a(o);o.1o()}}}4 C(5){E.1n?E.1n().1F():g.1A.1B();2(k<1){U=A?5.1p:5.1h;V=U-n;2(7.1i){V=n-U}Q=h.I((c-d),h.H(0,Y+V));6=Q*l;$8.e(f,Q);$s.e(f,-6)}}4 q(){D=0;$(g).N("1j",C);$(g).N("B",q);$8.N("B",q);g.1k=g.1s=1J}G 1t()}})(1Q);',62,135,'||if||function|event|contentPosition|options|thumb|scrollbar|contentSize|viewportSize|trackSize|thumbSize|css|posiLabel|document|Math|container|viewport|contentRatio|trackRatio|wheel|mousePosition|eventObject|this|end|sizeLabel|overview|find|bind|else|false|||width|isHorizontal|mouseup|drag|isdraging|window|var|return|max|min|tiny|offset|track|start|unbind|touches|hasTouchEvents|thumbPositionNew|scrollTo|sizeLabelCap|addEventListener|mousePositionNew|thumbPositionDelta|self|update|thumbPosition|setEvents||true|params|fn|ontouchstart|Scrollbar|axis|data|is|sScroll|break|case|hide|40|setSize|tsb|checkshow|pageY|scrollInvert|mousemove|ontouchmove|wheelSpeed|wheelLock|getSelection|preventDefault|pageX|wheelDelta|wheelSpeedDelta|ontouchend|initialize|checkhide|parseInt|documentElement|height|60|top|selection|empty|in|left|extend|removeAllRanges|each|welivebar_update|scb_scrollbar|null|welivebar|new|scb_tracker|scb_mover|toLowerCase|120|jQuery|detail|visible|charAt|hover|length|DOMMouseScroll|onmousewheel|mousedown|stopPropagation|hidden|show|scroll|switch|mousewheel|slice|toUpperCase|default|bottom|relative|fix'.split('|'),0,{}))
(function($) {
    $.tiny = $.tiny || {};
    $.tiny.scrollbar = {
        options: {
            axis: 'y',
            wheel: true,
            wheelSpeed: 60,
            wheelLock: true,
            scrollInvert: false,
            trackSize: false,
            thumbSize: false
        }
    };
    $.fn.welivebar = function(params) {
        var options = $.extend({}, $.tiny.scrollbar.options, params);
        this.each(function() {
            $(this).data('tsb', new Scrollbar($(this), options))
        });
        return this
    };
    $.fn.welivebar_update = function(sScroll) {
        return $(this).data('tsb').update(sScroll)
    };

    function Scrollbar($container, options) {
        var self = this,
            $viewport = $container.find(".viewport"),
            $overview = $container.find(".overview"),
            $scrollbar = $container.find(".scb_scrollbar"),
            $track = $scrollbar.find(".scb_tracker"),
            $thumb = $scrollbar.find(".scb_mover"),
            viewportSize = 0,
            contentSize = 0,
            contentPosition = 0,
            contentRatio = 0,
            trackSize = 0,
            trackRatio = 1,
            thumbSize = 0,
            thumbPosition = 0,
            mousePosition = 0,
            isdraging = 0,
            isHorizontal = options.axis === 'x',
            hasTouchEvents = "ontouchstart" in document.documentElement,
            sizeLabel = isHorizontal ? "width" : "height",
            posiLabel = isHorizontal ? "left" : "top";

        function initialize() {
            self.update();
            setEvents();
            return self
        }
        this.update = function(scrollTo) {
            sizeLabelCap = sizeLabel.charAt(0).toUpperCase() + sizeLabel.slice(1).toLowerCase();
            viewportSize = $viewport[0]['offset' + sizeLabelCap];
            contentSize = $overview[0]['scroll' + sizeLabelCap];
            if (viewportSize <= 0) viewportSize = 1;
            if (contentSize <= 0) contentSize = 1;
            contentRatio = viewportSize / contentSize;
            trackSize = options.trackSize || viewportSize;
            thumbSize = Math.min(trackSize, Math.max(0, (options.thumbSize || (trackSize * contentRatio))));
            if (thumbSize < 40) thumbSize = 40;
            if (options.thumbSize) {
                var x = trackSize - thumbSize;
                if (x == 0) x = 1;
                trackRatio = (contentSize - viewportSize) / x
            } else {
                trackRatio = contentSize / trackSize
            } if (contentRatio < 1 && !isdraging) {
                switch (scrollTo) {
                    case "bottom":
                        contentPosition = contentSize - viewportSize;
                        break;
                    case "relative":
                        contentPosition = Math.min(contentSize - viewportSize, Math.max(0, contentPosition));
                        break;
                    default:
                        contentPosition = parseInt(scrollTo, 10) || 0
                }
            } else {
                $scrollbar.hide()
            }
			checkshow();
            setSize()
        };

        function checkshow() {
            if (contentRatio < 1 && $scrollbar.is(":hidden")) {
                $viewport.width($viewport.width());
                $scrollbar.show();
                if (!mousePosition) mousePosition = $thumb.offset()[posiLabel]
            }
        }

        function checkhide() {
            if (contentRatio < 1 && $scrollbar.is(":visible")) {
                $viewport.width($viewport.width());
                $scrollbar.hide()
            }
        }

        function setSize() {
            $thumb.css(posiLabel, contentPosition / (trackRatio == 0 ? 1 : trackRatio));
            $overview.css(posiLabel, -contentPosition);
            mousePosition = $thumb.offset()[posiLabel];
            $scrollbar.css(sizeLabel, trackSize);
            $track.css(sizeLabel, trackSize);
            $thumb.css(sizeLabel, thumbSize)
        }

        function setEvents() {
            if (hasTouchEvents) {
                $viewport[0].ontouchstart = function(event) {
                    if (1 === event.touches.length) {
                        start(event.touches[0]);
                        event.stopPropagation()
                    }
                }
            } else {
                $thumb.bind("mousedown", start);
                $track.bind("mouseup", drag)
            } if (options.wheel && window.addEventListener) {
                $container[0].addEventListener("DOMMouseScroll", wheel, false);
                $container[0].addEventListener("mousewheel", wheel, false)
            } else if (options.wheel) {
                $container[0].onmousewheel = wheel
            }
        }

        function start(event) {
            mousePosition = isHorizontal ? event.pageX : event.pageY;
            thumbPosition = parseInt($thumb.css(posiLabel), 10) || 0;
            isdraging = 1;
            if (hasTouchEvents) {
                document.ontouchmove = function(event) {
                    event.preventDefault();
                    drag(event.touches[0])
                };
                document.ontouchend = end
            } else {
                $(document).bind("mousemove", drag);
                $(document).bind("mouseup", end);
                $thumb.bind("mouseup", end)
            }
        }

        function wheel(event) {
            if (contentRatio < 1) {
                var eventObject = event || window.event,
                 wheelSpeedDelta = eventObject.wheelDelta ? eventObject.wheelDelta / 120 : -eventObject.detail / 3;
                contentPosition -= wheelSpeedDelta * options.wheelSpeed;
                contentPosition = Math.min((contentSize - viewportSize), Math.max(0, contentPosition));
                $thumb.css(posiLabel, contentPosition / (trackRatio == 0 ? 1 : trackRatio));
                $overview.css(posiLabel, -contentPosition);
                if (options.wheelLock || (contentPosition !== (contentSize - viewportSize) && contentPosition !== 0)) {
                    eventObject = $.event.fix(eventObject);
                    eventObject.preventDefault()
                }
            }
        }

        function drag(event) {
            window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
            if (contentRatio < 1) {
                mousePositionNew = isHorizontal ? event.pageX : event.pageY;
                thumbPositionDelta = mousePositionNew - mousePosition;
                if (options.scrollInvert) {
                    thumbPositionDelta = mousePosition - mousePositionNew
                }
                thumbPositionNew = Math.min((trackSize - thumbSize), Math.max(0, thumbPosition + thumbPositionDelta));
                contentPosition = thumbPositionNew * trackRatio;
                $thumb.css(posiLabel, thumbPositionNew);
                $overview.css(posiLabel, -contentPosition)
            }
        }

        function end() {
            isdraging = 0;
            $(document).unbind("mousemove", drag);
            $(document).unbind("mouseup", end);
            $thumb.unbind("mouseup", end);
            document.ontouchmove = document.ontouchend = null
        }
        return initialize()
    }
})(jQuery);