/*
 * TBra
 * 
 * copyright Yahoo javascript
 * 
 * application LACE 2008
 *
 * modify by huwd QQ:31916326
 * Email : java_doc@163.com
 *
 * by company  
 */
if(!Array.prototype.indexOf)Array.prototype.indexOf=function(B,A){if(A==null)A=0;else if(A<0)A=Math.max(0,this.length+A);for(var C=A;C<this.length;C++)if(this[C]===B)return C;return-1};if(!Array.prototype.lastIndexOf)Array.prototype.lastIndexOf=function(B,A){if(A==null)A=this.length-1;else if(A<0)A=Math.max(0,this.length+A);for(var C=A;C>=0;C--)if(this[C]===B)return C;return-1};if(!Array.prototype.forEach)Array.prototype.forEach=function(A,C){var B=this.length;for(var D=0;D<B;D++)A.call(C,this[D],D,this)};if(!Array.prototype.filter)Array.prototype.filter=function(A,D){var C=this.length,B=[];for(var E=0;E<C;E++)if(A.call(D,this[E],E,this))B.push(this[E]);return B};if(!Array.prototype.map)Array.prototype.map=function(A,D){var C=this.length,B=[];for(var E=0;E<C;E++)B.push(A.call(D,this[E],E,this));return B};if(!Array.prototype.some)Array.prototype.some=function(A,C){var B=this.length;for(var D=0;D<B;D++)if(A.call(C,this[D],D,this))return true;return false};if(!Array.prototype.every)Array.prototype.every=function(A,C){var B=this.length;for(var D=0;D<B;D++)if(!A.call(C,this[D],D,this))return false;return true};Array.prototype.contains=function(A){return this.indexOf(A)!=-1};Array.prototype.copy=function(A){return this.concat()};Array.prototype.insertAt=function(A,B){this.splice(B,0,A)};Array.prototype.insertBefore=function(B,A){var C=this.indexOf(A);if(C==-1)this.push(B);else this.splice(C,0,B)};Array.prototype.removeAt=function(A){this.splice(A,1)};Array.prototype.remove=function(A){var B=this.indexOf(A);if(B!=-1)this.splice(B,1)};if(!String.prototype.toQueryParams)String.prototype.toQueryParams=function(){var B={},E=this.trim().split("&");for(var F=0;F<E.length;F++){var A=E[F].split("="),C=decodeURIComponent(A[0]),D=A[1]?decodeURIComponent(A[1]):undefined;if(B[C]!==undefined){if(B[C].constructor!=Array)B[C]=[B[C]];if(D)B[C].push(D)}else B[C]=D}return B};if(!String.prototype.trim)String.prototype.trim=function(){var A=/^\s+|\s+$/g;return function(){return this.replace(A,"")}}();if(!String.prototype.replaceAll)String.prototype.replaceAll=function(B,A){return this.replace(new RegExp(B,"gm"),A)};Math.randomInt=function(A){return Math.floor(Math.random()*(A+1))};$D=YAHOO.util.Dom;$E=YAHOO.util.Event;$=$D.get;TB={};TB.namespace=function(){var B=arguments,C=null,E,D,A;for(E=0;E<B.length;E=E+1){A=B[E].split(".");C=TB;for(D=(A[0]=="TB")?1:0;D<A.length;D=D+1){C[A[D]]=C[A[D]]||{};C=C[A[D]]}}return C};TB.namespace("env");TB.env={hostname:"taobao.com",scriptName:"tbyahoo.js",debug:false,lang:(navigator.userLanguage?navigator.userLanguage.toLowerCase():navigator.language.toLowerCase())};TB.namespace("locale");TB.locale={Messages:{},getMessage:function(A){return TB.locale.Messages[A]||A},setMessage:function(B,A){TB.locale.Messages[B]=A}};$M=TB.locale.getMessage;TB.trace=function(A){if(!TB.env.debug)return;if(window.console)window.console.debug(A);else alert(A)};TB.init=function(){this.namespace("widget","dom","bom","util","form","anim");var A=document.getElementsByTagName("script"),C,B;for(var F=0;F<A.length;F++)if((C=A[F].src.indexOf(TB.env.scriptName))>0){B=A[F].src.substring(0,C);var E=A[F].src.match(/\?(.*)$/);if(E){var D=E[1].toQueryParams();for(n in D){if(n=="t")n="timestamp";TB.env[n]=D[n]}}}};TB.init();TB.common={trim:function(A){return A.replace(/(^\s*)|(\s*$)/g,"")},EscapeHTML:function(B){var C=document.createElement("div"),A=document.createTextNode(B);C.appendChild(A);return C.innerHTML},unescapeHTML:function(A){var B=document.createElement("div");B.innerHTML=A.replace(/<\/?[^>]+>/gi,"");return B.childNodes[0]?B.childNodes[0].nodeValue:""},stripTags:function(A){return A.replace(/<\/?[^>]+>/gi,"")},toArray:function(B,A){var D=[];for(var C=A||0;C<B.length;C++)D[D.length]=B[C];return D},applyIf:function(C,B){if(C&&B&&typeof B=="object")for(var A in B)if(!YAHOO.lang.hasOwnProperty(C,A))C[A]=B[A];return C},apply:function(C,B){if(C&&B&&typeof B=="object")for(var A in B)C[A]=B[A];return C},_messagePattern:/\{([\w-]+)?\}/g,formatMessage:function(B,A,C){return B.replace(this._messagePattern,function(B,D){return C?C(A[D],D):A[D]})}};TB.applyIf=TB.common.applyIf;TB.apply=TB.common.apply;(function(){var F=navigator.userAgent.toLowerCase(),E=F.indexOf("opera")!=-1,C=F.indexOf("safari")!=-1,G=!E&&!C&&F.indexOf("gecko")>-1,D=!E&&F.indexOf("msie")!=-1,B=!E&&F.indexOf("msie 6")!=-1,A=!E&&F.indexOf("msie 7")!=-1;TB.bom={isOpera:E,isSafari:C,isGecko:G,isIE:D,isIE6:B,isIE7:A,getCookie:function(A){var B=document.cookie.match("(?:^|;)\\s*"+A+"=([^;]*)");return B?unescape(B[1]):""},setCookie:function(B,E,A,D,C){E=escape(E);E+=(D)?"; domain="+D:"";E+=(C)?"; path="+C:"";if(A){var F=new Date();F.setTime(F.getTime()+(A*86400000));E+="; expires="+F.toGMTString()}document.cookie=B+"="+E},removeCookie:function(A){setCookie(A,"",-1)},pickDocumentDomain:function(){var A=location.hostname.split("."),B=A.length,C=arguments[0]||(B<3?0:1);if(C>=B||B-C<2)C=B-2;return A.slice(C).join(".")},addBookmark:function(A,B){if(window.sidebar)window.sidebar.addPanel(A,B,"");else if(document.external)window.external.AddFavorite(B,A)}}})();TB.dom={insertAfter:function(A,B){var A=$(A),B=$(B);if(B.nextSibling)return B.parentNode.insertBefore(A,B.nextSibling);else return B.parentNode.appendChild(A)},getAncestorByTagName:function(A,B){A=$(A);B=B.toUpperCase();while(A.parentNode){if(A.tagName.toUpperCase()==B)return A;if(A.tagName.toUpperCase()=="BODY")return null;A=A.parentNode}return null},getAncestorByClassName:function(B,A){B=$(B);while(B.parentNode){if($D.hasClass(B,A))return B;if(B.tagName.toUpperCase=="BODY")return null;B=B.parentNode}return null},getNextSibling:function(A){var B=$(A).nextSibling;while(B.nodeType!=1)B=B.nextSibling;return B},getPreviousSibling:function(A){var B=$(A).previousSibling;while(B.nodeType!=1)B=B.previousSibling;return B},getFieldLabelHtml:function(A,D){var B=(D||A.parentNode).getElementsByTagName("label");for(var E=0;E<B.length;E++){var C=B[E].htmlFor||B[E].getAttribute("for");if(C==input.id)return B[E].innerHTML}},getIframeDocument:function(B){var A=$(B);return A.contentWindow?A.contentWindow.document:A.contentDocument},setFormAction:function(B,E){B=$("form");var D=B.elements["action"],C;if(D){var A=B.removeChild(D);C=function(){B.appendChild(A)}}B.action=E;if(C)C();return true}};TB.widget.SimpleTab=new function(){var C=YAHOO.util,A={eventType:"click",currentClass:"Current",tabClass:"",autoSwitchToFirst:true,stopEvent:true,delay:0.2},B=function(C){var A=[];if(!C)return A;for(var D=0,B=C.childNodes;D<B.length;D++)if(B[D].nodeType==1)A[A.length]=B[D];return A};this.decorate=function(M,O){M=$(M);O=TB.applyIf(O||{},A);var G={},P=B(M),I=P.shift(0),N=I.getElementsByTagName("li"),J,E;if(O.tabClass)J=$D.getElementsByClassName(O.tabClass,"*",M);else J=TB.common.toArray(I.getElementsByTagName("a"));var H=new C.CustomEvent("onSwitch",null,false,C.CustomEvent.FLAT);if(O.onSwitch)H.subscribe(O.onSwitch);var F=function(C){if(E)D();var B=J.indexOf(this);G.switchTab(B);H.fire(B);if(O.stopEvent){try{$E.stopEvent(C)}catch(A){}}return!O.stopEvent},K=function(A){var B=this;E=setTimeout(function(){F.call(B,A)},O.delay*1000);if(O.stopEvent)$E.stopEvent(A);return!O.stopEvent},D=function(){clearTimeout(E)};for(var L=0;L<J.length;L++){$E.on(J[L],"focus",F);if(O.eventType=="mouse"){$E.on(J[L],"mouseover",O.delay?K:F);$E.on(J[L],"mouseout",D)}else $E.on(J[L],"click",F)}TB.apply(G,{switchTab:function(A){$D.setStyle(P,"display","none");$D.removeClass(N,O.currentClass);$D.addClass(N[A],O.currentClass);$D.setStyle(P[A],"display","block")},subscribeOnSwitch:function(A){H.subscribe(A)}});G.onSwitch=G.subscribeOnSwitch;$D.setStyle(P,"display","none");if(O.autoSwitchToFirst)G.switchTab(0);return G}};(function(){var A=YAHOO.util;TB.widget.Slide=function(A,B){this.init(A,B)};TB.widget.Slide.defConfig={slidesClass:"Slides",triggersClass:"SlideTriggers",currentClass:"Current",eventType:"click",autoPlayTimeout:5,disableAutoPlay:false};TB.widget.Slide.prototype={init:function(C,D){this.container=$(C);this.config=TB.applyIf(D||{},TB.widget.Slide.defConfig);try{this.slidesUL=$D.getElementsByClassName(this.config.slidesClass,"ul",this.container)[0];this.slides=this.slidesUL.getElementsByTagName("li")}catch(B){throw new Error("can't find slides!")}this.delayTimeId=null;this.autoPlayTimeId=null;this.curSlide=-1;this.sliding=false;this.pause=false;this.onSlide=new A.CustomEvent("onSlide",this,false,A.CustomEvent.FLAT);if(YAHOO.lang.isFunction(this.config.onSlide))this.onSlide.subscribe(this.config.onSlide,this,true);this.initSlides();this.initTriggers();if(this.slides.length>0)this.play(1);if(!this.config.disableAutoPlay)this.autoPlay()},initTriggers:function(){var B=document.createElement("ul");this.container.appendChild(B);for(var C=0;C<this.slides.length;C++){var A=document.createElement("li");A.innerHTML=C+1;B.appendChild(A)}B.className=this.config.triggersClass;this.triggersUL=B;if(this.config.eventType=="mouse"){$E.on(this.triggersUL,"mouseover",this.mouseHandler,this,true);$E.on(this.triggersUL,"mouseout",function(A){clearTimeout(this.delayTimeId)},this,true)}else $E.on(this.triggersUL,"click",this.clickHandler,this,true)},initSlides:function(){$E.on(this.slides,"mouseover",function(){this.pause=true},this,true);$E.on(this.slides,"mouseout",function(){this.pause=false},this,true);$D.setStyle(this.slides,"display","none")},clickHandler:function(C){var B=$E.getTarget(C),A=parseInt(B.innerHTML);while(B!=this.container)if(B.nodeName.toUpperCase()=="LI"){if(!this.sliding)this.play(A,true);break}else B=B.parentNode},mouseHandler:function(C){var B=$E.getTarget(C),A=parseInt(B.innerHTML);while(B!=this.container)if(B.nodeName.toUpperCase()=="LI"){var D=this;this.delayTimeId=setTimeout(function(){D.play(A,true)},(D.sliding?0.5:0.1)*1000);break}else B=B.parentNode},play:function(D,B){D=D-1;if(D==this.curSlide)return;var C=this.curSlide>=0?this.curSlide:0;if(B&&this.autoPlayTimeId)clearInterval(this.autoPlayTimeId);var A=this.triggersUL.getElementsByTagName("li");A[C].className="";A[D].className=this.config.currentClass;this.slide(D);this.curSlide=D;if(B&&!this.config.disableAutoPlay)this.autoPlay()},slide:function(B){var A=this.curSlide>=0?this.curSlide:0;this.sliding=true;$D.setStyle(this.slides[A],"display","none");$D.setStyle(this.slides[B],"display","block");this.sliding=false;this.onSlide.fire(B)},autoPlay:function(){var B=this,A=function(){if(!B.pause&&!B.sliding){var A=(B.curSlide+1)%B.slides.length+1;B.play(A,false)}};this.autoPlayTimeId=setInterval(A,this.config.autoPlayTimeout*1000)}};TB.widget.ScrollSlide=function(A,B){this.init(A,B)};YAHOO.extend(TB.widget.ScrollSlide,TB.widget.Slide,{initSlides:function(){TB.widget.ScrollSlide.superclass.initSlides.call(this);$D.setStyle(this.slides,"display","")},slide:function(E){var C=this.curSlide>=0?this.curSlide:0,D={scroll:{by:[0,this.slidesUL.offsetHeight*(E-C)]}},B=new A.Scroll(this.slidesUL,D,0.5,A.Easing.easeOutStrong);B.onComplete.subscribe(function(){this.sliding=false;this.onSlide.fire(E)},this,true);B.animate();this.sliding=true}});TB.widget.FadeSlide=function(A,B){this.init(A,B)};YAHOO.extend(TB.widget.FadeSlide,TB.widget.Slide,{initSlides:function(){TB.widget.FadeSlide.superclass.initSlides.call(this);$D.setStyle(this.slides,"position","absolute");$D.setStyle(this.slides,"top",this.config.slideOffsetY||0);$D.setStyle(this.slides,"left",this.config.slideOffsetX||0);$D.setStyle(this.slides,"z-index",1)},slide:function(D){if(this.curSlide==-1)$D.setStyle(this.slides[D],"display","block");else{var C=this.slides[this.curSlide];$D.setStyle(C,"display","block");$D.setStyle(C,"z-index",10);var B=new A.Anim(C,{opacity:{to:0}},0.5,A.Easing.easeNone);B.onComplete.subscribe(function(){$D.setStyle(C,"z-index",1);$D.setStyle(C,"display","none");$D.setStyle(C,"opacity",1);this.sliding=false;this.onSlide.fire(D)},this,true);$D.setStyle(this.slides[D],"display","block");B.animate();this.sliding=true}}})})();TB.widget.SimpleSlide=new function(){this.decorate=function(A,B){if(!A)return;B=B||{};if(B.effect=="scroll"){if(navigator.product&&navigator.product=="Gecko")if(YAHOO.util.Dom.get(A).getElementsByTagName("iframe").length>0){new TB.widget.Slide(A,B);return}new TB.widget.ScrollSlide(A,B)}else if(B.effect=="fade")new TB.widget.FadeSlide(A,B);else new TB.widget.Slide(A,B)}};TB.widget.SimpleScroll=new function(){var B=YAHOO.util,A={delay:2,speed:20,startDelay:2,scrollItemCount:1};this.decorate=function(G,I){G=$(G);I=TB.applyIf(I||{},A);var D={},J=null,C=false,H=new B.CustomEvent("onScroll",D,false,B.CustomEvent.FLAT);if(I.onScroll)H.subscribe(I.onScroll);else H.subscribe(function(){for(var A=0;A<I.scrollItemCount;A++)G.appendChild(G.getElementsByTagName("li")[0])});var F=function(){if(C)return;G.scrollTop+=2;var A=I.lineHeight||G.getElementsByTagName("li")[0].offsetHeight;if(G.scrollTop%A<=1){clearInterval(J);H.fire();G.scrollTop=0;setTimeout(E,I.delay*1000)}},E=function(){var A=I.lineHeight||G.getElementsByTagName("li")[0].offsetHeight;if(G.scrollHeight-G.offsetHeight>=A)J=setInterval(F,I.speed)};$E.on(G,"mouseover",function(){C=true});$E.on(G,"mouseout",function(){C=false});setTimeout(E,I.startDelay*1000);TB.apply(D,{subscribeOnScroll:function(B,A){if(A===true&&H.subscribers.length>0)H.unsubscribeAll();H.subscribe(B)}});D.onScroll=D.subscribeOnScroll;return D}};TB.widget.SimplePopup=new function(){var H=YAHOO.util,D,A,B={position:"right",autoFit:true,eventType:"mouse",delay:0.2,disableClick:true,width:0,height:0},C=function(B,A){if(B.contains&&A!=null)return B.contains(A);else{while(A){if(A==B)return true;A=A.parentNode}return false}},F=function(A){var B=$E.getTarget(A);if(F._target==B)this.popup.style.display=="block"?this.hide():this.show();else this.show();$E.stopEvent(A);F._target=B},I=function(B){clearTimeout(A);var C=this;D=setTimeout(function(){C.show()},this.config.delay*1000);if(this.config.disableClick&&!this.trigger.onclick)this.trigger.onclick=function(A){$E.stopEvent($E.getEvent(A))}},G=function(B){clearTimeout(A);$E.stopEvent(B)},E=function(A){clearTimeout(D);$E.stopEvent(A);if(!C(this.popup,$E.getRelatedTarget(A)))this.delayHide()};this.decorate=function(C,K,M){if(YAHOO.lang.isArray(C)||(YAHOO.lang.isObject(C)&&C.length)){for(var N=0;N<C.length;N++)this.decorate(C[N],K,M);return}C=$(C);K=$(K);if(!C||!K)return;M=TB.applyIf(M||{},B);var J={},D=new H.CustomEvent("onShow",J,false,H.CustomEvent.FLAT);if(M.onShow)D.subscribe(M.onShow);var L=new H.CustomEvent("onHide",J,false,H.CustomEvent.FLAT);if(M.onHide)L.subscribe(M.onHide);if(M.eventType=="mouse"){$E.on(C,"mouseover",I,J,true);$E.on(C,"mouseout",E,J,true);if(!$E.getListeners(K,"mouseover"))$E.on(K,"mouseover",G);if(!$E.getListeners(K,"mouseout"))$E.on(K,"mouseout",E,J,true)}else if(M.eventType=="click")$E.on(C,"click",F,J,true);TB.apply(J,{popup:K,trigger:C,config:M,show:function(){this.hide();var F=$D.getXY(this.trigger);if(YAHOO.lang.isArray(this.config.offset)){F[0]+=parseInt(this.config.offset[0]);F[1]+=parseInt(this.config.offset[1])}var K=this.trigger.offsetWidth,G=this.trigger.offsetHeight,L=M.width,O=M.height,C=$D.getViewportWidth(),J=$D.getViewportHeight(),A=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),N=Math.max(document.documentElement.scrollTop,document.body.scrollTop),E=F[0],I=F[1];if(M.position=="left")E=F[0]-L;else if(M.position=="right")E=F[0]+K;else if(M.position=="bottom")I=I+G;else if(M.position=="top"){I=I-O;if(I<0)I=0}if(this.config.autoFit)if(I-N+O>J){I=J-O+N-2;if(I<0)I=0}this.popup.style.position="absolute";this.popup.style.top=I+"px";this.popup.style.left=E+"px";if(this.config.effect){if(this.config.effect=="fade"){this.popup.style.display="block";$D.setStyle(this.popup,"opacity",0);var B=new H.Anim(this.popup,{opacity:{to:1}},0.4);B.animate()}}else this.popup.style.display="block";D.fire()},hide:function(){this.popup.style.display="none";L.fire()},delayHide:function(){var B=this;A=setTimeout(function(){B.hide()},this.config.delay*1000)}});$D.setStyle(K,"display","none");return J}};TB.widget.SimpleRating=new function(){var defConfig={rateUrl:"",rateParams:"",scoreParamName:"score",topScore:5,currentRatingClass:"current-rating"},rateHandler=function(C,B){$E.stopEvent(C);var E=$E.getTarget(C),D=parseInt(E.innerHTML);try{E.blur()}catch(A){}B.rate(D)},updateCurrentRating=function(A,C,B){if(A)A.innerHTML=C;$D.setStyle(A,"width",C*100/B.topScore+"%")};this.decorate=function(ratingContainer,config){ratingContainer=$(ratingContainer);config=TB.applyIf(config||{},defConfig);var currentRatingLi=$D.getElementsByClassName(config.currentRatingClass,"li",ratingContainer)[0],onRateEvent=new YAHOO.util.CustomEvent("onRate",null,false,YAHOO.util.CustomEvent.FLAT);if(config.onRate)onRateEvent.subscribe(config.onRate);var handle={};handle.init=function(A){updateCurrentRating(currentRatingLi,A,config)};handle.update=function(A){if(A&&A.Average&&currentRatingLi)updateCurrentRating(currentRatingLi,A.Average,config);$E.purgeElement(ratingContainer,true,"click");for(var B=ratingContainer.getElementsByTagName("li"),C=B.length-1;C>0;C--)ratingContainer.removeChild(B[C]);onRateEvent.fire(A)};handle.rate=function(score){var indicator=TB.util.Indicator.attach(ratingContainer,{message:$M("pleaseWait")});indicator.show();ratingContainer.style.display="none";var postData=config.scoreParamName+"="+score;if(config.rateParams)postData+="&"+config.rateParams;YAHOO.util.Connect.asyncRequest("POST",config.rateUrl,{success:function(req){indicator.hide();ratingContainer.style.display="";var ret=eval("("+req.responseText+")");if(ret.Error){alert(ret.Error.Message);return}else handle.update(ret)},failure:function(A){indicator.hide();ratingContainer.style.display="";TB.trace($M("ajaxError"))}},postData)};handle.onRate=function(A){if(YAHOO.lang.isFunction(A))onRateEvent.subscribe(A)};var triggers=ratingContainer.getElementsByTagName("a");for(var i=0;i<triggers.length;i++)$E.on(triggers[i],"click",rateHandler,handle);return handle}};TB.widget.InputHint=new function(){var C={hintMessage:"",hintClass:"InputHint",appearOnce:false},A=/^\s*$/,B=function(B,A){A.disappear()},D=function(B,A){A.appear()};this.decorate=function(G,H){G=$(G);H=TB.applyIf(H||{},C);var F=H.hintMessage||G.title,E={};E.disappear=function(){if(F==G.value){G.value="";$D.removeClass(G,H.hintClass)}};E.appear=function(){if(A.test(G.value)||F==G.value){G.value=F;$D.addClass(G,H.hintClass)}};G.setAttribute("title",F);$E.on(G,"focus",B,E);$E.on(G,"drop",B,E);if(!H.appearOnce)$E.on(G,"blur",D,E);E.appear();return E}};TB.anim.Highlight=function(A,B){if(!A)return;this.init(A,B)};TB.anim.Highlight.defConfig={startColor:"#ffff99",duration:0.5,keepBackgroundImage:true};TB.anim.Highlight.prototype={init:function(C,D){var F=YAHOO.util;D=TB.applyIf(D||{},TB.anim.Highlight.defConfig);var E={backgroundColor:{from:D.startColor}},B=new F.ColorAnim(C,E,D.duration),G=B.getAttribute("backgroundColor");B.attributes["backgroundColor"]["to"]=G;if(D.keepBackgroundImage){var A=$D.getStyle(C,"background-image");B.onComplete.subscribe(function(){$D.setStyle(C,"background-image",A)})}this.onComplete=B.onComplete;this.animate=function(){$D.setStyle(C,"background-image","none");B.animate()}}};TB.util.Indicator=new function(){var B={message:"loading",useShim:false,useIFrame:false,centerIndicator:true},A=function(A,C){shim=document.createElement("div");shim.className="tb-indic-shim";$D.setStyle(shim,"display","none");A.parentNode.insertBefore(shim,A);if(C){var B=document.createElement("iframe");B.setAttribute("frameBorder",0);B.className="tb-indic-shim-iframe";A.parentNode.insertBefore(B,A)}return shim};this.attach=function(F,G){F=$(F);G=TB.applyIf(G||{},B);var C=document.createElement("div");C.className="tb-indic";$D.setStyle(C,"display","none");$D.setStyle(C,"position","static");C.innerHTML=$M(G.message);if(G.useShim){var E=A(F,G.useIFrame);E.appendChild(C)}else F.parentNode.insertBefore(C,F);var D={};D.show=function(E){if(G.useShim){var A=$D.getRegion(F),B=C.parentNode;$D.setStyle(B,"display","block");$D.setXY(B,[A[0],A[1]]);$D.setStyle(B,"width",(A.right-A.left)+"px");$D.setStyle(B,"height",(A.bottom-A.top)+"px");if(G.useIFrame){var D=B.nextSibling;$D.setStyle(D,"width",(A.right-A.left)+"px");$D.setStyle(D,"height",(A.bottom-A.top)+"px");$D.setStyle(D,"display","block")}$D.setStyle(C,"display","block");$D.setStyle(C,"position","absolute");if(G.centerIndicator){$D.setStyle(C,"top","50%");$D.setStyle(C,"left","50%");C.style.marginTop=-(C.offsetHeight/2)+"px";C.style.marginLeft=-(C.offsetWidth/2)+"px"}}else{$D.setStyle(C,"display","");if(E){$D.setStyle(C,"position","absolute");$D.setXY(C,E)}}};D.hide=function(){if(G.useShim){var B=C.parentNode;$D.setStyle(C,"display","none");$D.setStyle(B,"display","none");if(G.useIFrame)$D.setStyle(C.parentNode.nextSibling,"display","none");try{if(G.useIFrame)B.parentNode.removeChild(B.nextSibling);B.parentNode.removeChild(B)}catch(A){}}else{$D.setStyle(C,"display","none");try{C.parentNode.removeChild(C)}catch(A){}}};return D}};TB.util.QueryData=function(){this.data=[];this.addField=function(B){for(var C=0;C<arguments.length;C++){var A=arguments[C];if(A)this.add(A.name,encodeURIComponent(A.value))}};this.add=function(A,B){this.data.push({"name":A,"value":B})};this.get=function(A){for(var B=0;B<this.data.length;B++)if(this.data[B].name===A)return this.data[B].value;return null};this.toQueryString=function(){var A=this.data.map(function(A,B){return A.name+"="+A.value});return A.join("&")}};TB.util.Pagination=new function(){var PAGE_SEPARATOR="...",defConfig={pageUrl:"",prevPageClass:"PrevPage",noPrevClass:"NoPrev",prevPageText:"prevPageText",nextPageClass:"NextPage",nextPageText:"nextPageText",noNextClass:"NoNext",currPageClass:"CurrPage",pageParamName:"page",appendParams:"",pageBarMode:"bound",showIndicator:true,cachePageData:false},cancelHandler=function(A){$E.stopEvent(A)},pageHandler=function(A,B){$E.stopEvent(A);var C=$E.getTarget(A);B[1].gotoPage(B[0])},buildBoundPageList=function(J,C){var H=[],F=1,E=2,B=J-2,G=J+2,D=C-1,A=C;if(B<=E){F=0;E=0;B=1}if(G>=D){D=0;A=0;G=C}if(E>F){for(var I=F;I<=E;++I)H[H.length]=""+I;if((E+1)<B)H[H.length]=PAGE_SEPARATOR}for(I=B;I<=G;++I)H[H.length]=""+I;if(A>D){if((G+1)<D)H[H.length]=PAGE_SEPARATOR;for(I=D;I<=A;++I)H[H.length]=""+I}return H},buildPageEntry=function(A,C){var D=document.createElement("li");if(A!=PAGE_SEPARATOR){$D.addClass(D,(A=="prev")?C.prevPageClass:(A=="next")?C.nextPageClass:"");var B=document.createElement("a");B.setAttribute("title",(A=="prev")?$M(C.prevPageText):(A=="next")?$M(C.nextPageText):""+A);B.href=buildPageUrl(A,C)+"&t="+new Date().getTime();B.innerHTML=(A=="prev")?$M(C.prevPageText):(A=="next")?$M(C.nextPageText):A;D.appendChild(B)}else D.innerHTML=PAGE_SEPARATOR;return D},buildPageUrl=function(A,B){var C=B.pageUrl+(B.pageUrl.lastIndexOf("?")!=-1?"&":"?")+B.pageParamName+"="+A;if(B.appendParams)C+="&"+B.appendParams;return C};this.attach=function(pageBarContainer,pageDataContainer,config){pageBarContainer=$(pageBarContainer);pageDataContainer=$(pageDataContainer);config=TB.applyIf(config||{},defConfig);if(config.cachePageData)var pageDataCache={};var ulEl=document.createElement("ul");pageBarContainer.appendChild(ulEl);var pageLoadEvent=new YAHOO.util.CustomEvent("pageLoad",null,false,YAHOO.util.CustomEvent.FLAT),handle={};handle.rebuildPageBar=function(C){if(C){this.pageIndex=parseInt(C.PageIndex);this.totalCount=parseInt(C.TotalCount);this.pageCount=parseInt(C.PageCount);this.pageSize=parseInt(C.PageSize)}ulEl.innerHTML="";var B=this.repaginate(),A=buildPageEntry("prev",config);if(!this.isPrevPageAvailable()){$D.addClass(A,config.noPrevClass);$E.on(A,"click",cancelHandler)}else $E.on(A,"click",pageHandler,[this.pageIndex-1,this]);ulEl.appendChild(A);for(var F=0;F<B.length;F++){var E=buildPageEntry(B[F],config);if(B[F]==this.pageIndex){$D.addClass(E,config.currPageClass);$E.on(E,"click",cancelHandler)}else $E.on(E,"click",pageHandler,[B[F],this]);ulEl.appendChild(E)}var D=buildPageEntry("next",config);if(!this.isNextPageAvailable()){$D.addClass(D,config.noNextClass);$E.on(D,"click",cancelHandler)}else $E.on(D,"click",pageHandler,[this.pageIndex+1,this]);ulEl.appendChild(D)};handle.repaginate=function(){var C=config.pageBarMode;if(C=="bound")return buildBoundPageList(parseInt(this.pageIndex),parseInt(this.pageCount));else if(C=="line"){var A=[];for(var B=1;B<=this.pageCount;B++)A.push(B);return A}else if(C=="eye")return[]};handle.gotoPage=function(idx){this.disablePageBar();if(config.showIndicator){$D.setStyle(pageDataContainer,"display","none");var indicator=TB.util.Indicator.attach(pageDataContainer,{message:$M("loading")});indicator.show()}var url=buildPageUrl(idx,config);if(config.cachePageData)if(pageDataCache[url]){handle.showPage(pageDataCache[url]);return}YAHOO.util.Connect.asyncRequest("GET",url+"&t="+new Date().getTime(),{success:function(req){var resultSet=eval("("+req.responseText+")");handle.showPage(resultSet.Pagination);if(config.cachePageData)pageDataCache[url]=resultSet.Pagination;if(config.showIndicator){indicator.hide();$D.setStyle(pageDataContainer,"display","block")}},failure:function(A){if(config.showIndicator){$D.setStyle(pageDataContainer,"display","block");indicator.hide()}handle.rebuildPageBar();alert($M("ajaxError"))}})};handle.showPage=function(A){if(A.PageData&&YAHOO.lang.isString(A.PageData))pageDataContainer.innerHTML=A.PageData;this.rebuildPageBar(A);pageLoadEvent.fire(A)};handle.isNextPageAvailable=function(){return this.pageIndex<this.pageCount};handle.isPrevPageAvailable=function(){return this.pageIndex>1};handle.disablePageBar=function(){$D.addClass(pageBarContainer,"Disabled");$E.purgeElement(pageBarContainer,true,"click");var A=TB.common.toArray(pageBarContainer.getElementsByTagName("a"));A.forEach(function(A,B){$E.on(A,"click",cancelHandler);A.disabled=1})};handle.onPageLoad=function(A){if(YAHOO.lang.isFunction(A))pageLoadEvent.subscribe(A)};handle.setAppendParams=function(A){config.appendParams=A};return handle}};TB.util.CountdownTimer=new function(){var G=YAHOO.util,E=60,D=E*60,B=D*24,A={formatStyle:"short",formatPattern:"",hideZero:true,timeoutText:"timeoutText",updatable:true},F=function(A){return((A<10)?"0":"")+A},C=function(A){return function(C,G){switch(G){case"d":return parseInt(A/B);case"dd":return F(parseInt(A/B));case"hh":return F(parseInt(A%B/D));case"h":return parseInt(A%B/D);case"mm":return F(parseInt(A%B%D/E));case"m":return parseInt(A%B%D/E);case"ss":return F(parseInt(A%B%D%E));case"s":return parseInt(A%B%D%E)}}};this.attach=function(J,M,L){J=$(J);M=parseInt(M);L=TB.applyIf(L||{},A);var I={},H=new G.CustomEvent("onStart",null,false,G.CustomEvent.FLAT);if(L.onStart)H.subscribe(L.onStart);var F=new G.CustomEvent("onEnd",null,false,G.CustomEvent.FLAT);if(L.onEnd)F.subscribe(L.onEnd);var N=parseInt(new Date().getTime()/1000),O=N+M,K=function(){I.update()};I.update=function(){var H=L.formatPattern,G={},A=1;if(L.formatStyle=="long")H="{d}"+$M("day")+"{hh}"+$M("hour")+"{mm}"+$M("minute")+"{ss}"+$M("second");var I=O-parseInt(new Date().getTime()/1000);if(I<=0){J.innerHTML=$M(L.timeoutText);F.fire();return}else if(I>B){if(L.formatStyle=="short"){H="{d}"+$M("day")+"{hh}"+$M("hour");A=Math.floor(I%B%D)||D}}else if(I>D){if(L.formatStyle=="short"){H="{hh}"+$M("hour")+"{mm}"+$M("minute");A=Math.floor(I%D%E)||E}else if(L.formatStyle=="long"&&L.hideZero)H="{hh}"+$M("hour")+"{mm}"+$M("minute")+"{ss}"+$M("second")}else if(I>0)if(L.formatStyle=="short"||(L.formatStyle=="long"&&L.hideZero))H="{mm}"+$M("minute")+"{ss}"+$M("second");J.innerHTML=TB.common.formatMessage(H,G,C(I));if(L.updatable&&A>0)setTimeout(K,A*1000)};I.init=function(){this.update();H.fire()};I.init();return I}}

