﻿Type.registerNamespace('CustomExtender');
CustomExtender.GridViewFilterBehavior = function(element) {
    CustomExtender.GridViewFilterBehavior.initializeBase(this, [element]);
    
    this._popupBehavior = null;
    this._popupDirection = null;
    this._isOpen = null;
    
    this._toggleClickHandler=null
    this._optionsOpenHandler=null;
    this._optionsCloseHandler=null;
    this._hoverOverHandler = null;
    this._hoverOutHandler  = null;
    this._optionClickedHandler = null;
    this._documentClickedHandler = null;
    this._documentClickHandler = null;
    
    this._filterPanelID = null;
    this._dependentFilterId = null;
    this._dependentFilterChangedHandler = null

    this._targetPanelID = null;
    this._targetPanel = null;
    this._targetPanelClickHandler = null;
    
    this._okButtonId=null;
    this._okButton=null;
    this._okButtonClickHandler = null;
    
    
    this._cancelButtonId=null;
    this._cancelButton=null;
    this._cancelButtonHandler = null;
    
    this._SelectAllString="Select All";
    this._selectCheckedHandler = null
    
    this._inFilterCssClass="";
    this._notInFilterCssClass="";
    this._enableSelectAll=true;
    
    this._lookupTable =null;
    this._isLookupTableInitialized=false;
    
    // Added By Vanamali
    this._showTextBox = false;
    this._textBoxClass = "";
    this._imageHoverOverClass = "ajax__hoverOver_image";
    this._imageHoverOutClass = "ajax__hoverOut_image";
    
    
}
CustomExtender.GridViewFilterBehavior.prototype = {
initialize : function() {
    CustomExtender.GridViewFilterBehavior.callBaseMethod(this, 'initialize');
        this._isOpen = false;
        var element       = this.get_element();
        this._targetPanel = $get(this._targetPanelID);
        this._okButton    = $get(this._okButtonId);
        this._cancelButton = $get(this._cancelButtonId);
        
        //Create the Popup Behavior which will house the TargetPanel
        this._popupBehavior = $create(AjaxControlToolkit.PopupBehavior, 
                { 'id':this.get_id()+'PopupBehavior', 'parentElement':element, "positioningMode": this._popupDirection }, null, null, this._targetPanel);
        
        this._toggleClickHandler = Function.createDelegate(this,this._toggleVisibility);
        this._hoverOverHandler = Function.createDelegate(this,this._hoverOver);
        this._hoverOutHandler  = Function.createDelegate(this,this._hoverOut);
        this._documentClickHandler = Function.createDelegate(this,this._onDocClick);
        this._targetPanelClickHandler = Function.createDelegate(this,this._targetPreventClose);
                
        this._okButtonClickHandler= Function.createDelegate(this,this._okButtonClicked);
        this._cancelButtonHandler= Function.createDelegate(this,this._cancelButtonClicked);
        
        $addHandler( this._okButton , "click" , this._okButtonClickHandler );
        $addHandler( this._cancelButton , "click" , this._cancelButtonHandler );
        
        $addHandler( element , "click" , this._toggleClickHandler );
        $addHandler( element , "mouseover" , this._hoverOverHandler );
        $addHandler( element , "mouseout" , this._hoverOutHandler );
        
        //Remove all current classes
        element.className="";
        //element.src="javascript:void(0)";
        
        //Add the proper class
        Sys.UI.DomElement.toggleCssClass(element,this._imageHoverOutClass);
        
        //Hide the TargetPanel 
        this._targetPanel.style.display="none";
        
        //Create the Handler to get notified if the dependent filter changes
        this._dependentFilterChangedHandler = Function.createDelegate(this,this._dependentFilterChanged);
        //If the filter is dependent on another filter , then 
         if ( this._dependentFilterId.length >0 ) {
            //We need to subscribe to the DependentFilter's itemFiltered Event.
            //This is to rebuild the index , so that the filter does not show any data that was hidden
            //by a Filter Expression on a Dependent FilterExtender.
            this._hookDependentFilters( this );
          } else {
          //If the Extender has no dependent filters , then it should generate its lookup Table On initialize
          this._buildLookupTable(null);
          }
          
        },
        _hookDependentFilters : function(filterObject) {
            var _depFilterId = filterObject.get_dependentFilterId();
            var _depFilter = null;
            if( _depFilterId.length === 0 ) {return;}
            _depFilter = $find(_depFilterId); 
            if ( _depFilter === null ) {return;}
            _depFilter.add_itemFiltered(this._dependentFilterChangedHandler);
            
            //If the Filter one is dependent on is itself Dependent on another filter.
            //EX:  A    B   C are columns in a Grid
            //B is dependent on A , C is dependent on B , Hence indirectly , C is dependent on A.
            //If Extender A changes its filter Expression, then B & C need to update their Filter Choices too
            this._hookDependentFilters( _depFilter );
        },
     dispose : function() {
        CustomExtender.GridViewFilterBehavior.callBaseMethod(this, 'dispose');
        this._popupBehavior = null;
        this._popupDirection = null;
        this._isOpen = null;
        this._toggleClickHandler=null
        this._optionsOpenHandler=null;
        this._optionsCloseHandler=null;
        this._hoverOverHandler = null;
        this._hoverOutHandler  = null;
        this._optionClickedHandler = null;
        this._documentClickedHandler = null;
        this._documentClickHandler = null;
        this._filterPanelID = null;
        this._dependentFilterId = null;
        this._dependentFilterChangedHandler = null
        this._targetPanelID = null;
        this._targetPanel = null;
        this._targetPanelClickHandler = null;
        this._okButtonId=null;
        this._okButton=null;
        this._okButtonClickHandler = null;
        this._cancelButtonId=null;
        this._cancelButton=null;
        this._cancelButtonHandler = null;
        this._SelectAllString="Select All";
        this._selectCheckedHandler = null
        this._inFilterCssClass="";
        this._notInFilterCssClass="";
        this._enableSelectAll=true;
        this._lookupTable =null;
        this._isLookupTableInitialized=false;
            // Added By Vanamali
        this._showTextBox = false;
        this._textBoxClass = "";
        this._imageHoverOverClass = "";
        this._imageHoverOutClass = "";
        },
     
    //:: Getters and Setters :: 
    get_enableSelectAll : function() {
        /// <summary>
        ///  Returns if the Filter allows one to "Select All" elements
        /// </summary>
        /// <value type="Boolean">
        /// Whether or not SelectAll is Enabled.
        /// </value>
        return this._enableSelectAll;
    },
    set_enableSelectAll : function(value) {
       this._enableSelectAll= value;
    },
    get_showTextBox:function() {
        return this._showTextBox;
    },
    set_showTextBox:function(value) {
        this._showTextBox = value;
    },
    get_textBoxClass:function() {
        return this._textBoxClass;
    },
    set_textBoxClass:function(value) {
        this._textBoxClass = value;
    },
    get_textBoxClass:function() {
        return this._textBoxClass;
    },
    set_textBoxClass:function(value) {
        this._textBoxClass = value;
    },
    get_imageHoverOverClass:function() {
        return this._imageHoverOverClass;
    },
    set_imageHoverOverClass:function(value) {
        this._imageHoverOverClass = value;
    },
    get_imageHoverOutClass:function() {
        return this._imageHoverOutClass;
    },
    set_imageHoverOutClass:function(value) {
        this._imageHoverOutClass = value;
    },
    get_popupDirection:function() {
        return this._popupDirection;
    },
    set_popupDirection:function(value) {
        this._popupDirection = value;
    },
    get_filterText:function(){
        return this._filterText;
    },
    set_filterText:function(value){
        this._filterText= value;
    },
    get_toggleControlId : function() {
        return this._toggleControlId;
    },

    set_toggleControlId : function(value) {
        this._toggleControlId= value;
    },
    get_targetPanelID : function() {
        return this._targetPanelID;
    },
    get_filterPanelId : function() {
        return this._filterPanelID;
    },
    set_filterPanelId : function(value) {
        this._filterPanelID= value;
    },
    set_targetPanelID : function(value) {
        this._targetPanelID= value;
    },
    get_dependentFilterId : function(value) {
        return this._dependentFilterId;
    },
    set_dependentFilterId : function(value) {
        this._dependentFilterId= value;
    },
    get_notInFilterCssClass: function() {
        return this._okButtonId;
    },
    set_notInFilterCssClass: function(value) {
        this._notInFilterCssClass= value;
    },
    get_inFilterCssClass: function() {
        return this._okButtonId;
    },
    set_inFilterCssClass: function(value) {
        this._inFilterCssClass= value;
    },
    get_okButtonId : function() {
        return this._okButtonId;
    },
    set_okButtonId : function(value) {
        this._okButtonId = value;
    },
    get_cancelButtonId : function() {
        return this._cancelButtonId;
    },
    set_cancelButtonId : function(value) {
        this._cancelButtonId = value;
    },
    // :: Event Handling Functions :: 
    
    add_itemSelected:function(handler) {
        /// <summary>
        /// Add an event handler for the item Selected Event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().addHandler('itemSelected', handler);
    },
    remove_itemSelected:function(handler) {
        /// <summary>
        /// Removes an event handler for the item Selected Event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().removeHandler('itemSelected', handler);
    },
    raiseItemSelected:function(eventArgs) {
        var handler = this.get_events().getHandler('itemSelected');
        if (handler) {
            handler(this, eventArgs);
        }
    },
    add_itemFiltered:function(handler) {
        this.get_events().addHandler('ItemFiltered', handler);
    },
    remove_itemFiltered:function(handler) {
        this.get_events().removeHandler('ItemFiltered', handler);
    },
    raiseItemFiltered:function(eventArgs) {
        var handler = this.get_events().getHandler('ItemFiltered');
        if (handler) {
            handler(this, eventArgs);
        }
    },
    add_onOk:function(handler) {
        this.get_events().addHandler('onOk', handler);
    },
    remove_onOk:function(handler) {
        this.get_events().removeHandler('onOk', handler);
    },
    raiseOnOk:function(eventArgs) {
        var handler = this.get_events().getHandler('onOk');
        if (handler) {
            handler(this, eventArgs);
        }
    },
    add_onCancel:function(handler) {
        this.get_events().addHandler('onCancel', handler);
    },
    remove_onCancel:function(handler) {
        this.get_events().removeHandler('onCancel', handler);
    },
    raiseOnCancel:function(eventArgs) {
        var handler = this.get_events().getHandler('onCancel');
        if (handler) {
            handler(this, eventArgs);
        }
    },

    //:: Private Functions ::
    _toggleVisibility:function(evt) {
        /// <summary>
        ///  Display the element referenced by PopupControlID as a modal dialog
        /// </summary>
        ///<param name="evt" type="Sys.UI.DomEvent" domElement="false">
        ///  DOM Event that caused the Filter Popup to be displayed.
        ///</param>
        evt = evt === null ? window.event : evt;
        if ( this._isOpen === true )  {
         this._popupBehavior.hide(); 
         this._isOpen = false;
         this.get_element().className = "";
         this.get_element().className = this._imageHoverOutClass;
         }
        else {
            //Build the lookup table only if you the FilterPanel is going to be visible .
            this._buildLookupTable(evt);
            
            this._popupBehavior.show(); 
            this._isOpen = true;
            this.get_element().className = "";
            this.get_element().className = this._imageHoverOverClass;
        } 
        evt.preventDefault();
        evt.stopPropagation();
        return false;
    },
    _optionClicked:function(evt) {
       this.raiseItemSelected(new CustomExtender.ItemClickedEventArgs(evt.target,evt.target.nextSibling.nodeValue) );
       
    },
    _hoverOver:function(evt) {
        this.get_element().className = "";
        this.get_element().className = this._imageHoverOverClass;
    },
    _getText:function(option) {
        var _text = "";
        var _txtBoxNamer = "txt_"+this.get_element().id
        if ($get(_txtBoxNamer)!== null ){
            var _txtBox = $get(_txtBoxNamer);
            _text = "," + this._trim(_txtBox.value);
            if (_text===","){
                _text = "," + this._SelectAllString; //remove filter
            }
        }
        return _text;
      },
     _findSelected:function(option) {
        var _selectedOptions = new Sys.StringBuilder("");
        var _chkBoxNamer = "chk_"+this.get_element().id
        
        for( var _chkIndex=0; $get(_chkBoxNamer+_chkIndex)!== null ;_chkIndex++)  {
                var _chkBox = $get(_chkBoxNamer+_chkIndex);
                if( _chkBox.checked ) {
                    _selectedOptions.append(",")
                    _selectedOptions.append(_chkBox.nextSibling.nodeValue);
                }
            }
        return _selectedOptions.toString();
      },
     _hoverOut:function(evt) {
        if( this._isOpen !== true ) {
            this.get_element().className = "";
            this.get_element().className = this._imageHoverOutClass;
        }
     },
    _openOptions:function(evt) {
        
    },
    _closeOptions:function(evt) {
    },
    _onDocClick : function(evt) {
        if( this._isOpen === true && evt.target.id !== this._targetPanelID ) {
            this._popupBehavior.hide(); 
            this.get_element().className = this._imageHoverOutClass;
            this._isOpen = false; 
            }
    },
    _targetPreventClose:function(evt) {
        evt.preventDefault();
        evt.stopPropagation();
        return false;
    },
    HideOptions:function(evt) {
        if( this._isOpen === true ) {
        this._popupBehavior.hide(); 
        this.get_element().className = this._imageHoverOutClass;
        this._isOpen = false; 
       }
    },
    
     //When we Show All rows , it should be dependent on the actual rows that have already been filtered.
    //In English , For any filter that is dependent on another filter , the term "All Rows" would  
    //mean all rows that are shown as a result of a filter expression on the Filter it is dependent on.
    //If the Filter is not dependent on any other Filter , then "All Rows" means all rows in the Table.
    //EX: Grid has 2 Columns  A  B , and has about 10 rows of data
    // Scenario 1 : B depends on A 
        //User uses Filter A filters to some rows , there are 4 rows of data shown
        //No filter on B should show more rows than are allowed by the filter on A.
        //So if user Chooses "Select All" on B , then one should see 4 rows m not 10 .
    // Scenario 2 : B is not dependent on  A
        //After filtering on A ,
        //If user Chooses "Select All" on B , then one should see all the rows in the Grid , i.e 10 
   _showAllRows:function() {
        var _rowsToBeShown = this._lookupTable[this._SelectAllString].split(',');
        var _rowsInTable = this._getRowsInTable();
        for( _rowIndex=0;_rowIndex< _rowsToBeShown.length;_rowIndex++) {
             if( typeof(_rowsInTable.childNodes[_rowsToBeShown[_rowIndex]]) === 'undefined' ) 
                        continue;
             _rowsInTable.childNodes[_rowsToBeShown[_rowIndex]].className= this._isInFilterCssClass;
        } 
    },
    _getRowsInTable:function() {
       var _parentCell = this._findParentCell(this.get_element());
       var _rowsInTable  =  null;
       
       if( Sys.Browser.agent == Sys.Browser.Firefox ) {
            _rowsInTable = _parentCell.parentNode.parentNode;
       }
       else if( Sys.Browser.agent == Sys.Browser.InternetExplorer || Sys.Browser.agent == Sys.Browser.Opera ) {
            _rowsInTable = _parentCell.parentElement.parentElement;
       }
       return _rowsInTable;
    },
    _hideAllRows:function() {
        var _rowsInTable = this._getRowsInTable();
        for( _rowIndex=1;_rowIndex < _rowsInTable.childNodes.length;_rowIndex++) {
            _rowsInTable.childNodes[_rowIndex].className= this._notInFilterCssClass; 
        }  
    },
    _filterRows:function(evt) {
        var _currentRowFilter ="";
        if(this._showTextBox) {
            _currentRowFilter = this._getText(evt.target);
        }else{
             _currentRowFilter = this._findSelected(evt.target);
        }
        var _individualFilter = _currentRowFilter.split(',');
        // No Filter Selected
        if( _individualFilter.length == 1 ) return;
       
        //Hide all rows first
        this._hideAllRows();
        
        var _rowsInTable = this._getRowsInTable();
        if( _individualFilter[1] == this._SelectAllString) {
          this._showAllRows();  
          //Raise the ItemFiltered Event.
          //function(item, filterText,numRowsHidden,numRowsShown) 
          this.raiseItemFiltered( new CustomExtender.ItemFilteredEventArgs(this,_currentRowFilter,0,_rowsInTable.rows.length));
          return;
        }
        var _numRowsShown = 0;
        var alertText ="";
        //Show only the rows that match the filter.
        for( var _filterIndex=0;_filterIndex < _individualFilter.length;_filterIndex++) {
            var _rowsToBeShown =null;
            var index;
            for( var prop in this._lookupTable ) {
                var strCellValue = this._trim(prop.toLowerCase());
                var strFilter=this._trim(_individualFilter[_filterIndex].toLowerCase());
                var index = strCellValue.indexOf(strFilter);
                if( this._trim(prop.toLowerCase()) == this._trim(_individualFilter[_filterIndex].toLowerCase()) || (index >=0 && strFilter!="")) 
                {
                    _rowsToBeShown = this._lookupTable[prop].split(',');
                    break;
                }
            }

            if( _rowsToBeShown !== null) {
                for( _rowIndex=0;_rowIndex< _rowsToBeShown.length;_rowIndex++) {
                    if( typeof(_rowsInTable.rows[_rowsToBeShown[_rowIndex]]) === 'undefined' ) 
                        continue;
                    _rowsInTable.rows[_rowsToBeShown[_rowIndex]].className=this._inFilterCssClass
                    _numRowsShown++;
                } 
            }
        }
        //Raise the ItemFiltered Event.
        this.raiseItemFiltered( new CustomExtender.ItemFilteredEventArgs(this,_currentRowFilter,_rowsInTable.rows.length-_numRowsShown,_numRowsShown));
        
    },
    
    _okButtonClicked:function(evt) {
        this._filterRows(evt);
        this._toggleVisibility(evt);
        
        this.raiseOnOk(new Sys.CancelEventArgs());
        evt.preventDefault();
        evt.stopPropagation();
        
        return false;
    },
     _cancelButtonClicked:function(evt) {
        this._toggleVisibility(evt);
        this.raiseOnCancel(new Sys.CancelEventArgs());
        evt.preventDefault();
        evt.stopPropagation();
        return false;
    },
    _findParentCell:function(el) {
        var _parentCell=null;
        var _pointerToElement = el;
        while( typeof(_pointerToElement)  !== 'undefined' && _pointerToElement.tagName !=='TR') {
            if ( ( _pointerToElement.tagName === 'TH' )|| ( _pointerToElement.tagName === 'TD' ) ) {
                _parentCell = _pointerToElement;break;
            }
            if( Sys.Browser.agent == Sys.Browser.Firefox ) {
                _pointerToElement = _pointerToElement.parentNode
            }
            else if( Sys.Browser.agent == Sys.Browser.InternetExplorer || Sys.Browser.agent == Sys.Browser.Opera ) {
                _pointerToElement = _pointerToElement.parentElement  ;
                }
        }
        return _parentCell;
    },
    _trim:function(stringObj){
        return stringObj.replace(/^\s+|\s+$/g,"");
    },
    _selectAllClick:function(evt){
        var _toBeChecked = evt.target.checked;
        var _chkBoxNamer = "chk_"+this.get_element().id
        for( var _chkIndex=0; $get(_chkBoxNamer+_chkIndex)!== null ;_chkIndex++)  {
                var _chkBox = $get(_chkBoxNamer+_chkIndex);
                _chkBox.checked =_toBeChecked;
            }
    },
    //Writen by Vanamali
    _buildTextBox:function() {
        var _txtBoxNamer = "txt_"+this.get_element().id        
        var _filterPanel = $get(this._filterPanelID);
        
        var _tableElement = document.createElement("TABLE");
        var _tBodyElement = document.createElement("TBODY");
              
        if( _filterPanel.childNodes.length > 0 ) {
            _filterPanel.removeChild(_filterPanel.childNodes[0]);
        }
       
        var _trElement = document.createElement("TR");
        var _tdElement = document.createElement("TD");
        var _txtBox = document.createElement("INPUT");        

        _txtBox.type = "text";
        _txtBox.id = _txtBoxNamer;
        _txtBox.className  = this._textBoxClass;
        _tdElement.appendChild( _txtBox);
        _trElement.appendChild( _tdElement );
        _tBodyElement.appendChild(_trElement);
        _tableElement.appendChild(_tBodyElement);
        _filterPanel.appendChild(_tableElement);
    },
    _buildCheckBoxList:function() {
        
        var _chkBoxNamer = "chk_"+this.get_element().id
        var _chkIndex=0;
        this._optionClickedHandler = Function.createDelegate(this,this._optionClicked);
        var _filterPanel = $get(this._filterPanelID);
        
        if( _filterPanel.childNodes.length > 0 ) {
            _filterPanel.removeChild(_filterPanel.childNodes[0]);
        }

        var _tableElement = document.createElement("TABLE");
        var _tBodyElement = document.createElement("TBODY");
        
       
        if( this._enableSelectAll === true ) {
            this._selectCheckedHandler = Function.createDelegate(this,this._selectAllClick);
            var _trElement = document.createElement("TR");
            var _tdElement = document.createElement("TD");
            var _chkBox = document.createElement("INPUT");
            
            _chkBox.type="checkbox";
            _chkBox.id = _chkBoxNamer +_chkIndex++;   
            
            var _txtEl = document.createTextNode(this._SelectAllString);
                _tdElement.appendChild( _chkBox);
                _tdElement.appendChild( _txtEl );
                _trElement.appendChild( _tdElement );
                _tBodyElement.appendChild(_trElement);
                _tableElement.appendChild(_tBodyElement);
                
                $addHandler( _chkBox ,"click",this._selectCheckedHandler);
                $addHandler( _chkBox ,"click",this._optionClickedHandler);
                }
        
        for( var prop in this._lookupTable ) {
            if( prop === this._SelectAllString ) continue;
                 //TR
                var _trElement = document.createElement("TR");
                //TD
                var _tdElement = document.createElement("TD");
                //Check Box 
                var _chkBox = document.createElement("INPUT");
                _chkBox.type="checkbox";
                _chkBox.id = _chkBoxNamer +_chkIndex++;
                // Text Element
                var _txtEl = document.createTextNode(prop);
                _tdElement.appendChild( _chkBox );
                _tdElement.appendChild( _txtEl );
                _trElement.appendChild( _tdElement );
                _tBodyElement.appendChild(_trElement);
                _tableElement.appendChild(_tBodyElement);
                $addHandler( _chkBox ,"click",this._optionClickedHandler);
            }
           _filterPanel.appendChild(_tableElement);
            
     },
     _dependentFilterChanged : function(sender,eventArgs) {
        this._isLookupTableInitialized = false;
      },
     //When we build the lookup table 
     //
    _buildLookupTable:function(evt) {
        try { 
         if( this._isLookupTableInitialized === true ) return;
         //find out which Column the Extender is added.
        //Find the Cell Index: Walk back up the tree from the element until  you find a TH or a TD
        var _cellIndex =-1;
        var _rows = null;
        _cellIndex = this._findParentCell(this.get_element()).cellIndex;
        _rows = this._getRowsInTable();
        //Loop through all the Rows under the current , for the same column
        this._lookupTable = new Object();
        //for ( var _rowIndex=1;_rowIndex<_rows.childNodes.length && _rows.childNodes[_rowIndex].tagName !== 'TFOOT';_rowIndex++ ) {
        for ( var _rowIndex=1;_rowIndex<_rows.rows.length ;_rowIndex++ ) {
                if( this._dependentFilterId !== null ) {
                    if(_rows.childNodes[_rowIndex].className === this._notInFilterCssClass) continue;
                }
                var _cellText = "";
                
                switch(Sys.Browser.agent) {
                    case Sys.Browser.InternetExplorer: _cellText = _rows.rows[_rowIndex].cells[_cellIndex].innerText; break;
                    case Sys.Browser.Firefox: _cellText = _rows.rows[_rowIndex].cells[_cellIndex].textContent; break;
                    case Sys.Browser.Opera:_cellText = _rows.rows[_rowIndex].cells[_cellIndex].text; break;
                    default : alert("Please use IE or FF");break;
                }
                _cellText = this._trim( _cellText );
                
                //Will run only for the first Time        
                if( typeof(this._lookupTable[this._SelectAllString]) === 'undefined') {
                    this._lookupTable[this._SelectAllString] = _rowIndex 
                } else {
                    this._lookupTable[this._SelectAllString] += ","+_rowIndex 
                }
                
                if( typeof(this._lookupTable[_cellText]) === 'undefined') {
                    this._lookupTable[_cellText] = _rowIndex +",";     
                } else {
                    this._lookupTable[_cellText] += _rowIndex +","; 
                }   
                this._lookupTable[this._SelectAllString]
          }  
          if(this._showTextBox) {
              this._buildTextBox();
          }else{
               this._buildCheckBoxList();
          }
          this._isLookupTableInitialized = true;
       }
     catch(err) {
//          Sys.Debug.fail("Found Something");
//          Sys.Debug.trace(" Error in buildLookup Table");
        }
     }
    
}
CustomExtender.GridViewFilterBehavior.registerClass('CustomExtender.GridViewFilterBehavior', AjaxControlToolkit.BehaviorBase);
CustomExtender.ItemClickedEventArgs = function(item, text) {
    CustomExtender.ItemClickedEventArgs.initializeBase(this);
    
    this._item = item;
    this._text = text;
    this._isChecked = item.checked;
    
}
CustomExtender.ItemClickedEventArgs.prototype = {
    get_item : function() {
        /// <value type="Sys.UI.DomElement" DomElement="true" mayBeNull="true">
        /// Item
        /// </value>
        return this._item;
    },
    set_item : function(value) {
        this._item = value;
    },
    
     get_isChecked : function() {
        /// <value type="Sys.UI.DomElement" DomElement="true" mayBeNull="true">
        /// Item
        /// </value>
        return this._isChecked;
    },
    set_isChecked : function(value) {
        this._isChecked = value;
    },
    
    get_text : function() {
        /// <value type="String" maybeNull="true">
        /// Text of the item
        /// </value>
        return this._text;
    },
    set_text : function(value) {
        this._text = value;
    }
}
CustomExtender.ItemClickedEventArgs.registerClass('CustomExtender.ItemClickedEventArgs', Sys.EventArgs);

