//====================================================================
//	Report Functions
//====================================================================

//	[ start page navigation ]
	function BuildPageNav(p)
		{
//		alert(p);
//		alert('Build Page Nav');
		document.getElementById('divPageNav2').style.display = 'none';
//		alert(getCookie('tRecords'));
		var tRecords = getCookie('tRecords');
//		var pSize = 10; // page size;
		var pSize = getCookie('PageSize');
		var nSize = 20; // nav size;
		var tPages = Math.ceil(tRecords/pSize); // total pages
		var nString = '';  // nav string;

	if(getCookie('tRecords') > '0')
		{
//		alert('c');

		if(nSize > tPages)	// if nav size > total page then nav size = total pages
			{
			nSize = tPages
			}
		var sNum = 1; // start number;
		if(p > nSize)
			{
			sNum = (((p*1)-nSize)+1);
			}
//		  var nString = '';  // nav string;

//		-- start opening of navigation bar --
		nString = nString + "Result Pages: ";
//		alert(tPages);
		if(tPages > 1)
			{
			if(p == 1)
				{
				nString = nString + "<span class=\"pNavItem\" style=\"color: #A6A6A6; cursor:default;\">|< First Page</span>";
				nString = nString + "<span class=\"pNavItem\" style=\"color: #A6A6A6; cursor:default;\"><< Prev</span>";
				}
			else
				{
				nString = nString + "<span class=\"pNavItem\" style=\"cursor:pointer;\" onmouseover=\"StyleNav(this, 'i');\" onmouseout=\"StyleNav(this, 'o');\" onclick=\"BuildPageNav('1'); InitResults('1');\">|<u>< First Page</u></span>";
				nString = nString + "<span class=\"pNavItem\" style=\"cursor:pointer;\" onmouseover=\"StyleNav(this, 'i');\" onmouseout=\"StyleNav(this, 'o');\" onclick=\"BuildPageNav('" + ((p*1)-1) + "'); InitResults('" + ((p*1)-1) + "')\"><u><< Prev</u></span>";
				}
			}

//		-- start loop of page numbers --
		for(var n = sNum; n <= ((sNum+nSize)-1); n++)
			{
			if(n == p)
				{
				nString = nString + "<span class=\"pNavItem\" style=\"cursor:default;\">" + n;
				}
			else
				{
				nString = nString + "<span class=\"pNavItem\" style=\"cursor:pointer;\" onmouseover=\"StyleNav(this, 'i');\" onmouseout=\"StyleNav(this, 'o');\" onclick=\"BuildPageNav('" + n + "');  InitResults('" + n + "')\"><u>" + n + "</u>";
				}

		if(n < (sNum+nSize) || n < tPages)
			{
//			nString = nString  + " "
			}
		nString = nString + "</span>";
		}
 
//		-- start closing of navigation bar --
		if(tPages > 1)
			{
			if(p == tPages)
				{
				nString = nString + "<span class=\"pNavItem\" style=\"color: #A6A6A6; cursor:default;\"><u>Next >></u></span>";
				nString = nString + "<span class=\"pNavItem\" style=\"color: #A6A6A6; cursor:default;\"><u>Last Page ></u>|</span>";
				}
			else
				{
				nString = nString + "<span class=\"pNavItem\" style=\"cursor:pointer;\" onmouseover=\"StyleNav(this, 'i');\" onmouseout=\"StyleNav(this, 'o');\" onclick=\"BuildPageNav('" + ((p*1)+1) + "'); InitResults('" + ((p*1)+1) + "')\"><u>Next >></u></span>";
				nString = nString + "<span class=\"pNavItem\" style=\"cursor:pointer;\" onmouseover=\"StyleNav(this, 'i');\" onmouseout=\"StyleNav(this, 'o');\" onclick=\"BuildPageNav('" + tPages + "'); InitResults('" + tPages + "')\"><u>Last Page ></u>|</span>";
				}
			}

		}
	else
		{
		nString = nString + ""
		}

//	[ end page navigation ]
 
// 	alert(nString);
 
	document.getElementById('divPageNav1').innerHTML = nString;
	document.getElementById('divPageNav2').innerHTML = nString;
//	document.getElementById('divPageNav2').style.display='block';
//	setTimeout(RetrieveResults(),500);
	}


	function StyleNav(item, act)
		{
//		border: solid 1px #555555; padding-bottom: 1; 
//		alert(item + ', ' + act);
		if(act == 'i')
			{
			item.style.borderColor = '#555555';
			item.style.backgroundColor = '#EEECE3'
			}
		else
			{
			item.style.borderColor = '';
			item.style.backgroundColor = '';
			}
		}