<div id="paginazione_main">&nbsp;Pagina <?=$npage+1?> di <?=$ntotpage?></div>
<?
if(!isset($hrefp)) $hrefp=$href0;
if(!isset($onclick)) $onclick="";
$hrefp=trim($hrefp,"&");
$hrefp .= "&";

$backpage = $npage-1; if ($npage==0) $backpage = 0;
$nextpage = $npage+1; if ($npage==$ntotpage-1) $nextpage = $npage;
$msid="";
#if(isset($_cks) && $_cks=="KO") $msid = "&_cks=KO";
?>
   <a href="<?=$hrefp?>npage=<?=$backpage.$msid?>" onclick="<?=$onclick?>" ><div class="pboxnav" ><<</div></a>
   <? 
if($ntotpage<14)
{  
   
   for($ip=0;$ip<$ntotpage;$ip++){ 
   	
   	$class= "pbox";if($ip==$npage) $class="pboxon";
   	?>
 <a href="<?=$hrefp?>npage=<?=$ip?><?=$msid?>"  onclick="<?=$onclick?>" > <div class="<?=$class?>"><?=$ip+1?></div></a>
   <? } ?>
   <? } else { ?>
   
   <?
    $ip=0;
    $class= "pbox";if($ip==$npage) $class="pboxon";
   ?>
  <a href="<?=$hrefp?>npage=<?=$ip?><?=$msid?>"  onclick="<?=$onclick?>" > <div class="<?=$class?>"><?=$ip+1?></div></a>
  
  <?
  $punti1 = "...";
  $punti2 = "...";
  $start = $npage-4;
  if($start<1) $start = 1; else {
  ?>
  <div class="pbox">...</div>
  <?
  }
  $end = $npage+4;if($end>=$ntotpage) $end = $ntotpage-1; 
 
 
   for($ip=$start;$ip<$end;$ip++){ 
   	
   	$class= "pbox";if($ip==$npage) $class="pboxon";
   	?>
 <a href="<?=$hrefp?>npage=<?=$ip?><?=$msid?>"  onclick="<?=$onclick?>" > <div class="<?=$class?>"><?=$ip+1?></div></a>
   <? }  
   
   if($end<$ntotpage-1) {
  ?>
  <div class="pbox">...</div>
  <?
  }
 
    $ip=$ntotpage-1;
    $class= "pbox";if($ip==$npage) $class="pboxon";
   ?>
    <a href="<?=$hrefp?>npage=<?=$ip?><?=$msid?>"  onclick="<?=$onclick?>" > <div class="<?=$class?>"><?=$ip+1?></div></a>
 <? } ?>
  <a href="<?=$hrefp?>npage=<?=$nextpage?><?=$msid?>"  onclick="<?=$onclick?>" ><div class="pboxnav">>></div></a>
