Type.registerNamespace("Friends.ManageGridItem");
Friends.ManageGridItem = function(element) {
    Friends.ManageGridItem.initializeBase(this, [element]); 
    this.itemId=null;
    this.isInSList=false;
    this.clickFired=false;
    this._hoverFired=false;    
    this._statusEl=null;
    this._nameEl=null,
    this._picEl=null;
    this._fadeDelegate=null;
    this._timerH=null;
}

Friends.ManageGridItem.prototype = {    
    initialize : function() {        
        Friends.ManageGridItem.callBaseMethod(this, 'initialize');
        
        if(this.get_statusEl()){
            this.isInSList = Sys.UI.DomElement.containsCssClass(this._statusEl, 'actionExists');
        }
        $addHandlers(this._element, {click: this.raise_itemClicked, mouseover:this._onHover, mouseout:this._onBlur}, this);
        this._fadeDelegate = Function.createDelegate(this, this.fadeProgressAndClose);
    },
    
    dispose : function() {
        $clearHandlers(this._element);
        Friends.ManageGridItem.callBaseMethod(this, 'dispose');
    },
   
    _onHover : function(evt) {
        if(!this._hoverFired && !this.clickFired){
            this._hoverFired = true;
            var hoverH = this.get_events().getHandler('itemHover');
            hoverH && hoverH(this, evt);
        }
    },
    
    _onBlur : function(evt) {
       if(this._hoverFired && !this.clickFired){
            this._hoverFired = false;
            var blurH = this.get_events().getHandler('itemBlur');
            blurH && blurH(this, evt);
        }
    },
    
    get_statusEl : function() {
        if(!this._statusEl){
            this._statusEl = getElementsByClassName(this._element, 'div', 'actionbar')[0];
        }
        return this._statusEl;
    },
    
    get_nameEl : function() {
        if(!this._nameEl){
            this._nameEl = getElementsByClassName(this._element, 'span', 'friendname')[0];
        }
        return this._nameEl;
    },
    
    get_picEl : function() {
        if(!this._picEl){
            this._picEl = getElementsByClassName(this._element, 'img', 'mGridItemImg')[0];
        }
        return this._picEl;
    },
    
    _showErr : function() {
		Sys.UI.DomElement.removeCssClass(this.get_statusEl(), "actionWait");
		Sys.UI.DomElement.addCssClass(this.get_statusEl(), "actionErr");
		 _proxy_jslib_assign('', this.get_statusEl(), 'innerHTML', '=', ( MySpaceRes.ViewAllFriendsPage.Error));
	},
		
	fadeProgressAndClose : function(isAdd) {
	    // TODO - try using the MySpace.UI.Effects.FadeAnimation
	    this._timerH && clearTimeout(this._timerH);
		if(this.get_statusEl()){
			Sys.UI.DomElement.removeCssClass(this.get_statusEl(), "actionWait");
			Sys.UI.DomElement.removeCssClass(this.get_statusEl(), "actionExists");			
			if (! this.get_statusEl().opacity){this.get_statusEl().opacity = 100;}
			
			this.get_statusEl().opacity -= 4;
			
			if (this.get_statusEl().isAlpha || this.get_statusEl().filters){
				this.get_statusEl().isAlpha = true;
				this.get_statusEl().style.filter = 'alpha(opacity='+ this.get_statusEl().opacity +')';
			}
			else{
				this.get_statusEl().style.opacity = (this.get_statusEl().opacity/100);
			}
			
			if(this.get_statusEl().opacity > 0){
			    var that = this; 
				this._timerH =  _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0)((function() { 				            
				            return function() {
				                    that.fadeProgressAndClose.call(that, isAdd)

 }
				             })() ,40);
			}			
			else{
			     _proxy_jslib_assign('', this.get_statusEl(), 'innerHTML', '=', ( ""));						
				if(this._element){
					if (isAdd){
					    this.get_statusEl().className = "actionbar actionExists";						
						this._element.className="friendsbox friendsboxinlist";						
					}
					else{
						this.get_statusEl().className = "actionbar actionNotExists";													    
						this._element.className="friendsbox";						
					}					
				}
				
				this.get_statusEl().opacity = 100;
				if(this.get_statusEl().filters){				
					this.get_statusEl().style.filter = '';			
				}
				else{
					this.get_statusEl().style.opacity = 1;
				}				
			}
		}
	},
   
    //grid item click event
    add_itemClicked : function(handler) {
        this.get_events().addHandler('itemClicked', handler);
    },    
    remove_itemClicked : function(handler) {
        this.get_events().removeHandler('itemClicked', handler);
    },    
    raise_itemClicked : function(evt) {
        if(!this.clickFired){
            var clickH = this.get_events().getHandler('itemClicked');
            clickH && clickH(this, evt);
        }
    },
    
    add_itemHover : function(handler) {
        this.get_events().addHandler('itemHover', handler);
    },    
    remove_itemHover : function(handler) {
        this.get_events().removeHandler('itemHover', handler);
    },    
    
    add_itemBlur : function(handler) {
        this.get_events().addHandler('itemBlur', handler);
    },    
    remove_itemBlur : function(handler) {
        this.get_events().removeHandler('itemBlur', handler);
    }
}
Friends.ManageGridItem.registerClass('Friends.ManageGridItem', Sys.UI.Control);

Type.registerNamespace("Friends.ManageGrid");
Friends.ManageGrid = function(element) {
    Friends.ManageGrid.initializeBase(this, [element]);
    this.baseImgUrl;    
}

Friends.ManageGrid.prototype = {
    _manageItems:{},
    _mGridItemsCount:0,
    _activeWSIDs:[],
    _iScroller:null,
    _loadingCircles:"<img src='{0}/loadercircles.gif'/>",
    _addActMsg:null,
    _removeActMsg:null,
    initialize : function() {        
        Friends.ManageGrid.callBaseMethod(this, 'initialize');
        
	this._buildManageGrid();
    },
    
    dispose : function() {        
        Friends.ManageGrid.callBaseMethod(this, 'dispose');
    },
    
    registerIScroller : function(iScroller) {
	    this._iScroller = iScroller;
	},
    
	_buildManageGrid : function() {
        var friends = getElementsByClassName(this._element, "div", "friendsbox");
        var mItemId;
        if(friends){
            for(var i=0;i<friends.length;i++){
                mItemId =  _proxy_jslib_handle(friends, (i), 0, 0).id.split('_')[1];
                 _proxy_jslib_assign('', this._manageItems, (mItemId), '=', ( $create(Friends.ManageGridItem, {'itemId': mItemId},{itemClicked: Function.createDelegate(this, this._onManageItemClicked), itemHover:Function.createDelegate(this,this._showAction),itemBlur:Function.createDelegate(this,this._hideAction)}, null,  _proxy_jslib_handle(friends, (i), 0, 0))));
            }
            this._mGridItemsCount = friends.length;
        }
	},
	
	_clearManageGrid : function() {
	    if(this._manageItems){
	        for(var item in this._manageItems){	            
	             _proxy_jslib_handle(this._manageItems, (item), 0, 0).dispose();
	             _proxy_jslib_assign('delete', (this._manageItems), (item), '');
	             _proxy_jslib_assign('delete', (this._manageItems), ('item'), '');
	        }
	        this._mGridItemsCount = 0;	        
	    }
	},
	
	_getItemCount : function(inSList) {
	    var itemsInSList = 0;
	    var itemsNotInSList = 0;
	    if(this._manageItems){
	        for(var item in this._manageItems){	            
	             _proxy_jslib_handle(this._manageItems, (item), 0, 0).isInSList ? itemsInSList++ : itemsNotInSList++;
	        }
	    }
	    return (inSList ? itemsInSList : itemsNotInSList);
	},
	
	_showAction : function(src, evt) {
	    if(this._canAddMore === undefined || this._canAddMore > 0){
	        var mItemEl =  _proxy_jslib_handle(null, 'src', src, 0, 0).get_element()
		    var mItemStatusEl =  _proxy_jslib_handle(null, 'src', src, 0, 0).get_statusEl();
		    if(mItemEl && mItemStatusEl){			
		        if ( _proxy_jslib_handle(null, 'src', src, 0, 0).isInSList){
                    mItemStatusEl.className="actionbar actionRemove";
			        mItemEl.className="friendsbox friendsboxremove";
			        mItemEl.title = this._removeActMsg;
		        }
		        else{
		            mItemStatusEl.className="actionbar actionAdd";
			        mItemEl.className="friendsbox friendsboxadd";
			        mItemEl.title = this._addActMsg;
		        }
		    }
		}
	},
	
	_hideAction : function(src, evt) {
	    if(this._canAddMore === undefined || this._canAddMore > 0){		
		    var mItemEl =  _proxy_jslib_handle(null, 'src', src, 0, 0).get_element()
		    var mItemStatusEl =  _proxy_jslib_handle(null, 'src', src, 0, 0).get_statusEl();
		    mItemEl.title = "";
		    if(mItemEl && mItemStatusEl){			
		        if ( _proxy_jslib_handle(null, 'src', src, 0, 0).isInSList){
		    	    mItemStatusEl.className="actionbar actionExists";
				    mItemEl.className="friendsbox friendsboxinlist";		    
			    }
		        else{
		            mItemStatusEl.className="actionbar actionNotExists";
			        mItemEl.className="friendsbox ";			        
		        }
		    }
		}
	},
	
	_onManageItemClicked : function(src, evt) {
		if(this._canAddMore === undefined || this._canAddMore > 0){
		    //proceed only if friendid is not exists in the WS active list		
		    var friendid =  _proxy_jslib_handle(null, 'src', src, 0, 0).itemId;
		    if(Array.indexOf(this._activeWSIDs,friendid,0)<0){
			    Array.add(this._activeWSIDs, friendid);
			     _proxy_jslib_handle(null, 'src', src, 0, 0).clickFired = true;			
			     _proxy_jslib_handle(null, 'src', src, 0, 0).get_statusEl().className = "actionbar actionWait";	
			    if ( _proxy_jslib_handle(null, 'src', src, 0, 0).isInSList){
			        this._callRemoveFriend([friendid]);											
			    }
			    else{
			        this._callAddFriend([friendid]);				
			    }
		    }
		}
	},
			
	_callAddFriend : function(friendIds) {		
		return false;
	},	
	
	_callRemoveFriend : function(friendIds) {
		return false;
	},

	_onManageItemSucceeded : function(result, userContext, methodName) {
	    var mItemIds = userContext.fIds;
	    var manageGrid = userContext.manageo; 
		for(var i=0;i<mItemIds.length;i++){
			Array.remove(manageGrid._activeWSIDs,  _proxy_jslib_handle(mItemIds, (i), 0, 0));
		}
		if(!result.ErrMsg){						
			// result contains the friendIds for which add operation failed.
			manageGrid._manageItemAction(mItemIds, result.FailedIds, userContext.isAdd);
			manageGrid._showSaved();
		}
		else{
			manageGrid._checkErrCode(result.ErrCode);			
			manageGrid._manageItemAction(mItemIds, mItemIds, userContext.isAdd);	
		}
	},	
	
	_onManageGridWSFailed : function(error, userContext, methodName) {
	    var manageGrid = userContext.manageo;
		if(error && error.ErrMsg && error.ErrMsg.length > 0 ) 
		{
			manageGrid._checkErrCode(error.ErrCode);
			// Hide the AJAX loading image
			if(manageGrid._element.className.indexOf("memberitemloader") >= 0){
				manageGrid._element.className="memberspanel";
				 _proxy_jslib_assign('', manageGrid._element, 'innerHTML', '=', ( ""));				
			}
			 _proxy_jslib_assign('', manageGrid._element, 'innerHTML', '=', ( error.ErrMsg));	        
		}
	},
	
	_checkErrCode : function(eCode) {
		// Authentication failed.
		if(eCode && eCode == -1){
			 _proxy_jslib_handle(null, 'location', location, 0, 0).reload(true);
		}
	},

    _manageItemAction : function(friendIds, failedIds, addAction) { 
	    var mItem;
	    var actionbar;
	    var friendId;
	    
	    for(var i=0;i<friendIds.length;i++){
			
			friendId =  _proxy_jslib_handle(friendIds, (i), 0, 0);
			this._quickFind &&	this._quickFind.UpdateMemberShipStatus(friendId, addAction);			
				
			mItem =  _proxy_jslib_handle(this._manageItems, (friendId), 0, 0);
			if(mItem){
			    actionbar= mItem.get_statusEl();
			    mItem.clickFired = false;								
    			
			    // Friends that were failed during Add operation.
			    if(failedIds && failedIds.length > 0 && Array.indexOf(failedIds,friendId,0)>=0){
				    mItem._showErr();
				    mItem.fadeProgressAndClose(false);
			    }
			    else{
			        if(addAction){		    
			            this._iScroller && this._iScroller.addFriendToSList(friendId,  _proxy_jslib_handle(mItem.get_nameEl(), 'innerHTML', '', 0, 0),  _proxy_jslib_handle(mItem.get_picEl(), 'src', '', 0, 0));
				         _proxy_jslib_assign('', actionbar, 'innerHTML', '=', ( MySpaceRes.ViewAllFriendsPage.Added));
				    }
				    else{
				        this._iScroller && this._iScroller.removeFriendFromList([friendId], failedIds);
				         _proxy_jslib_assign('', actionbar, 'innerHTML', '=', (MySpaceRes.ViewAllFriendsPage.Removed));	
				    }
				    mItem.isInSList = addAction;
				    mItem.fadeProgressAndClose(addAction);		    
			    }
			}
			else{
			    // for items which are not in the Grid but in the IScroll List.
			    addAction || (this._iScroller && this._iScroller.removeFriendFromList([friendId], failedIds));
			}
		}
	}	
}
Friends.ManageGrid.registerClass('Friends.ManageGrid', Sys.UI.Control);

