(function($){$.fn.jqRevolve=function(o){o=$.extend({next:".revolve-down",prev:".revolve-up",ell:".ellipsis",content:".revolve-content",startPos:0,maxSpeed:60,speed:"normal"},o||{});return this.each(function(){JR.sane=true;var content=exists(o.content,this,"content"),next=exists(o.next,this.parent,"next"),prev=exists(o.prev,this.parent,"prev");ell=exists(o.ell,this.parent,"ell");if(this._jqRev||!JR.sane)return;S++;$(this).css("overflow","hidden");css(this,"relative");css(content,"absolute");H[S]= {content:content,next:next,prev:prev,ell:ell,pressure:1,maxSpeed:o.maxSpeed,start:o.startPos,speed:o.speed};tag(this,next,prev,ell);$(this).jqrRefresh();next.mousedown(function(){JR.start(H[this._jqRev],"-=")});prev.mousedown(function(){JR.start(H[this._jqRev],"+=")})})};$.fn.jqrRefresh=function(){return this.each(function(){var s=this._jqRev,h=H[s],e=$(this);var clone=h.content.clone().css({position:"absolute",top:-9999,left:-9999,height:"auto",width:e.css("width"),"line-height":e.css("line-height")}); $("body").append(clone);(function resize(){var size=clone.height(),view=e.height();pos=h.center&&size<view?50:h.start;h.max=size-view;if(h.max<4){h.next.hide();h.prev.hide();h.ell.hide()}else h.content.css({top:-(h.max*pos/100)+"px",height:size+999});clone.remove()})()})};$.jqRevolve={hash:{},start:function(h,dir){var step=150;total=4500,duration=step,halt=false;function stop(){halt=true}$().one("mouseup",stop);(function scroll(){var p=h.maxSpeed,pos=parseInt(h.content.css("top"));if(halt||pos>=0&& dir=="+="||Math.abs(pos)>=h.max&&dir=="-=")return h.content.queue("fx",[]);var newPos=dir=="+="?pos+p:pos-p;if(dir=="+="&&newPos>0||dir=="-="&&Math.abs(newPos)>=h.max){p=dir=="+="?0-pos:h.max-Math.abs(pos);halt=true}if(Math.abs(newPos)+4>=h.max)h.ell.hide();else h.ell.show();duration+=step;h.content.queue("fx",[]).animate({top:dir+p},h.speed);setTimeout(scroll,step)})()}};function exists(s,e,d){var ret=typeof s=="string"?$(s,e):$(s);if(ret.length==0){alert("jqRevolve: could not find "+d+" element!"); JR.sane=false}return ret}function tag(){var i=arguments.length;while(i--)$(arguments[i])[0]._jqRev=S}function css(e,p){if($(e).css("position")=="static")$(e).css("position",p)}var S=0,JR=$.jqRevolve,H=JR.hash})(jQuery);
