function pagination(page,length,total){
	count = total;
	page = (!page) ? 1 : page ;
	page = (page == 0 ? 1 : page);
	recordsPerPage = length;
	start = (page-1) * recordsPerPage;
	adjacents = "2";
	prev = page - 1;
	next = page + 1;
	lastpage = Math.ceil(count/recordsPerPage);
	lpm1 = lastpage - 1;   
	pagination = "";
	if(lastpage > 1){
		pagination += "<div class='col-md-12 pagination'>";
		if (page > 1){
			pagination += "<a href=\"#Page="+(prev)+"\" class=\"pageClick\">&laquo; Previous&nbsp;&nbsp;</a>";
		}else{
			pagination += "<span class='disabled'>&laquo; Previous&nbsp;&nbsp;</span>";
		}
		if (lastpage < 7 + (adjacents * 2)){   
			for (counter = 1; counter <= lastpage; counter++)
			{
				if (counter == page)
					pagination += "<span class='current'>"+counter+"</span>";
				else
					pagination += "<a href=\"#Page="+(counter)+"\" class=\"pageClick\">"+counter+"</a>";     
			}
		}  
		else if(lastpage > 5 + (adjacents * 2)){
			if(page < 1 + (adjacents * 2)){
				for(counter = 1; counter < 4 + (adjacents * 2); counter++){
					if(counter == page)
						pagination += "<span class='current'>"+counter+"</span>";
					else
						pagination += "<a href=\"#Page="+(counter)+"\" class=\"pageClick\">"+counter+"</a>";     
				}
				$pagination += "...";
				$pagination += "<a href=\"#Page="+(lpm1)+"\" class=\"pageClick\">"+lpm1+"</a>";
				$pagination += "<a href=\"#Page="+(lastpage)+"\" class=\"pageClick\">"+lastpage+"</a>";   
			}
			else if($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)){
				pagination += "<a href=\"#Page=\"1\"\" class=\"pageClick\">1</a>";
				pagination += "<a href=\"#Page=\"2\"\" class=\"pageClick\">2</a>";
				pagination += "...";
				for(counter = page - adjacents; counter <= page + adjacents; counter++){
					if(counter == page)
						pagination += "<span class='current'>"+counter+"</span>";
					else
						pagination += "<a href=\"#Page="+(counter)+"\" class=\"pageClick\">"+counter+"</a>";     
				}
				$pagination += "..";
				$pagination += "<a href=\"#Page="+(lpm1)+"\" class=\"pageClick\">"+lpm1+"</a>";
				$pagination += "<a href=\"#Page="+(lastpage)+"\" class=\"pageClick\">"+lastpage+"</a>";   
			}
			else{
				pagination += "<a href=\"#Page=\"1\"\" class=\"pageClick\">1</a>";
				pagination += "<a href=\"#Page=\"2\"\" class=\"pageClick\">2</a>";
				pagination += "..";
				for(counter = lastpage - (2 + (adjacents * 2)); counter <= lastpage; counter++){
					if(counter == page)
						pagination += "<span class='current'>"+counter+"</span>";
					else
						pagination += "<a href=\"#Page="+(counter)+"\" class=\"pageClick\">"+counter+"</a>";     
				}
			}
		}
		if(page < counter - 1){
			pagination += "<a href=\"#Page="+(next)+"\" class=\"pageClick\">Next &raquo;</a>";
		}else{
			pagination += "<span class='disabled'>Next &raquo;</span>";
		}
		pagination += "</div>";       
	}
	return pagination;
}