CustomExtender.ItemFilteredEventArgs = function(item, filterText,numRowsHidden,numRowsShown) {
    CustomExtender.ItemFilteredEventArgs.initializeBase(this);
    
    this._item = item;
    this._filterText = filterText;
    this._rowsShown= numRowsShown;
    this._rowsHidden= numRowsHidden;
    
}
  CustomExtender.ItemFilteredEventArgs.prototype = {
    get_rowsShown : function() {
        return this._rowsShown;
    },
    set_rowsShown : function(value) {
        this._rowsShown = value
    },
    get_rowsHidden : function() {
        return this._rowsHidden;
    },
    set_rowsHidden : function(value) {
        this._rowsHidden = value
    },
    get_filterText : function() {
        /// <value type="Sys.UI.DomElement" DomElement="true" mayBeNull="true">
        /// Item
        /// </value>
        return this._filterText;
    },
    set_filterText: function(value) {
        this._filterText = value;
    },
    get_item : function() {
        /// <value type="String" maybeNull="true">
        /// Text of the item
        /// </value>
        return this._item;
    },
    set_item : function(value) {
        this._item = value;
    }
}
CustomExtender.ItemFilteredEventArgs.registerClass('CustomExtender.ItemFilteredEventArgs', Sys.EventArgs);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();