Type.registerNamespace('SpottedScript.Controls.PaginationControl2');
SpottedScript.Controls.PaginationControl2.Controller=function(view){this.view=view;view.get_uiPrevPage().setAttribute('onclick','');$addHandler(view.get_uiPrevPage(),'click',Function.createDelegate(this,this.prevClick));view.get_uiNextPage().setAttribute('onclick','');$addHandler(view.get_uiNextPage(),'click',Function.createDelegate(this,this.nextClick));this.set_$0(Number.parseInvariant(view.get_uiLastPage().innerHTML));this.set_$1(Number.parseInvariant(view.get_uiCurrentPage().innerHTML));}
SpottedScript.Controls.PaginationControl2.Controller.prototype={view:null,lastPage:0,get_$0:function(){return this.lastPage;},set_$0:function($p0){this.lastPage=$p0;if(this.lastPage===1){this.view.get_uiContainer().style.display='none';}else if(this.lastPage<0){this.view.get_uiLastPage().innerHTML='many';}else{this.view.get_uiContainer().style.display='';this.view.get_uiLastPage().innerHTML=this.lastPage.toString();}return $p0;},currentPage:0,get_$1:function(){return this.currentPage;},set_$1:function($p0){this.currentPage=$p0;this.view.get_uiCurrentPage().innerHTML=this.currentPage.toString();return $p0;},$2:null,prevClick:function(e){e.preventDefault();this.$4();},nextClick:function(e){e.preventDefault();this.$3();},$3:function(){this.moveToPage((this.get_$1()===this.get_$0())?1:(this.get_$1()+1));},$4:function(){if(this.get_$1()>1||this.get_$0()>0){this.moveToPage((this.get_$1()===1)?this.get_$0():(this.get_$1()-1));}},moveToPage:function(page){if((page>this.get_$0()&&this.get_$0()>0)||page<1){page=1;}this.set_$1(page);if(this.$2){this.$2(this,new SpottedScript.IntEventArgs(page));}}}
SpottedScript.Controls.PaginationControl2.View=function(clientId){this.clientId=clientId;}
SpottedScript.Controls.PaginationControl2.View.prototype={clientId:null,get_uiContainer:function(){return document.getElementById(this.clientId+'_uiContainer');},get_uiPrevPage:function(){return document.getElementById(this.clientId+'_uiPrevPage');},get_uiCurrentPage:function(){return document.getElementById(this.clientId+'_uiCurrentPage');},get_uiLastPage:function(){return document.getElementById(this.clientId+'_uiLastPage');},get_uiNextPage:function(){return document.getElementById(this.clientId+'_uiNextPage');}}
SpottedScript.Controls.PaginationControl2.Controller.registerClass('SpottedScript.Controls.PaginationControl2.Controller');
SpottedScript.Controls.PaginationControl2.View.registerClass('SpottedScript.Controls.PaginationControl2.View');
