/*!
 * Tiny Scrollbar 1.65
 * http://www.baijs.nl/tinyscrollbar/
 *
 * Copyright 2010, Maarten Baijs
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-2.0.php
 *
 * Date: 10 / 05 / 2011
 * Depends on library: jQuery
 * 
 */
(function(a){a.tiny=a.tiny||{};a.tiny.scrollbar={options:{axis:"y",wheel:40,scroll:true,size:"auto",sizethumb:"auto"}};a.fn.tinyscrollbar=function(c){var c=a.extend({},a.tiny.scrollbar.options,c);this.each(function(){a(this).data("tsb",new b(a(this),c))});return this};a.fn.tinyscrollbar_update=function(c){return a(this).data("tsb").update(c)};function b(p,f){var j=this;var s=p;var i={obj:a(".viewport",p)};var g={obj:a(".overview",p)};var d={obj:a(".scrollbar",p)};var l={obj:a(".track",d.obj)};var o={obj:a(".thumb",d.obj)};var k=f.axis=="x",m=k?"left":"top",u=k?"Width":"Height";var q,x={start:0,now:0},n={};function c(){j.update();r();return j}this.update=function(y){i[f.axis]=i.obj[0]["offset"+u];g[f.axis]=g.obj[0]["scroll"+u];g.ratio=i[f.axis]/g[f.axis];d.obj.toggleClass("disable",g.ratio>=1);l[f.axis]=f.size=="auto"?i[f.axis]:f.size;o[f.axis]=Math.min(l[f.axis],Math.max(0,(f.sizethumb=="auto"?(l[f.axis]*g.ratio):f.sizethumb)));d.ratio=f.sizethumb=="auto"?(g[f.axis]/l[f.axis]):(g[f.axis]-i[f.axis])/(l[f.axis]-o[f.axis]);q=(y=="relative"&&g.ratio<=1)?Math.min((g[f.axis]-i[f.axis]),Math.max(0,q)):0;q=(y=="bottom"&&g.ratio<=1)?(g[f.axis]-i[f.axis]):isNaN(parseInt(y))?q:parseInt(y);v()};function v(){o.obj.css(m,q/d.ratio);g.obj.css(m,-q);n.start=o.obj.offset()[m];var y=u.toLowerCase();d.obj.css(y,l[f.axis]);l.obj.css(y,l[f.axis]);o.obj.css(y,o[f.axis])}function r(){o.obj.bind("mousedown",h);o.obj[0].ontouchstart=function(y){y.preventDefault();o.obj.unbind("mousedown");h(y.touches[0]);return false};l.obj.bind("mouseup",t);if(f.scroll&&this.addEventListener){s[0].addEventListener("DOMMouseScroll",w,false);s[0].addEventListener("mousewheel",w,false)}else{if(f.scroll){s[0].onmousewheel=w}}}function h(z){n.start=k?z.pageX:z.pageY;var y=parseInt(o.obj.css(m));x.start=y=="auto"?0:y;a(document).bind("mousemove",t);document.ontouchmove=function(A){a(document).unbind("mousemove");t(A.touches[0])};a(document).bind("mouseup",e);o.obj.bind("mouseup",e);o.obj[0].ontouchend=document.ontouchend=function(A){a(document).unbind("mouseup");o.obj.unbind("mouseup");e(A.touches[0])};return false}function w(z){if(!(g.ratio>=1)){z=a.event.fix(z||window.event);var y=z.wheelDelta?z.wheelDelta/120:-z.detail/3;q-=y*f.wheel;q=Math.min((g[f.axis]-i[f.axis]),Math.max(0,q));o.obj.css(m,q/d.ratio);g.obj.css(m,-q);z.preventDefault()}}function e(y){a(document).unbind("mousemove",t);a(document).unbind("mouseup",e);o.obj.unbind("mouseup",e);document.ontouchmove=o.obj[0].ontouchend=document.ontouchend=null;return false}function t(y){if(!(g.ratio>=1)){x.now=Math.min((l[f.axis]-o[f.axis]),Math.max(0,(x.start+((k?y.pageX:y.pageY)-n.start))));q=x.now*d.ratio;g.obj.css(m,-q);o.obj.css(m,x.now)}return false}return c()}})(jQuery);
