var CoreshopSearchShopResultPaginator = new Class({
	Extends: CoreshopResultPaginator,
	options: {
		pagedItemClassName: '',
		numItemsPerPage: 20,
		shopPagCtrlPrefix: 'shopsResultsPagination'
	},
	initialize: function(options) {
		
		
		this.initPagination();
		//alert(this.shopPagCtrlEles);
		options.shopPageCtrlEles = this.shopPagCtrlEles;
		this.parent(options);
		
		this.updatePaginationLabels(null);
		this.addEvent('pageChanged', this.updatePaginationLabels.bind(this));
	},
	shopPagCtrlEles: [],
	initPagination: function() {
		//add all control elements to member var
		
		this.shopPagCtrlEles = { 'Start':$empty, 'End':$empty, 'Total':$empty, 'NextLink':$empty, 'PrevLink':$empty, 'PageLinks': $empty };
		
		this.shopPagCtrlEles["Start"] = [$(this.options.shopPagCtrlPrefix+'TopStart'), $(this.options.shopPagCtrlPrefix+'BtmStart')];
		this.shopPagCtrlEles["End"] = [$(this.options.shopPagCtrlPrefix+'TopEnd'), $(this.options.shopPagCtrlPrefix+'BtmEnd')];
		this.shopPagCtrlEles["Total"] = [$(this.options.shopPagCtrlPrefix+'TopTotal'), $(this.options.shopPagCtrlPrefix+'BtmTotal')];
		this.shopPagCtrlEles["NextLink"] = [$(this.options.shopPagCtrlPrefix+'TopNextLink'), $(this.options.shopPagCtrlPrefix+'BtmNextLink')];
		this.shopPagCtrlEles["PrevLink"] = [$(this.options.shopPagCtrlPrefix+'TopPrevLink'), $(this.options.shopPagCtrlPrefix+'BtmPrevLink')];
		this.shopPagCtrlEles["PageLinks"] = [$$('.'+this.options.shopPagCtrlPrefix+'BtmLinks'), $$('.'+this.options.shopPagCtrlPrefix+'TopLinks')];
		
		
	},
	updatePaginationLabels: function(event) {
		//alert('updating labels');
		this.shopPagCtrlEles["Start"].each(function(item) {
			item.innerHTML = (this.options.numItemsPerPage * (this.currentPageNum)) + 1;
		}.bind(this));

		
		
		
		var tmpTotalItems = parseInt((this.pagedItems.length-1)*this.options.numItemsPerPage)+(this.pagedItems[this.pagedItems.length-1].length);
		//alert(this.options.numItemsPerPage+'::'+(this.currentPageNum));
		var tmpEndRange = parseInt(this.options.numItemsPerPage * (this.currentPageNum+1));
		//alert(tmpTotalItems+"---"+tmpEndRange);
		if(tmpTotalItems < tmpEndRange) {
			tmpEndRange = tmpTotalItems;
		}
		
		this.shopPagCtrlEles["End"].each(function(item) {
			item.innerHTML = tmpEndRange;
		});	
		this.shopPagCtrlEles["Total"].each(function(item) {
			item.innerHTML = tmpTotalItems;
		});
			

			/*
			if(tmpTotalItems < ((this.options.numItemsPerPage * (this.currentPageNum)))) {

				document.getElementById('shopsResultsPaginationTopNextLink').style.display = 'none';

				document.getElementById('shopsResultsPaginationBtmNextLink').style.display = 'none';
			}
			*/
			
			
			this.updateClickHandlers(this.shopPagCtrlEles);
			
			/*
			
			if(this.currentPageNum == 1) {
				this.shopPagCtrlEles["Top"]["PrevLink"].setStyle('display', 'none');
				this.shopPagCtrlEles["Btm"]["PrevLink"].setStyle('display', 'none');
			}
			else {
				if(this.shopPagCtrlEles["Top"]["PrevLink"].getStyle('display') != 'inline')
					this.shopPagCtrlEles["Top"]["PrevLink"].setStyle('display', 'inline');
				if(this.shopPagCtrlEles["Btm"]["PrevLink"].getStyle('display') != 'inline')
					this.shopPagCtrlEles["Btm"]["PrevLink"].setStyle('display', 'inline');
			}
			if(this.currentPageNum == this.numPages) {
				this.shopPagCtrlEles["Top"]["NextLink"].setStyle('display', 'none');
				this.shopPagCtrlEles["Btm"]["NextLink"].setStyle('display', 'none');
			}
			else {
				if(this.shopPagCtrlEles["Top"]["NextLink"].getStyle('display') != 'inline')
					this.shopPagCtrlEles["Top"]["NextLink"].setStyle('display', 'inline');
				if(this.shopPagCtrlEles["Btm"]["NextLink"].getStyle('display') != 'inline')
					this.shopPagCtrlEles["Btm"]["NextLink"].setStyle('display', 'inline');
			}
				*/
	},
	nextPage: function() {
		this.parent();
	},
	prevPage: function() {
		this.parent();
	},
	gotoPage: function(passedCurrPageNum) {
		this.parent(passedCurrPageNum);
	}
});
