/*
 * Validate the page number entered by end user on client side.
 * paging function 
 * added by Harry
 * 09-09-2008
/*--------------------------------------------------------------------*/

function checkPageNum(txt, pageCount)
{
    var inValue = txt.value.replace(/ /g, "");
    if(inValue == "")
    {
        txt.value = "1";
        return true;
    }
    var pat_hd = /^\d+$/;
    if(!pat_hd.test(inValue))
    {
        //alert("You should enter numeric characters.");
        alert("Invalid page number.");
        txt.select();
        return false;
    }
    if(parseInt(inValue)>pageCount)
    {
        //alert("The value should less than "+ pageCount +".");
        alert("Invalid page number.");
        txt.select();
        return false;
    }
    if(parseInt(inValue)<pageCount)
    {
        if(parseInt(inValue) == 0)
        {
            alert("Invalid page number.");
            txt.select();
            return false;
        }
    }
    return true;
}

function changePage(clientId, dropdown, repeaterId, panelId)
{
    if(clientId != "")
    {
        var input = document.getElementById(repeaterId + clientId);
        
        if(input.type == "text")
        {
            //page number from textbox
            gotoPage(input.value, dropdown, repeaterId, panelId);
        }
    }
    else
    {
        gotoPage("", dropdown, repeaterId, panelId);
    }
}

function gotoPage(pageindex, dropdown, repeaterId, panelId)
{
    var argument = "";
    
    var ids = dropdown.split(",");
    
    argument += document.getElementById(repeaterId + ids[0]).value;
    argument += "|" + document.getElementById(repeaterId + ids[1]).value;
    
    if(pageindex != "")
    {
        argument += "|" + pageindex;
    }
    
    if(panelId == "")
    {
        __doPostBack(repeaterId, argument);
    }
    else
    {
        //there is a RadAjaxPanel
        AjaxNS.AR(repeaterId, argument, panelId, event);
    }
}






