        var totalRecords ;
        var noOfRecs ;
        var numOfPages2display ;
        var OrginalLinkValue; 
        var initialOffset = 1;
        var numofPages;
        var currPageNo;

        function PageInit(start, recordSize, pageSize, pageLength) {

            if (pageSize > 0) {
                OrginalLinkValue = start;
                if (((start - 1) / pageSize) > 5) {
                    start = start - (pageSize * 5);
                }
                else {
                    start = 1;
                }
                currPageNo = start;
                totalRecords = recordSize;
                noOfRecs = pageSize;
                numOfPages2display = pageLength;
                numofPages = eval(totalRecords) / eval(noOfRecs);
                numofPages = Math.ceil(numofPages);
                DisplayLinks(totalRecords, currPageNo);
            }
        }
        
        function DisplayLinks(totalRecords, pageNo) {

            var i;
            var mySpan;
            var texthtml = "";
            var infohtml = "";
            var ccc ="";
            var lastvalue = (eval(totalRecords) + 1) - OrginalLinkValue;
            if (lastvalue > noOfRecs) {
                ccc = eval(OrginalLinkValue) + eval(noOfRecs) - 1;
            }
            else {
                ccc = totalRecords;
            }
            infohtml += '<li>' + OrginalLinkValue + ' to ' + ccc + ' of ' + totalRecords + ' Records </li>';
            texthtml += '<ul>';
		    texthtml += '<li><a href="javascript:void(0)" id="lblFirstPage" class="first" onclick="FirstPageClick()"><strong>&lt;&lt;First</strong></a></li>';
		    texthtml += '<li><a href="javascript:void(0)" id="lblPrevious" class="previous" onclick="PreviousClick()"><strong>Previous</strong></a></li>';
            for (i = pageNo, j=0; j < numOfPages2display && i < (totalRecords + 1); i = eval(i) + eval(noOfRecs), j++) {
                if (i >= 1 && i <= totalRecords) {
                    var toVal;                    
                    if(eval(totalRecords) < eval(noOfRecs)) // if the total records are less than no of records to be disply in a page.
                    {
                        toVal = eval(i) + eval(totalRecords) - 1;
                    }
                    else
                    {
                        toVal = eval(i) + eval(noOfRecs) - 1;
                        if((toVal - 1) > totalRecords) // if the last limit is less than the total records
                        {
                            toVal = totalRecords;
                        }
                    }
                    var thirdvalue = "";
                    if (i != 1) {
                        var firstvalue = i.toString().substr(0, i.toString().length - 1);
                        var secondvalue = i.toString().substr(i.toString().length - 1, i.toString().length);
                        thirdvalue =parseInt(firstvalue) + parseInt(secondvalue);
                    }
                    else {
                        thirdvalue = 1;
                    }
                    if (i == OrginalLinkValue) {
                        texthtml += '<li class="current"><a href = "javascript:void(0)" onclick="linkClick(' + i + ')" ';
                        texthtml += '>' + thirdvalue + '</a></li> &nbsp;&nbsp;';
                    }
                    else {
                        texthtml += '<li><a href = "javascript:void(0)" onclick="linkClick(' + i + ')" ';
                        texthtml += '>' + thirdvalue + '</a></li> &nbsp;&nbsp;';                       
                    }                    
                }
            }

            texthtml += '<li><a href="javascript:void(0)" id="lblNext" class="next" onclick="NextClick()" ><strong>Next</strong></a></li>';
            texthtml += '<li><a href="javascript:void(0)" id="lblLastPage" class="last" onclick="LastPageClick()"><strong>Last&gt;&gt;</strong></a></li>';
            texthtml += '</ul>';

            if (parseInt(totalRecords) > noOfRecs) {
                $('#paginglink').html(texthtml);
            }            
            $('#totalrecordlink').html(infohtml);
//             $('.paging').show();

            //Enable-Disable Start Point
            if (initialOffset == OrginalLinkValue) {
				$(".first").hide();
				$(".previous").hide();				
			}
            else {
				$(".previous").show();	
            }
            if ((eval(OrginalLinkValue) + eval(noOfRecs)) >= totalRecords) {

				$(".next").hide();
				$(".last").hide();		
	        }
            else {

				$(".next").show();
            }
            //Enable-Disable End Point
        }

        function linkClick(currPageNo) {
            postForm("", "paging", currPageNo);            		
		}

		function PreviousClick() {
        
            if (OrginalLinkValue > initialOffset) {
                linkClick(eval(OrginalLinkValue) - eval(noOfRecs));
            }
        }

        function NextClick() {

            if ((OrginalLinkValue + noOfRecs) < totalRecords) {
                linkClick(eval(OrginalLinkValue) + eval(noOfRecs));
            }
        }

        function FirstPageClick() {
            linkClick(1);
        }

        function LastPageClick() {

            var pagegs = eval(totalRecords) / eval(noOfRecs);
            var last = Math.ceil(pagegs);
            var floor = Math.floor(pagegs);
            if (last > floor) {
                last = (floor * noOfRecs) + 1;
            }
            else {
                last = ((floor * noOfRecs) - noOfRecs + 1);
            }
            linkClick(last);
        }