Type.registerNamespace("Friends.ManageGridForEdit");
Friends.ManageGridForEdit = function(element) {
    Friends.ManageGridForEdit.initializeBase(this, [element]);    
    // Paging info
	this.pageNum;
	this.firstId;
	this.lastId;
	//Quick Find info
	this.isQFEnabled=false;
	this.isQFCached="false";
	this.totalFCount=0;
	this.requesterId=null;
			
	this.thName;	
}

Friends.ManageGridForEdit.prototype = {
    _catDropDown:null,
    _currDDIndex:0,
    _alphaPagerBar:null,
    _showQuickFind:false,
    _quickFind:null,
    _query:null,
    _newQuery:null,
    _newQueryTx:null,
    _mPagers:null,
    _addAllBarEl:null,
    _addAllOnPage:null,
    _addAllOnPageConfirmMsg:null,
    _savedShown:false,
    _savedShownImg:null,
    _savedShownTxt:null,
    initialize : function() {        
        Friends.ManageGridForEdit.callBaseMethod(this, 'initialize');
        this._query = "All Friends";
        this._setDropDown();
        
        var managePanel = $get("rightpanel");
		this._setAlphaBar(managePanel);
		this._setAddAllOnPage(managePanel);						
    },
    
    dispose : function() {
        $clearHandlers(this._catDropDown);        
        this._addAllOnPage && $clearHandlers(this._addAllOnPage);
        Friends.ManageGridForEdit.callBaseMethod(this, 'dispose');
    },
    
    _buildManageGrid : function() {
        Friends.ManageGridForEdit.callBaseMethod(this, '_buildManageGrid');
        this._updateAddAllBarVisibility();
    },
    
    // Attaches the event handler for friends filter drop down
	_setDropDown : function() {
		this._catDropDown = $get("myfriends_display").childNodes[1];		
		$addHandler(this._catDropDown, 'change', Function.createDelegate(this,this._catDropDownChanged));		
	},
	
	// Initializes the client object for Alphabar
	_setAlphaBar : function(managePanel) {	    	    
	    this._alphaPagerBar = new (FriendsCategories.AlphaBar)();
	    if(this._alphaPagerBar){	    
		    this._alphaPagerBar.Initialize(managePanel);    		
		    //Hookup Alphabar events 
	        if($get("nav_top")){
		          this._alphaPagerBar.AddAlphaLinkClicked(Function.createDelegate(this, this._alphaClicked));
		    }    		
		    //Hookup Pager events
		    if($get("nav_bottom")){
			    this._alphaPagerBar.AddPagerLinkClicked(Function.createDelegate(this,this._pageNumClicked));
		    }
		    this._mPagers = getElementsByClassName(managePanel, "span", "pager_container");
		}
	},
	
	// Hook up events to add all button click
	_setAddAllOnPage : function(managePanel) {
	    this._addAllBarEl = getElementsByClassName(managePanel, "div", "mGridAddAll")[0];
	    if(this._addAllBarEl){
	        this._addAllOnPage = getElementsByClassName(this._addAllBarEl, "button", "addAllBarBtn")[0];
	        this._addAllOnPage && $addHandler(this._addAllOnPage, 'click', Function.createDelegate(this,this._addAllOnPageClicked));
	        this._updateAddAllBarVisibility();
	    }
	},
	
	_updateAddAllBarVisibility : function() {	    
	    if(this._addAllBarEl){
	        this._addAllBarEl.style.visibility = this._mGridItemsCount ? "visible" : "hidden";
	    }
	},
	
	// Event handler for Category Dropdown change event
	_catDropDownChanged : function(evt) {
		if( _proxy_jslib_handle(evt.target, 'value', '', 0, 0) == "noop"){
			evt.target.selectedIndex = this._currDDIndex;			
		}
		else{			
			this._currDDIndex = evt.target.selectedIndex;
			var selectedOption =  _proxy_jslib_handle(evt.target.options, (evt.target.selectedIndex), 0, 0);
			this._alphaClicked(evt.target, selectedOption);
			this._alphaPagerBar.UpdateAlphaTitle( _proxy_jslib_handle(selectedOption, 'innerHTML', '', 0, 0));						
		}
		evt.preventDefault();
	},
	
	_alphaClicked : function(sender, e) {
	    if(e){
		    if(  _proxy_jslib_handle(e, 'href', '', 0, 0) &&  _proxy_jslib_handle(e, 'href', '', 0, 0).indexOf("(") != -1){
		        this._newQuery =  _proxy_jslib_handle(e, 'innerHTML', '', 0, 0);
		    }
		    else{
	            this._newQuery = "All";
	        }
	        this._newQueryTx =  _proxy_jslib_handle(e, 'innerHTML', '', 0, 0);	    
	    }  
		this._showLoading();
		this._showQuickFind = false;
		this._quickFind && this._quickFind.ClearInput();
			
		return false;
	},
	
	// Event handler for the pager link click event
	_pageNumClicked : function(sender, e) {
	    // calculate jump	    
	    var start = e.indexOf("(") + 1;
	    var end = e.indexOf(")");
	    sender.jump = e.substr(start, end - start) - this.pageNum;
	    
	    /*if(manageFriends._historyObj)
	    {
			manageFriends._historyObj.addHistory("P",manageFriends._rightPanelCatId, manageFriends._query, manageFriends._pageNum, jump, manageFriends._firstId, manageFriends._lastId,manageFriends._currDDIndex, manageFriends._currDDHtml,manageFriends._newQuery, manageFriends._newQueryTx );	    
		}*/

		this._showQuickFind = false;
		this._showLoading();		
		return false;
	},
	
	// Event handler for the Add all button click
	_addAllOnPageClicked : function(evt) {	    
	    if(!Sys.UI.DomElement.containsCssClass(this._addAllOnPage, "submitBtnOff")){
	        if(confirm(this._addAllOnPageConfirmMsg)){
                var fIda = new (Array)();            
                for(var item in this._manageItems){
                    if(! _proxy_jslib_handle(this._manageItems, (item), 0, 0).isInSList){
                        Array.add(fIda,  _proxy_jslib_handle(this._manageItems, (item), 0, 0).itemId);
                    }
                }
	            if(fIda.length > 0){
	                this._callAddFriend(fIda);
	            }
	        }
	    }
	    evt.preventDefault();	
	},
	
	_onQuickFindInput : function(inputString) {
		this._showQuickFind = true;
		
		if(inputString === ""){	
			this._showQuickFind = false;
			if(!this._newQuery){
			    this._newQuery = "All" ;
			}			
			this._alphaClicked();			
		}
		else if(inputString.length == 1){			
			//Reset the display box
			this._currDDIndex = this._catDropDown.selectedIndex = 0;				
			
			//Highlight the Alpha Char
			this._alphaPagerBar.UpdateAlpha(inputString.toUpperCase());
			this._alphaPagerBar.UpdateAlphaTitle( _proxy_jslib_handle( _proxy_jslib_handle(this._catDropDown, (this._currDDIndex), 0, 0), 'innerHTML', '', 0, 0));						
		}
		this._showLoading();
	},
	
	_onQuickFindDataReceived : function(membersHtml, pagerHtml, friendList) {	    
		// insert pager		    		    
		this._alphaPagerBar.ClearPager();
		for(var i=0;i<this._mPagers.length;i++){					
			 _proxy_jslib_assign('',  _proxy_jslib_handle(this._mPagers, (i), 0, 0), 'innerHTML', '=', ( pagerHtml));									
		}					
		this._alphaPagerBar.ShowPager(this._mPagers);
		this._onCatFriendsGridReceived(membersHtml);	    
	},	

	
	_showLoading: function() {
	    this._clearManageGrid();		
		var height = this._element.offsetHeight;		
		this._element.style.height = height + "px";
		this._element.className="memberitemloader";
	     _proxy_jslib_assign('', this._element, 'innerHTML', '=', ( String.format(this._loadingCircles,this.baseImgUrl) + " " + MySpaceRes.ViewAllFriendsPage.LoadingData));
	},
		
	_onPageFriendsGridReceived : function(result, userContext, methodName) {
		//Race conditions check
		if (userContext._showQuickFind) return;
		
		// Update the pager.
		if((methodName && methodName.indexOf("PagingFriends") > 0) || !result.ErrMsg){
			if (result.PagerHtml && result.PagerHtml.length > 0){
				// insert pager		    		    
				userContext._alphaPagerBar.ClearPager();
				for(var i=0;i<userContext._mPagers.length;i++){					
					 _proxy_jslib_assign('',  _proxy_jslib_handle(userContext._mPagers, (i), 0, 0), 'innerHTML', '=', ( result.PagerHtml));					
					userContext._alphaPagerBar.ResetPager( _proxy_jslib_handle(userContext._mPagers, (i), 0, 0));
				}
			}
			else{
				//Hide pager
				userContext._alphaPagerBar.HidePager(userContext._mPagers);
			}						
		}
		if(!result.ErrMsg){
			userContext._element.className="memberspanel";
			if (methodName && methodName.indexOf("AlphaFriends") > 0 ){			    
				userContext._alphaPagerBar.UpdateAlpha(userContext._newQueryTx);
				userContext._query = userContext._newQuery;
			}		   
		   	userContext._pageNum = result.PageNum;
			userContext._firstId = result.FirstID;
			userContext._lastId = result.LastID;					
			userContext._onCatFriendsGridReceived(result.FriendsGridHtml);
	    }
	    else{
		    userContext._alphaPagerBar.UpdateAlpha(userContext._newQueryTx);    
			// Hiding the Add all friends button
			$get("edit_catnav").style.visibility = "hidden";
			userContext._onManageGridWSFailed(result, userContext, methodName);
	    }
	},
	
	_onCatFriendsGridReceived : function(mGridHtml) {	    
	    this._element.style.height ="";	
	    this._element.style.minHeight ="335px";	    	  
	     _proxy_jslib_assign('', this._element, 'innerHTML', '=', ( mGridHtml));
	    this._buildManageGrid();
	},
	
	_onBatchActionSucceeded : function(result, userContext, methodName) {
		if(!result.ErrMsg){
			 _proxy_jslib_handle(null, 'location', location, 0, 0).reload(true);
		}
		else{
			userContext._onManageGridWSFailed(result, userContext, methodName);
		}
	},

	// Message Bar update
	_showSaved : function() {
		if(!this._savedShown && (this._canAddMore === undefined || this._canAddMore > 0)){
			this._savedShownImg && (this._savedShownImg.style.visibility = "visible");
			this._savedShownTxt && ( _proxy_jslib_assign('', this._savedShownTxt, 'innerHTML', '=', ( MySpaceRes.ViewAllFriendsPage.AddMembersSaved)));
			this._savedShown = true;		
			 _proxy_jslib_handle(null, 'setTimeout', setTimeout, 1, 0) ( Function.createDelegate(this, this._showSaveInstructions), 4000 );
		}
	},
	
	_showSaveInstructions : function() {
	    this._savedShownImg && (this._savedShownImg.style.visibility = "hidden");
	    this._savedShownTxt && ( _proxy_jslib_assign('', this._savedShownTxt, 'innerHTML', '=', ( MySpaceRes.ViewAllFriendsPage.ClickToAddRemove)));
	    this._savedShown = false;		
	},
	
	_callAddFriend : function(friendIds) {		
		return false;
	},	
	
	_callRemoveFriend : function(friendIds) {
		return false;
	}
}
Friends.ManageGridForEdit.registerClass('Friends.ManageGridForEdit', Friends.ManageGrid);


