<?
function getPagination($table,$module,$id)
{
	$w=$GLOBALS['db']->query("select id from ".$table." where deleted='0'");
	$i==0;
	while($r=$GLOBALS['db']->fetchByAssoc($w))
	{
		$tab[$i+1]=$r['id'];
		if($id==$r['id'])$n=$i+1;
		$i++;
	}
	if($n==1)
	{
		$buttons['prev']['disabled']="disabled";
		$buttons['prev']['offon']="_off";
		$buttons['prev']['id']=$tab[$n-1];
		$buttons['next']['disabled']="";
		$buttons['next']['offon']="";
		$buttons['next']['id']=$tab[$n+1];
	}
	elseif($n==mysql_num_rows($w))
	{
		$buttons['prev']['disabled']="";
		$buttons['prev']['offon']="";
		$buttons['prev']['id']=$tab[$n-1];
		$buttons['next']['disabled']="disabled";
		$buttons['next']['offon']="_off";
		$buttons['next']['id']=$tab[$n+1];
	}
	else
	{
		$buttons['prev']['disabled']="";
		$buttons['prev']['offon']="";
		$buttons['prev']['id']=$tab[$n-1];
		$buttons['next']['disabled']="";
		$buttons['next']['offon']="";
		$buttons['next']['id']=$tab[$n+1];
	}
	$html='<tr colspan="4">
<td colspan="40" nowrap align=\'right\' class=\'listViewPaginationTdS1\'><button type=\'button\' class=\'button\' title=\'Return to List\' onClick=\'location.href="index.php?action=index&module='.$module.'&offset=0";\'>Return to List</button>&nbsp;&nbsp;&nbsp;&nbsp;<button onClick=\'location.href="index.php?module='.$module.'&action=DetailView&record='.$buttons['prev']['id'].'";\' type=\'button\' class=\'button\' title=\'Previous\' '.$buttons['prev']['disabled'].'><img src=\'themes/Sugar/images/previous'.$buttons['prev']['offon'].'.gif\' width=\'8\' height=\'11\' alt=\'Previous\'  border=\'0\' align=\'absmiddle\'></button>&nbsp;&nbsp;('.$n.' of '.mysql_num_rows($w).')&nbsp;&nbsp;<button type=\'button\' class=\'button\' title=\'Next\' onClick=\'location.href="index.php?module='.$module.'&action=DetailView&record='.$buttons['next']['id'].'";\' '.$buttons['next']['disabled'].'><img src=\'themes/Sugar/images/next'.$buttons['next']['offon'].'.gif\' width=\'8\' height=\'11\' alt=\'Next\'  border=\'0\' align=\'absmiddle\'></button>&nbsp;&nbsp;</td></tr>';
	
	return $html;
}
?>