

YAHOO.namespace("extension");YAHOO.extension.Carousel=function(B,A){this.init(B,A)};YAHOO.extension.Carousel.prototype={UNBOUNDED_SIZE:1000000,init:function(N,J){var I=this;this.getCarouselItem=this.getItem;var B="carousel-list";var C="carousel-clip-region";var F="carousel-next";var E="carousel-prev";this._carouselElemID=N;this.carouselElem=YAHOO.util.Dom.get(N);this._prevEnabled=true;this._nextEnabled=true;this.cfg=new YAHOO.util.Config(this);this.cfg.addProperty("scrollBeforeAmount",{value:0,handler:function(P,O,Q){},validator:I.cfg.checkNumber});this.cfg.addProperty("scrollAfterAmount",{value:0,handler:function(P,O,Q){},validator:I.cfg.checkNumber});this.cfg.addProperty("loadOnStart",{value:true,handler:function(P,O,Q){},validator:I.cfg.checkBoolean});this.cfg.addProperty("orientation",{value:"horizontal",handler:function(P,O,Q){I.reload()},validator:function(O){if(typeof O=="string"){return("horizontal,vertical".indexOf(O.toLowerCase())!=-1)}else{return false}}});this.cfg.addProperty("size",{value:this.UNBOUNDED_SIZE,handler:function(P,O,Q){I.reload()},validator:I.cfg.checkNumber});this.cfg.addProperty("numVisible",{value:3,handler:function(P,O,Q){I.reload()},validator:I.cfg.checkNumber});this.cfg.addProperty("firstVisible",{value:1,handler:function(P,O,Q){I.moveTo(O[0])},validator:I.cfg.checkNumber});this.cfg.addProperty("scrollInc",{value:3,handler:function(P,O,Q){},validator:I.cfg.checkNumber});this.cfg.addProperty("animationSpeed",{value:0.25,handler:function(P,O,Q){I.animationSpeed=O[0]},validator:I.cfg.checkNumber});this.cfg.addProperty("animationMethod",{value:YAHOO.util.Easing.easeOut,handler:function(P,O,Q){}});this.cfg.addProperty("animationCompleteHandler",{value:null,handler:function(P,O,Q){if(I._animationCompleteEvt){I._animationCompleteEvt.unsubscribe(I._currAnimationCompleteHandler,I)}I._currAnimationCompleteHandler=O[0];if(I._currAnimationCompleteHandler){if(!I._animationCompleteEvt){I._animationCompleteEvt=new YAHOO.util.CustomEvent("onAnimationComplete",I)}I._animationCompleteEvt.subscribe(I._currAnimationCompleteHandler,I)}}});this.cfg.addProperty("autoPlay",{value:0,handler:function(Q,O,R){var P=O[0];if(P>0){I.startAutoPlay()}else{I.stopAutoPlay()}}});this.cfg.addProperty("wrap",{value:false,handler:function(P,O,Q){},validator:I.cfg.checkBoolean});this.cfg.addProperty("navMargin",{value:0,handler:function(P,O,Q){I.calculateSize()},validator:I.cfg.checkNumber});this.cfg.addProperty("revealAmount",{value:0,handler:function(P,O,Q){I.reload()},validator:I.cfg.checkNumber});this.cfg.addProperty("prevElementID",{value:null,handler:function(P,O,Q){if(I._carouselPrev){YAHOO.util.Event.removeListener(I._carouselPrev,"click",I._scrollPrev)}I._prevElementID=O[0];if(I._prevElementID==null){I._carouselPrev=YAHOO.util.Dom.getElementsByClassName(E,"div",I.carouselElem)[0]}else{I._carouselPrev=YAHOO.util.Dom.get(I._prevElementID)}YAHOO.util.Event.addListener(I._carouselPrev,"click",I._scrollPrev,I)}});this.cfg.addProperty("prevElement",{value:null,handler:function(P,O,Q){if(I._carouselPrev){YAHOO.util.Event.removeListener(I._carouselPrev,"click",I._scrollPrev)}I._prevElementID=O[0];if(I._prevElementID==null){I._carouselPrev=YAHOO.util.Dom.getElementsByClassName(E,"div",I.carouselElem)[0]}else{I._carouselPrev=YAHOO.util.Dom.get(I._prevElementID)}YAHOO.util.Event.addListener(I._carouselPrev,"click",I._scrollPrev,I)}});this.cfg.addProperty("nextElementID",{value:null,handler:function(P,O,Q){if(I._carouselNext){YAHOO.util.Event.removeListener(I._carouselNext,"click",I._scrollNext)}I._nextElementID=O[0];if(I._nextElementID==null){I._carouselNext=YAHOO.util.Dom.getElementsByClassName(F,"div",I.carouselElem)}else{I._carouselNext=YAHOO.util.Dom.get(I._nextElementID)}if(I._carouselNext){YAHOO.util.Event.addListener(I._carouselNext,"click",I._scrollNext,I)}}});this.cfg.addProperty("nextElement",{value:null,handler:function(P,O,Q){if(I._carouselNext){YAHOO.util.Event.removeListener(I._carouselNext,"click",I._scrollNext)}I._nextElementID=O[0];if(I._nextElementID==null){I._carouselNext=YAHOO.util.Dom.getElementsByClassName(F,"div",I.carouselElem)}else{I._carouselNext=YAHOO.util.Dom.get(I._nextElementID)}if(I._carouselNext){YAHOO.util.Event.addListener(I._carouselNext,"click",I._scrollNext,I)}}});this.cfg.addProperty("disableSelection",{value:true,handler:function(P,O,Q){},validator:I.cfg.checkBoolean});this.cfg.addProperty("loadInitHandler",{value:null,handler:function(P,O,Q){if(I._loadInitHandlerEvt){I._loadInitHandlerEvt.unsubscribe(I._currLoadInitHandler,I)}I._currLoadInitHandler=O[0];if(I._currLoadInitHandler){if(!I._loadInitHandlerEvt){I._loadInitHandlerEvt=new YAHOO.util.CustomEvent("onLoadInit",I)}I._loadInitHandlerEvt.subscribe(I._currLoadInitHandler,I)}}});this.cfg.addProperty("loadNextHandler",{value:null,handler:function(P,O,Q){if(I._loadNextHandlerEvt){I._loadNextHandlerEvt.unsubscribe(I._currLoadNextHandler,I)}I._currLoadNextHandler=O[0];if(I._currLoadNextHandler){if(!I._loadNextHandlerEvt){I._loadNextHandlerEvt=new YAHOO.util.CustomEvent("onLoadNext",I)}I._loadNextHandlerEvt.subscribe(I._currLoadNextHandler,I)}}});this.cfg.addProperty("loadPrevHandler",{value:null,handler:function(P,O,Q){if(I._loadPrevHandlerEvt){I._loadPrevHandlerEvt.unsubscribe(I._currLoadPrevHandler,I)}I._currLoadPrevHandler=O[0];if(I._currLoadPrevHandler){if(!I._loadPrevHandlerEvt){I._loadPrevHandlerEvt=new YAHOO.util.CustomEvent("onLoadPrev",I)}I._loadPrevHandlerEvt.subscribe(I._currLoadPrevHandler,I)}}});this.cfg.addProperty("prevButtonStateHandler",{value:null,handler:function(P,O,Q){if(I._currPrevButtonStateHandler){I._prevButtonStateHandlerEvt.unsubscribe(I._currPrevButtonStateHandler,I)}I._currPrevButtonStateHandler=O[0];if(I._currPrevButtonStateHandler){if(!I._prevButtonStateHandlerEvt){I._prevButtonStateHandlerEvt=new YAHOO.util.CustomEvent("onPrevButtonStateChange",I)}I._prevButtonStateHandlerEvt.subscribe(I._currPrevButtonStateHandler,I)}}});this.cfg.addProperty("nextButtonStateHandler",{value:null,handler:function(P,O,Q){if(I._currNextButtonStateHandler){I._nextButtonStateHandlerEvt.unsubscribe(I._currNextButtonStateHandler,I)}I._currNextButtonStateHandler=O[0];if(I._currNextButtonStateHandler){if(!I._nextButtonStateHandlerEvt){I._nextButtonStateHandlerEvt=new YAHOO.util.CustomEvent("onNextButtonStateChange",I)}I._nextButtonStateHandlerEvt.subscribe(I._currNextButtonStateHandler,I)}}});if(J){this.cfg.applyConfig(J)}YAHOO.util.Event.addListener(this.carouselElem,"mousedown",this._handleMouseDownForSelection,this,true);this._origFirstVisible=this.cfg.getProperty("firstVisible");this._currLoadInitHandler=this.cfg.getProperty("loadInitHandler");this._currLoadNextHandler=this.cfg.getProperty("loadNextHandler");this._currLoadPrevHandler=this.cfg.getProperty("loadPrevHandler");this._currPrevButtonStateHandler=this.cfg.getProperty("prevButtonStateHandler");this._currNextButtonStateHandler=this.cfg.getProperty("nextButtonStateHandler");this._currAnimationCompleteHandler=this.cfg.getProperty("animationCompleteHandler");this._nextElementID=this.cfg.getProperty("nextElementID");if(!this._nextElementID){this._nextElementID=this.cfg.getProperty("nextElement")}this._prevElementID=this.cfg.getProperty("prevElementID");if(!this._prevElementID){this._prevElementID=this.cfg.getProperty("prevElement")}this._autoPlayTimer=null;this._priorLastVisible=this._priorFirstVisible=this.cfg.getProperty("firstVisible");this._lastPrebuiltIdx=0;this.carouselList=YAHOO.util.Dom.getElementsByClassName(B,"ul",this.carouselElem)[0];if(this._nextElementID==null){this._carouselNext=YAHOO.util.Dom.getElementsByClassName(F,"div",this.carouselElem)[0]}else{this._carouselNext=YAHOO.util.Dom.get(this._nextElementID)}if(this._prevElementID==null){this._carouselPrev=YAHOO.util.Dom.getElementsByClassName(E,"div",this.carouselElem)[0]}else{this._carouselPrev=YAHOO.util.Dom.get(this._prevElementID)}this._clipReg=YAHOO.util.Dom.getElementsByClassName(C,"div",this.carouselElem)[0];if(this.isVertical()){YAHOO.util.Dom.addClass(this.carouselList,"carousel-vertical")}this._scrollNextAnim=new YAHOO.util.Motion(this.carouselList,this.scrollNextParams,this.cfg.getProperty("animationSpeed"),this.cfg.getProperty("animationMethod"));this._scrollPrevAnim=new YAHOO.util.Motion(this.carouselList,this.scrollPrevParams,this.cfg.getProperty("animationSpeed"),this.cfg.getProperty("animationMethod"));if(this._carouselNext){YAHOO.util.Event.addListener(this._carouselNext,"click",this._scrollNext,this)}if(this._carouselPrev){YAHOO.util.Event.addListener(this._carouselPrev,"click",this._scrollPrev,this)}var H=this.cfg.getProperty("loadInitHandler");if(H){this._loadInitHandlerEvt=new YAHOO.util.CustomEvent("onLoadInit",this);this._loadInitHandlerEvt.subscribe(H,this)}var L=this.cfg.getProperty("loadNextHandler");if(L){this._loadNextHandlerEvt=new YAHOO.util.CustomEvent("onLoadNext",this);this._loadNextHandlerEvt.subscribe(L,this)}var M=this.cfg.getProperty("loadPrevHandler");if(M){this._loadPrevHandlerEvt=new YAHOO.util.CustomEvent("onLoadPrev",this);this._loadPrevHandlerEvt.subscribe(M,this)}var K=this.cfg.getProperty("animationCompleteHandler");if(K){this._animationCompleteEvt=new YAHOO.util.CustomEvent("onAnimationComplete",this);this._animationCompleteEvt.subscribe(K,this)}var A=this.cfg.getProperty("prevButtonStateHandler");if(A){this._prevButtonStateHandlerEvt=new YAHOO.util.CustomEvent("onPrevButtonStateChange",this);this._prevButtonStateHandlerEvt.subscribe(A,this)}var G=this.cfg.getProperty("nextButtonStateHandler");if(G){this._nextButtonStateHandlerEvt=new YAHOO.util.CustomEvent("onNextButtonStateChange",this);this._nextButtonStateHandlerEvt.subscribe(G,this)}var D=this._calculateVisibleExtent();YAHOO.util.Event.onAvailable(this._carouselElemID+"-item-"+D.start,this._calculateSize,this);if(this.cfg.getProperty("loadOnStart")){this._loadInitial()}},_handleMouseDownForSelection:function(A){if(this.cfg.getProperty("disableSelection")){YAHOO.util.Event.preventDefault(A);YAHOO.util.Event.stopPropagation(A)}},clear:function(){var A=this.cfg.getProperty("loadInitHandler");if(A){this._removeChildrenFromNode(this.carouselList);this._lastPrebuiltIdx=0}this.stopAutoPlay();this._priorLastVisible=this._priorFirstVisible=this._origFirstVisible;this.cfg.setProperty("firstVisible",this._origFirstVisible,true);this.moveTo(this._origFirstVisible)},reload:function(B){if(this._isValidObj(B)){this.cfg.setProperty("numVisible",B)}this.clear();var A=this._calculateVisibleExtent();YAHOO.util.Event.onAvailable(this._carouselElemID+"-item-"+A.start,this._calculateSize,this);this._loadInitial()},load:function(){var A=this._calculateVisibleExtent();YAHOO.util.Event.onAvailable(this._carouselElemID+"-item-"+A.start,this._calculateSize,this);this._loadInitial()},addItem:function(C,B,D){if(C>this.cfg.getProperty("size")){return null}var E=this.getItem(C);if(!this._isValidObj(E)){E=this._createItem(C,B);this.carouselList.appendChild(E)}else{if(this._isValidObj(E.placeholder)){var A=this._createItem(C,B);this.carouselList.replaceChild(A,E);E=A}}if(this._isValidObj(D)){YAHOO.util.Dom.addClass(E,D)}if(this.isVertical()){setTimeout(function(){E.style.display="block"},1)}return E},insertBefore:function(B,D){if(B>=this.cfg.getProperty("size")){return null}if(B<1){B=1}var A=B-1;if(A>this._lastPrebuiltIdx){this._prebuildItems(this._lastPrebuiltIdx,B)}var C=this._insertBeforeItem(B,D);this._enableDisableControls();return C},insertAfter:function(B,D){if(B>this.cfg.getProperty("size")){B=this.cfg.getProperty("size")}var A=B+1;if(A>this._lastPrebuiltIdx){this._prebuildItems(this._lastPrebuiltIdx,A+1)}var C=this._insertAfterItem(B,D);if(A>this.cfg.getProperty("size")){this.cfg.setProperty("size",A,true)}this._enableDisableControls();return C},scrollNext:function(){this._scrollNext(null,this);this._autoPlayTimer=null;if(this.cfg.getProperty("autoPlay")!==0){this._autoPlayTimer=this.startAutoPlay()}},scrollPrev:function(){this._scrollPrev(null,this)},scrollTo:function(A){this._position(A,true)},moveTo:function(A){this._position(A,false)},startAutoPlay:function(A){if(this._isValidObj(A)){this.cfg.setProperty("autoPlay",A,true)}if(this._autoPlayTimer!==null){return this._autoPlayTimer}var C=this;var B=function(){C.scrollNext()};this._autoPlayTimer=setTimeout(B,this.cfg.getProperty("autoPlay"));return this._autoPlayTimer},stopAutoPlay:function(){if(this._autoPlayTimer!==null){clearTimeout(this._autoPlayTimer);this._autoPlayTimer=null}},isVertical:function(){return(this.cfg.getProperty("orientation")!="horizontal")},isItemLoaded:function(A){var B=this.getItem(A);if(this._isValidObj(B)&&!this._isValidObj(B.placeholder)){return true}return false},getItem:function(A){var B=this._carouselElemID+"-item-"+A;var C=YAHOO.util.Dom.get(B);return C},show:function(){YAHOO.util.Dom.setStyle(this.carouselElem,"display","block");this.calculateSize()},hide:function(){YAHOO.util.Dom.setStyle(this.carouselElem,"display","none")},calculateSize:function(){var f=this.carouselList.childNodes;var Q=null;for(var a=0;a<f.length;a++){Q=f[a];if(Q.tagName=="LI"||Q.tagName=="li"){break}}var Z=this.cfg.getProperty("navMargin");var h=this.cfg.getProperty("numVisible");var H=this.cfg.getProperty("firstVisible");var d=this._getStyleVal(Q,"paddingLeft");var W=this._getStyleVal(Q,"paddingRight");var c=this._getStyleVal(Q,"marginLeft");var V=this._getStyleVal(Q,"marginRight");var U=this._getStyleVal(Q,"paddingTop");var C=this._getStyleVal(Q,"paddingBottom");var T=this._getStyleVal(Q,"marginTop");var A=this._getStyleVal(Q,"marginBottom");YAHOO.util.Dom.removeClass(this.carouselList,"carousel-vertical");YAHOO.util.Dom.removeClass(this.carouselList,"carousel-horizontal");if(this.isVertical()){var S=d+W+c+V;YAHOO.util.Dom.addClass(this.carouselList,"carousel-vertical");var F=U+C+T+A;var J=this._getStyleVal(this.carouselList,"paddingTop");var Y=this._getStyleVal(this.carouselList,"paddingBottom");var I=this._getStyleVal(this.carouselList,"marginTop");var X=this._getStyleVal(this.carouselList,"marginBottom");var g=J+Y+I+X;var O=(this._isExtraRevealed())?(this.cfg.getProperty("revealAmount")+(F)/2):0;var D=this._getStyleVal(Q,"height",true);this.scrollAmountPerInc=(D+F);var E=this._getStyleVal(Q,"width");this.carouselElem.style.width=(E+S)+"px";this._clipReg.style.height=(this.scrollAmountPerInc*h+O*2+g)+"px";this.carouselElem.style.height=(this.scrollAmountPerInc*h+O*2+Z*2+g)+"px";var b=(this._isExtraRevealed())?(O-(Math.abs(T-A)+Math.abs(U-C))/2):0;YAHOO.util.Dom.setStyle(this.carouselList,"position","relative");YAHOO.util.Dom.setStyle(this.carouselList,"top",""+b+"px");var M=YAHOO.util.Dom.getY(this.carouselList);YAHOO.util.Dom.setY(this.carouselList,M-this.scrollAmountPerInc*(H-1))}else{YAHOO.util.Dom.addClass(this.carouselList,"carousel-horizontal");var R=this._getStyleVal(this.carouselList,"paddingLeft");var L=this._getStyleVal(this.carouselList,"paddingRight");var P=this._getStyleVal(this.carouselList,"marginLeft");var K=this._getStyleVal(this.carouselList,"marginRight");var G=R+L+P+K;var e=c+V;var S=e+W+d;var O=(this._isExtraRevealed())?(this.cfg.getProperty("revealAmount")+(S)/2):0;var E=Q.offsetWidth;this.scrollAmountPerInc=E+e;this._clipReg.style.width=(this.scrollAmountPerInc*h+O*2)+"px";this.carouselElem.style.width=(this.scrollAmountPerInc*h+Z*2+O*2+G)+"px";var B=(this._isExtraRevealed())?(O-(Math.abs(V-c)+Math.abs(W-d))/2-(P+R)):0;YAHOO.util.Dom.setStyle(this.carouselList,"position","relative");YAHOO.util.Dom.setStyle(this.carouselList,"left",""+B+"px");var N=YAHOO.util.Dom.getX(this.carouselList);YAHOO.util.Dom.setX(this.carouselList,N-this.scrollAmountPerInc*(H-1))}},setProperty:function(C,B,A){this.cfg.setProperty(C,B,A)},getProperty:function(A){return this.cfg.getProperty(A)},getFirstItemRevealed:function(){return this._firstItemRevealed},getLastItemRevealed:function(){return this._lastItemRevealed},getFirstVisible:function(){return this.cfg.getProperty("firstVisible")},getLastVisible:function(){var B=this.cfg.getProperty("firstVisible");var A=this.cfg.getProperty("numVisible");return B+A-1},_getStyleVal:function(A,C,D){var B=YAHOO.util.Dom.getStyle(A,C);var E=D?parseFloat(B):parseInt(B,10);if(C=="height"&&isNaN(E)){E=A.offsetHeight}else{if(isNaN(E)){E=0}}return E},_calculateSize:function(A){A.calculateSize();A.show()},_removeChildrenFromNode:function(B){if(!this._isValidObj(B)){return }var A=B.childNodes.length;while(B.hasChildNodes()){B.removeChild(B.firstChild)}},_prebuildLiElem:function(A){if(A<1){return }var B=document.createElement("li");B.id=this._carouselElemID+"-item-"+A;B.placeholder=true;this.carouselList.appendChild(B);this._lastPrebuiltIdx=(A>this._lastPrebuiltIdx)?A:this._lastPrebuiltIdx},_createItem:function(B,A){if(B<1){return }var C=document.createElement("li");C.id=this._carouselElemID+"-item-"+B;if(typeof (A)==="string"){C.innerHTML=A}else{C.appendChild(A)}return C},_insertAfterItem:function(B,A){return this._insertBeforeItem(B+1,A)},_insertBeforeItem:function(G,A){var B=this.getItem(G);var D=this.cfg.getProperty("size");if(D!=this.UNBOUNDED_SIZE){this.cfg.setProperty("size",D+1,true)}for(var C=this._lastPrebuiltIdx;C>=G;C--){var F=this.getItem(C);if(this._isValidObj(F)){F.id=this._carouselElemID+"-item-"+(C+1)}}var H=this._createItem(G,A);var E=this.carouselList.insertBefore(H,B);this._lastPrebuiltIdx+=1;return H},insertAfterEnd:function(A){return this.insertAfter(this.cfg.getProperty("size"),A)},_position:function(A,B){var C=this._priorFirstVisible;if(A>C){var D=A-C;this._scrollNextInc(D,B)}else{var E=C-A;this._scrollPrevInc(E,B)}},_scrollPrev:function(B,A){if(B!==null){A.stopAutoPlay()}A._scrollPrevInc(A.cfg.getProperty("scrollInc"),(A.cfg.getProperty("animationSpeed")!==0))},_scrollNext:function(B,A){if(B!==null){A.stopAutoPlay()}A._scrollNextInc(A.cfg.getProperty("scrollInc"),(A.cfg.getProperty("animationSpeed")!==0))},_handleAnimationComplete:function(C,B,A){var E=A[0];var D=A[1];E._animationCompleteEvt.fire(D)},_areAllItemsLoaded:function(D,C){var A=true;for(var B=D;B<=C;B++){var E=this.getItem(B);if(!this._isValidObj(E)){this._prebuildLiElem(B);A=false}else{if(this._isValidObj(E.placeholder)){A=false}}}return A},_prebuildItems:function(C,B){for(var A=C;A<=B;A++){var D=this.getItem(A);if(!this._isValidObj(D)){this._prebuildLiElem(A)}}},_isExtraRevealed:function(){return(this.cfg.getProperty("revealAmount")>0)},_scrollNextInc:function(E,J){if(this._scrollNextAnim.isAnimated()||this._scrollPrevAnim.isAnimated()){return false}var N=this.cfg.getProperty("numVisible");var L=this._priorFirstVisible;var I=this._priorLastVisible;var O=this.cfg.getProperty("size");var A=this._calculateAllowableScrollExtent();if(this.cfg.getProperty("wrap")&&I==A.end){this.scrollTo(A.start);return }var K=L+E;var G=K+N-1;if(G>A.end){G=A.end;K=G-N+1}E=K-L;this.cfg.setProperty("firstVisible",K,true);if(E>0){if(this._isValidObj(this.cfg.getProperty("loadNextHandler"))){var D=this._calculateVisibleExtent(K,G);var F=(I+1)<D.start?(I+1):D.start;var H=this._areAllItemsLoaded(F,D.end);this._loadNextHandlerEvt.fire(D.start,D.end,H)}if(J){var M={points:{by:[-this.scrollAmountPerInc*E,0]}};if(this.isVertical()){M={points:{by:[0,-this.scrollAmountPerInc*E]}}}this._scrollNextAnim=new YAHOO.util.Motion(this.carouselList,M,this.cfg.getProperty("animationSpeed"),this.cfg.getProperty("animationMethod"));if(this.cfg.getProperty("animationCompleteHandler")){this._scrollNextAnim.onComplete.subscribe(this._handleAnimationComplete,[this,"next"])}this._scrollNextAnim.animate()}else{if(this.isVertical()){var B=YAHOO.util.Dom.getY(this.carouselList);YAHOO.util.Dom.setY(this.carouselList,B-this.scrollAmountPerInc*E)}else{var C=YAHOO.util.Dom.getX(this.carouselList);YAHOO.util.Dom.setX(this.carouselList,C-this.scrollAmountPerInc*E)}}}this._priorFirstVisible=K;this._priorLastVisible=G;this._enableDisableControls();return false},_scrollPrevInc:function(G,J){if(this._scrollNextAnim.isAnimated()||this._scrollPrevAnim.isAnimated()){return false}var N=this.cfg.getProperty("numVisible");var L=this._priorFirstVisible;var I=this._priorLastVisible;var O=this.cfg.getProperty("size");var K=L-G;var A=this._calculateAllowableScrollExtent();K=(K<A.start)?A.start:K;var F=K+N-1;if(F>A.end){F=A.end;K=F-N+1}G=L-K;this.cfg.setProperty("firstVisible",K,true);if(G>0){if(this._isValidObj(this.cfg.getProperty("loadPrevHandler"))){var E=this._calculateVisibleExtent(K,F);var C=(L-1)>E.end?(L-1):E.end;var H=this._areAllItemsLoaded(E.start,C);this._loadPrevHandlerEvt.fire(E.start,E.end,H)}if(J){var M={points:{by:[this.scrollAmountPerInc*G,0]}};if(this.isVertical()){M={points:{by:[0,this.scrollAmountPerInc*G]}}}this._scrollPrevAnim=new YAHOO.util.Motion(this.carouselList,M,this.cfg.getProperty("animationSpeed"),this.cfg.getProperty("animationMethod"));if(this.cfg.getProperty("animationCompleteHandler")){this._scrollPrevAnim.onComplete.subscribe(this._handleAnimationComplete,[this,"prev"])}this._scrollPrevAnim.animate()}else{if(this.isVertical()){var B=YAHOO.util.Dom.getY(this.carouselList);YAHOO.util.Dom.setY(this.carouselList,B+this.scrollAmountPerInc*G)}else{var D=YAHOO.util.Dom.getX(this.carouselList);YAHOO.util.Dom.setX(this.carouselList,D+this.scrollAmountPerInc*G)}}}this._priorFirstVisible=K;this._priorLastVisible=F;this._enableDisableControls();return false},_enableDisableControls:function(){var C=this.cfg.getProperty("firstVisible");var A=this.getLastVisible();var B=this._calculateAllowableScrollExtent();if(this._prevEnabled){if(C===B.start){this._disablePrev()}}if(this._prevEnabled===false){if(C>B.start){this._enablePrev()}}if(this._nextEnabled){if(A===B.end){this._disableNext()}}if(this._nextEnabled===false){if(A<B.end){this._enableNext()}}},_loadInitial:function(){var C=this.cfg.getProperty("firstVisible");this._priorLastVisible=this.getLastVisible();if(this._loadInitHandlerEvt){var A=this._calculateVisibleExtent(C,this._priorLastVisible);var B=this._areAllItemsLoaded(1,A.end);this._loadInitHandlerEvt.fire(A.start,A.end,B)}if(this.cfg.getProperty("autoPlay")!==0){this._autoPlayTimer=this.startAutoPlay()}this._enableDisableControls()},_calculateAllowableScrollExtent:function(){var D=this.cfg.getProperty("scrollBeforeAmount");var A=this.cfg.getProperty("scrollAfterAmount");var B=this.cfg.getProperty("size");var C={start:1-D,end:B+A};return C},_calculateVisibleExtent:function(D,A){if(!D){D=this.cfg.getProperty("firstVisible");A=this.getLastVisible()}var B=this.cfg.getProperty("size");D=D<1?1:D;A=A>B?B:A;var C={start:D,end:A};this._firstItemRevealed=-1;this._lastItemRevealed=-1;if(this._isExtraRevealed()){if(D>1){this._firstItemRevealed=D-1;C.start=this._firstItemRevealed}if(A<B){this._lastItemRevealed=A+1;C.end=this._lastItemRevealed}}return C},_disablePrev:function(){this._prevEnabled=false;if(this._prevButtonStateHandlerEvt){this._prevButtonStateHandlerEvt.fire(false,this._carouselPrev)}if(this._isValidObj(this._carouselPrev)){YAHOO.util.Event.removeListener(this._carouselPrev,"click",this._scrollPrev)}},_enablePrev:function(){this._prevEnabled=true;if(this._prevButtonStateHandlerEvt){this._prevButtonStateHandlerEvt.fire(true,this._carouselPrev)}if(this._isValidObj(this._carouselPrev)){YAHOO.util.Event.addListener(this._carouselPrev,"click",this._scrollPrev,this)}},_disableNext:function(){if(this.cfg.getProperty("wrap")){return }this._nextEnabled=false;if(this._isValidObj(this._nextButtonStateHandlerEvt)){this._nextButtonStateHandlerEvt.fire(false,this._carouselNext)}if(this._isValidObj(this._carouselNext)){YAHOO.util.Event.removeListener(this._carouselNext,"click",this._scrollNext)}},_enableNext:function(){this._nextEnabled=true;if(this._isValidObj(this._nextButtonStateHandlerEvt)){this._nextButtonStateHandlerEvt.fire(true,this._carouselNext)}if(this._isValidObj(this._carouselNext)){YAHOO.util.Event.addListener(this._carouselNext,"click",this._scrollNext,this)}},_isValidObj:function(A){if(null==A){return false}if("undefined"==typeof (A)){return false}return true}};