Friends.ManageGridForCatEdit = function(element) {
    Friends.ManageGridForCatEdit.initializeBase(this, [element]);
    this.sListCatId=null;    
	this.catName = null;
	this.catDesc = null;
	this.catPriv = null;    
}
Friends.ManageGridForCatEdit.prototype = {
    initialize : function() {        
        Friends.ManageGridForCatEdit.callBaseMethod(this, 'initialize');
        this._addActMsg = MySpaceRes.ViewAllFriendsPage.AddToCategory;
        this._removeActMsg = MySpaceRes.ViewAllFriendsPage.RemoveFromCategory;
        this._addAllOnPageConfirmMsg = MySpaceRes.ViewAllFriendsPage.AddAllConfirm;
        
        if(this.isQFEnabled){
            this._quickFind = new (FriendsCategories.AddMembersFind)(this.totalFCount, this.requesterId, Function.createDelegate(this, this._onQuickFindInput), Function.createDelegate(this, this._onQuickFindDataReceived), this.isQFCached, this.sListCatId);
        }
        this._setEditCatLinks();
    },
    
    dispose : function() {
        Friends.ManageGridForCatEdit.callBaseMethod(this, 'dispose');
	},
	
	_setAddAllOnPage : function(managePanel) {
	    Friends.ManageGridForCatEdit.callBaseMethod(this, '_setAddAllOnPage', [managePanel]);
	    if(this._addAllBarEl){
	        this._savedShownImg = getElementsByClassName(this._addAllBarEl, "img" , "frndSavedCheck")[0];
	        this._savedShownTxt = getElementsByClassName(this._addAllBarEl, "span" , "frndSavedTxt")[0];
	    }
	},
	
	_setEditCatLinks : function() {	
		//wrapping the category title				
		this._updateCatName(null, {cName:this._catName});
		var headerRLinks = getElementsByClassName( _proxy_jslib_handle(document, 'body', '', 0, 0), "a", "BreadcrumbLinkTopRight");
		if(headerRLinks && headerRLinks.length > 1){
		    var editCato = new (FriendsCategories.EditCat)();		
		    editCato.init(headerRLinks[2], this.sListCatId, this.catName, this.catDesc, this.catPriv);
		    editCato.addEditCatClicked(Function.createDelegate(this,this._updateCatName));
		}
	},
	
	_callAddFriend : function(friendIds) {
		//Call webservice
		MySpace.Web.Modules.Friends.Services.FriendsService.AddFriendToCategory(this.sListCatId,friendIds,this._onManageItemSucceeded, this._onManageGridWSFailed, {manageo:this, fIds:friendIds, isAdd:true});
		return false;
	},	
	
	_callRemoveFriend : function(friendIds) {
		//Call webservice
		MySpace.Web.Modules.Friends.Services.FriendsService.RemoveFriendFromCategory(this.sListCatId,friendIds,this._onManageItemSucceeded, this._onManageGridWSFailed, {manageo:this, fIds:friendIds, isAdd:false});
		return false;
	},
	
	_showSaveInstructions : function() {
	    Friends.ManageGridForCatEdit.callBaseMethod(this, '_showSaveInstructions');
	    this._savedShownTxt && ( _proxy_jslib_assign('', this._savedShownTxt, 'innerHTML', '=', ( MySpaceRes.ViewAllFriendsPage.ClickToAddRemove)));
	},
	
	_alphaClicked : function(sender, e) {		
		Friends.ManageGridForCatEdit.callBaseMethod(this, '_alphaClicked', [sender, e]);
		MySpace.Web.Modules.Friends.Services.FriendsService.GetAlphaFriends(this._newQuery, this.sListCatId,  _proxy_jslib_handle(this._catDropDown, 'value', '', 0, 0), this.thName, this._onPageFriendsGridReceived, this._onManageGridWSFailed, this);
		return false;
	},
	
	_pageNumClicked : function(sender, e) {
	    Friends.ManageGridForCatEdit.callBaseMethod(this, '_pageNumClicked', [sender, e]);
		MySpace.Web.Modules.Friends.Services.FriendsService.GetPagingFriends(this.sListCatId,  _proxy_jslib_handle(this._catDropDown, 'value', '', 0, 0), this.thName, this._query, this.pageNum, sender.jump, this.firstId, this.lastId,this._onPageFriendsGridReceived, this._onManageGridWSFailed, this);
	
		return false;
	},
	
	_updateCatName : function(sender, e) {
		if(e && e.cName){
			 _proxy_jslib_assign('', $get("_fCatNameLink"), 'innerHTML', '=', ( this._encodeAmpersands(e.cName.call(TextFilterWBR))));
		}
	},
	
	_encodeAmpersands : function(str) {
		str =  _proxy_jslib_handle(str, 'replace', '', 1, 0)(/&$/g, "&amp;");
		str =  _proxy_jslib_handle(str, 'replace', '', 1, 0)(/\s&$/g, " &amp;");
		str =  _proxy_jslib_handle(str, 'replace', '', 1, 0)(/\s&\s/g, " &amp; "); 
		
		return str;
	}
}
Friends.ManageGridForCatEdit.registerClass('Friends.ManageGridForCatEdit', Friends.ManageGridForEdit);

// Manage friends grid for Editing IM friends.
Friends.ManageGridForIMEdit = function(element) {
    Friends.ManageGridForIMEdit.initializeBase(this, [element]);    
}
Friends.ManageGridForIMEdit.prototype = {
    _MaxIMContacts:1000,
    _canAddMore:0,
    _rContactsScroller:null,
    _addAllBarMsgs:[],    
    initialize : function() {        
        Friends.ManageGridForIMEdit.callBaseMethod(this, 'initialize');
        this._addActMsg = MySpaceRes.ViewAllFriendsPage.AddToRegularList;
        this._removeActMsg = MySpaceRes.ViewAllFriendsPage.RemoveFromRegularList;
        this._addAllOnPageConfirmMsg = MySpaceRes.ViewAllFriendsPage.AddAllOnPageToRegularList;
        if(this.isQFEnabled){
            this._quickFind = new (FriendsCategories.WebIMMembersFind)(this.totalFCount, this.requesterId, Function.createDelegate(this, this._onQuickFindInput), Function.createDelegate(this, this._onQuickFindDataReceived), this.isQFCached);
        }
    },
    
    dispose : function() {
        this._addAllYourBtn && $clearHandlers(this._addAllYourBtn);
        this._addAllYourBtn = null;
        Friends.ManageGridForIMEdit.callBaseMethod(this, 'dispose');
	},
	
	registerIScroller : function(iScroller, boundToGrid) {
	    if(boundToGrid){
	        Friends.ManageGridForCatEdit.callBaseMethod(this, 'registerIScroller', [iScroller]);
	    }
	    else{ // recentContactsIScroller
	        this._rContactsScroller = iScroller;
	    }
	    if(this._iScroller && this._rContactsScroller){
	        this.updateAddAllBar();
        }
	},
	
	_setAddAllOnPage : function(managePanel) {
	    Friends.ManageGridForCatEdit.callBaseMethod(this, '_setAddAllOnPage', [managePanel]);
	    if(this._addAllBarEl){
	        this._addAllBarMsgs = getElementsByClassName(this._addAllBarEl, "span" , "frndSavedTxt");
	        this._savedShownImg = getElementsByClassName(this._addAllBarEl, "img" , "frndSavedCheck")[1];
	        this._savedShownTxt = this._addAllBarMsgs[1];
	        this._addRemoveMsg =  _proxy_jslib_handle(this._addAllBarMsgs[1], 'innerHTML', '', 0, 0);
	        
	        this._addAllYourBtn = getElementsByClassName(this._addAllBarEl, "button" , "addAllBarBtn")[1];
	        this._addAllYourBtn && $addHandler(this._addAllYourBtn, 'click', Function.createDelegate(this,this._addAllFrndsClicked));
	    }
	},
	
	updateAddAllBar : function() {
	    if(this._mGridItemsCount){	    	    	    
	        this._canAddMore = this._MaxIMContacts - (this._rContactsScroller.totalRecords + this._iScroller.totalRecords);
	        var addCountForPage = this._getItemCount(false);    
	        if(this._canAddMore > 0){
	            // Add all on this page	    
	            if(!this._addAllOnPage.disabled && (addCountForPage > this._canAddMore)){ // disabling the add all friends on the page button
	                this._addAllOnPage.disabled = true;	                
	                Sys.UI.DomElement.addCssClass(this._addAllOnPage, "submitBtnOff");
	            }
	            else if(this._addAllOnPage.disabled && (addCountForPage <= this._canAddMore)){ // enabling the add all friends on the page button
	                this._addAllOnPage.disabled = false;
	                Sys.UI.DomElement.removeCssClass(this._addAllOnPage, "submitBtnOff");	                
	            }
	            this._addAllBarMsgs[0] && ( _proxy_jslib_assign('', this._addAllBarMsgs[0], 'innerHTML', '=', ( String.format(MySpaceRes.ViewAllFriendsPage.AddToIMList, this._canAddMore))));
	            //change the background to Pink
	            if(Sys.UI.DomElement.containsCssClass(this._addAllBarEl, "pinkBackGround")){
	                Sys.UI.DomElement.removeCssClass(this._addAllBarEl, "pinkBackGround");
	                Sys.UI.DomElement.addCssClass(this._addAllBarEl, "grayBackGround");
	                this._addAllBarMsgs[1] && ( _proxy_jslib_assign('', this._addAllBarMsgs[1], 'innerHTML', '=', ( this._addRemoveMsg)));
	            }	        
	        }
	        else{
	            // disabling the add all friends on this page button.
	            this._addAllOnPage.disabled = true;	            
	            Sys.UI.DomElement.addCssClass(this._addAllOnPage, "submitBtnOff");
	            // changing the message text
	            this._addAllBarMsgs[0] && ( _proxy_jslib_assign('', this._addAllBarMsgs[0], 'innerHTML', '=', ( MySpaceRes.ViewAllFriendsPage.MaxIMFriends)));
	            this._addAllBarMsgs[1] && ( _proxy_jslib_assign('', this._addAllBarMsgs[1], 'innerHTML', '=', ( MySpaceRes.ViewAllFriendsPage.RemoveIMFriends)));
	            //change the background to Red
	            if(Sys.UI.DomElement.containsCssClass(this._addAllBarEl, "grayBackGround")){
	                Sys.UI.DomElement.removeCssClass(this._addAllBarEl, "grayBackGround");
	                Sys.UI.DomElement.addCssClass(this._addAllBarEl, "pinkBackGround");
	            }
	        }
	    }
	},	
	
	_callAddFriend : function(friendIds) {
		//Call webservice
		MySpace.Web.Modules.Friends.Services.FriendsService.AddFriendToIMContacts(friendIds,this._onManageItemSucceeded, this._onManageGridWSFailed, {manageo:this, fIds:friendIds, isAdd:true});
		return false;
	},	
	
	_callRemoveFriend : function(friendIds) {
		//Call webservice
		MySpace.Web.Modules.Friends.Services.FriendsService.RemoveFriendFromIMContacts(friendIds,this._onManageItemSucceeded, this._onManageGridWSFailed, {manageo:this, fIds:friendIds, isAdd:false});
		return false;
	},
	
	_manageItemAction : function(friendIds, failedIds, addAction) {
	    Friends.ManageGridForIMEdit.callBaseMethod(this, '_manageItemAction', [friendIds, failedIds, addAction]);
	    this.updateAddAllBar();
	},
	
	_showSaveInstructions : function() {
	    Friends.ManageGridForIMEdit.callBaseMethod(this, '_showSaveInstructions');
	    this._savedShownTxt && ( _proxy_jslib_assign('', this._savedShownTxt, 'innerHTML', '=', ( this._addRemoveMsg)));
	},
		
	_alphaClicked : function(sender, e) {		
		Friends.ManageGridForIMEdit.callBaseMethod(this, '_alphaClicked', [sender, e]);
		MySpace.Web.Modules.Friends.Services.FriendsService.GetIMAlphaFriends(this._newQuery,  _proxy_jslib_handle(this._catDropDown, 'value', '', 0, 0), this.thName, this._onPageFriendsGridReceived, this._onManageGridWSFailed, this);
		return false;
	},
	
	_pageNumClicked : function(sender, e) {
	    Friends.ManageGridForIMEdit.callBaseMethod(this, '_pageNumClicked', [sender, e]);
		MySpace.Web.Modules.Friends.Services.FriendsService.GetIMPagingFriends( _proxy_jslib_handle(this._catDropDown, 'value', '', 0, 0), this.thName, this._query, this.pageNum, sender.jump, this.firstId, this.lastId,this._onPageFriendsGridReceived, this._onManageGridWSFailed, this);	
		return false;
	},
	
    _onCatFriendsGridReceived : function(mGridHtml) {
        Friends.ManageGridForIMEdit.callBaseMethod(this, '_onCatFriendsGridReceived', [mGridHtml]);
        this.updateAddAllBar();
    },
	
	_addAllFrndsClicked : function(evt) {
	    if(!Sys.UI.DomElement.containsCssClass(this._addAllYourBtn, "submitBtnOff")){
	        if(confirm(MySpaceRes.ViewAllFriendsPage.AddAllToRegularList)){
               MySpace.Web.Modules.Friends.Services.FriendsService.AddAllFriendsToIMContacts(this._onBatchActionSucceeded, this._onManageGridWSFailed, this);
	        }
	    }
	    evt.preventDefault();	    
	}
}
Friends.ManageGridForIMEdit.registerClass('Friends.ManageGridForIMEdit', Friends.ManageGridForEdit);

