
function inoFindDrugs(variableName, uniqueId, pnlResultId, tbDrugNameId, ddlIsGroupId, cbxOnlyFundId, pnlSearchResultTitleId, lblResultDescriptionId, imgLoadingId, useRedirectUrl)
{
    this.VariableName = variableName;
    this.UniqueId = uniqueId;
    this.PnlResultId = pnlResultId;
    this.TbDrugNameId = tbDrugNameId;
    this.DdlIsGroupId = ddlIsGroupId;
    this.CbxOnlyFundId = cbxOnlyFundId;
    this.PnlSearchResultTitleId = pnlSearchResultTitleId;
    this.LblResultDescriptionId = lblResultDescriptionId;
    this.ImgLoadingId = imgLoadingId;
    this.UseRedirectUrl = useRedirectUrl;
    
    this.StrEnterFilter = "Please select IS group.";
    this.StrLoading = "Loading...";
    
    this.pageNumber = 0;
    this.sortBy = "";
    this.sortOrder = "";
    
    this.FilterLetter = "";
    
    this.IFrame = null;
    
    this.SearchDrug = function()
    {
        if (this.UseRedirectUrl)
        {
            return true;
        }

        this.FilterLetter = "";
        
        this.doCallback("SearchDrug");
        
        return false;
    }
    
    //Raises when the page index is changed.
    this.ChangePage = function(pageNumber)
    {
        this.pageNumber = pageNumber;
        
        this.doCallback("ChangePage");
    }
    
    //Calls a callback that change order in the GridVew.
    this.Sort = function(sortBy, orderType)
    {
        this.sortBy = sortBy;
        this.sortOrder = orderType;
    
        this.doCallback("Sort");
    }
    
    //Calls a callback that change order in the GridVew.
    this.doCallback = function(command)
    {
        var tbDrugName = document.getElementById(this.TbDrugNameId);
        var ddlIsGroup = document.getElementById(this.DdlIsGroupId);
        var cbxOnlyFund = document.getElementById(this.CbxOnlyFundId);

        var callbackArgs = "<Command>"+command+"</Command>";
            callbackArgs += "<DrugName>" + tbDrugName.value + "</DrugName>";
            callbackArgs += "<IsCode>" + ddlIsGroup.options[ddlIsGroup.selectedIndex].value + "</IsCode>";
            callbackArgs += "<OnlyFund>" + (cbxOnlyFund.checked ? "1" : "0") + "</OnlyFund>";
            callbackArgs += "<FilterLetter>" + this.FilterLetter + "</FilterLetter>";
            callbackArgs += "<PageNumber>" + this.pageNumber + "</PageNumber>";
            callbackArgs += "<SortBy>" + this.sortBy + "</SortBy>";
            callbackArgs += "<SortOrder>" + this.sortOrder + "</SortOrder>";
            
        var context = this.VariableName;
        
        this.prepareSearch();
          
        WebForm_DoCallback(this.UniqueId, callbackArgs, ReceiveCallBackData, context,  null, true);
    }
    
    this.prepareSearch = function()
    {
        document.getElementById(this.PnlSearchResultTitleId).style.display = "block";
        document.getElementById(this.LblResultDescriptionId).innerHTML = this.StrLoading;
        document.getElementById(this.ImgLoadingId).style.display = "block";
    }
    
    this.SetResultDescription = function(resultText)
    {
        document.getElementById(this.LblResultDescriptionId).innerHTML = resultText;
        document.getElementById(this.ImgLoadingId).style.display = "none";
    }
    
    this.ShowHelp = function(toolTipId)
    { 
        var tooltip = document.getElementById(toolTipId);
        
        if (tooltip.style.display != "block")
        {
            tooltip.style.display = "block";
            
            if (document.all)
            {
                if (this.IFrame == null)
                {
                    this.IFrame = document.createElement("iframe");
                    this.IFrame.id = this.VariableName +"_iframe";
                }
                
                this.IFrame.style.position = "absolute";
                this.IFrame.style.zIndex = "199";
                this.IFrame.style.display = 'block';
                this.IFrame.style.width = tooltip.offsetWidth;
                this.IFrame.style.height = tooltip.offsetHeight;
                this.IFrame.style.left = tooltip.offsetLeft;
                this.IFrame.style.top = tooltip.offsetTop; 
                
                tooltip.parentNode.insertBefore(this.IFrame,tooltip);
            }
        }
        else
        {
            tooltip.style.display = "none";
            
            if (document.all)
            {
                this.IFrame.style.display = 'none';
            }
        }
    }
}
