<?php

        
    # Paginate website results
    
    if ($cms['read_old_link'] == 'on' && get_log()['posts'] > 0) {
        
        
        
        print '<div id="res-nav">';

        if ($n > 0) {
            
            
            
            if ($menutype != 2) {
            
            
            
                #Menu links
                $order = [  'Newer posts',
                            'Older posts'
                          ];
                
                
                
                
                if ($cms['reverse_order'] == 'on')
                    rsort($order);
                
                
                
                
                #Home page
                $home = '<a href="./">&laquo;</a>';
                
                
                #Previous page
                $prevpage = '<a href="?max='.$prevlink.'"><span id="prev" class="navbutton">&lsaquo; '.$order[0].'</span></a>';
                
                
                #Home and Previous posts
                $homeprev = '<a href="./"><span id="prev" class="navbutton">&lsaquo; '.$order[0].'</span></a>';
                
                
                #Next page
                $nextpage = '<a href="?max='.$nextlink.'"><span id="next" class="navbutton">'.$order[1].' &rsaquo;</span></a>';
                
                
                #Final page
                $finalpage ='<a href="?max='.$finallink.'"><span class="navbutton">&raquo;</span></a>';
                
                
                
                
                # <== Home and previous page
                if (($ofp > 2 * $n) && ($ofp != '')) 
                    echo $home.$prevpage;
                            
                
                # <== Home page or previous page
                if ($ofp == 2 * $n) 
                    echo $homeprev;
                

                # Next page ==>
                if ($c > $ofp)
                    echo $nextpage.$finalpage;
            
            }
            
            
            
            
            # Type 2 pagination menu    
            
            else {
         
                     
                if ($cpg-$nol == 2)
                    $hlp = '&nbsp;&nbsp;';
                    
                if ($cpg-$nol > 1)
                    $firstpage = '<a href="?max='.$n.'" class="navbuttonnum" title="First page">1</a> '.$hlp;
                
                
                if ($cpg < $tnp)
                    $lastpage = ' <a href="?max='.$finallink.'" class="navbuttonnum" title="Last page">'.$tnp.'</a>';
                    
                    
                if ($cpg+$nol+1 < $tnp)
                    $lastpage = '&hellip;'.$lastpage;
                
                
                
                # Print the menu            
                if ($cpg > 1)
                    print '<a href="?max='.$prevlink.'" title="Go to previous page">&lsaquo;</a> &nbsp;';
                
                echo $firstpage;
            
        
                for ($l=$fnl; $l<$cpg; $l++)
                    print '<a href="?max='.$n*$l.'" class="fnl'.$l.' navbuttonnum">'.$l.'</a> ';
                    
                print '<span class="navbuttonnum"> &nbsp;['.$cpg.']&nbsp; </span>';
                
                    
                for ($r=1; $r<=$nol && $cpg+$r<$tnp; $r++)
                    print ' <a href="?max='.$n*($cpg+$r).'" class="navbuttonnum">'.($cpg+$r).'</a> ';
                        
                        
                echo $lastpage;
                
                if ($cpg < $tnp)
                    print ' &nbsp;<a href="?max='.$nextlink.'" title="Go to next page">&rsaquo;</a>';
                
            }
            
        }


        print '</div>';
    
    }


?>