// Each Item in the infinite scroll list
FriendsCategories.ScrollListItem = function(element) {
    FriendsCategories.ScrollListItem.initializeBase(this, [element]);
    this._actionEls= [];    
}

FriendsCategories.ScrollListItem.prototype = {
    _clrAnimations:[],
    initialize : function() {        
        var removeL = getElementsByClassName(this._element, "a", "removelink");
        if(removeL && removeL.length > 0){
            Array.add(this._actionEls,removeL[0]);
            $addHandler(removeL[0], 'click', Function.createDelegate(this, this.raise_removedClicked));
        }
        FriendsCategories.ScrollListItem.callBaseMethod(this, 'initialize');
    },
    
    dispose : function() {
        var containsCss = Sys.UI.DomElement.containsCssClass;
        for(var i=0;i<this._actionEls.length;i++){            
            $clearHandlers( _proxy_jslib_handle(this._actionEls, (i), 0, 0));            
             _proxy_jslib_assign('', this._actionEls, (i), '=', ( null));
        }
        Array.clear(this._actionEls);
        FriendsCategories.ScrollListItem.callBaseMethod(this, 'dispose');
    },
    
    disposeAnimations : function() {
        if(this._clrAnimations){
            for(var i=0;i<this._clrAnimations.length;i++){
                 _proxy_jslib_handle(this._clrAnimations, (i), 0, 0).dispose();
                 _proxy_jslib_assign('', this._clrAnimations, (i), '=', ( null));
            }
            Array.clear(this._clrAnimations);
        } 
    },
    
    _getColorAnimationo : function() {
                
        for(var i=0;i<this._clrAnimations.length;i++){
            if(! _proxy_jslib_handle(this._clrAnimations, (i), 0, 0).get_isPlaying()){
                return  _proxy_jslib_handle(this._clrAnimations, (i), 0, 0);
            }
        }
        var clrAnimo = $create(MySpace.UI.Effects.ColorAnimation,{'duration':'3','property':'style','propertyKey':'backgroundColor'});
        if(clrAnimo){
            Array.add(this._clrAnimations, clrAnimo);            
            return clrAnimo;
        }
        return null;
    },
    
    playAnimation : function(isErr) {
        var clrAnimo = this._getColorAnimationo();
        if(clrAnimo){
            clrAnimo.set_target(this._element);
            clrAnimo.set_startValue(isErr?'#FCDEDE':'#FFFBCC');
            clrAnimo.set_endValue('#FFFFFF');
            clrAnimo.play();
        }
    },
    
    displayExtraAction : function(visible) {
        if(this._actionEls && this._actionEls[1]){
            if(visible){                
                Sys.UI.DomElement.removeCssClass(this._actionEls[1], "hide");
            }
            else{                
                Sys.UI.DomElement.addCssClass(this._actionEls[1], "hide");
            }
        }
    },    
            
    //remove item click event
    add_removeClicked : function(handler) {
        this.get_events().addHandler('removeClicked', handler);
    },    
    remove_removeClicked : function(handler) {
        this.get_events().removeHandler('removeClicked', handler);
    },    
    raise_removedClicked : function(evt) {
        var removeH = this.get_events().getHandler('removeClicked');
        removeH && removeH(this, evt);
    }   
}
FriendsCategories.ScrollListItem.registerClass('FriendsCategories.ScrollListItem', Sys.UI.Control);

// infinite scroll list
FriendsCategories.ScrollList = function(element) {
    FriendsCategories.ScrollList.initializeBase(this, [element]);
    this._livelistMembers = {};
	this.totalRecords = null;
	this.pageSize = null;
	this.currentCount = null;
	this.bindToGrid = false;
	this.baseImageUrl=null;
    this.viewProfileLink=null;	
	this._adding = false;
	this._scrollBox = null;
	this._liveListEl = null;
	this._nofriendsspan = null;
	this._scrollListMsg = null;
	this._removedEl = null;		
	this._nextPage = 2;
	this._minListCount =10;
	this._deletedCount = 0;
	this._itemRemoveHandler = null;	
	this._mGrid = null;
	this._timerId = null;
	this._emptyListMsg = null;
	this._wsIDs = [];	
}

