(function(){var C=YAHOO.util.Dom;var A=YAHOO.util.Event;var B=YAHOO.util.Element;SODON.widget.ScrollView=function(D,E){this.init.apply(this,arguments)};SODON.widget.ScrollView.cfg=function(D){SODON.widget.ScrollView.cfg.superclass.constructor.apply(this,arguments)};YAHOO.extend(SODON.widget.ScrollView.cfg,SODON.util.Config,{_DEFAULT_CONFIG:{DIRECTION:"horizontal",UNIQUE_ID:null,SCREEN_SIZE:1,MOVE_SIZE:1,ITEM_WIDTH:null,ITEM_HEIGHT:null,ITEM_SPACE:null,EASING:YAHOO.util.Easing.easeOut,CLASSNAME_MASK:"scroll-mask",CLASSNAME_ITEM_CONTAINER:"scroll-item-container",CLASSNAME_ITEM:"scroll-item",CLASSNAME_ID:null,TOP_MOVE_BUTTON:null,RIGHT_MOVE_BUTTON:null,BOTTOM_MOVE_BUTTON:null,LEFT_MOVE_BUTTON:null}});SODON.widget.ScrollView.prototype={oContainer:null,_items:null,_mask:null,Config:null,cfg:null,anim:null,moveDirection:null,init:function(D,E){this.oContainer=C.get(D)||"scroll-container";this._items=C.getChildren(this.oContainer);this._mask=this.oContainer.parentNode;this.Config={};this.cfg=new SODON.widget.ScrollView.cfg(this);this.cfg.setupConfig();if(E!=null){this.cfg.setConfig(E)}if(this._items.length>=3*this.cfg.getConfigProperty("SCREEN_SIZE")){this.cfg.setConfigProperty("MOVE_SIZE",this.cfg.getConfigProperty("SCREEN_SIZE"))}var H="";if(this.cfg.getConfigProperty("UNIQUE_ID")!=null){H=this.cfg.getConfigProperty("UNIQUE_ID")+"-"}var G="";if(this.cfg.getConfigProperty("CLASSNAME_ID")!=null){G=this.cfg.getConfigProperty("CLASSNAME_ID")+"-"}if(!C.hasClass(this.oContainer,G+this.cfg.getConfigProperty("CLASSNAME_ITEM_CONTAINER"))){C.addClass(this.oContainer,G+this.cfg.getConfigProperty("CLASSNAME_ITEM_CONTAINER"))}C.setStyle(this.oContainer,"position","absolute");C.setStyle(this.oContainer,"top","0px");C.setStyle(this.oContainer,"left","0px");if(this.cfg.getConfigProperty("DIRECTION")=="vertical"){C.setStyle(this.oContainer,"width",this.cfg.getConfigProperty("ITEM_WIDTH")+"px");C.setStyle(this.oContainer,"height",(this._items.length*(this.cfg.getConfigProperty("ITEM_HEIGHT")+this.cfg.getConfigProperty("ITEM_SPACE")))+"px")}else{C.setStyle(this.oContainer,"width",(this._items.length*(this.cfg.getConfigProperty("ITEM_WIDTH")+this.cfg.getConfigProperty("ITEM_SPACE")))+"px");C.setStyle(this.oContainer,"height",this.cfg.getConfigProperty("ITEM_HEIGHT")+"px")}var F=0;while(F<this.cfg.getConfigProperty("MOVE_SIZE")){C.insertBefore(C.getLastChild(this.oContainer),C.getFirstChild(this.oContainer));if(this.cfg.getConfigProperty("DIRECTION")=="vertical"){C.setStyle(this.oContainer,"top",(parseInt(C.getStyle(this.oContainer,"top"))-(this.cfg.getConfigProperty("ITEM_HEIGHT")+this.cfg.getConfigProperty("ITEM_SPACE")))+"px")}else{C.setStyle(this.oContainer,"left",(parseInt(C.getStyle(this.oContainer,"left"))-(this.cfg.getConfigProperty("ITEM_WIDTH")+this.cfg.getConfigProperty("ITEM_SPACE")))+"px")}F++}if(!C.hasClass(this._mask,G+this.cfg.getConfigProperty("CLASSNAME_MASK"))){C.addClass(this._mask,G+this.cfg.getConfigProperty("CLASSNAME_MASK"))}C.setStyle(this._mask,"position","relative");C.setStyle(this._mask,"overflow","hidden");if(this.cfg.getConfigProperty("DIRECTION")=="vertical"){C.setStyle(this._mask,"width",(1*this.cfg.getConfigProperty("ITEM_WIDTH"))+"px");C.setStyle(this._mask,"height",(this.cfg.getConfigProperty("SCREEN_SIZE")*this.cfg.getConfigProperty("ITEM_HEIGHT"))+"px")}else{C.setStyle(this._mask,"width",(this.cfg.getConfigProperty("SCREEN_SIZE")*this.cfg.getConfigProperty("ITEM_WIDTH"))+"px");C.setStyle(this._mask,"height",(1*this.cfg.getConfigProperty("ITEM_HEIGHT"))+"px")}F=0;while(F<this._items.length){if(!C.hasClass(this._items[F],G+this.cfg.getConfigProperty("CLASSNAME_ITEM"))){C.addClass(this._items[F],G+this.cfg.getConfigProperty("CLASSNAME_ITEM"))}C.setStyle(this._items[F],"overflow","hidden");C.setStyle(this._items[F],"width",this.cfg.getConfigProperty("ITEM_WIDTH")+"px");C.setStyle(this._items[F],"height",this.cfg.getConfigProperty("ITEM_HEIGHT")+"px");if(this.cfg.getConfigProperty("DIRECTION")=="vertical"){C.setStyle(this._items[F],"margin-bottom",this.cfg.getConfigProperty("ITEM_SPACE")+"px")}else{C.setStyle(this._items[F],"margin-right",this.cfg.getConfigProperty("ITEM_SPACE")+"px")}F++}this.anim=new YAHOO.util.Anim(this.oContainer,{});this.initEvents()},topMove:function(){if(this.isMove("top")){this.moveDirection="top";if(this._items.length==this.cfg.getConfigProperty("SCREEN_SIZE")+1){this.move()}else{this.prepareItems();this.move()}}},rightMove:function(){if(this.isMove("right")){this.moveDirection="right";this.prepareItems();this.move()}},bottomMove:function(){if(this.isMove("bottom")){this.moveDirection="bottom";this.prepareItems();this.move()}},leftMove:function(){if(this.isMove("left")){this.moveDirection="left";if(this._items.length==this.cfg.getConfigProperty("SCREEN_SIZE")+1){this.move()}else{this.prepareItems();this.move()}}},isMove:function(D){if(!this.anim.isAnimated()){if(this.cfg.getConfigProperty("DIRECTION")=="horizontal"&&(D=="right"||D=="left")){return true}else{if(this.cfg.getConfigProperty("DIRECTION")=="vertical"&&(D=="top"||D=="bottom")){return true}}}return false},prepareItems:function(){var D=0;if(this.moveDirection=="top"||this.moveDirection=="left"){D=0;while(D<this.cfg.getConfigProperty("MOVE_SIZE")){C.insertBefore(C.getLastChild(this.oContainer),C.getFirstChild(this.oContainer));if(this.moveDirection=="top"){C.setStyle(this.oContainer,"top",(parseInt(C.getStyle(this.oContainer,"top"))-(this.cfg.getConfigProperty("ITEM_HEIGHT")+this.cfg.getConfigProperty("ITEM_SPACE")))+"px")}else{C.setStyle(this.oContainer,"left",(parseInt(C.getStyle(this.oContainer,"left"))-(this.cfg.getConfigProperty("ITEM_WIDTH")+this.cfg.getConfigProperty("ITEM_SPACE")))+"px")}D++}}else{D=0;while(D<this.cfg.getConfigProperty("MOVE_SIZE")){C.insertAfter(C.getFirstChild(this.oContainer),C.getLastChild(this.oContainer));if(this.moveDirection=="bottom"){C.setStyle(this.oContainer,"top",(parseInt(C.getStyle(this.oContainer,"top"))+(this.cfg.getConfigProperty("ITEM_HEIGHT")+this.cfg.getConfigProperty("ITEM_SPACE")))+"px")}else{C.setStyle(this.oContainer,"left",(parseInt(C.getStyle(this.oContainer,"left"))+(this.cfg.getConfigProperty("ITEM_WIDTH")+this.cfg.getConfigProperty("ITEM_SPACE")))+"px")}D++}}},move:function(){var E=this;var D={};if(this.moveDirection=="top"){var F=(parseInt(C.getStyle(this.oContainer,"top"))+this.cfg.getConfigProperty("MOVE_SIZE")*(this.cfg.getConfigProperty("ITEM_HEIGHT")+this.cfg.getConfigProperty("ITEM_SPACE")));D={top:{to:F,unit:"px"}}}else{if(this.moveDirection=="right"){var I=(parseInt(C.getStyle(this.oContainer,"left"))-this.cfg.getConfigProperty("MOVE_SIZE")*(this.cfg.getConfigProperty("ITEM_WIDTH")+this.cfg.getConfigProperty("ITEM_SPACE")));D={left:{to:I,unit:"px"}}}else{if(this.moveDirection=="bottom"){var G=(parseInt(C.getStyle(this.oContainer,"top"))-this.cfg.getConfigProperty("MOVE_SIZE")*(this.cfg.getConfigProperty("ITEM_HEIGHT")+this.cfg.getConfigProperty("ITEM_SPACE")));D={top:{to:G,unit:"px"}}}else{if(this.moveDirection=="left"){var H=(parseInt(C.getStyle(this.oContainer,"left"))+this.cfg.getConfigProperty("MOVE_SIZE")*(this.cfg.getConfigProperty("ITEM_WIDTH")+this.cfg.getConfigProperty("ITEM_SPACE")));D={left:{to:H,unit:"px"}}}}}}this.anim=new YAHOO.util.Anim(this.oContainer,D,1,this.cfg.getConfigProperty("EASING"));this.anim.onComplete.subscribe(function(J){if(E._items.length==E.cfg.getConfigProperty("SCREEN_SIZE")+1){if(E.moveDirection=="top"||E.moveDirection=="left"){E.prepareItems()}}});this.anim.animate()},initEvents:function(){var D=this;if(this.cfg.getConfigProperty("TOP_MOVE_BUTTON")!=null){A.on(C.get(this.cfg.getConfigProperty("TOP_MOVE_BUTTON")),"click",function(E){D.topMove()})}if(this.cfg.getConfigProperty("RIGHT_MOVE_BUTTON")!=null){A.on(C.get(this.cfg.getConfigProperty("RIGHT_MOVE_BUTTON")),"click",function(E){D.rightMove()})}if(this.cfg.getConfigProperty("BOTTOM_MOVE_BUTTON")!=null){A.on(C.get(this.cfg.getConfigProperty("BOTTOM_MOVE_BUTTON")),"click",function(E){D.bottomMove()})}if(this.cfg.getConfigProperty("LEFT_MOVE_BUTTON")!=null){A.on(C.get(this.cfg.getConfigProperty("LEFT_MOVE_BUTTON")),"click",function(E){D.leftMove()})}}}})();