function showNext(id) {
	psForm = document.getElementById("page-selector");
	psForm.entry_id.value = id;
	psForm.direction.value = "fw";
	psForm.submit();
}

function showPrevious(id) {
	psForm = document.getElementById("page-selector");
	psForm.entry_id.value = id;
	psForm.direction.value = "bw";
	psForm.submit();
}

function WPageSelector(i, c) {
	
	//this.id = id;
	this.count = c;
	this.currentIndex = i;
	
	this.setTotalPagesCount = function(count) {
		this.count = count;
	}
	
	this.setCurrentPage = function(index) {
		this.currentIndex = index;
	}
	
	this.create = function() {
		document.pageSelector = this;
		//this.update();
		/*
		var html = "<div id='page-selector'><div id='prev'><a onclick='document.pageSelector.onPrevious();' href='#'>Önceki</a></div>";
		html += "<div id='pages-info'>"+this.currentIndex+"/"+this.count+"</div><div id='next'><a onclick='document.pageSelector.onNext();' href='#'>Sonraki</a></div></div>";
		document.getElementById(this.id).innerHTML = html;
		*/
	}
	
	this.onPrevious = function() {
		if (this.currentIndex>1) {
			this.currentIndex--;
			document.getElementById("ps_currentPageIndex").value = this.currentIndex;
			document.getElementById("ps_totalPagesCount").value = this.count;
			document.getElementById("page-selector").submit();
		}
	}
	
	this.onNext = function() {
		if (this.currentIndex<this.count) {
			this.currentIndex++;
			document.getElementById("ps_currentPageIndex").value = this.currentIndex;
			document.getElementById("ps_totalPagesCount").value = this.count;
			document.getElementById("page-selector").submit();
		}
	}
	
	this.update = function() {
		var html = "<form id='page-selector' action='apage.php' method='post'><div id='prev'><a onclick='document.pageSelector.onPrevious();' href='#'>Önceki</a></div>";
		html += "<div id='pages-info'>"+this.currentIndex+"/"+this.count+"</div><div id='next'><a onclick='document.pageSelector.onNext();' href='#'>Sonraki</a></div>";
		html += "<input type='hidden' id='ps_currentPageIndex' value='0' /><input type='hidden' id='ps_totalPagesCount' value='0' /></form>";
		document.getElementById(this.id).innerHTML = html;
	}
}