FriendsCategories.ScrollList.prototype = {
    _listItemHtml:"<a title='{0}' href='{4}' class='viewlink' target='_blank'><img class='catLiveListItem' src='{1}' border='0'/><span class='leftListItemName'>{2}</span></a><a href='#' class='removelink'><img src='{3}/icon_remove.gif' border='0'></a>",
    _removeAllLink: null,
    initialize : function() {        
        FriendsCategories.ScrollList.callBaseMethod(this, 'initialize');
        
        this._scrollBox = getElementsByClassName(this._element, "div", "iScrollerBox")[0];
		this._liveListEl = $get('catfriends_scroll_list',this._element);
		this._nofriendsspan = $get('livelistnofriendsmsg', this._element);
		this._scrollListMsg = $get("livelistloader", this._element);
		
		this._itemRemoveHandler = Function.createDelegate(this, this._sItemRemoveClicked);	
		if(this._liveListEl && this._liveListEl.childNodes){
		    this._buildScrollListItems(this._liveListEl.childNodes);
		}
				
		// register with manage friends grid
		this.bindToGrid && this._registerWithManageGrid();
		
		//Display No memeber messager if the total records is 0
		this._checkAndShowNoFriendsMsg();
		
		// Hook up the on scroll event		
		$addHandler(this._scrollBox, 'scroll', Function.createDelegate(this, this._getMoreFriends));
		this.bindToGrid = !!this.bindToGrid;
		
		//Add Click Handler for remove all link
		if(this.bindToGrid){
		    this._removeAllLink = $get("removeallLink");		
		    this._removeAllLink && $addHandler(this._removeAllLink, 'click', Function.createDelegate(this, this._removeAllClicked));
		}		
    },
    
    dispose : function() {
        for(var i in this._livelistMembers){            
             _proxy_jslib_handle(this._livelistMembers, (i), 0, 0).remove_removeClicked(this._itemRemoveHandler);
            this._itemRemoveHandler = null;
             _proxy_jslib_handle(this._livelistMembers, (i), 0, 0).disposeAnimations();
             _proxy_jslib_handle(this._livelistMembers, (i), 0, 0).dispose();            
             _proxy_jslib_assign('delete', (this._livelistMembers), (i), '');
        }
        Array.clear(this._livelistMembers);
        
        if(this._removeAllLink){
		    $clearHandlers(this._removeAllLink);
		    this._removeAllLink = null;
		}
        this._livelistMembers = null;
        this._liveListEl = null;
	    this._nofriendsspan = null;
	    this._scrollListMsg = null;
	    this._mGrid = null;
	    	    
	    this._scrollBox && $clearHandlers(this._scrollBox);
	    this._scrollBox = null;
        FriendsCategories.ScrollList.callBaseMethod(this, 'dispose');        
    },
    
    _registerWithManageGrid : function() {
        this._timerId && clearTimeout(this._timerId);
        this._mGrid = $find("memberspanel");
        if(this._mGrid){             
             this._mGrid.registerIScroller(this, this.bindToGrid);                          
        }
        else{            
            this._timerId =  _proxy_jslib_handle(window, 'setTimeout', '', 1, 0)(Function.createDelegate(this, this._registerWithManageGrid),500);
        }        
    },    
    
    _buildScrollListItems : function(sItems, showClrEffect) {               
        for(var i=0;i<sItems.length;i++){
            var sItem =  _proxy_jslib_handle(sItems, (i), 0, 0);
            var sItemId = sItem.id;
            if(sItemId && sItemId.length > 0){
                 _proxy_jslib_assign('', this._livelistMembers, (sItemId), '=', ( $create(FriendsCategories.ScrollListItem,null,{'removeClicked':this._itemRemoveHandler},null,sItem)));
                showClrEffect &&  _proxy_jslib_handle(this._livelistMembers, (sItemId), 0, 0).playAnimation();
            }
        }		
    },
    
    _checkAndShowNoFriendsMsg : function() {		
		if (this.totalRecords == 0){			
			 _proxy_jslib_assign('', this._nofriendsspan, 'innerHTML', '=', ( this._emptyListMsg ));
			//Sys.UI.DomElement.removeCssClass(this._nofriendsspan, "hide");
			this._nofriendsspan.style.display = "block";
		}
		else{
			//Sys.UI.DomElement.addCssClass(this._nofriendsspan, "hide");
			this._nofriendsspan.style.display = "none";
		}
	},	
	
	_getMoreFriends : function(evt) {	
		if(this.currentCount < this.totalRecords && !this._adding){
		    if (this._scrollBox.scrollTop > (this._scrollBox.scrollHeight - this._scrollBox.clientHeight -30)){			    
			     _proxy_jslib_assign('', this._scrollListMsg, 'innerHTML', '=', ( MySpaceRes.ViewAllFriendsPage.LoadingData));
			    this._adding = true;
			    //Call webservice			    
			    this._getMoreFriendsWSCall(evt);
			}
		}
	},
    
    _onMorefrndsReceived : function(result, userContext, methodName) {
    	if(!result.ErrMsg){			
			 _proxy_jslib_assign('', userContext._scrollListMsg, 'innerHTML', '=', (" "));			
			
			userContext._addToSList(result.FriendsInfo);
			if(result.FriendsInfo.length > 0){						
				userContext.currentCount += result.FriendsInfo.length;
				userContext._nextPage++;								
			}							
			userContext._adding = false;
		}
		else{
			userContext.OnServerCallFailed(result, userContext, methodName);
		}
    }, 
    
    _onMorefrndsFailed : function(result, userContext, methodName) {        
        userContext._mGrid && userContext._mGrid._checkErrCode(result.ErrCode);
		
		result && result.ErrMsg && ( _proxy_jslib_assign('', userContext._scrollListMsg, 'innerHTML', '=', ( result.ErrMsg)));
		userContext._adding = false;				
    },
    
    _getMoreFriendsWSCall : function(evt) {
        evt.preventDefault();
    },
	    
    _sItemRemoveClicked : function(src, evt) {
	    evt.preventDefault();
    },
    
    _onFriendRemovedSucceeded : function(result, userContext, methodName) {
        var friendIDs = Array.clone(userContext._wsIDs);
        Array.clear(userContext._wsIDs);
		if(!result.ErrMsg){
			//userContext.removeFriendFromList(friendIDs, result.FailedIds);			
			if(userContext.bindToGrid){
			    userContext._mGrid && userContext._mGrid._manageItemAction(friendIDs, result.FailedIds, false);
			}
			else{
			    userContext.removeFriendFromList(friendIDs, result.FailedIds);
			}
		}
		else{		    
			userContext._mGrid && userContext._mGrid._checkErrCode(result.ErrCode);
			userContext._onFriendRemovedFailed(result, userContext, methodName);
		}
	},
	
	_onFriendRemovedFailed : function(result, userContext, methodName) {	
	    Array.clear(userContext._wsIDs);
		result && result.ErrMsg && ( _proxy_jslib_assign('', userContext._scrollListMsg, 'innerHTML', '=', (result.ErrMsg)));
	},    
        
    _createListItem : function(fInfo) {  		
	    var childli = document.createElement('li');
	    childli.id = fInfo.FriendId;	    
         _proxy_jslib_assign('', childli, 'innerHTML', '=', ( String.format(this._listItemHtml, 
                                            MySpaceRes.ViewAllFriendsPage.RemoveFromCategory, 
                                            fInfo.ImageUrl, 
                                            fInfo.Name,
                                            this.baseImageUrl,
                                            String.format(this.viewProfileLink,fInfo.FriendId)))); 
	          
	    return childli;
    },
    
    _removeDomItems:function(friendIds, failedIds, disposeItem) {
        var removedEls = [];
        for(var i=0;i<friendIds.length;i++){
		    var friendId =  _proxy_jslib_handle(friendIds, (i), 0, 0);
		    var sListItem =  _proxy_jslib_handle(this._livelistMembers, (friendId), 0, 0);
		    var element= sListItem && sListItem.get_element();
		    if(element){
			    if(failedIds && failedIds.length > 0 && Array.indexOf(failedIds,parseInt( _proxy_jslib_handle(friendIds, (i), 0, 0), 10),0)>=0){
			        sListItem.playAnimation(true);
			    }
			    else{
			        if(disposeItem){										
				        sListItem.dispose();
				        sListItem = null;				        
				    }					
				    this._liveListEl.removeChild(element);
			    }
			    if(disposeItem){
			        element = null

 }
			    else{
			        Array.add(removedEls, element);
			    }
		    }
	    }	    
	    return removedEls;	    
    },
    
    _addAtTop : function(childLi) {
        if(this._liveListEl.childNodes && this._liveListEl.childNodes.length > 0){
	        this._liveListEl.insertBefore(childLi,this._liveListEl.childNodes[0]);	        
	    }
	    else{
		    this._liveListEl.appendChild(childLi);
		}
    },
    
    _addToSList: function(fInfos) {
	    var newItems = [];
	    if(fInfos){	     
	        for (var i=0;i<fInfos.length;i++){
			    var fInfo =  _proxy_jslib_handle(fInfos, (i), 0, 0);
			    if(! _proxy_jslib_handle(this._livelistMembers, (fInfo.FriendId), 0, 0)){
			        var childLi = this._createListItem(fInfo);
			        this._liveListEl.appendChild(childLi);
			        Array.add(newItems, childLi);
			    }
			}			    
		    if(newItems.length > 0){
		        this._buildScrollListItems(newItems);
		    }			    			    		    
		 }
	},
	
	addFriendToSList : function(friendId, friendName, friendImgUrl) {
	    var childLi = this._createListItem({'FriendId':friendId, 'Name':friendName, 'ImageUrl':friendImgUrl});	    
	    this._addAtTop(childLi);
		childLi && this._buildScrollListItems([childLi], true);
		this.currentCount++;
		this.totalRecords++;
		this._checkAndShowNoFriendsMsg();
	},
	
	removeFriendFromList : function(friendIds, failedIds) {
	    if(friendIds && friendIds.length > 0){
	        this._removeDomItems(friendIds, failedIds, true)

  

 var updateCount = friendIds.length - (failedIds?failedIds.length:0);
		    this.currentCount -= updateCount;
		    this.totalRecords -= updateCount;
		    //See if we need to retrieve more
			if(this.currentCount < this._minListCount && this.totalRecords > this.currentCount){
			    this._getMoreFriends();
			}
		    this._checkAndShowNoFriendsMsg();
		}
	},
	
	_removeAllClicked : function() {
		return false;
	},
	
	_onRemoveAllSucceeded: function(result, userContext, methodName) {
		if(!result.ErrMsg){
			 _proxy_jslib_handle(null, 'location', location, 0, 0).reload(true);
		}
		else{
			userContext._onFriendRemovedFailed(result, userContext, methodName);
		}
	},
	
	cleanSList : function() {
	    var friendIds = [];
	    if(this._liveListEl && this._liveListEl.childNodes){
		    for(var i=0;i<this._liveListEl.childNodes.length;i++){
		        Array.add(friendIds,  _proxy_jslib_handle(this._liveListEl.childNodes, (i), 0, 0));
		    }
		}
		this._removeDomItems(friendIds, [], true);	    
	},
	
	_prepareWSCall : function(sItem) {	
        if(this._wsIDs && this._wsIDs.length === 0){
            if(sItem && sItem.get_id()){
                Array.add(this._wsIDs, sItem.get_id());
                return true;
            }
        } 
	    return false;
	}			        
}
FriendsCategories.ScrollList.registerClass('FriendsCategories.ScrollList', Sys.UI.Control);

// Manage Category friends infinite scroll list
FriendsCategories.CatScrollList = function(element) {
    FriendsCategories.CatScrollList.initializeBase(this, [element]);
	this.categoryId = null;
	this.lastRecordId = null;
	this._minListCount =10;		
}

FriendsCategories.CatScrollList.prototype = {        
    _counterEl:null,
    _statusEl:null,
    _clrAnimo:null,    
    initialize : function() {
        this._emptyListMsg = MySpaceRes.ViewAllFriendsPage.NoFriendsInCategory;
        FriendsCategories.CatScrollList.callBaseMethod(this, 'initialize');        
        // Counter
        this._counterEl = $get("friendsCount");
        this._updateCounter();
        		
		//Caching status element
		this._statusEl = $get("friendStatus");
		if(this._statusEl){
		    this._clrAnimo = $create(MySpace.UI.Effects.ColorAnimation,{'duration':'3','property':'style','propertyKey':'backgroundColor'});
		    this._clrAnimo.set_target(this._statusEl);
		}
    },
    
    dispose : function() {		
		if(this._statusEl){
		    this._clrAnimo.dispose();
		    this._statusEl = null;
		}
        FriendsCategories.CatScrollList.callBaseMethod(this, 'dispose');
    },
    
    _getMoreFriendsWSCall : function() {
        MySpace.Web.Modules.Friends.Services.FriendsService.GetMoreFriends(this.categoryId,this.pageSize,this.lastRecordId,this._nextPage ,this._onMorefrndsReceived, this._onMorefrndsFailed, this);
    },
    
    _onMorefrndsReceived : function(result, userContext, methodName) {
        FriendsCategories.CatScrollList.callBaseMethod(userContext, '_onMorefrndsReceived', [result, userContext, methodName]);
        // the last record Id
        if(result.FriendsInfo.length > 0){
            userContext.lastRecordId =  _proxy_jslib_handle(result.FriendsInfo, (result.FriendsInfo.length - 1), 0, 0).FriendId;
        }
    },
    
    _sItemRemoveClicked : function(src, evt) {
        this._prepareWSCall( _proxy_jslib_handle(null, 'src', src, 0, 0)) && MySpace.Web.Modules.Friends.Services.FriendsService.RemoveFriendFromCategory(this.categoryId,this._wsIDs,this._onFriendRemovedSucceeded, this._onFriendRemovedFailed, this);
	    evt.preventDefault();
    },
    
    _updateCounter: function() {				
        if(this._counterEl){
            if (this.totalRecords >= 100000){
	            this._counterEl.className = "counter_7";
            }
            else if (this.totalRecords >= 10000){
	            this._counterEl.className = "counter_6";
            }
            else if (this.totalRecords >= 1000){
	            this._counterEl.className = "counter_5";
            }
            else if (this.totalRecords >= 100){
	            this._counterEl.className = "counter_4";
            }
            else if (this.totalRecords >= 10){
	            this._counterEl.className = "counter_3";
            }
            else{
	            this._counterEl.className = "counter_2";
            }		
             _proxy_jslib_assign('', this._counterEl, 'innerHTML', '=', ( this.totalRecords + " "));
		}
	},
	
	playStatusAnimation : function(isErr) {
        if(this._clrAnimo && !this._clrAnimo.get_isPlaying()){
            this._statusEl.style.display = "block";	
            this._clrAnimo.set_startValue(isErr?'#FCDEDE':'#FFFBCC');
            this._clrAnimo.set_endValue('#EEEEEE');
            this._clrAnimo.play();
        }
	},
	
	removeFriendFromList : function(friendIds, failedIds) {
	    FriendsCategories.CatScrollList.callBaseMethod(this, 'removeFriendFromList', [friendIds, failedIds]);
	    this._updateCounter();
	    this.playStatusAnimation(true);
	},
	
	addFriendToSList : function(friendId, friendName, friendImgUrl) {
	    FriendsCategories.CatScrollList.callBaseMethod(this, 'addFriendToSList', [friendId, friendName, friendImgUrl]);
	    this._updateCounter();
	    this.playStatusAnimation();
	},
	
	_removeAllClicked : function() {
		if (confirm(MySpaceRes.ViewAllFriendsPage.RemoveAllConfirm)){			
			MySpace.Web.Modules.Friends.Services.FriendsService.RemoveAllFriends(this.categoryId , this._onRemoveAllSucceeded, this._onFriendRemovedFailed, this);
		}
	}			
}
FriendsCategories.CatScrollList.registerClass('FriendsCategories.CatScrollList', FriendsCategories.ScrollList);


Type.registerNamespace("Friends.IMScrollList");

// Manage IM friends infinite scroll list
Friends.IMScrollList = function(element) {
    Friends.IMScrollList.initializeBase(this, [element]);
	this.lastRecordId = null;
	
	this.listHeadEl = null;
	this._minListCount =10;
}

