function listBox(item,maxNumItems,p){
 	var totItems = $('#'+item+' li').length;
 	var startIndex = ((p-1)*maxNumItems);
 	var endIndex = (startIndex+maxNumItems-1);
 	var totPages = Math.ceil(totItems/maxNumItems);
 	var max = 3;
 	$('#'+item).show();
 	$('#'+item+' li').each(
 		function(intIndex){
 			if(intIndex>=startIndex && intIndex<=endIndex){
 				$("span[type='hiddenImage']", this).html("<img src='"+$("span",this).attr('rel')+"' class='smallImage' border='0' />");
 				$(this).css('display','list-item');
 			}else{
 				$(this).css('display','none');
 			}
 			
 			if(intIndex==endIndex || intIndex==(totItems-1)){
 				$(this).find('.subSidebar').css('border','0px');
 				$(this).find('.subSidebar').css('padding','0px');
 				$(this).find('.subSidebar').css('margin','0px');
 			}
 		}
 	);
 	
 	if(totPages>1){
 		var showPrev = "";
	 	if(p!=1){
	 		var prevPage = (p-1);
	 		showPrev = '<a href=\"#\" onclick=\"listBox(\''+item+'\','+maxNumItems+','+prevPage+'); return false;\">prev</a>&nbsp;';
	 	}
	 	$('#'+item+' p.morePages').html(showPrev+' page ');
	 	var dottedBefore = false;
	 	var dottedAfter = false;

	 	for(i=1;i<=totPages;i++){
	 		var showPage = (i==p) ? '<b>'+i+'</b>&nbsp;' : '<a href=\"#\" onclick=\"listBox(\''+item+'\','+maxNumItems+','+i+'); return false;\">'+i+'</a>&nbsp;' ;
	 		
	 		if (totPages > 8)
	 		{
	 			if (i > p - max && i < p + max)
	 			{
		 			$('#'+item+' p.morePages').append(showPage); 				
	 			}
	 			else
	 			{
	 				if (i <= p - max && dottedBefore == false)
	 				{
		 				$('#'+item+' p.morePages').append('...');
	 					dottedBefore = true;
	 				}
	 				else
	 				if (i >= p + max && dottedAfter == false)
	 				{
		 				$('#'+item+' p.morePages').append('...');
	 					dottedAfter = true;
	 				}
	 			}	 			
	 		}
	 		else {
	 			$('#'+item+' p.morePages').append('<a href=\"#\" onclick=\"listBox(\''+item+'\','+maxNumItems+','+i+'); return false;\">'+showPage+'</a>');
	 		}
	 	}
	 	if(p!=totPages){
	 		var nextPage = (p+1);
	 		$('#'+item+' p.morePages').append('&nbsp;<a href=\"#\" onclick=\"listBox(\''+item+'\','+maxNumItems+','+nextPage+'); return false;\">next</a>');
	 	}
 	}else{
 		$('#'+item+' p.morePages').html('');
	}
	
	// show item
	$('#'+item).fadeIn('slow');
 }
