wordpress numeric pagination for category page

function blog_pagination($pages = '', $range = 2)
{  
     $showitems = ($range * 2)+1;  

     global $paged;
     if(empty($paged)) $paged = 1;

     if($pages == '')
     {
         global $wp_query;
         $pages = $wp_query->max_num_pages;
         if(!$pages)
         {
             $pages = 1;
         }
     }   

     if(1 != $pages)
     {
         echo "<div class='pagination'>";
         if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='?".get_pagenum_link(1)."'>&laquo;</a>";

         for ($i=1; $i <= $pages; $i++)
         {
             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
             {
				 
				  echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='?page=".$i."' class='inactive' >".$i."</a>";
             }
         }

         if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) 
		 
 
		 echo "<a href='?page=".$pages."'>&raquo;</a>";
         echo "</div>\n";
     }
}

$i=1;
global $paged;
$paged = (get_query_var('page')) ? get_query_var('page') : 1;

$args = array( 'category_name' => $cat , 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 20, 'paged' => $paged , 'orderby' =>'date','order' => 'DESC' );

 $additional_loop = new WP_Query($args);
 while ($additional_loop->have_posts()) : $additional_loop->the_post();
 ?>
 
 <div class="single_posts_thumb">
	<?php if(has_post_thumbnail()){?>
	<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
	<?php } else { ?>
	<a href="<?php the_permalink(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/blog_dflt_thumb.png"/></a>
	<?php } ?>
</div> 

<?php
$i++;
endwhile;
wp_reset_postdata();

?>

<?php	blog_pagination($additional_loop->max_num_pages, 3); ?>