Friends.IMScrollList.prototype = {
        initialize : function() { 
        this._emptyListMsg = this.bindToGrid ? MySpaceRes.ViewAllFriendsPage.EmptyRegularContactList : MySpaceRes.ViewAllFriendsPage.EmptyRecentContactList;       
        Friends.IMScrollList.callBaseMethod(this, 'initialize');                
        
        // for the IM friends Scroll list        
        if(this.bindToGrid){            
            // Header div
            this.listHeadEl = $get("IMFriendsHeader");            
        }
        else{ //Recent Conatcts scroll list
            this._registerWithManageGrid();            
            this.listHeadEl = $get("RecentContactsHeader");
        }
    },
    
    dispose : function() {
        Friends.IMScrollList.callBaseMethod(this, 'dispose');
    },
    
    _getMoreFriendsWSCall : function() {
        MySpace.Web.Modules.Friends.Services.FriendsService.GetMoreIMFriends(this.bindToGrid,this.pageSize,this.lastRecordId,this._nextPage ,this._onMorefrndsReceived, this._onMorefrndsFailed, this);
    },
    
    _onMorefrndsReceived : function(result, userContext, methodName) {
        FriendsCategories.CatScrollList.callBaseMethod(userContext, '_onMorefrndsReceived', [result, userContext, methodName]);
        // the last record Id
        if(result.FriendsInfo.length > 0){
            userContext.lastRecordId =  _proxy_jslib_handle(result.FriendsInfo, (result.FriendsInfo.length - 1), 0, 0).FriendId;
        }
    },
    
    _sItemRemoveClicked : function(src, evt) {
        this._prepareWSCall( _proxy_jslib_handle(null, 'src', src, 0, 0)) && MySpace.Web.Modules.Friends.Services.FriendsService.RemoveFriendFromIMContacts(this._wsIDs,this._onFriendRemovedSucceeded, this._onFriendRemovedFailed, this);	    
	    evt.preventDefault();
    },
    
    removeFriendFromList : function(friendIds, failedIds) {
	    Friends.IMScrollList.callBaseMethod(this, 'removeFriendFromList', [friendIds, failedIds]);
	    this.updateListHeader();
	    // update the Mgrid for recent contacts scroller
	    this.bindToGrid || this._mGrid && this._mGrid.updateAddAllBar && this._mGrid.updateAddAllBar();
	},
	
	addFriendToSList : function(friendId, friendName, friendImgUrl) {
	    Friends.IMScrollList.callBaseMethod(this, 'addFriendToSList', [friendId, friendName, friendImgUrl]);
	    //this.updateItemAction();
	    this.updateListHeader();
	},
	
	_removeAllClicked : function() {
		if (confirm(MySpaceRes.ViewAllFriendsPage.RemoveAllIMFriends)){			
			MySpace.Web.Modules.Friends.Services.FriendsService.RemoveAllContacts(this._onRemoveAllSucceeded, this._onFriendRemovedFailed, this);
		}
	},    
		
	updateListHeader : function() {
	    this.listHeadEl && ( _proxy_jslib_assign('', this.listHeadEl, 'innerHTML', '=', ( String.format( _proxy_jslib_handle(MySpaceRes.ViewAllFriendsPage, ((this.bindToGrid ? "IMFriends" : "RecentContacts")), 0, 0), this.totalRecords))));
	},
	
	resetSList : function() {
	    this.cleanSList();
	    // make WS call to get the new data
	    this._addToSList();	    
	}	
}
Friends.IMScrollList.registerClass('Friends.IMScrollList', FriendsCategories.ScrollList);



// Edit Category Class
// ------------------

FriendsCategories.EditCat = function() {
	 this._catId;
	 this._catName;
	 this._catDesc;
	 this._catPrivacy;
	 this._newPrivacy = null;
	 this._editP;
	 this._pEl;
	 this.OnCatDescEnter = false;
}
FriendsCategories.EditCat.registerClass('FriendsCategories.EditCat');
FriendsCategories.EditCat.prototype = 
{
	init : function(el, catId, catName, catDesc, catPrivacy) {		
		FriendsCategories.EditCat.initializeBase(this);
		this._catId = catId;
		this._catName = catName;
		this._catPrivacy = catPrivacy;		
		this._catDesc = catDesc;
		
		$addHandler(el,"click", Function.createDelegate(this,this._showEditPop));
	},
	
	editCategoryPopup : function() {
	    var btnSaveId = this._catId + "btnSave"; // the submit button id
	    var spnCharCount = this._catId + "charCnt";
	    var spnDescCharCount = this._catId + "charDescCnt";
	    var spnValReq = this._catId + "valReq";
		
		var remainingChars = 68 - this._decodedHtml(this._catName).length;
		if (remainingChars < 0)
		{
			remainingChars = 0;
		}
		
		var remainingCharsDesc = 100 - this._decodedHtml(this._catDesc).length;
		if ( remainingCharsDesc < 0 )
		{
			remainingCharsDesc = 0;
		}
		var content = new (Sys.StringBuilder)("<label for='category_name' class='popUpCategoryName'>" + MySpaceRes.ViewAllFriendsPage.CategoryNameField + "</label><br />");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<textarea class='popUpEditInput' name='CategoryName' rows='1' wrap='off'");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(" maxlength='68' id='CategoryName' class='popUpEditInput' onbeforepaste='doBeforePaste(this);' onchange='limitInput(this, \"" + spnCharCount + "\", \"" + btnSaveId + "\", \"" + spnValReq + "\", event);' onkeyup='limitInput(this, \"" + spnCharCount + "\", \"" + btnSaveId + "\", \"" + spnValReq + "\", event);' onkeypress='limitInput(this, \"" + spnCharCount + "\", \"" + btnSaveId + "\", \"" + spnValReq + "\", event);' onpaste='doPaste(this, \"" + spnCharCount + "\");' maxLength='68' />" +  this._catName + "</textarea>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<span id='"+spnValReq+"' class='cNameErr' style='color:Red;visibility:hidden;'>*</span>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<span id='charsLeft' class='popUpCharsLeft'  >");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<span id='"+spnCharCount+"'>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(remainingChars);
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</span><span  class='catcreatetotal'>/68</span></span>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<div id='customErr' class='popUpCustomErr'></div>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</p><p><label for='category_name' class='popUpCategoryName'>" + MySpaceRes.ViewAllFriendsPage.CategoryEditDescriptionLabel + "</label><br />");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<textarea class='popUpEditInputDesc' name='CategoryDesc' ");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(" maxlength='100' id='CategoryDesc' class='popUpEditInput' onbeforepaste='doBeforePaste(this);' onchange='limitInput(this, \"" + spnDescCharCount + "\", \"" + btnSaveId + "\",null, event);' onkeyup='limitInput(this, \"" + spnDescCharCount + "\", \"" + btnSaveId + "\", null, event);' onkeypress='limitInput(this, \"" + spnDescCharCount + "\", \"" + btnSaveId + "\", null, event);' onpaste='doPaste(this, \"" + spnDescCharCount + "\");' maxLength='100' > " +  this._catDesc + "</textarea>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<span class='popUpCharsLeftDesc'>");        
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<span id='"+spnDescCharCount+"'>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(remainingCharsDesc);
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</span><span  class='catcreatetotal'>/100</span></span>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</p><p><label for='privacy' class='popUpViewableBy'>");        
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(MySpaceRes.ViewAllFriendsPage.ViewableByLabel); 
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</label><br />");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<div id='popUpPrivWrap' class='popUpPrivWrap'>"); // begin wrapper for radio buttons
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<span id='PrivacyList' class='buttonList'>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<input id='PrivacyList_0' class='popUpRadio' type='radio' name='PrivacyList' value='Private' /><label for='PrivacyList_0' class='popUpDefaultText'>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(MySpaceRes.ViewAllFriendsPage.JustMeCategorySecurityLabel); 
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</label><br />");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<input id='PrivacyList_1' class='popUpRadio' type='radio' name='PrivacyList' value='MembersOnly' /><label for='PrivacyList_1' class='popUpDefaultText'>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(MySpaceRes.ViewAllFriendsPage.MembersOnlyCategorySecurityLabel);  
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<span class='popUpDefaultText'>&nbsp;");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(MySpaceRes.ViewAllFriendsPage.MembersOnlyDescriptionText); 
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</span></label><br />");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<input id='PrivacyList_2' class='popUpRadio' type='radio' name='PrivacyList' value='Public' checked='checked' /><label for='PrivacyList_2' class='popUpDefaultText'>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(MySpaceRes.ViewAllFriendsPage.EveryoneCategorySecurityLabel);
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<span class='popUpDefaultText'>&nbsp;");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append(MySpaceRes.ViewAllFriendsPage.SameAsProfileDescriptionText);
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</span></label></span><br /></p>");
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("</div>"); // end wrapper for radio buttons
         _proxy_jslib_handle(null, 'content', content, 0, 0).append("<hr class='popUpHzLine' /><br /><div id='createButtons'>");
		 _proxy_jslib_handle(null, 'content', content, 0, 0).append("<div id='popUpSavingCat' class='popUpSavingCat'>" + MySpaceRes.ViewAllFriendsPage.SavingCategory + "</div>");
		 _proxy_jslib_handle(null, 'content', content, 0, 0).append("<button id='cancelBtn' class='submitBtn cancelGrey' type='button'><span>" + MySpaceRes.ViewAllFriendsPage.CancelButtonText + "</span></button>&nbsp;&nbsp;");
		 _proxy_jslib_handle(null, 'content', content, 0, 0).append("<button id='"+btnSaveId+"' class='submitBtn' type='submit'><span>" + MySpaceRes.ViewAllFriendsPage.SaveButtonText + "</span></button>");
		 _proxy_jslib_handle(null, 'content', content, 0, 0).append("</div>");
        
		this._editP = this._createEditPop( _proxy_jslib_handle( _proxy_jslib_handle(null, 'content', content, 0, 0), 'toString', '', 1, 0)(), MySpaceRes.ViewAllFriendsPage.EditCategoryLink);
	    this._pEl = this._editP._element;

		var catDescElem = $get("CategoryDesc",this._pEl);
		
		if(catDescElem)
		{			
			$addHandler(catDescElem, "keydown", Function.createDelegate(this,this.removeEnter));
		}
	    var actionBtns = getElementsByClassName(this._pEl, "button", "submitBtn");	    	    
		$addHandler(actionBtns[0], "click", Function.createDelegate(this,this._popOverCancel));
		$addHandler(actionBtns[1], "click", Function.createDelegate(this,this._popOverCB));		
		
		this._catNameBox = getElementsByClassName(this._pEl, "textarea", "popUpEditInput")[0];
		this._catDescBox = getElementsByClassName(this._pEl, "textarea", "popUpEditInputDesc")[0]

 

 this._pErr = getElementsByClassName(this._pEl, "div", "popUpCustomErr")[0];
	},
	
	removeEnter : function(evt) {
		if (evt.keyCode == 13)
		{			
			evt.preventDefault();
			evt.stopPropagation();
			this.OnCatDescEnter = true;						
			return false;
		}	
	},
	
	_decodedHtml : function(str) {
		var tmpDiv = document.createElement('div');
		if (str != null && str.length > 0)
		{
			str = this._encodeAmpersands(str);
			 _proxy_jslib_assign('', tmpDiv, 'innerHTML', '=', ( str));
		}
		else
		{
			return "";
		}
		
		return tmpDiv.innerText || tmpDiv.textContent || str;
	},
	
	_encodeAmpersands : function(str) {
		str =  _proxy_jslib_handle(str, 'replace', '', 1, 0)(/&$/g, "&amp;");
		str =  _proxy_jslib_handle(str, 'replace', '', 1, 0)(/\s&$/g, " &amp;");
		str =  _proxy_jslib_handle(str, 'replace', '', 1, 0)(/\s&\s/g, " &amp; "); 
		
		return str;
	},
	
	_updateCatInfo : function() {
		var spnCharCount = this._catId + "charCnt";		
		var cNm = this._decodedHtml(this._catName);
			
		var catNameChar = 68 - (cNm ? cNm.length : 0);		
		if (catNameChar < 0)
        {
			catNameChar = 0;
        }
		 _proxy_jslib_assign('', $get(spnCharCount), 'innerHTML', '=', ( catNameChar));

		var spnDescCharCount = this._catId + "charDescCnt";
		var cDsc = this._decodedHtml(this._catDesc);
		
		var catDescChar = 100 - (this._pEl, "span", cDsc ? cDsc.length : 0);	
		if (catDescChar < 0)
        {
			catDescChar = 0;
        }
         _proxy_jslib_assign('', $get(spnDescCharCount), 'innerHTML', '=', ( catDescChar));
                
         _proxy_jslib_assign('', this._catNameBox, 'value', '=', ( cNm));
		 _proxy_jslib_assign('', this._catDescBox, 'value', '=', ( cDsc));
	},	 	
	 		
	_createEditPop : function(content, title, callback) {
		var temp=document.createElement("div");
		 _proxy_jslib_assign('', temp, 'innerHTML', '=', ("<div class='friendsPopup_wrapper' style='z-index:1000001;left:0px;width:100%;display:none;visibility:hidden;'><div class='friendsPopup_box'><a></a><div class='friendsPopup_title'></div><div class='friendsPopup_content'></div><div class='friendsPopup_buttons'></div></div></div>"));
		var popup = $create(MySpace.UI._Popup,{title:title, content: _proxy_jslib_handle(null, 'content', content, 0, 0), callback:callback},null,null,temp.firstChild);
		
		return popup;
	},
	
	_showEditPop : function(evt) {		
		if(!this._editP){
			// creates the modal pop over for the passed Element
			this.editCategoryPopup();
		}
		//set the privacy setting.
		var catPList = getElementsByClassName(this._pEl, "input", "popUpRadio")
		if(catPList)
		{
			for(var i=0;i<catPList.length;i++)
			{
				if( _proxy_jslib_handle( _proxy_jslib_handle(catPList, (i), 0, 0), 'value', '', 0, 0) == this._catPrivacy)
				{
					 _proxy_jslib_handle(catPList, (i), 0, 0).checked = true;
				}
			}
		}
		this._setSelects(false);				
		
		this._editP.show();
		
		this._updateCatInfo();
		
		evt.preventDefault();		
	},
	
	_setSelects: function(visible) {
		// hide the select elements on the page for IE6
		if(browser.isIE6x)
		{
			var selects =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)("select");
			if(selects)
			{
				for(var i=0;i<selects.length; i++)
				{
					 _proxy_jslib_handle(selects, (i), 0, 0).style.visibility = visible ? "visible" : "hidden";
				}
			}
		}
	},
		
	_popOverCB : function(evt) {
		//check the name/privacy changed and call the web service to update those
		var newName = null;
		var newDesc = null;
		
		this._newPrivacy = null;	
			
		if(this._pEl)
		{
			newName =  _proxy_jslib_handle(getElementsByClassName(this._pEl, "textarea", "popUpEditInput")[0], 'value', '', 0, 0);
			if(newName.length == 0)
			{	
				getElementsByClassName(this._pEl, "span", "cNameErr")[0].style.visibility="visible";
				return;
			}
			if(newName == this._catName)
			{
				newName = null;
			}			
		}
		
		if(this._pEl)
		{
			newDesc =  _proxy_jslib_handle(getElementsByClassName(this._pEl, "textarea", "popUpEditInputDesc")[0], 'value', '', 0, 0);
			
			if(newDesc == this._catDesc)
			{
				newDesc = null;
			}		
		}
		
		//Privacy check
		var catPList = getElementsByClassName(this._pEl, "input", "popUpRadio")
		if(catPList)
		{
			for(var i=0;i<catPList.length;i++)
			{
				if( _proxy_jslib_handle(catPList, (i), 0, 0).checked &&  _proxy_jslib_handle( _proxy_jslib_handle(catPList, (i), 0, 0), 'value', '', 0, 0) != this._catPrivacy)
				{
					this._newPrivacy =  _proxy_jslib_handle( _proxy_jslib_handle(catPList, (i), 0, 0), 'value', '', 0, 0);
				}
			}
		}
						 
		//call the web service
		if(newName || this._newPrivacy || (newDesc != null))
		{
			// Show spinner in the popup
			getElementsByClassName(this._pEl, "div", "popUpSavingCat")[0].style.visibility = "visible";
			
			MySpace.Web.Modules.Friends.Services.FriendsService.UpdateExistingCategory(this._catId,newName,newDesc,this._newPrivacy,this._onCatEdited,this._onCatEditFailed,this);
		}
		else if(!this.OnCatDescEnter)
		{			
			this._popOverCancel();
		}	
		
		this.OnCatDescEnter = false;
	},
	
	_popOverCancel : function(evt) {
		// Hide the spinner
		getElementsByClassName(this._pEl, "div", "popUpSavingCat")[0].style.visibility = "hidden";
		// Hide the text required indicator
		getElementsByClassName(this._pEl, "span", "cNameErr")[0].style.visibility="hidden";
		
		this._setSelects(true);
		this._editP._hide();
	},
	
	_onCatEdited : function(result, userContext, methodName) {
		// Clear error if there is any		
		userContext._pErr.style.display = "none";	
				
		// Hide the spinner
		getElementsByClassName(userContext._pEl, "div", "popUpSavingCat")[0].style.visibility = "hidden";
		if(!result.HasError)
		{
			// Hide the popup
			userContext._popOverCancel();
			
			if(result.Result)
			{
				userContext._catName = result.Result;
			}
			
			if(result.Privacy)
			{
				userContext._catPrivacy = userContext._newPrivacy;
			}
			
			if(result.Description != 'undefined' && result.Description != null)
			{
				userContext._catDesc = result.Description;
			}
			
			userContext._raiseEvent('editCatClicked', {cName: result.Result, cDesc: result.Description, cPriv: result.Privacy});	
		}
		else
		{
			// Show error			
			userContext._pErr.style.display = "block";
			 _proxy_jslib_assign('', userContext._pErr, 'innerHTML', '=', ( result.Result));
		}
	},	
	
	_onCatEditFailed : function(result, userContext, methodName) {
	},
	
    addEditCatClicked : function(handler) {
        this._getEvents().addHandler('editCatClicked', handler);
    },
    
    _getEvents : function() {
        if(!this._events){
            this._events = new (Sys.EventHandlerList)();
        }
        return this._events;
    },
            
    _raiseEvent : function(eventName, eventArgs) {
        var handler = this._getEvents().getHandler(eventName);
        if(handler){
            if(!eventArgs){
                eventArgs = Sys.EventArgs.Empty;
            }
            handler(this, eventArgs);
        }
    }

}

