var pageElement=Array();var paginatorId='';var currentPage=1;var allItems=0;var lastPage=1;var startPage=1;var itemsPerPage=6;var firstPageSymbol='First Page';var previousPageSymbol='<';var nextPageSymbol='>';var lastPageSymbol='Last Page';var separator='  ';var paginatorPosition='bottom';var paginatorStyle=1;var enablePageOfOption=false;var enableGoToPage=false;var textGoToPage='Go to';var enableSelectNoItems=false;var textSelectNoItems='Items Per Page';var paginatorValues=Array(5,10,15,20,25,30);var anchorLink='javascript:void(0);';var showIfSinglePage=false;jQuery.fn.extend({pagination:function(){paginatorId=this;switch(paginatorPosition){case'top':{paginatorId.before('<div class="paginator"></div>');break}
case'bottom':{paginatorId.after('<div class="paginator"></div>');break}
case'both':{paginatorId.before('<div class="paginator"></div>');paginatorId.after('<div class="paginator"></div>');break}
default:{paginatorId.after('<div class="paginator"></div>')}}
initPaginator()},depagination:function(){$('.paginator').remove();paginatorId.children().show()}});function initPaginator(){if(itemsPerPage<1)itemsPerPage=5;allItems=paginatorId.children().length;if(allItems%itemsPerPage==0)lastPage=parseInt(allItems/itemsPerPage);else lastPage=parseInt(allItems/itemsPerPage)+1;if((startPage<1)||(startPage>lastPage))startPage=1;if(!showIfSinglePage){if(lastPage>1)appendContent(startPage,1)}else appendContent(startPage,1)}
function appendContent(a,b){if(a<0){if(a==-1)a=currentPage-1;else a=currentPage+1}
currentPage=a;till=(currentPage-1)*itemsPerPage;if(!b){paginatorId.fadeOut(200,"easeOutQuad",function(){createPaginator();paginatorId.children().hide();paginatorId.children().slice(till,itemsPerPage+till).show();paginatorId.fadeIn(200,"easeInQuad")})}else{createPaginator();paginatorId.children().hide();paginatorId.children().slice(till,itemsPerPage+till).show()}}
function createPaginator(){$(".paginator").html("");var a='';var b='';var c='';var d='';var e=' Page '+currentPage+' of '+lastPage+' Page(s) ';var f=' '+textGoToPage+' <select onchange="appendContent(this.value);" >';var g=' '+textSelectNoItems+' <select onchange="itemsPerPage=Number(this.value);initPaginator();" >';for(var i=0;i<paginatorValues.length;i++){if(itemsPerPage==paginatorValues[i])g+='<option value="'+paginatorValues[i]+'" selected="selected">'+paginatorValues[i]+'</option>';else g+='<option value="'+paginatorValues[i]+'">'+paginatorValues[i]+'</option>'}
g+='</select>';if(currentPage==1){style='<a href="'+anchorLink+'" class="disabled" title="First Page">'+firstPageSymbol+'</a>'+separator;a=b=style;style='<a href="'+anchorLink+'" class="disabled" title="Previous Page">'+previousPageSymbol+'</a>'+separator;a+=style;b+=style;c+=style;d+=style}else{style='<a href="'+anchorLink+'" class="active" onclick="appendContent(1);" title="First Page">'+firstPageSymbol+'</a>'+separator;a=b=style;style='<a href="'+anchorLink+'" class="active" onclick="appendContent(-1);" title="Previous Page">'+previousPageSymbol+'</a>'+separator;a+=style;b+=style;c+=style;d+=style}
for(var i=1;i<=lastPage;i++){if(i==currentPage){a+='<a href="'+anchorLink+'" class="inactive" title="Page '+i+'">'+i+'</a>'+separator;b+='<a href="'+anchorLink+'" class="inactive" title="Page '+i+'">'+i+'/'+lastPage+'</a>'+separator;c+='<a href="'+anchorLink+'" class="inactive" title="Page '+i+'">'+i+'</a>'+separator;f+='<option value="'+i+'" selected="selected">'+i+'</option>'}else{style='<a href="'+anchorLink+'" class="active" onclick="appendContent('+i+');" title="Page '+i+'">'+i+'</a>'+separator;a+=style;c+=style;f+='<option value="'+i+'">'+i+'</option>'}}
f+='</select>';if(currentPage==lastPage){style='<a href="'+anchorLink+'" class="disabled" title="Next Page">'+nextPageSymbol+'</a>';a+=style;b+=style;c+=style;d+=style;style=separator+'<a href="'+anchorLink+'" class="disabled" title="Last Page">'+lastPageSymbol+'</a>';a+=style;b+=style}else{style='<a href="'+anchorLink+'" class="active" onclick="appendContent(-2);" title="Next Page">'+nextPageSymbol+'</a>';a+=style;b+=style;c+=style;d+=style;style=separator+'<a href="'+anchorLink+'" class="active" onclick="appendContent('+lastPage+');" title="Last Page">'+lastPageSymbol+'</a>';a+=style;b+=style}
switch(paginatorStyle){case 1:style=a;break;case 2:style=b;break;case 3:style=c;break;case 4:style=d;break;default:style=a}
if(enablePageOfOption)style+='<span class="inactive" title="Page Information">'+e+'</span>';if(enableGoToPage)style+='<span class="inactive" title="Select Page">'+f+'</span>';if(enableSelectNoItems)style+='<span class="inactive" title="Select no. of items per page">'+g+'</span>';$(".paginator").html(style)}
