/*publish time:2011-08-25 11:06:55*/
TMall=TMall||{};TMall.BackTop=function(){function C(){this.start=0;this.step=100;this.updateValue=function(K,N,L,M){E.scrollTo(0,-L*(K/=M)*(K-2)+N)};this.getValue=function(){return E.pageYOffset||G.body.scrollTop||G.documentElement.scrollTop}}function H(K){if(!(this instanceof H)){return new H(K)}this.config={};this.scrollBtn=null;this._init(K)}var I=KISSY,J=I.DOM,F=I.Event,G=document,E=window,B=I.UA.ie==6,D="hidden",A={triggerId:"J_ScrollTopBtn",triggerClass:"backToTop",style:"",bottom:50,right:10,baseLine:400};C.prototype.scrollTop=function(K){var Q=this,L=Q.getValue(),M=null,P=Q.start,N=0,O=parseInt(L/100);if(K!==L){N=K-L;M=setInterval(function(){if(P<=O){Q.updateValue(P,L,N,O);P++}else{clearInterval(M)}},5)}};I.augment(H,{_init:function(K){var L=this;L.config=I.merge(K,A);I.ready(function(M){L.createEl();L.scrollBtn=M.get("#"+L.config.triggerId);L.addEvent()})},createEl:function(){var K=this.config,L=J.create("<a>",{css:{display:"block",textIndent:"-9999px",position:B?"absolute":"fixed",bottom:K.bottom,right:K.right,height:"58px",width:"58px",outline:"none",opacity:"0",overflow:"hidden",background:"#000 url(http://img04.taobaocdn.com/tps/i4/T1hx49XnFnXXXXXXXX-24-13.png) 16px 21px no-repeat"},id:K.triggerId,"class":K.triggerClass+" hidden",text:"\u8fd4\u56de\u9876\u90e8",href:"#"});K.style||J.attr(L,"style",J.attr(L,"style")+K.style);J.addStyleSheet(".hidden{visibility:hidden}");J.append(L,"body")},addEvent:function(){function K(){var P=J.hasClass(L,D),O=parseInt(J.scrollTop(G));if(O>M&&P){P=new I.Anim(L,{opacity:0.25},0.3);P.run();J.removeClass(L,D)}else{if(O<M&&!P){P=new I.Anim(L,{opacity:0},0.3);P.run();J.addClass(L,D)}}if(B){P=J.viewportHeight(G);O=O+P-N.bottom-J.height(L);J.css(L,"top",O)}}var N=this.config,L=I.get("#"+N.triggerId),M=parseInt(N.baseLine);if(L){F.on(E,"scroll",K);F.on(L,"click",function(O){O.halt();(new C(G.documentElement)).scrollTop(0)});F.on(L,"mouseover",function(){(new I.Anim(L,{opacity:1},0.3)).run()});F.on(L,"mouseout",function(){(new I.Anim(L,{opacity:0.25},0.3)).run()})}}});H.init=function(K){H(K)};return H}();