//// Create new category methods

CheckCategoryNameBox = function CheckCategoryNameBox() {
	if ( categoryNameBox != null && 
		categoryNameCountBox != null &&
		 _proxy_jslib_handle(categoryNameBox, 'value', '', 0, 0) != categoryNameBox.defaultValue )
	{	
		categoryNameBox.className = "inp";
 		 _proxy_jslib_assign('', categoryNameCountBox, 'innerHTML', '=', (  _proxy_jslib_handle( _proxy_jslib_handle(categoryNameBox.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0) -  _proxy_jslib_handle(categoryNameBox, 'value', '', 0, 0).length));;		
	}
}

function doBeforePaste(control) {
   maxLength =  _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0);
   if(maxLength)
   {
	   event.returnValue = false;
   }
}

function doPaste(control, outputCtrl) {
   maxLength =  _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0);
    value= _proxy_jslib_assign_rval('', 'value', '=', (  _proxy_jslib_handle(control, 'value', '', 0, 0)), value);
   if(maxLength)
   {
		event.returnValue = false;
		maxLength = parseInt(maxLength);
		var o = control.document.selection.createRange();
		var iInsertLength = maxLength -  _proxy_jslib_handle(null, 'value', value, 0, 0).length + o.text.length;
		var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
		o.text = sData;
	}
	
	 _proxy_jslib_assign('', outputCtrl, 'innerHTML', '=', (   _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0) -  _proxy_jslib_handle(control, 'value', '', 0, 0).length));
}

function limitInput(control, outputCtrl, submitBtn, txtValidCtrl, e) {	
	outputCtrl =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)( outputCtrl );

	if (txtValidCtrl)
	{
		$get(txtValidCtrl).style.visibility = "hidden";
	}
	
	//
	if( _proxy_jslib_handle(control, 'value', '', 0, 0).length >  _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0))
	{
		 _proxy_jslib_assign('', control, 'value', '=', (  _proxy_jslib_handle(control, 'value', '', 0, 0).substring(0, _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0))));
	}
	
	 _proxy_jslib_assign('', outputCtrl, 'innerHTML', '=', (   _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0) -  _proxy_jslib_handle(control, 'value', '', 0, 0).length));
		
	if ( submitBtn && submitFormOnEnter(submitBtn, e) )
		return false;
	
	if( !e ) 
	{
		//if the browser did not pass the event information to the
		//function, we will have to obtain it from the event register
		if( window.event ) 
		{
			//Internet Explorer
			e = window.event;
		} 
		else 
		{
			//total failure, we have no way of referencing the event
			return;
		}
	}	
	
	if( typeof( e.keyCode ) == '46' ) 
	{
		//DOM
		e = e.keyCode;
		 _proxy_jslib_assign('', outputCtrl, 'innerHTML', '=', (   _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0) -  _proxy_jslib_handle(control, 'value', '', 0, 0).length));		
	} 
	else if( typeof( e.which ) == '46' ) 
	{
		//NS 4 compatible
		e = e.which;
		 _proxy_jslib_assign('', outputCtrl, 'innerHTML', '=', (   _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0) -  _proxy_jslib_handle(control, 'value', '', 0, 0).length));		
	} 
	else if( typeof( e.charCode ) == '46' ) 
	{
		//also NS 6+, Mozilla 0.9+
		e = e.charCode;
		 _proxy_jslib_assign('', outputCtrl, 'innerHTML', '=', (   _proxy_jslib_handle( _proxy_jslib_handle(control.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0) -  _proxy_jslib_handle(control, 'value', '', 0, 0).length));
	}	
	else 
	{
		//total failure, we have no way of obtaining the key code
		return;
	}
}

function toggleAllCheckBoxes(on) {    
    var inputs =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('input');
    for(var i = 0; i < inputs.length; i++) {
        if ( _proxy_jslib_handle(inputs, (i), 0, 0).type === "checkbox") {
             _proxy_jslib_handle(inputs, (i), 0, 0).checked = on;
        }
    }
}

function setAll(on) {
    // only iterate if we're turning something off
    if (on)
        return;
    
    var inputs =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('input');
    for(var i = 0; i < inputs.length; i++) {
        if ( _proxy_jslib_handle(inputs, (i), 0, 0).type === "checkbox" &&
             _proxy_jslib_handle(inputs, (i), 0, 0).name === "selectAll") 
        {
              _proxy_jslib_handle(inputs, (i), 0, 0).checked = on;
        }
    }
}

function areAnyChecked() {
    var inputs =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('input');
    for(var i = 0; i < inputs.length; i++) {
        if ( _proxy_jslib_handle(inputs, (i), 0, 0).type === "checkbox") {
            if ( _proxy_jslib_handle(inputs, (i), 0, 0).checked) {
                return true;
            }
        }
    }
    
    return false;
}

function confirmDelete(confirmString, noSelectionString) {
    var selected = false;
    var count = 0;
    
    var inputs =  _proxy_jslib_handle(document, 'getElementsByTagName', '', 1, 0)('input');
    for(var i = 0; i < inputs.length; i++) {
        if ( _proxy_jslib_handle(inputs, (i), 0, 0).type === "checkbox") {
            if ( _proxy_jslib_handle(inputs, (i), 0, 0).checked &&  _proxy_jslib_handle(inputs, (i), 0, 0).id.indexOf("friendid") > -1) {
                selected = true;
                count++;
            }
        }
    }
    
    if (!selected) {
        alert(noSelectionString);
        return false;
    } else {
        confirmString =  _proxy_jslib_handle(confirmString, 'replace', '', 1, 0)("{0}", count);
        return confirm(confirmString);
    }
}

function DeleteCategory(ctrl, catId, confirmationString) {
	var response = confirm(confirmationString);
	
	if (response == true)
	{
		__catPostBack("DELETE:" + catId);
	}
	else
	{
		return false;
	}
}

function __catPostBack(eventArgument) {
	var theForm = document.forms[('aspnetForm')];
	if (!theForm) {
	    theForm = document.aspnetForm;
	}
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
		if(!theForm.__EVENTARGUMENT)
		{
			var eventArgEl = document.createElement('input');
			 _proxy_jslib_handle(eventArgEl, 'setAttribute', '', 1, 0)("type","hidden");
			 _proxy_jslib_handle(eventArgEl, 'setAttribute', '', 1, 0)("name","__EVENTARGUMENT");
			 _proxy_jslib_handle(eventArgEl, 'setAttribute', '', 1, 0)("id","__EVENTARGUMENT");
			theForm.appendChild(eventArgEl);
		}        
         _proxy_jslib_assign('', theForm.__EVENTARGUMENT, 'value', '=', ( eventArgument));
        theForm.submit();
    }
}

