	// jQuery function for pagination on single listing page	
	function pageselectCallback(page_index, jq){
		// Get number of elements per pagination page from form
	    var items_per_page = 10;
	    var max_elem = Math.min((page_index+1) * items_per_page, $('#hiddenresult div.result').length);
	    var new_content = '';

	    // Creates pager range for sub-heading
	    var totalentries = $('#hiddenresult div.result').length;
	    var low_range = (page_index*items_per_page) + 1;
	    var high_range = max_elem;
	    
	    if(totalentries > 0){
	    	var range = 'Displaying ' + low_range + '-' + high_range + ' of ' + totalentries;
	    	$('#count').empty().append(range);
	    }
		
		if(totalentries == 0){
			new_content += '<p><strong>There have not been any submissions to the guestbook yet.<\/strong><\/p>\n';
			new_content += '<p><strong>Be the first by filling out the form to the right!<\/strong><\/p>\n';
		}else {
		    for(var i=page_index*items_per_page;i<max_elem;i++) {
		    	new_content += $('#hiddenresult div.result:eq('+i+')').html();
			}
	    }
	    
	    // Replace old content with new content
	    $('#Searchresult').empty().append(new_content);
	    
	    // Prevent click eventpropagation
		return false;
	}
	
	$(document).ready(function(){
		var num_entries = $('#hiddenresult div.result').length;
		$("#Pagination").pagination(num_entries, {
			num_edge_entries: 1,
			num_display_entries: 10,
			callback: pageselectCallback,
			link_to:"#",
			items_per_page: 10
		});	
	});
