function rebuildTable( page)
{	
		
	var perPage = 990;
	if( $('.innerContent').height() < perPage ) return false;	
	if( !page ) var page = 1;

	and_move_a_little = (page == 1 ? 0 : 20);
	$('.innerContent').css('top', - ((page-1)*perPage-and_move_a_little) + 'px') ;
	var numPages = Math.ceil( $('.innerContent').height() / perPage );
	
	if ( page == numPages)
	{
		var myHeight = $('.innerContent').height() - (numPages - 1) * perPage;
		$('.innerContent').parent().css('height', (myHeight-20) + 'px');
	}else{
			$('.innerContent').parent().css('height', 'auto');
	}
	
	if( page == 1) $('.innerContent').parent().css('height', 'auto');
	
	if( $.browser.msie && $.browser.version == '6.0' && $('.innerContent').height() > perPage)
	{
		$('.innerContent').parent().css('height', parseInt(perPage - 20) + 'px');
	}
	
	createPager(page);
}

function createPager(active)
{
	var perPage = 987;
	var div = '#pagin';
	
	$(div).html('');
	//if( $('.innerContent').height() < perPage ) return false;
	
	var numPages = Math.ceil( $('.innerContent').height() / perPage );
	
	/* create links */
	for (i=1; i<=numPages; i++)
	{
		var pagin = '';		
		pagin = $(document.createElement('a')).text(i).attr('href','#');
		$(div).append(pagin);
		
		$(div).append('&nbsp;');
	}
	
	/* set onclick*/
	i = 1;
	$(div + ' a').each(function(){
		if ( i == active )
		{
			$(this).bind('click',function(){return false;}).addClass('active');
		} else {
			if( i == 1 )
				$( this ).bind('click', function(){rebuildTable( 1 ); return false;});				
			else
			$(this).bind('click', function(e){  rebuildTable( $(this).text() ); return false; });
		}
		i++;
	});
}

$(document).ready(function(){	
	  rebuildTable(1);	  
});