if (!window.PageControl) {
    window.PageControl = {
        pageIndex: null,
        pageCount: null,
        callBack: null,
        filterName: null,
        
        setup: function(map) {
    		this.pageIndex = map.pageIndex;
    		this.pageCount = map.pageCount;
    		this.callBack = map.callBack;
    		this.filterName = map.filterName;
        },
        
        goPage: function(index){
    		if(this.validate(index)){
    			$(this.filterName +".pageIndex").value = index;
    			eval(this.callBack);
    		} else {
    			alert( Bundle.getMessage('error.invalid.page') );
    		}
        },

        validate: function(index){
        	return (index > 0 && index <= this.pageCount);
        },
        
        first: function() {
            this.goPage(1);
        },
        
        next: function() {
        	this.goPage(this.pageIndex + 1);
        },
        
        previous: function() {
        	this.goPage(this.pageIndex - 1);
        },
        
        last: function() {
        	this.goPage(this.pageCount);
        }
    };
}