function CustomFailureHandler(result, methodName) {
	// error message label
	var errElem = $get("err_name_" + result.CategoryId);
	
	// error indicator	
	$get("name_valid_" + result.CategoryId).style.display = "inline";
	
	if (methodName == "UpdateCategoryName")
	{
		// show edit controls
		$get("edit_name_" + result.CategoryId).style.display = "block";
		$get("char_view_" + result.CategoryId).style.display = "block";
		
		errElem.style.display = "block";
		if (typeof(result) != "undefined" && result.Result != "")
		{
			 _proxy_jslib_assign('', errElem, 'innerHTML', '=', ( result.Result));
		}
	}
	
	if (methodName == "UpdateCategoryPrivacy")
	{
		errElem.style.display = "block";
		 _proxy_jslib_assign('', errElem, 'innerHTML', '=', ( result.Result));
	}
}

function ValidateCreate() {	
	if (  _proxy_jslib_handle(categoryNameBox, 'value', '', 0, 0) == categoryNameBox.defaultValue ||
		 _proxy_jslib_handle(categoryNameBox, 'value', '', 0, 0).length == 0 )
	{
		categoryValidate.style.display = 'inline';
		return false;
	}		
	
	return true;
}


function resizeImage(friendImg, maxWidth, maxHeight) {	
	
	if(friendImg.width > 0 && friendImg.height > 0)
	{
		if(!maxWidth) maxWidth = 70;
		if(!maxHeight) maxHeight = 90;
		
		if(friendImg.height>friendImg.width)
		{
			friendImg.height = maxHeight ;
			friendImg.width = parseInt((friendImg.width * maxHeight)/friendImg.height) ;		
		}
		else
		{
			friendImg.height = parseInt((friendImg.height * maxWidth)/friendImg.width) ;
			friendImg.width = maxWidth;				
		}   
	}     
}

function resizeImageWithId(friendImgId, maxWidth, maxHeight) {
	resizeImage($get(friendImgId), maxWidth, maxHeight);
}

function ModifyViewStatus(linkId, catId, tooltipId, hidemeimgId) {
		var elem = $get(linkId);
		var toolElem = $get(tooltipId);
		var hidemeImg = $get(hidemeimgId);
		
		var isPublic = (elem.getAttribute("IsPublic") == "false") ;
		
		MySpace.Web.Modules.Friends.Services.FriendsService.UpdateMembershipStatus(catId, isPublic);
		if (isPublic) 
		{
			elem.className = "hidemelink";
			hidemeImg.style.display = "none";
			 _proxy_jslib_assign('', elem, 'innerHTML', '=', ( MySpaceRes.FriendCategories.HideMe));
			 _proxy_jslib_handle(elem, 'setAttribute', '', 1, 0)("IsPublic", "true");
			 _proxy_jslib_handle(toolElem, 'setAttribute', '', 1, 0)("IsPublic", "true");			
		} 
		else 
		{
		   elem.className = "unhidemelink";
		   hidemeImg.style.display = "";
		    _proxy_jslib_assign('', elem, 'innerHTML', '=', ( MySpaceRes.FriendCategories.ShowMe));
		    _proxy_jslib_handle(elem, 'setAttribute', '', 1, 0)("IsPublic", "false");
		    _proxy_jslib_handle(toolElem, 'setAttribute', '', 1, 0)("IsPublic", "false");		   
		}
}

// Create Category Class
// ------------------
FriendsCategories.CreateCat = function() {} 
FriendsCategories.CreateCat.registerClass('FriendsCategories.CreateCat');

FriendsCategories.CreateCat = function() {
	 this._charCountCrtl = null;
	 this._catNameCrtl = null;
	 this._reqTxtCtrl = null;
	 this._submitBtn = null;
	 this._tTipC = null;
	 
	 // Disposing Create Category EventHandlers and Objects
	this.CreateCatUnload = function() {
	    $removeHandler(createCatso._catNameCrtl, "beforepaste", createCatso.doBeforePaste);
		$removeHandler(createCatso._catNameCrtl, "blur", createCatso.doBlurBox);
		$removeHandler(createCatso._catNameCrtl, "change", createCatso.limitInput);
		$removeHandler(createCatso._catNameCrtl, "keyup", createCatso.limitInput);
		$removeHandler(createCatso._catNameCrtl, "focus", createCatso.doResetBox);
		$removeHandler(createCatso._catNameCrtl, "keypress", createCatso.limitInput);
		$removeHandler(createCatso._catNameCrtl, "paste", createCatso.doPaste);
		
		$removeHandler(createCatso._submitBtn, "click", createCatso.validateCreate);
	}
}

FriendsCategories.CreateCat.prototype = 
{
	initialize : function(charCountCrtl, catNameCrtl, reqTxtCtrl, catDescId, catDescCharCountId) {		
		FriendsCategories.CreateCat.initializeBase(this);
		this._charCountCrtl = $get(charCountCrtl);
		this._catNameCrtl = $get(catNameCrtl);
		this._reqTxtCtrl = $get(reqTxtCtrl);
		this._submitBtn = $get('createCatBtn');
		
		var catDesc = $get(catDescId)
		
		if (this._charCountCrtl != null && 
			this._catNameCrtl != null &&
			this._reqTxtCtrl != null && 
			this._submitBtn != null)
		{						 			
			this.preventCharInput(this._catNameCrtl, this._charCountCrtl, parseInt( _proxy_jslib_handle( _proxy_jslib_handle(this._catNameCrtl.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0)),true);
			this.preventCharInput(catDesc, $get(catDescCharCountId), parseInt( _proxy_jslib_handle( _proxy_jslib_handle(catDesc.attributes, ("maxLength"), 0, 0), 'value', '', 0, 0)),false);
			$addHandler(this._submitBtn, "click", this.validateCreate);
		}
		
		// create tool tip
		this.createCatTTip();
		
		// 
		Sys.Application.add_unload(this.CreateCatUnload);
	},
	
	preventCharInput : function(inputctrl, limitdispctrl, allowedChars, submitOnEnter) {
			inputctrl.LimitControl = limitdispctrl;
			inputctrl.AllowedChars = allowedChars;
			inputctrl.SubmitOnEnter = submitOnEnter;
			
			$addHandler(inputctrl, "keydown", this.removeEnter);
			$addHandler(inputctrl, "beforepaste", this.doBeforePaste);
			$addHandler(inputctrl, "blur", this.doBlurBox);
			$addHandler(inputctrl, "change", this.limitInput);
			$addHandler(inputctrl, "keyup", this.limitInput);
			$addHandler(inputctrl, "focus", this.doResetBox);
			$addHandler(inputctrl, "keypress", this.limitInput);
			$addHandler(inputctrl, "paste", this.doPaste);			
	},
	
	doBeforePaste : function(evt) {
	   var maxLength = evt.target.AllowedChars;
	   if(maxLength)
	   {
		   event.returnValue = false;
	   }
	},
	
	doBlurBox : function(evt) {	
		if (  _proxy_jslib_handle(evt.target, 'value', '', 0, 0) == "")
		{
			 _proxy_jslib_assign('', evt.target, 'value', '=', ( evt.target.defaultValue));
			Sys.UI.DomElement.addCssClass(evt.target, "grey");			
		}
	},
	
	doPaste : function(evt) {
	   var maxLength = evt.target.AllowedChars;
	   var value =  _proxy_jslib_handle(evt.target, 'value', '', 0, 0);
	   if(maxLength)
	   {
			event.returnValue = false;
			maxLength = parseInt(maxLength);
			var o = evt.target.document.selection.createRange();
			var iInsertLength = maxLength -  _proxy_jslib_handle(null, 'value', value, 0, 0).length + o.text.length;
			var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
			o.text = sData;
		}
		
		 _proxy_jslib_assign('', evt.target.LimitControl, 'innerHTML', '=', (  evt.target.AllowedChars -  _proxy_jslib_handle(evt.target, 'value', '', 0, 0).length));
	},

	doResetBox : function(evt) {
		if ( _proxy_jslib_handle(evt.target, 'value', '', 0, 0) == evt.target.defaultValue)
		{
			 _proxy_jslib_assign('', evt.target, 'value', '=', ( ""));
			Sys.UI.DomElement.removeCssClass(evt.target, "grey");			
		}
	},
	
	removeEnter : function(evt) {
		if ( (!evt.target.SubmitOnEnter && evt.keyCode == 13)) 
		{			
			evt.preventDefault();
			evt.stopPropagation();			
			return;
		}	
	},
	limitInput : function(evt) {	
		if (createCatso._reqTxtCtrl)
		{
			createCatso._reqTxtCtrl.style.display = "none";
		}
		
		
		//
		if( _proxy_jslib_handle(evt.target, 'value', '', 0, 0).length > evt.target.AllowedChars)
		{
			 _proxy_jslib_assign('', evt.target, 'value', '=', (  _proxy_jslib_handle(evt.target, 'value', '', 0, 0).substring(0,evt.target.AllowedChars)));
		}
		
		 _proxy_jslib_assign('', evt.target.LimitControl, 'innerHTML', '=', (  evt.target.AllowedChars -  _proxy_jslib_handle(evt.target, 'value', '', 0, 0).length));
			
		if (evt.target.SubmitOnEnter && !createCatso.submitFormOnEnter(evt))
		{
			return false;
		}	
			
		if( !evt ) 
		{
			//if the browser did not pass the event information to the
			//function, we will have to obtain it from the event register
			if( window.event ) 
			{evt = window.event;}//Internet Explorer 
			else {return;}//total failure, we have no way of referencing the event
		}	
		
		if( typeof( evt.keyCode ) == '46' ) 
		{
			//DOM
			evt = evt.keyCode;
			 _proxy_jslib_assign('', evt.target.LimitControl, 'innerHTML', '=', ( evt.target.AllowedChars -  _proxy_jslib_handle(evt.target, 'value', '', 0, 0).length));		
		} 
		else if( typeof( evt.which ) == '46' ) 
		{
			//NS 4 compatible
			evt = evt.which;
			 _proxy_jslib_assign('', evt.target.LimitControl, 'innerHTML', '=', ( evt.target.AllowedChars -  _proxy_jslib_handle(evt.target, 'value', '', 0, 0).length));
		} 
		else if( typeof( evt.charCode ) == '46' ) 
		{
			//also NS 6+, Mozilla 0.9+
			evt = evt.charCode;
			 _proxy_jslib_assign('', evt.target.LimitControl, 'innerHTML', '=', ( evt.target .AllowedChars -  _proxy_jslib_handle(evt.target, 'value', '', 0, 0).length));
		}	
		else {return;}//total failure, we have no way of obtaining the key code
	},
	
	submitFormOnEnter : function(evt) {				
		var e = evt?evt:window.event;	
		
		if (!e) return true;
			
		if ((e.which == 13) || (e.keyCode == 13))
		{		
			createCatso.validateCreate(evt);
			return false;
		}
		
		return true;
	},
	
	validateCreate : function(evt) {	
		if (  _proxy_jslib_handle(createCatso._catNameCrtl, 'value', '', 0, 0) == createCatso._catNameCrtl.defaultValue ||
			 _proxy_jslib_handle(createCatso._catNameCrtl, 'value', '', 0, 0).length == 0 )
		{
			createCatso._reqTxtCtrl.style.display = "inline";
			createCatso._reqTxtCtrl.style.visibility = "visible";
			
			evt.preventDefault();
			return false;
		}		
		
		$get('SavingCatContainer').style.visibility = "visible";
		return true;
	},
	
	//-----------------------
	// create category client work.
	//SPONSORSHIP CHANGE: Modified for category sponsorship work, revert the changes after sponsorship is over 
	createCatTTip : function() {
		var targetEl = $get("tellAboutCat");
		$create(FriendsCategories.AjaxToolTip,{'targets':[targetEl], 'tTipContent':MySpaceRes.ViewAllFriendsPage.CreateCategoryTooltip, 'tTipCss':'tellAboutTip','tTipPtrCss':'tellAboutTop','tTipTextCss':'tellAboutText','tTipShowOnFocus':0});		
	}
}
var createCatso = new (FriendsCategories.CreateCat)(); ;
_proxy_jslib_flush_write_buffers() ;