YAHOO.widget.Effects=function(){return{version:'0.8'}}();YAHOO.widget.Effects.Hide=function(inElm){this.element=YAHOO.util.Dom.get(inElm);YAHOO.util.Dom.setStyle(this.element,'display','none');YAHOO.util.Dom.setStyle(this.element,'visibility','hidden');}
YAHOO.widget.Effects.Hide.prototype.toString=function(){return'Effect Hide ['+this.element.id+']';}
YAHOO.widget.Effects.Show=function(inElm){this.element=YAHOO.util.Dom.get(inElm);YAHOO.util.Dom.setStyle(this.element,'display','block');YAHOO.util.Dom.setStyle(this.element,'visibility','visible');}
YAHOO.widget.Effects.Show.prototype.toString=function(){return'Effect Show ['+this.element.id+']';}
YAHOO.widget.Effects.Fade=function(inElm,opts){this.element=YAHOO.util.Dom.get(inElm);var attributes={opacity:{from:1,to:0}};this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){YAHOO.widget.Effects.Hide(this.element);this.onEffectComplete.fire();},this,true);if(!delay){this.effect.animate();}}
YAHOO.widget.Effects.Fade.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.Fade.prototype.toString=function(){return'Effect Fade ['+this.element.id+']';}
YAHOO.widget.Effects.Appear=function(inElm,opts){this.element=YAHOO.util.Dom.get(inElm);YAHOO.util.Dom.setStyle(this.element,'opacity','0');YAHOO.widget.Effects.Show(this.element);var attributes={opacity:{from:0,to:1}};this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:3);var delay=((opts&&opts.delay)?opts.delay:false);this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){this.onEffectComplete.fire();},this,true);if(!delay){this.effect.animate();}}
YAHOO.widget.Effects.Appear.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.Appear.prototype.toString=function(){return'Effect Appear ['+this.element.id+']';}
YAHOO.widget.Effects.BlindUp=function(inElm,opts){var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);var ghost=((opts&&opts.ghost)?opts.ghost:false);this.element=YAHOO.util.Dom.get(inElm);this._height=$T.getHeight(this.element);this._top=parseInt($D.getStyle(this.element,'top'));this._opts=opts;YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');var attributes={height:{to:0}};if(ghost){attributes.opacity={to:0,from:1}}
this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);if(opts&&opts.bind&&(opts.bind=='bottom')){var attributes={height:{from:0,to:parseInt(this._height)},top:{from:(this._top+parseInt(this._height)),to:this._top}};if(ghost){attributes.opacity={to:1,from:0}}}
this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){if(this._opts&&this._opts.bind&&(this._opts.bind=='bottom')){YAHOO.util.Dom.setStyle(this.element,'top',this._top+'px');}else{YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'height',this._height);}
YAHOO.util.Dom.setStyle(this.element,'opacity',1);this.onEffectComplete.fire();},this,true);if(!delay){this.animate();}}
YAHOO.widget.Effects.BlindUp.prototype.prepStyle=function(){if(this._opts&&this._opts.bind&&(this._opts.bind=='bottom')){YAHOO.util.Dom.setStyle(this.element,'height','0px');YAHOO.util.Dom.setStyle(this.element,'top',this._height);}
YAHOO.widget.Effects.Show(this.element);}
YAHOO.widget.Effects.BlindUp.prototype.animate=function(){this.prepStyle();this.effect.animate();}
YAHOO.widget.Effects.BlindUp.prototype.toString=function(){return'Effect BlindUp ['+this.element.id+']';}
YAHOO.widget.Effects.BlindDown=function(inElm,opts){var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);var ghost=((opts&&opts.ghost)?opts.ghost:false);this.element=YAHOO.util.Dom.get(inElm);this._opts=opts;this._height=parseInt($T.getHeight(this.element));this._top=parseInt($D.getStyle(this.element,'top'));YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');var attributes={height:{from:0,to:this._height}};if(ghost){attributes.opacity={to:1,from:0}}
this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);if(opts&&opts.bind&&(opts.bind=='bottom')){var attributes={height:{to:0,from:parseInt(this._height)},top:{to:(this._top+parseInt(this._height)),from:this._top}};if(ghost){attributes.opacity={to:0,from:1}}}
this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);if(opts&&opts.bind&&(opts.bind=='bottom')){this.effect.onComplete.subscribe(function(){YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'top',this._top+'px');YAHOO.util.Dom.setStyle(this.element,'height',this._height+'px');YAHOO.util.Dom.setStyle(this.element,'opacity',1);this.onEffectComplete.fire();},this,true);}else{this.effect.onComplete.subscribe(function(){YAHOO.util.Dom.setStyle(this.element,'opacity',1);this.onEffectComplete.fire();},this,true);}
if(!delay){this.animate();}}
YAHOO.widget.Effects.BlindDown.prototype.prepStyle=function(){if(this._opts&&this._opts.bind&&(this._opts.bind=='bottom')){}else{YAHOO.util.Dom.setStyle(this.element,'height','0px');}
YAHOO.widget.Effects.Show(this.element);}
YAHOO.widget.Effects.BlindDown.prototype.animate=function(){this.prepStyle();this.effect.animate();}
YAHOO.widget.Effects.BlindDown.prototype.toString=function(){return'Effect BlindDown ['+this.element.id+']';}
YAHOO.widget.Effects.BlindRight=function(inElm,opts){var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);var ghost=((opts&&opts.ghost)?opts.ghost:false);this.element=YAHOO.util.Dom.get(inElm);this._width=parseInt(YAHOO.util.Dom.getStyle(this.element,'width'));this._left=parseInt(YAHOO.util.Dom.getStyle(this.element,'left'));this._opts=opts;YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var attributes={width:{from:0,to:this._width}};if(ghost){attributes.opacity={to:1,from:0}}
if(opts&&opts.bind&&(opts.bind=='right')){var attributes={width:{to:0},left:{to:this._left+parseInt(this._width),from:this._left}};if(ghost){attributes.opacity={to:0,from:1}}}
this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);if(opts&&opts.bind&&(opts.bind=='right')){this.effect.onComplete.subscribe(function(){YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'width',this._width+'px');YAHOO.util.Dom.setStyle(this.element,'left',this._left+'px');this._width=null;YAHOO.util.Dom.setStyle(this.element,'opacity',1);this.onEffectComplete.fire();},this,true);}else{this.effect.onComplete.subscribe(function(){YAHOO.util.Dom.setStyle(this.element,'opacity',1);this.onEffectComplete.fire();},this,true);}
if(!delay){this.animate();}}
YAHOO.widget.Effects.BlindRight.prototype.prepStyle=function(){if(this._opts&&this._opts.bind&&(this._opts.bind=='right')){}else{YAHOO.util.Dom.setStyle(this.element,'width','0');}}
YAHOO.widget.Effects.BlindRight.prototype.animate=function(){this.prepStyle();this.effect.animate();}
YAHOO.widget.Effects.BlindRight.prototype.toString=function(){return'Effect BlindRight ['+this.element.id+']';}
YAHOO.widget.Effects.BlindLeft=function(inElm,opts){var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);var ghost=((opts&&opts.ghost)?opts.ghost:false);this.ghost=ghost;this.element=YAHOO.util.Dom.get(inElm);this._width=YAHOO.util.Dom.getStyle(this.element,'width');this._left=parseInt(YAHOO.util.Dom.getStyle(this.element,'left'));this._opts=opts;YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');var attributes={width:{to:0}};if(ghost){attributes.opacity={to:0,from:1}}
this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);if(opts&&opts.bind&&(opts.bind=='right')){var attributes={width:{from:0,to:parseInt(this._width)},left:{from:this._left+parseInt(this._width),to:this._left}};if(ghost){attributes.opacity={to:1,from:0}}}
this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);if(opts&&opts.bind&&(opts.bind=='right')){this.effect.onComplete.subscribe(function(){this.onEffectComplete.fire();},this,true);}else{this.effect.onComplete.subscribe(function(){YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'width',this._width);YAHOO.util.Dom.setStyle(this.element,'left',this._left+'px');YAHOO.util.Dom.setStyle(this.element,'opacity',1);this._width=null;this.onEffectComplete.fire();},this,true);}
if(!delay){this.animate();}}
YAHOO.widget.Effects.BlindLeft.prototype.prepStyle=function(){if(this._opts&&this._opts.bind&&(this._opts.bind=='right')){YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'width','0px');YAHOO.util.Dom.setStyle(this.element,'left',parseInt(this._width));if(this.ghost){YAHOO.util.Dom.setStyle(this.element,'opacity',0);}
YAHOO.widget.Effects.Show(this.element);}}
YAHOO.widget.Effects.BlindLeft.prototype.animate=function(){this.prepStyle();this.effect.animate();}
YAHOO.widget.Effects.BlindLeft.prototype.toString=function(){return'Effect BlindLeft ['+this.element.id+']';}
YAHOO.widget.Effects.Fold=function(inElm,opts){var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);this.ghost=((opts&&opts.ghost)?opts.ghost:false);this.element=YAHOO.util.Dom.get(inElm);this._to=5;if(!delay){YAHOO.widget.Effects.Show(this.element);}
YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');this.done=false;this._height=parseInt($T.getHeight(this.element));this._width=YAHOO.util.Dom.getStyle(this.element,'width');this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);if(opts&&opts.to){this._to=opts.to;}
var attributes={height:{to:this._to}};this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){if(this.done){YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'height',this._height+'px');YAHOO.util.Dom.setStyle(this.element,'width',this._width);this.onEffectComplete.fire();}else{this.done=true;this.effect.attributes={width:{to:0},height:{from:this._to,to:this._to}}
if(this.ghost){this.effect.attributes.opacity={to:0,from:1}}
this.animate();}},this,true);if(!delay){this.animate();}}
YAHOO.widget.Effects.Fold.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.Fold.prototype.toString=function(){return'Effect Fold ['+this.element.id+']';}
YAHOO.widget.Effects.UnFold=function(inElm,opts){var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);this.ghost=((opts&&opts.ghost)?opts.ghost:false);this.element=YAHOO.util.Dom.get(inElm);this._height=$T.getHeight(this.element);this._width=YAHOO.util.Dom.getStyle(this.element,'width');this._to=5;YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');this.done=false;this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);if(opts&&opts.to){this._to=opts.to;}
attributes={height:{from:0,to:this._to},width:{from:0,to:parseInt(this._width)}};if(this.ghost){attributes.opacity={to:.15,from:0}}
this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){if(this.done){this.onEffectComplete.fire();this.done=false;}else{this.done=true;this.effect.attributes={width:{from:parseInt(this._width),to:parseInt(this._width)},height:{from:this._to,to:parseInt(this._height)}}
if(this.ghost){this.effect.attributes.opacity={to:1,from:.15}}
this.effect.animate();}},this,true);if(!delay){this.animate();}}
YAHOO.widget.Effects.UnFold.prototype.prepStyle=function(){YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'height','0px');YAHOO.util.Dom.setStyle(this.element,'width','0px');this.effect.attributes=attributes;}
YAHOO.widget.Effects.UnFold.prototype.animate=function(){this.prepStyle();YAHOO.widget.Effects.Show(this.element);this.effect.animate();}
YAHOO.widget.Effects.UnFold.prototype.toString=function(){return'Effect UnFold ['+this.element.id+']';}
YAHOO.widget.Effects.ShakeLR=function(inElm,opts){this.element=YAHOO.util.Dom.get(inElm);this._offSet=10;this._maxCount=5;this._counter=0;this._elmPos=YAHOO.util.Dom.getXY(this.element);var attributes={left:{to:(-this._offSet)}};this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);if(opts&&opts.offset){this._offSet=opts.offset;}
if(opts&&opts.maxcount){this._maxCount=opts.maxcount;}
var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:.25);var delay=((opts&&opts.delay)?opts.delay:false);this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){if(this.done){this.onEffectComplete.fire();}else{if(this._counter<this._maxCount){this._counter++;if(this._left){this._left=null;this.effect.attributes={left:{to:(-this._offSet)}}}else{this._left=true;this.effect.attributes={left:{to:this._offSet}}}
this.effect.animate();}else{this.done=true;this._left=null;this._counter=null;this.effect.attributes={left:{to:0}}
this.effect.animate();}}},this,true);if(!delay){this.effect.animate();}}
YAHOO.widget.Effects.ShakeLR.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.ShakeLR.prototype.toString=function(){return'Effect ShakeLR ['+this.element.id+']';}
YAHOO.widget.Effects.ShakeTB=function(inElm,opts){this.element=YAHOO.util.Dom.get(inElm);this._offSet=10;this._maxCount=5;this._counter=0;this._elmPos=YAHOO.util.Dom.getXY(this.element);var attributes={top:{to:(-this._offSet)}};if(opts&&opts.offset){this._offSet=opts.offset;}
if(opts&&opts.maxcount){this._maxCount=opts.maxcount;}
this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:.25);var delay=((opts&&opts.delay)?opts.delay:false);this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){if(this.done){this.onEffectComplete.fire();}else{if(this._counter<this._maxCount){this._counter++;if(this._left){this._left=null;this.effect.attributes={top:{to:(-this._offSet)}}}else{this._left=true;this.effect.attributes={top:{to:this._offSet}}}
this.effect.animate();}else{this.done=true;this._left=null;this._counter=null;this.effect.attributes={top:{to:0}}
this.effect.animate();}}},this,true);if(!delay){this.effect.animate();}}
YAHOO.widget.Effects.ShakeTB.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.ShakeTB.prototype.toString=function(){return'Effect ShakeTB ['+this.element.id+']';}
YAHOO.widget.Effects.Drop=function(inElm,opts){this.element=YAHOO.util.Dom.get(inElm);this._height=parseInt($T.getHeight(this.element));this._top=parseInt($D.getStyle(this.element,'top'));var attributes={top:{from:this._top,to:(this._top+this._height)},opacity:{from:1,to:0}};this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeIn);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'top',this._top+'px');YAHOO.util.Dom.setStyle(this.element,'opacity',1);this.onEffectComplete.fire();},this,true);if(!delay){this.animate();}}
YAHOO.widget.Effects.Drop.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.Drop.prototype.toString=function(){return'Effect Drop ['+this.element.id+']';}
YAHOO.widget.Effects.Pulse=function(inElm,opts){this.element=YAHOO.util.Dom.get(inElm);this._counter=0;this._maxCount=9;var attributes={opacity:{from:1,to:0}};if(opts&&opts.maxcount){this._maxCount=opts.maxcount;}
this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeIn);var secs=((opts&&opts.seconds)?opts.seconds:.25);var delay=((opts&&opts.delay)?opts.delay:false);this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){if(this.done){this.onEffectComplete.fire();}else{if(this._counter<this._maxCount){this._counter++;if(this._on){this._on=null;this.effect.attributes={opacity:{to:0}}}else{this._on=true;this.effect.attributes={opacity:{to:1}}}
this.effect.animate();}else{this.done=true;this._on=null;this._counter=null;this.effect.attributes={opacity:{to:1}}
this.effect.animate();}}},this,true);if(!delay){this.effect.animate();}}
YAHOO.widget.Effects.Pulse.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.Pulse.prototype.toString=function(){return'Effect Pulse ['+this.element.id+']';}
YAHOO.widget.Effects.Shrink=function(inElm,opts){this.start_elm=YAHOO.util.Dom.get(inElm);this.element=this.start_elm.cloneNode(true);this.start_elm.parentNode.replaceChild(this.element,this.start_elm);YAHOO.widget.Effects.Hide(this.start_elm);YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);var attributes={width:{to:0},height:{to:0},fontSize:{from:100,to:0,unit:'%'},opacity:{from:1,to:0}};this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){this.element.parentNode.replaceChild(this.start_elm,this.element);this.onEffectComplete.fire();},this,true);if(!delay){this.effect.animate();}}
YAHOO.widget.Effects.Shrink.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.Shrink.prototype.toString=function(){return'Effect Shrink ['+this.element.id+']';}
YAHOO.widget.Effects.Grow=function(inElm,opts){this.element=YAHOO.util.Dom.get(inElm);var h=parseInt($T.getHeight(this.element));var w=parseInt(YAHOO.util.Dom.getStyle(this.element,'width'));YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);var attributes={width:{to:w,from:0},height:{to:h,from:0},fontSize:{from:0,to:100,unit:'%'},opacity:{from:0,to:1}};this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){this.onEffectComplete.fire();},this,true);if(!delay){this.animate();}}
YAHOO.widget.Effects.Grow.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.Grow.prototype.toString=function(){return'Effect Grow ['+this.element.id+']';}
YAHOO.widget.Effects.TV=function(inElm,opts){var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeIn);var secs=((opts&&opts.seconds)?opts.seconds:1);var delay=((opts&&opts.delay)?opts.delay:false);this.element=YAHOO.util.Dom.get(inElm);this.done=false;this._height=parseInt($T.getHeight(this.element));this._width=parseInt(YAHOO.util.Dom.getStyle(this.element,'width'));YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');var attributes={top:{from:0,to:(this._height/2)},height:{to:5}};this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);this.effect=new YAHOO.util.Anim(this.element,attributes,secs,ease);this.effect.onComplete.subscribe(function(){if(this.done){this.onEffectComplete.fire();YAHOO.widget.Effects.Hide(this.element);YAHOO.util.Dom.setStyle(this.element,'height',this._height+'px');YAHOO.util.Dom.setStyle(this.element,'width',this._width+'px');YAHOO.util.Dom.setStyle(this.element,'top','');YAHOO.util.Dom.setStyle(this.element,'left','');YAHOO.util.Dom.setStyle(this.element,'opacity','1');}else{this.done=true;this.effect.attributes={top:{from:(this._height/2),to:(this._height/2)},left:{from:0,to:(this._width/2)},height:{from:5,to:5},width:{to:5},opacity:{from:1,to:0}};this.effect.animate();}},this,true);if(!delay){this.animate();}}
YAHOO.widget.Effects.TV.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.TV.prototype.toString=function(){return'Effect TV ['+this.element.id+']';}
YAHOO.widget.Effects.Shadow=function(inElm,opts){var delay=((opts&&opts.delay)?opts.delay:false);var topOffset=((opts&&opts.top)?opts.top:8);var leftOffset=((opts&&opts.left)?opts.left:8);var shadowColor=((opts&&opts.color)?opts.color:'#ccc');var shadowOpacity=((opts&&opts.opacity)?opts.opacity:.75);this.element=YAHOO.util.Dom.get(inElm);if(YAHOO.util.Dom.get(this.element.id+'_shadow')){this.shadow=YAHOO.util.Dom.get(this.element.id+'_shadow');}else{this.shadow=document.createElement('div');this.shadow.id=this.element.id+'_shadow';this.element.parentNode.appendChild(this.shadow);}
var h=parseInt($T.getHeight(this.element));var w=parseInt(YAHOO.util.Dom.getStyle(this.element,'width'));var z=this.element.style.zIndex;if(!z){z=1;this.element.style.zIndex=z;}
YAHOO.util.Dom.setStyle(this.element,'overflow','hidden');YAHOO.util.Dom.setStyle(this.shadow,'height',h+'px');YAHOO.util.Dom.setStyle(this.shadow,'width',w+'px');YAHOO.util.Dom.setStyle(this.shadow,'background-color',shadowColor);YAHOO.util.Dom.setStyle(this.shadow,'opacity',0);YAHOO.util.Dom.setStyle(this.shadow,'position','absolute');this.shadow.style.zIndex=(z-1);var xy=YAHOO.util.Dom.getXY(this.element);this.onEffectComplete=new YAHOO.util.CustomEvent('oneffectcomplete',this);var attributes={opacity:{from:0,to:shadowOpacity},top:{from:xy[1],to:(xy[1]+topOffset)},left:{from:xy[0],to:(xy[0]+leftOffset)}};this.effect=new YAHOO.util.Anim(this.shadow,attributes);this.effect.onComplete.subscribe(function(){this.onEffectComplete.fire();},this,true);if(!delay){this.animate();}}
YAHOO.widget.Effects.Shadow.prototype.animate=function(){this.effect.animate();}
YAHOO.widget.Effects.Shadow.prototype.toString=function(){return'Effect Shadow ['+this.element.id+']';}
YAHOO.widget.Effects.Puff=function(inElm,opts){var start_elm=YAHOO.util.Dom.get(inElm);this.element=start_this.element.cloneNode(true);start_this.element.parentNode.replaceChild(this.element,start_elm);YAHOO.widget.Effects.Hide(start_elm);var xy=YAHOO.util.Dom.getXY(this.element);var h=parseInt($T.getHeight(this.element));var w=parseInt(YAHOO.util.Dom.getStyle(this.element,'width'));var nh=((h/2)+h);var nw=((w/2)+w);var nto=((nh-h)/2);var nlo=((nw-w)/2);var nt=xy[1]-nto;var nl=xy[0]-nlo;YAHOO.util.Dom.setStyle(this.element,'position','absolute');var attributes={top:{to:nt},left:{to:nl},width:{to:nw},height:{to:nh},opacity:{from:1,to:0}};var ease=((opts&&opts.ease)?opts.ease:YAHOO.util.Easing.easeOut);var secs=((opts&&opts.seconds)?opts.seconds:1);var puff=new YAHOO.util.Anim(this.element,attributes,secs,ease);puff.onComplete.subscribe(function(){this.element=this.getEl();this.element.parentNode.replaceChild(start_elm,elm);});puff.animate();return puff;}
if(!YAHOO.Tools){$T={getHeight:function(el){return YAHOO.util.Dom.getStyle(el,'height');}}}
YAHOO.widget.Effects.Batch=function(effects,opts){}
YAHOO.widget.Effects.ContainerEffect=function(){}
YAHOO.widget.Effects.ContainerEffect.BlindUpDownBinded=function(overlay,dur){var bupdownbinded=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindUp',opts:{bind:'bottom'}},duration:dur},{attributes:{effect:'BlindDown',opts:{bind:'bottom'}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bupdownbinded.init();return bupdownbinded;}
YAHOO.widget.Effects.ContainerEffect.BlindUpDown=function(overlay,dur){var bupdown=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindDown'},duration:dur},{attributes:{effect:'BlindUp'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bupdown.init();return bupdown;}
YAHOO.widget.Effects.ContainerEffect.BlindLeftRightBinded=function(overlay,dur){var bleftrightbinded=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindLeft',opts:{bind:'right'}},duration:dur},{attributes:{effect:'BlindRight',opts:{bind:'right'}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bleftrightbinded.init();return bleftrightbinded;}
YAHOO.widget.Effects.ContainerEffect.BlindLeftRight=function(overlay,dur){var bleftright=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindRight'},duration:dur},{attributes:{effect:'BlindLeft'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bleftright.init();return bleftright;}
YAHOO.widget.Effects.ContainerEffect.BlindRightFold=function(overlay,dur){var brightfold=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindRight'},duration:dur},{attributes:{effect:'Fold'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);brightfold.init();return brightfold;}
YAHOO.widget.Effects.ContainerEffect.BlindLeftFold=function(overlay,dur){var bleftfold=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindLeft',opts:{bind:'right'}},duration:dur},{attributes:{effect:'Fold'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bleftfold.init();return bleftfold;}
YAHOO.widget.Effects.ContainerEffect.UnFoldFold=function(overlay,dur){var bunfold=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'UnFold'},duration:dur},{attributes:{effect:'Fold'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bunfold.init();return bunfold;}
YAHOO.widget.Effects.ContainerEffect.BlindDownDrop=function(overlay,dur){var bdowndrop=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindDown'},duration:dur},{attributes:{effect:'Drop'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bdowndrop.init();return bdowndrop;}
YAHOO.widget.Effects.ContainerEffect.BlindUpDrop=function(overlay,dur){var bupdrop=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindUp',opts:{bind:'bottom'}},duration:dur},{attributes:{effect:'Drop'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bupdrop.init();return bupdrop;}
YAHOO.widget.Effects.ContainerEffect.BlindUpDownBindedGhost=function(overlay,dur){var bupdownbinded=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindUp',opts:{ghost:true,bind:'bottom'}},duration:dur},{attributes:{effect:'BlindDown',opts:{ghost:true,bind:'bottom'}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bupdownbinded.init();return bupdownbinded;}
YAHOO.widget.Effects.ContainerEffect.BlindUpDownGhost=function(overlay,dur){var bupdown=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindDown',opts:{ghost:true}},duration:dur},{attributes:{effect:'BlindUp',opts:{ghost:true}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bupdown.init();return bupdown;}
YAHOO.widget.Effects.ContainerEffect.BlindLeftRightBindedGhost=function(overlay,dur){var bleftrightbinded=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindLeft',opts:{bind:'right',ghost:true}},duration:dur},{attributes:{effect:'BlindRight',opts:{bind:'right',ghost:true}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bleftrightbinded.init();return bleftrightbinded;}
YAHOO.widget.Effects.ContainerEffect.BlindLeftRightGhost=function(overlay,dur){var bleftright=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindRight',opts:{ghost:true}},duration:dur},{attributes:{effect:'BlindLeft',opts:{ghost:true}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bleftright.init();return bleftright;}
YAHOO.widget.Effects.ContainerEffect.BlindRightFoldGhost=function(overlay,dur){var brightfold=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindRight',opts:{ghost:true}},duration:dur},{attributes:{effect:'Fold',opts:{ghost:true}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);brightfold.init();return brightfold;}
YAHOO.widget.Effects.ContainerEffect.BlindLeftFoldGhost=function(overlay,dur){var bleftfold=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindLeft',opts:{bind:'right',ghost:true}},duration:dur},{attributes:{effect:'Fold',opts:{ghost:true}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bleftfold.init();return bleftfold;}
YAHOO.widget.Effects.ContainerEffect.UnFoldFoldGhost=function(overlay,dur){var bleftfold=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'UnFold',opts:{ghost:true}},duration:dur},{attributes:{effect:'Fold',opts:{ghost:true}},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bleftfold.init();return bleftfold;}
YAHOO.widget.Effects.ContainerEffect.BlindDownDropGhost=function(overlay,dur){var bdowndrop=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindDown',opts:{ghost:true}},duration:dur},{attributes:{effect:'Drop'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bdowndrop.init();return bdowndrop;}
YAHOO.widget.Effects.ContainerEffect.BlindUpDropGhost=function(overlay,dur){var bupdrop=new YAHOO.widget.ContainerEffect(overlay,{attributes:{effect:'BlindUp',opts:{bind:'bottom',ghost:true}},duration:dur},{attributes:{effect:'Drop'},duration:dur},overlay.element,YAHOO.widget.Effects.Container);bupdrop.init();return bupdrop;}
YAHOO.widget.Effects.Container=function(el,attrs,dur){var opts={delay:true};if(attrs.opts){for(var i in attrs.opts){opts[i]=attrs.opts[i];}}
var func=eval('YAHOO.widget.Effects.'+attrs.effect);var eff=new func(el,opts);eff.onStart=eff.effect.onStart;eff.onTween=eff.effect.onTween;eff.onComplete=eff.onEffectComplete;return eff;}

var current_avatar;
var current_type;

YAHOO.namespace("dollspace.container");

function init_email_panel() {
	
	// Define various event handlers for Dialog
	var handleSubmit = function() {
        document.emailavatar.avatarid.value = current_avatar;
        document.emailavatar.type.value = current_type;
		var x = this.submit();
		if (x != false) {
		    YAHOO.dollspace.container.wait.setHeader("Sending email, please wait...");
		    YAHOO.dollspace.container.wait.show();
		}
	};
	var handleCancel = function() {
		this.cancel();
	};
	var handleSuccess = function(o) {
        YAHOO.dollspace.container.wait.hide();
		var response = o.responseText;
		if (response == -1) {
        	getEl("error_msg").innerHTML = "Email could not be sent";
        	YAHOO.dollspace.container.emailDialog.show();
		} else {
		    //do nothing
		}
	};
	var handleFailure = function(o) {
        YAHOO.dollspace.container.wait.hide();
		alert("Submission failed: " + o.status);
	};
	
	// Instantiate the Dialog
	YAHOO.dollspace.container.emailDialog = new YAHOO.widget.Dialog("email-dialog", 
							{ width : "30em",
							  fixedcenter : true,
							  visible : false, 
							  constraintoviewport : true,
							  buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
								      { text:"Cancel", handler:handleCancel } ]
							});

    


    function trim(stringToTrim) {
	    return stringToTrim.replace(/^\s+|\s+$/g,"");
    }
    
    function checkEmail(email) {
        var regExp = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
        return regExp.test(email);
    }

    function checkEmails(emails){
    	var emailArray = emails.split(",");
    	var invEmails = "";
    	for(i = 0; i <= (emailArray.length - 1); i++){
    	    var testEmail = trim(emailArray[i]);
    		if(checkEmail(testEmail)){
	    		//Do what ever with the email.
		    }else{
    			invEmails += testEmail + "\n";
    		}
    	}
	    if(invEmails != ""){
    		alert("Invalid address:\n" + invEmails);
    		return false;
    	}
    	return true;
    }
    
    
	// Validate the entries in the form to require that both email and message are entered
	YAHOO.dollspace.container.emailDialog.validate = function() {
		var data = this.getData();
        var filter = /^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-Z0-9\._%-]+@[A-Z0-9\.-]+))?$/i;

        var email = trim(data.email);		
		if (email == "" || data.message == "") {
			alert("Please enter an email address and message");
			return false;
		} else {
		    //if (!(filter.test(email))) {
		    if (!checkEmails(email)) {
		        //alert("Please enter a valid email address");
		        return false;
		    }
            return true;
		    //return checkEmails(data.email);
		}
	};

	// Wire up the success and failure handlers
	YAHOO.dollspace.container.emailDialog.callback = { success: handleSuccess,
						     failure: handleFailure };
	
	// Render the Dialog
	YAHOO.dollspace.container.emailDialog.render();
	
	var emailDialog = document.getElementById('email-dialog');
	emailDialog.style.display = "block";
}




function init_panels() {
	YAHOO.dollspace.container.saved_panel = new YAHOO.widget.Panel("saved-panel", { width:"400px", visible:false, fixedcenter: true, constraintoviewport:true } );
	YAHOO.dollspace.container.saved_panel.render();

	var savedPanel = document.getElementById('saved-panel');
	savedPanel.style.display = "block";
    init_email_panel();
}

    var handleSaveAvatarSuccess = function(o){
        //YAHOO.dollspace.container.saved_panel.setBody(o.responseText);
        if (o.responseText == 0) {
            if (current_type == "avatar") {
                getEl("saved-panel-output").innerHTML = "This avatar has been saved to 'My Favorite Avatars' in your profile";
            } else {
                getEl("saved-panel-output").innerHTML = "This icon has been saved to 'My Favorite Buddy Icons' in your profile";
            }
            YAHOO.dollspace.container.saved_panel.show();
        } else {
            alert(o.responseText);
        }   
    };

    var handleSaveAvatarFailure = function(o){
    	alert("Avatar could not be saved");
    };

    var saveAvatarCallback =
    {
      success:handleSaveAvatarSuccess,
      failure:handleSaveAvatarFailure,
      argument:['foo','bar']
    };

    var sUrl = "/favlist/addavatar";

    var makeSaveAvatarRequest = function(avatar_id, image_type){
        var postData;
        if (image_type == "avatar") {
            postData = "avatarid="+avatar_id;
        } else {
            postData = "iconid="+avatar_id;
            sUrl = "/favlist/addicon";
        }
    	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, saveAvatarCallback, postData);
    }

    var sUrl1 = "/avatar/makemyavatar";

    var handleMakeMyAvatarSuccess = function(o){
        //YAHOO.dollspace.container.saved_panel.setBody(o.responseText);
        if (o.responseText == 0) {
            getEl("saved-panel-output").innerHTML = "This avatar has been made as your profile avatar";
            YAHOO.dollspace.container.saved_panel.show();
        } else {
            alert(o.responseText);
        }   
    };

    var handleMakeMyAvatarFailure = function(o){
    	alert("Make my avatar request failed");
    };

    var makeMyAvatarCallback =
    {
      success:handleMakeMyAvatarSuccess,
      failure:handleMakeMyAvatarFailure,
      argument:['foo','bar']
    };

    var makeMyAvatarRequest = function(avatar_id, image_type){
        var postData = "avatarid="+avatar_id;
    	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl1, makeMyAvatarCallback, postData);
    }

YAHOO.util.Event.onDOMReady(init_panels);

    function show_login_error()
    {
        getEl("login_error_msg").innerHTML = "You need to be logged in before you can use this feature";
	    YAHOO.dollspace.container.dialog1.show();
    }

    function make_favorite(avatar_id, image_type)
    {
       current_avatar = avatar_id;
       current_type = image_type;
	   if (current_user != '') { 
	     makeSaveAvatarRequest(avatar_id, image_type);
       } else { 
         show_login_error();
       } 
    }
    function send_email(avatar_id, image_type)
    {
       current_avatar = avatar_id;
       current_type = image_type;
	  if (current_user != '') { 
	    YAHOO.dollspace.container.emailDialog.show();
      } else { 
        show_login_error();
      } 
    }
    function make_my_avatar(avatar_id, image_type)
    {
       current_avatar = avatar_id;
       current_type = image_type;
	   if (current_user != '') { 
	     makeMyAvatarRequest(avatar_id, image_type);
       } else { 
         show_login_error();
       } 
    }
    
