1function pageRange(page,pageCount){
2
3var start = page-2,
4 end = page+2;
5
6if(end>pageCount){
7 start-=(end-pageCount);
8 end=pageCount;
9}
10if(start<=0){
11 end+=((start-1)*(-1));
12 start=1;
13}
14
15end = end>pageCount?pageCount:end;
16
17return {start:start, end:end};
18}
19