		
function buildPagination( rowCount, pageSetPages ) 
{ 
	pageLoop = 0; 
	startIndex = gStartIndex*1;
	perPage = gPerPage*1;
	
	rowRanges = document.getElementById("rowRangeSPAN");
	pageLinks = document.getElementById("pageLinksSPAN");
	if ( rowCount <= 0 )
	{
		rowRanges.innerHTML = "";
		pageLinks.innerHTML = "";
		if ( document.getElementById("rowRangeSPAN2") )
		{
			document.getElementById("rowRangeSPAN2").innerHTML = "";
			document.getElementById("pageLinksSPAN2").innerHTML = "";
		}
	}
	else
	{
		if ( rowCount <= perPage ) 
		{
			rowRanges.innerHTML = "Viewing " + ( (startIndex*1) + 1 ) + " - " + rowCount + " of " + rowCount;
			pageLinks.innerHTML = "";
			if ( document.getElementById("rowRangeSPAN2") )
			{
				document.getElementById("rowRangeSPAN2").innerHTML = "Viewing " + ( (startIndex*1) + 1 ) + " - " + rowCount + " of " + rowCount;
				document.getElementById("pageLinksSPAN2").innerHTML = "";
			}
		}
		else 
		{
			rowRanges.innerHTML = "&nbsp;&nbsp;of " + rowCount;
			if ( document.getElementById("rowRangeSPAN2") )
			{document.getElementById("rowRangeSPAN2").innerHTML = "&nbsp;&nbsp;of " + rowCount;}

			//get total number of pages 
			pageCount = (rowCount / perPage).toString();
			if ( pageCount.indexOf(".") > -1 ) 
			{pageLoop = (pageCount.substring( 0, pageCount.indexOf(".") )*1) + 1;}
			else 
			{pageLoop = pageCount;}

			currentPage = ((startIndex*1) + (perPage*1))/perPage;

			useHtml = "";

			//build page links
			useHtml = useHtml + "<select onchange=\"pageMove(this.value);\">";
			for ( i = 1; i < (pageLoop*1); i++ ) 
			{
				if ( currentPage == i ) 
				{useHtml = useHtml + '<option value="Page ' + i + '" selected="true">Viewing ' + ((perPage*(i-1)) + 1) + ' - ' + ((perPage*(i-1)) + perPage) + '</option>';}
				else
				{useHtml = useHtml + '<option value="Page ' + i + '">Show ' + ((perPage*(i-1)) + 1) + ' - ' + ((perPage*(i-1)) + perPage) + '</option>';}
			}
			if ( currentPage == i ) 
			{useHtml = useHtml + '<option value="Page ' + i + '" selected="true">Viewing ' + ((perPage*(i-1)) + 1) + ' - ' + rowCount + '</option>';}
			else
			{useHtml = useHtml + '<option value="Page ' + i + '">Show ' + ((perPage*(i-1)) + 1) + ' - ' + rowCount + '</option>';}
			useHtml = useHtml + "</select>";
			
			//add links to SPANs
			pageLinks.innerHTML = useHtml;
			if ( document.getElementById("pageLinksSPAN2") )
			{document.getElementById("pageLinksSPAN2").innerHTML = useHtml;}
		}
	}
} 

function pageMove( moveDirection ) 
{
	//move to a page 
	if ( moveDirection.indexOf("Page") > -1 ) 
	{
		currentPage = moveDirection.substring( moveDirection.indexOf(" ") + 1, moveDirection.length );
		startIndex = (currentPage * perPage) - perPage;
		if ( startIndex < 0 ) 
		{startIndex = 0;}
	}
	//move to a start location 
	else if ( moveDirection.indexOf("Start") > -1 ) 
	{
		startIndex = moveDirection.substring( moveDirection.indexOf(" ") + 1, moveDirection.length );
		currentPage = ((startIndex*1) + (perPage*1))/perPage;
	}
	else 
	{
		//get next xml data 
		if ( moveDirection == "next" ) 
		{
			startIndex = (startIndex*1) + (perPage*1);
			currentPage = ((startIndex*1) + (perPage*1))/perPage; 
		}
		//get previous xml data 
		else if ( moveDirection == "prev" ) 
		{
			startIndex = startIndex - perPage;
			if ( startIndex < 0 ) 
			{startIndex = 0;}
			currentPage = ((startIndex*1) + (perPage*1))/perPage; 
		}
	}
	
	gStartIndex = startIndex;
	executeSearch();
}

