MySpace.UI.Carousel=function(A){this._carouselElemID=A.id;this.carouselElem=A;MySpace.UI.Carousel.initializeBase(this,[A])};MySpace.UI.Carousel.prototype={UNBOUNDED_SIZE:1000000,carouselListClass:"carousel-list",carouselClipRegionClass:"carousel-clip-region",carouselElem:null,carouselList:null,_carouselElemID:null,_prevEnabled:true,_nextEnabled:true,_scrollBeforeAmount:0,_scrollAfterAmount:0,_loadOnStart:true,_orientation:"horizontal",_size:1000000,_numVisible:3,_firstVisible:1,_scrollInc:3,_animationSpeed:0.25,_animationMethod:MySpace.UI.Effects.Easing.backOut,_autoPlay:0,_wrap:false,_navMargin:0,_revealAmount:0,_prevElement:null,_nextElement:null,_disableSelection:true,_fps:20,_numRows:1,get_scrollBeforeAmount:function(){return this._scrollBeforeAmount},set_scrollBeforeAmount:function(A){this._scrollBeforeAmount=A},get_scrollAfterAmount:function(){return this._scrollAfterAmount},set_scrollAfterAmount:function(A){this._scrollAfterAmount=A},get_loadOnStart:function(){return this._loadOnStart},set_loadOnStart:function(A){this._loadOnStart=A},get_orientation:function(){return this._orientation},set_orientation:function(A){this._orientation=A},get_size:function(){return this._size},set_size:function(A){this._size=A},get_numVisible:function(){return this._numVisible},set_numVisible:function(A){this._numVisible=A},get_firstVisible:function(){return this._firstVisible},set_firstVisible:function(A){this._firstVisible=A},get_scrollInc:function(){return this._scrollInc},set_scrollInc:function(A){this._scrollInc=A},get_animationSpeed:function(){return this._animationSpeed},set_animationSpeed:function(A){this._animationSpeed=A},get_animationMethod:function(){return this._animationMethod},set_animationMethod:function(A){this._animationMethod=A},get_autoPlay:function(){return this._autoPlay},set_autoPlay:function(A){this._autoPlay=A},get_wrap:function(){return this._wrap},set_wrap:function(A){this._wrap=A},get_navMargin:function(){return this._navMargin},set_navMargin:function(A){this._navMargin=A},get_revealAmount:function(){return this._revealAmount},set_revealAmount:function(A){this._revealAmount=A},get_prevElement:function(){return typeof(this._prevElement)==="string"?$get(this._prevElement):this._prevElement},set_prevElement:function(A){this._prevElement=A},get_nextElement:function(){return typeof(this._nextElement)==="string"?$get(this._nextElement):this._nextElement},set_nextElement:function(A){this._nextElement=A},get_disableSelection:function(){return this._disableSelection},set_disableSelection:function(A){this._disableSelection=A},get_fps:function(){return this._fps},set_fps:function(A){this._fps=A},get_numRows:function(){return this._numRows},set_numRows:function(A){this._numRows=A},_autoPlayTimer:null,_clipReg:null,_doPrebuild:true,_lastPrebuiltIdx:0,_revealLeft:0,_revealTop:0,_origFirstVisible:null,_startValue:0,_endValue:0,_priorLastVisible:null,_priorFirstVisible:null,_scrollNextAnim:null,_pages:[1],initialize:function(){this.classPrefix="carousel"+(this.get_orientation()=="vertical"?"-vert":"");this.addStyles();this._scrollPrevHandler=Function.createDelegate(this,this._scrollPrev);this._scrollNextHandler=Function.createDelegate(this,this._scrollNext);$addHandler(this.carouselElem,"mousedown",Function.createDelegate(this,this._handleMouseDownForSelection));this._priorLastVisible=this._priorFirstVisible=this._origFirstVisible=this.get_firstVisible();this.carouselList=MySpace.UI.getElementsByClassName(this.carouselListClass,this.carouselElem)[0];this._clipReg=MySpace.UI.getElementsByClassName(this.carouselClipRegionClass,this.carouselElem)[0];if(this.isVertical()){Sys.UI.DomElement.addCssClass(this.carouselList,"carousel-vertical")}var C=$create(MySpace.UI.Effects.LengthAnimation,{target:this.carouselList,property:"style",propertyKey:this.isVertical()?"top":"left",startValue:0,endValue:0,duration:this._animationSpeed,fps:this._fps,easingFunction:this._animationMethod});this._scrollNextAnim=C;this._scrollPrevAnim=C;if(!this.get_prevElement()){this.set_prevElement(MySpace.Utils.Selector.query("."+this.classPrefix+"-prev",this._element)[0])}if(this.get_prevElement()){var B=this.get_prevElement();$addHandler(B,"click",this._scrollPrevHandler);Sys.UI.DomElement.addCssClass(B,this.classPrefix+"-prev");setTimeout(function(){B.style.width="1px";B.style.width=""},100)}if(!this.get_nextElement()){this.set_nextElement(MySpace.Utils.Selector.query("."+this.classPrefix+"-next",this._element)[0])}if(this.get_nextElement()){$addHandler(this.get_nextElement(),"click",this._scrollNextHandler);Sys.UI.DomElement.addCssClass(this.get_nextElement(),this.classPrefix+"-next")}var A=this._calculateVisibleExtent();MySpace.UI.Event.onAvailable(this._carouselElemID+"-item-"+A.start,this._calculateSize,this);if(this._loadOnStart){this._loadInitial()}},addStyles:function(){if(MySpace.UI.Carousel.stylesAdded){return}MySpace.UI.Carousel.stylesAdded=true;MySpace.UI.addStyles(".carousel-component {position:relative;overflow:hidden;display:none;background:#e2edfa;padding:0px;-moz-border-radius:6px;color:#618cbe;}.carousel-component ul.carousel-list {width:10000000px;position:relative;z-index:1;margin:0px;padding:0px;line-height:0px;}.carousel-component .carousel-list li {float:left;list-style:none;overflow:hidden;text-align:center;margin:4px;width:79px;font:10px verdana,arial,sans-serif;color:#666;padding: 10px 10px 10px 10px;}.carousel-component .carousel-vertical li {margin-bottom:0px;float:left;clear:left;overflow:hidden;display:block;}.carousel-component .carousel-clip-region {overflow:hidden;margin:0px auto;position:relative;}.carousel-next, .carousel-prev, .carousel-vert-next, .carousel-vert-prev { width:24px; height:24px; cursor:pointer; background-image:url('"+MySpace.StaticContentBase+"/modules/common/static/img/carousel.gif'); }.carousel-next { background-position: -24px 0; }.carousel-prev-disabled { cursor:default; background-position: 0 -24px; }.carousel-next-disabled { cursor:default; background-position: -24px -24px; }.carousel-vert-next { background-position: -72px 0; }.carousel-vert-prev { background-position: -48px 0; }.carousel-vert-next-disabled { background-position: -72px -24px; }.carousel-vert-prev-disabled { background-position: -48px -24px; }",true)},_handleMouseDownForSelection:function(A){if(this._disableSelection){A.preventDefault();A.stopPropagation()}},animationCompleteHandler:function(C,B){var A=C.get_events().getHandler("onAnimationComplete");if(A){A(C,B)}},clear:function(){this.carouselList.style.left="";this.carouselList.style.top="";this._startValue=0;this._endValue=0;this._size=1000000;if(this.get_events().getHandler("onLoadInit")){this._removeChildrenFromNode(this.carouselList);this._lastPrebuiltIdx=0}this.stopAutoPlay();this._priorLastVisible=this._priorFirstVisible=this._origFirstVisible;this._firstVisible=this._origFirstVisible;this.moveTo(this._origFirstVisible)},reload:function(B){if(this._isValidObj(B)){this._numVisible=B}this.clear();var A=this._calculateVisibleExtent();MySpace.UI.Event.onAvailable(this._carouselElemID+"-item-"+A.start,this._calculateSize,this);this.onReloadHandler();this._loadInitial()},load:function(){var A=this._calculateVisibleExtent();MySpace.UI.Event.onAvailable(this._carouselElemID+"-item-"+A.start,this._calculateSize,this);this._loadInitial()},addItem:function(C,B,E){C=C<1?1:C;if(C>this._size){return null}var F=this.getItem(C);if(!this._isValidObj(F)){F=this._createItem(C,B);var D;if(!this._doPrebuild){D=this.getRefIdx(C)}if(D){this.carouselList.insertBefore(F,this.carouselList.childNodes[D])}else{this.carouselList.appendChild(F)}}else{if(this._isValidObj(F.placeholder)){var A=this._createItem(C,B);this.carouselList.replaceChild(A,F);F=A}}if(this._isValidObj(E)){Sys.UI.DomElement.addCssClass(F,E)}if(this.isVertical()){setTimeout(function(){F.style.display="block"},1)}return F},getRefIdx:function(A){var D;for(var C=0,B=this.carouselList.childNodes.length;C<B;C++){if(this.carouselList.childNodes[C].tagName){var E=this.carouselList.childNodes[C].id.substring(this.carouselList.childNodes[C].id.lastIndexOf("-")+1);if(E>A){D=C;break}}}return D},insertBefore:function(B,D){if(B>=this._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._size){B=this._size}var A=B+1;if(A>this._lastPrebuiltIdx){this._prebuildItems(this._lastPrebuiltIdx,A+1)}var C=this._insertAfterItem(B,D);if(A>this._size){this._size=A}this._enableDisableControls();return C},scrollNext:function(){this._scrollNext.call(this,null);this._autoPlayTimer=null;if(this._autoPlay!==0){this._autoPlayTimer=this.startAutoPlay()}},scrollTo:function(A){this._position(A,true)},moveTo:function(A){this._position(A,false)},startAutoPlay:function(A){if(this._isValidObj(A)){this._autoPlay=A}if(this._autoPlayTimer!==null){return this._autoPlayTimer}var C=this;var B=function(){C.scrollNext()};this._autoPlayTimer=setTimeout(B,this._autoPlay);return this._autoPlayTimer},stopAutoPlay:function(){if(this._autoPlayTimer!==null){clearTimeout(this._autoPlayTimer);this._autoPlayTimer=null}},isVertical:function(){return this._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=$get(B,this._element);return C},show:function(){this.carouselElem.style.display="block";this.calculateSize()},hide:function(){this.carouselElem.style.display="none"},calculateSize:function(){var e=this.carouselList.childNodes;var Q=null;for(var a=0;a<e.length;a++){Q=e[a];if(Q.tagName=="LI"||Q.tagName=="li"){break}}if(e.length>0){var Z=this._navMargin;var g=this._numVisible;var G=this._firstVisible;var c=this._getStyleVal(Q,"paddingLeft");var W=this._getStyleVal(Q,"paddingRight");var b=this._getStyleVal(Q,"marginLeft");var V=this._getStyleVal(Q,"marginRight");var U=this._getStyleVal(Q,"paddingTop");var B=this._getStyleVal(Q,"paddingBottom");var T=this._getStyleVal(Q,"marginTop");var A=this._getStyleVal(Q,"marginBottom");var K=Sys.UI.DomElement.getLocation(this.carouselList);Sys.UI.DomElement.removeCssClass(this.carouselList,"carousel-vertical");Sys.UI.DomElement.removeCssClass(this.carouselList,"carousel-horizontal");if(this.isVertical()){var S=c+W+b+V;Sys.UI.DomElement.addCssClass(this.carouselList,"carousel-vertical");var E=U+B+T+A;var I=this._getStyleVal(this.carouselList,"paddingTop");var Y=this._getStyleVal(this.carouselList,"paddingBottom");var H=this._getStyleVal(this.carouselList,"marginTop");var X=this._getStyleVal(this.carouselList,"marginBottom");var f=I+Y+H+X;var O=(this._isExtraRevealed())?(this._revealAmount+(E)/2):0;var C=this._getStyleVal(Q,"height",true);this.scrollAmountPerInc=(C+E);var D=this._getStyleVal(Q,"width");this.carouselElem.style.width=(D+S)+"px";this._clipReg.style.height=(this.scrollAmountPerInc*g+O*2+f)+"px";this.carouselElem.style.height=(this.scrollAmountPerInc*g+O*2+Z*2+f)+"px";this._revealTop=(this._isExtraRevealed())?(O-(Math.abs(T-A)+Math.abs(U-B))/2):0;this.carouselList.style.position="relative";this.carouselList.style.top=""+this._revealTop+"px";var M=0;this.carouselList.style.top=(M-this.scrollAmountPerInc*(G-1)+this._revealTop)+"px"}else{Sys.UI.DomElement.addCssClass(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 J=this._getStyleVal(this.carouselList,"marginRight");var F=R+L+P+J;var d=b+V;var S=d+W+c;var O=(this._isExtraRevealed())?(this._revealAmount+(S)/2):0;var D=Q.offsetWidth;this.scrollAmountPerInc=D+d;this._clipReg.style.width=(this.scrollAmountPerInc*g+O*2)+"px";this.carouselElem.style.width=(this.scrollAmountPerInc*g+Z*2+O*2+F)+"px";this._revealLeft=(this._isExtraRevealed())?(O-(Math.abs(V-b)+Math.abs(W-c))/2-(P+R)):0;this.carouselList.style.position="relative";this.carouselList.style.left=""+this._revealLeft+"px";var N=0;this.carouselList.style.left=(N-this.scrollAmountPerInc*(G-1)+this._revealLeft)+"px"}}},getFirstItemRevealed:function(){return this._firstItemRevealed},getLastItemRevealed:function(){return this._lastItemRevealed},getFirstVisible:function(){return this._firstVisible},getLastVisible:function(){var B=this._firstVisible;var A=this._numVisible;return B+(this._numRows*A)-1},_getStyleVal:function(A,C,D){var B=MySpace.UI.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;if(this._doPrebuild){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._size;if(D!=this.UNBOUNDED_SIZE){this._size=this._size+1}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._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(A){if(A!==null){this.stopAutoPlay()}this._scrollPrevInc(this._scrollInc*this._numRows,(this._animationSpeed!==0));this.onScrollPrevHandler()},_scrollNext:function(A){if(A!==null){this.stopAutoPlay()}this._scrollNextInc(this._scrollInc*this._numRows,(this._animationSpeed!==0));this.onScrollNextHandler()},_areAllItemsLoaded:function(D,C){D=parseInt(D/this._numRows)+(D%this._numRows>0?1:0);C=parseInt(C/this._numRows)+(C%this._numRows>0?1:0);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._revealAmount>0)},_getPrevElements:function(A){A=Math.round(A/this._numRows);var D=0;for(var C=0,B=this.carouselList.childNodes.length;C<B;C++){if(this.carouselList.childNodes[C].tagName){var E=this.carouselList.childNodes[C].id.substring(this.carouselList.childNodes[C].id.lastIndexOf("-")+1);if(E<A){D++}}}return D},_scrollNextInc:function(C,I){if(this._scrollNextAnim.get_isPlaying()||this._scrollPrevAnim.get_isPlaying()){return false}var L=this._numVisible;var K=this._priorFirstVisible;var G=this._priorLastVisible;var M=this._size;var A=this._calculateAllowableScrollExtent();if(this._wrap&&G==A.end){this.scrollTo(A.start);return}var J=K+C;var E=J+(this._numRows*L)-1;if(E>A.end){E=A.end}C=Math.round((J-K)/this._numRows);this._firstVisible=J;if(C>0){if(this.get_events().getHandler("onLoadNext")){var B=this._calculateVisibleExtent(J,E);var D=(G+1)<B.start?(G+1):B.start;var F=this._areAllItemsLoaded(D,B.end);this.loadNextHandler(B.start,B.end,F)}this._startValue=this._endValue;if(this._doPrebuild){this._endValue+=-this.scrollAmountPerInc*C}else{this._endValue=-this._getPrevElements(J)*this.scrollAmountPerInc}if(I){this._scrollNextAnim.set_startValue(this._startValue);if(this.isVertical()){this._scrollNextAnim.set_endValue(this._endValue+this._revealTop)}else{this._scrollNextAnim.set_endValue(this._endValue+this._revealLeft)}this._scrollNextAnim.add_ended(Function.createCallback(this.animationCompleteHandler,this,"next"));this._scrollNextAnim.play()}else{var H=Sys.UI.DomElement.getLocation(this.carouselList);if(this.isVertical()){this.carouselList.style.top=this._endValue+this._revealTop+"px"}else{this.carouselList.style.left=this._endValue+this._revealLeft+"px"}}}this._priorFirstVisible=J;this._priorLastVisible=E;this._enableDisableControls();return false},_scrollPrevInc:function(G,K){if(this._scrollNextAnim.get_isPlaying()||this._scrollPrevAnim.get_isPlaying()){return false}var N=this._numVisible;var M=this._priorFirstVisible;var I=this._priorLastVisible;var O=this._size;var L=M-G;var A=this._calculateAllowableScrollExtent();L=(L<A.start)?A.start:L;var F=L+(this._numRows*N)-1;if(F>A.end){F=A.end;L=F-N+1}G=Math.round((M-L)/this._numRows);this._firstVisible=L;if(G>0){if(this.get_events().getHandler("onLoadPrev")){var E=this._calculateVisibleExtent(L,F);var C=(M-1)>E.end?(M-1):E.end;var H=this._areAllItemsLoaded(E.start,C);this.loadPrevHandler(E.start,E.end,H)}this._startValue=this._endValue;if(this._doPrebuild){this._endValue+=this.scrollAmountPerInc*G}else{this._endValue=-this._getPrevElements(L)*this.scrollAmountPerInc}if(K){this._scrollPrevAnim.set_startValue(this._startValue);this._scrollPrevAnim.set_endValue(this._endValue+this._revealLeft);this._scrollPrevAnim.add_ended(Function.createCallback(this.animationCompleteHandler,this,"prev"));this._scrollPrevAnim.play()}else{var J=Sys.UI.DomElement.getLocation(this.carouselList);if(this.isVertical()){var B=0;this.carouselList.style.top=this._endValue+"px"}else{var D=0;this.carouselList.style.left=this._endValue+"px"}}}this._priorFirstVisible=L;this._priorLastVisible=F;this._enableDisableControls();return false},_enableDisableControls:function(){var C=this._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._firstVisible;this._priorLastVisible=this.getLastVisible();if(this.get_events().getHandler("onLoadInit")){var A=this._calculateVisibleExtent(C,this._priorLastVisible);var B=this._areAllItemsLoaded(1,A.end);this.loadInitHandler(A.start,A.end,B)}if(this._autoPlay!==0){this._autoPlayTimer=this.startAutoPlay()}this._enableDisableControls()},_calculateAllowableScrollExtent:function(){var D=this._scrollBeforeAmount;var A=this._scrollAfterAmount;var B=this._size;var C={start:1-D,end:B+A};return C},_calculateVisibleExtent:function(D,A){if(!D){D=this._firstVisible;A=this.getLastVisible()}var B=this._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;this.prevButtonStateHandler(false);if(this.get_prevElement()){$removeHandler(this.get_prevElement(),"click",this._scrollPrevHandler);Sys.UI.DomElement.addCssClass(this.get_prevElement(),this.classPrefix+"-prev-disabled")}},_enablePrev:function(){this._prevEnabled=true;this.prevButtonStateHandler(true);if(this.get_prevElement()){$addHandler(this.get_prevElement(),"click",this._scrollPrevHandler);Sys.UI.DomElement.removeCssClass(this.get_prevElement(),this.classPrefix+"-prev-disabled")}},_disableNext:function(){if(this._wrap){return}this._nextEnabled=false;this.nextButtonStateHandler(false);if(this.get_nextElement()){$removeHandler(this.get_nextElement(),"click",this._scrollNextHandler);Sys.UI.DomElement.addCssClass(this.get_nextElement(),this.classPrefix+"-next-disabled")}},_enableNext:function(){this._nextEnabled=true;this.nextButtonStateHandler(true);if(this.get_nextElement()){$addHandler(this._nextElement,"click",this._scrollNextHandler);Sys.UI.DomElement.removeCssClass(this.get_nextElement(),this.classPrefix+"-next-disabled")}},_isValidObj:function(A){if(null==A){return false}if("undefined"==typeof(A)){return false}return true},loadInitHandler:function(D,C,A){var B=this.get_events().getHandler("onLoadInit");if(B){B(this,[D,C,A])}},loadNextHandler:function(D,C,A){var B=this.get_events().getHandler("onLoadNext");if(B){B(this,[D,C,A])}},loadPrevHandler:function(D,C,A){var B=this.get_events().getHandler("onLoadPrev");if(B){B(this,[D,C,A])}},prevButtonStateHandler:function(A){var B=this.get_events().getHandler("onPrevButtonStateChange");if(B){B(this,[A,$get(this._prevElement)])}},nextButtonStateHandler:function(A){var B=this.get_events().getHandler("onNextButtonStateChange");if(B){B(this,[A,this.get_nextElement()])}},onReloadHandler:function(){var B=this.get_events().getHandler("onReload");if(B){var A=new Sys.EventArgs();B(this,A)}},onScrollNextHandler:function(){var B=this.get_events().getHandler("onScrollNext");if(B){var A=new Sys.EventArgs();B(this,A)}},onScrollPrevHandler:function(){var B=this.get_events().getHandler("onScrollPrev");if(B){var A=new Sys.EventArgs();B(this,A)}},add_onAnimationComplete:function(A){this.get_events().addHandler("onAnimationComplete",A)},remove_onAnimationComplete:function(A){this.get_events().removeHandler("onAnimationComplete",A)},add_onLoadInit:function(A){this.get_events().addHandler("onLoadInit",A)},remove_onLoadInit:function(A){this.get_events().removeHandler("onLoadInit",A)},add_onLoadNext:function(A){this.get_events().addHandler("onLoadNext",A)},remove_onLoadNext:function(A){this.get_events().removeHandler("onLoadNext",A)},add_onLoadPrev:function(A){this.get_events().addHandler("onLoadPrev",A)},remove_onLoadPrev:function(A){this.get_events().removeHandler("onLoadPrev",A)},add_onPrevButtonStateChange:function(A){this.get_events().addHandler("onPrevButtonStateChange",A)},remove_onPrevButtonStateChange:function(A){this.get_events().removeHandler("onPrevButtonStateChange",A)},add_onNextButtonStateChange:function(A){this.get_events().addHandler("onNextButtonStateChange",A)},remove_onNextButtonStateChange:function(A){this.get_events().removeHandler("onNextButtonStateChange",A)},add_onReload:function(A){this.get_events().addHandler("onReload",A)},remove_onReload:function(A){this.get_events().removeHandler("onReload",A)},add_onScrollNext:function(A){this.get_events().addHandler("onScrollNext",A)},remove_onScrollNext:function(A){this.get_events().removeHandler("onScrollNext",A)},add_onScrollPrev:function(A){this.get_events().addHandler("onScrollPrev",A)},remove_onScrollPrev:function(A){this.get_events().removeHandler("onScrollPrev",A)},dispose:function(){MySpace.UI.Carousel.callBaseMethod(this,"dispose")}};MySpace.UI.Carousel.registerClass("MySpace.UI.Carousel",Sys.UI.Control);MySpace.UI._Event=function(){MySpace.UI._Event.initializeBase(this)};MySpace.UI._Event.prototype={POLL_RETRYS:2000,POLL_INTERVAL:20,isIE:Sys.Browser.agent===Sys.Browser.InternetExplorer,locked:null,loadComplete:false,onAvailStack:[],retryCount:0,_interval:null,initialize:function(){if(!this.loadComplete){this.loadComplete=true;this._tryPreloadAttach()}},startInterval:function(){if(!this._interval){var A=this;var B=Function.createDelegate(this,this._tryPreloadAttach);this._interval=setInterval(B,this.POLL_INTERVAL)}},onAvailable:function(F,C,G,E,D){var A=(typeof(F)==="string")?[F]:F;for(var B=0;B<A.length;B=B+1){this.onAvailStack.push({id:A[B],fn:C,obj:G,override:E,checkReady:D})}this.retryCount=this.POLL_RETRYS;this.startInterval()},_tryPreloadAttach:function(){if(this.onAvailStack.length===0){this.retryCount=0;clearInterval(this._interval);this._interval=null;return}if(this.locked){return}if(this.isIE){if(!MySpace.Application.isDOMLoaded){this.startInterval();return}}this.locked=true;var G=!this.loadComplete;if(!G){G=(this.retryCount>0&&this.onAvailStack.length>0)}var F=[];var H=function(J,K){var I=J;if(K.override){if(K.override===true){I=K.obj}else{I=K.override}}K.fn.call(I,K.obj)};var B,A,E,D,C=[];for(B=0,A=this.onAvailStack.length;B<A;B=B+1){E=this.onAvailStack[B];if(E){D=$get(E.id);if(D){if(E.checkReady){if(loadComplete||D.nextSibling||!G){C.push(E);this.onAvailStack[B]=null}}else{H(D,E);this.onAvailStack[B]=null}}else{F.push(E)}}}for(B=0,A=C.length;B<A;B=B+1){E=C[B];H(this.getEl(E.id),E)}this.retryCount--;if(G){for(B=this.onAvailStack.length-1;B>-1;B--){E=this.onAvailStack[B];if(!E||!E.id){this.onAvailStack.splice(B,1)}}this.startInterval()}else{clearInterval(this._interval);this._interval=null}this.locked=false}};MySpace.UI._Event.registerClass("MySpace.UI._Event",Sys.Component);MySpace.UI.Event=new MySpace.UI._Event();MySpace.UI._Dom=function(){MySpace.UI._Dom.initializeBase(this)};MySpace.UI._Dom.prototype={getStyle:function(A,D){if(document.defaultView&&document.defaultView.getComputedStyle){var C=null;if(D=="float"){D="cssFloat"}var B=A.ownerDocument.defaultView.getComputedStyle(A,"");if(B){C=B[D]}return A.style[D]||C}else{if(document.documentElement.currentStyle&&Sys.Browser.agent===Sys.Browser.InternetExplorer){switch(D){case"opacity":var F=100;try{F=A.filters["DXImageTransform.Microsoft.Alpha"].opacity}catch(E){try{F=A.filters("alpha").opacity}catch(E){}}return F/100;case"float":D="styleFloat";default:var C=A.currentStyle?A.currentStyle[D]:null;return(A.style[D]||C)}}else{return A.style[D]}}}};MySpace.UI._Dom.registerClass("MySpace.UI._Dom",Sys.Component);MySpace.UI.Dom=new MySpace.UI._Dom();MySpace.UI.CarouselPager=function(A){this._carouselElemID=A.id;this.carouselElem=A;MySpace.UI.CarouselPager.initializeBase(this,[A])};MySpace.UI.CarouselPager.prototype={MAX_ITEMS:1500,POLL_RETRYS:2000,POLL_INTERVAL:20,_countNode:null,_interval:null,_retryCount:0,_totalResults:0,_pagers:[],get_ids:function(){return this._ids},set_ids:function(A){this._ids=A},get_totalResults:function(){return this._totalResults},initialize:function(){MySpace.UI.CarouselPager.callBaseMethod(this,"initialize");this._pagers=[];this._retryCount=this.POLL_RETRYS;this._countNode=MySpace.Utils.Selector.query(".pagingTotalItems",this._element)[0];this._resetTotalItems(false);this.add_onReload(Function.createDelegate(this,this._resetPager));if(this._nextElement){this.add_onScrollNext(Function.createDelegate(this,this._updatePager))}if(this._prevElement){this.add_onScrollPrev(Function.createDelegate(this,this._updatePager))}},isCarousel:function(){return(this._totalResults<=this.MAX_ITEMS)},_checkTotalLoaded:function(){this._totalResults=parseInt(this._countNode.innerHTML);if(this._totalResults>0&&this._retryCount>0){this._size=this._totalResults;clearInterval(this._interval);this._interval=null;this._retryCount=0;this._initPager();return}this._retryCount--},_initPager:function(){if(this._pagers.length>0){this._pagers[0].reset(this._totalResults)}var D={itemsPerPage:this._scrollInc*this._numRows};D.siblingPagerIds=this._ids;D.contentNode=this._element;D.enableBackButton=false;this._doPrebuild=(this._totalResults<=this.MAX_ITEMS);var B=function(F,E){F.carousel.scrollTo((E.currentPage-1)*F.carousel._numRows*F.carousel.get_scrollInc()+1);F.render(F.carousel.get_totalResults())};var A;for(var C=0;C<this._ids.length;C++){A=$create(MySpace.UI.ClientPager,D,{pageChangeBegin:B,pageChangeEnd:function(F,E){}},null,$get(this._ids[C],this._element));A.carousel=this;Array.add(this._pagers,A)}},resetPagerLinks:function(){for(var A=0;A<this._pagers.length;A++){this._pagers[A].reset()}},_resetPager:function(){this._retryCount=this.POLL_RETRYS;this._resetTotalItems(true)},_resetTotalItems:function(A){if(A){this._countNode.innerHTML=""}var B=Function.createDelegate(this,this._checkTotalLoaded);this._interval=setInterval(B,this.POLL_INTERVAL)},_updatePager:function(){for(var A=0;A<this._pagers.length;A++){var B=Math.round(this._firstVisible/(this._numRows*this._scrollInc))+1;this._pagers[A]._goToPage(B)}},_updatePagerCount:function(){for(var A=0;A<this._pagers.length;A++){this._pagers[A]._updateXtoYofZ()}}};MySpace.UI.CarouselPager.registerClass("MySpace.UI.CarouselPager",MySpace.UI.Carousel);
