var description = '';
function pager(thisId,thisStartNum,rowsOnPage,limit,rowCountTotal,numberDiv,locationHref,doWrite) {

	if(!thisId) {

		document.write('usage: moePageLink(thisId,thisStartNum,rowsOnPage,limit,rowCountTotal,numberDiv,locationHref)')	

	} else {

		var thisId, thisStartNum, rowsOnPage, limit, locationHref, rowCountTotal;
		var pageCountTotal, pageCountTotal2, maxPageCount, numberDiv, maxNumPerRow, startPageNum, startPos,addPageNum, addNum, maxAddNum, i; 

/*		if(thisId!='')
			thisId = '_' + thisId;
		else
			thisId = '';
*/
		if(thisStartNum=='')
			thisStartNum = 1;
		else
			thisStartNum = thisStartNum;

		if(rowCountTotal>rowsOnPage) {

			if (doWrite=='true')
				document.write('<div style="height:35px"><div class="pager"><div class="anumbers" id="' + numberDiv + thisId + '"></div></div></div>');

			pageCountTotal = Math.ceil(rowCountTotal/rowsOnPage);			// total count of pages
			pageCountTotal2 = parseInt(rowCountTotal/rowsOnPage);			// total count of pages
			maxPageCount = pageCountTotal2*rowsOnPage;								// max result count
			numberDiv = document.getElementById(numberDiv + thisId);	// id of div containing number_links
			
			if (doWrite!='true')
			   numberDiv.innerHTML='';
			   
			maxNumPerRow = 10;																				// Set max shown nums per search
			startPageNum = ((thisStartNum-1)/rowsOnPage)+1;
			startPos = parseInt((startPageNum-1)/maxNumPerRow);
			addPageNum = maxNumPerRow*(startPos*rowsOnPage);
			addNum = startPos*maxNumPerRow;
			maxAddNum = addPageNum+(maxNumPerRow*rowsOnPage);

			if(startPos=='0')
				startPos = '';

			if (maxNumPerRow>pageCountTotal)
				var maxNumPerRow = pageCountTotal+1;	

			if(addPageNum>0)
				numberDiv.innerHTML += "<a href='javascript:gotoPage(" + (((addNum-maxNumPerRow)*rowsOnPage)+1) + ",\"" + limit + "\",\"" + locationHref + "\", " + rowsOnPage + ",\"" + thisId + "\")'>&laquo;</a>";

			if(thisStartNum>1)
				numberDiv.innerHTML += "<a href='javascript:gotoPage(" + parseInt(thisStartNum-rowsOnPage) + ",\"" + limit + "\",\"" + locationHref + "\", " + rowsOnPage + ",\"" + thisId + "\")'>&lt;</a>";

			for(i = 0; i < maxNumPerRow; i++) {
				if (pageCountTotal>=(i+1+addNum)) {
					if (((i*rowsOnPage)+1+addPageNum)==thisStartNum)
						numberDiv.innerHTML += "<strong>" + (i+1+addNum) + "</strong>";
					else
						numberDiv.innerHTML += "<a href='javascript:gotoPage(" + ((i*rowsOnPage)+1+addPageNum) + ",\"" + limit + "\",\"" + locationHref + "\", " + rowsOnPage + ",\"" + thisId + "\")'>" + (i+1+addNum) + "</a>";
				}
			}

			if(maxPageCount>thisStartNum)
				numberDiv.innerHTML += "<a href='javascript:gotoPage(" + parseInt(thisStartNum+rowsOnPage) + ",\"" + limit + "\",\"" + locationHref + "\", " + rowsOnPage + ",\"" + thisId + "\")'>&gt;</a>";

			if(maxPageCount>maxAddNum)
				numberDiv.innerHTML += "<a href='javascript:gotoPage(" + (((addNum+maxNumPerRow)*rowsOnPage)+1) + ",\"" + limit + "\",\"" + locationHref + "\", " + rowsOnPage + ",\"" + thisId + "\")'>&raquo;</a>";

			if(pageCountTotal>9)
				numberDiv.innerHTML += '';			
//				numberDiv.innerHTML += '<span class="left">[' + pageCountTotal + ' sider]</span>';
		}
		else {
			numberDiv = document.getElementById(numberDiv + thisId);	// id of div containing number_links
			
			if (doWrite!='true' && numberDiv!=null)
			   numberDiv.innerHTML='';
		}
	}
}

function gotoPage(startnum,limit,locationHref, endline, thisid) {
	if (locationHref!="" && locationHref.substring(0,1)!=':')
		self.location.href = locationHref + limit + '&startline=' + startnum + '&endline=' + (startnum + endline - 1)
	else
		loaddata(locationHref.substring(1,locationHref.length) + limit + '&startline=' + startnum + '&endline=' + (startnum + endline - 1)+'&thisid='+thisid , thisid,'pager');
}