/*
 * Quick feedback
 */
function quickFeedback(){
    var pw = new PopWindow({
        optEnabled: true,
        left:0,
        top:0,
        width:500,
        title:"Feedback"
    });
    pw.appendNode(new Element("div").update("hello world"));
}


/*
 * Central notice
 */
var CentralNotice = {
    show: function(content){
        if(!content){
            content="Processing...";
        }
        CentralNotice.update(content);
    },
    hide: function(){
        CentralNotice.getEl().hide();
    },
    update: function(content){
        var noticeEl = CentralNotice.getEl();
        var contentEl = noticeEl.down().down();
        contentEl.update(content);
        var width = document.body.offsetWidth;
        var left = width/2 - noticeEl.getWidth()/2;
        noticeEl.show();
        noticeEl.setStyle({
            "left":left+"px",
            "top":0
        });
    },
    getEl: function(){
        var noticeEl = $("centralNotice");
        if(!noticeEl) {
            noticeEl = new Element("div", {
                id:"centralNotice"
            });
            noticeEl.innerHTML = "<div class='inner'><div class='content'></div></div>";
            document.body.appendChild(noticeEl);
        }
        return noticeEl;
    }
}
function showCentralNoticer(content, noticerID) {
    if(typeof(noticerID)=='undefined') noticerID = "centralNoticer";
    if(typeof(content)=='undefined') content = "Processing...";
    var noticerBox = $(noticerID+"_box");
    var noticerContent = $(noticerID+"_content");
    if(!noticerBox) {
        noticerBox = document.createElement("div");
        noticerBox.className = "centralNoticerBox";
        noticerBox.id = noticerID+"_box";
        noticerContent = document.createElement("div");
        noticerContent.id = noticerID+"_content";
        noticerContent.className = "centralNoticerContent";
        noticerBox.appendChild(noticerContent);
        document.body.appendChild(noticerBox);
    }
    //TODO
    noticerContent.innerHTML = content;
    var width = document.body.offsetWidth;
    var left = width/2 - $(noticerID+"_box").getWidth()/2;
    noticerBox.show();
    noticerBox.setStyle({
        "left":left+"px",
        "top":0
    });

}
function updateCentralNoticer(content, noticerID) {
    if(typeof(noticerID)=='undefined') noticerID = "centralNoticer";
    var noticerBox = $(noticerID+"_content");
    noticerBox.innerHTML = content;
}
function hideCentralNoticer(delay) {
    if(typeof(noticerID)=='undefined') noticerID = "centralNoticer";
    if(typeof(delay)=='undefined') delay = 1;
    delay = delay*1000;
    $(noticerID+"_box").style.display="none";
}

/*
 * Browser version
 * Copyright (c) 2009 leinte & Diigo System.
 */
var BrowserVersion={
    IE:     !!(window.attachEvent && !window.opera),
    Opera:  !!window.opera,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
    MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/),
    getIEVersion: function(){
        var rv = null;
        if (navigator.appName == 'Microsoft Internet Explorer'){
            var ua = navigator.userAgent;
            var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
            if (re.exec(ua) != null)
                rv = parseFloat( RegExp.$1 );
        }
        return rv
    },
    isIE6:  function(){
        var version = BrowserVersion.getIEVersion();
        return version && BrowserVersion.getIEVersion() <= 6
    }
}

/*
 * Pop-up Window
 * Copyright (c) 2009 A.D. & Diigo System.
 * Author: A.D.(allenbobo@gmail.com) 2009-8-25
 *
 * options:
 * 1. left: left of coordinate
 * 2. top: top of coordinate
 * 3. width: the width of pop-up window
 * 4. title: window title
 * 5. root: the relative root element
 * 6. optEnabled: enable save, cancel buttons.
 *
 * Prerequisite:
 * 1. prototype.js
 * 2. var BrowserVersion
 *
 * Usage:
 * 1. Include front-end-utils.js and front-end-utils.css in your requesting page.
 * 2. new PopWindow({...})
 *
 * Example:
 * Create save bookmark pop-up window
 *
 * // create pop-up window
 * pw = new PopWindow({optEnabled: true, left:120, top:0, width:500,
 *           title: "Save Bookmark", root: "leftColumn"});
 *
 * // append pop-up window content
 * pw.appendNode(createSaveItemTemp(args));
 *
 * // init buttons' value and action
 * pw.submitBtn.value = "Save";
 * pw.cancelBtn.value = "Cancel";
 * pw.submit = function(){ submitAction();}
 * pw.cancel = function(){ cancelAction();}
 *
 */
var PopWindow = Class.create({
    initialize: function(options) {
        if(PopWindow.instance){
            PopWindow.instance.hide();
        }
        if($("diigoPopWindow")){
            $("diigoPopWindow").remove();
        }
        PopWindow.instance = this;
        this.selectX = 0;
        this.selectY = 0;
        this.offsetX = options.left || 0;
        this.offsetY = options.top || 0;
        this.width = options.width || 400;
        var titleWord = options.title.blank() ? "&nbsp;" : options.title;
        this.root = options.root || document;
        this.optEnabled = options.optEnabled || false;
        this.dragEnabled = false;
        if(typeof(this.root)=="string" && !this.root.blank()){
            this.root = $(this.root);
        }
        this.window  = new Element("div", {
            id:"diigoPopWindow"
        });
        var inner = new Element("div", {
            id:"diigoPopWindowInner"
        });
        this.title = new Element("div", {
            id:"wTop"
        });
        this.closeLink = new Element("a", {
            id:"wCloseLink",
            href:"javascript:void(0);",
            title:"Close Window"
        });
        this.closeLink.innerHTML = "<img src='/images/close_icon.gif' alt='close' />";
        this.closeLink.onclick = PopWindow.instance.doCancel.bind(this);
        this.title.appendChild(this.closeLink);

        this.titleName = new Element("h3", {
            id:"wTitle"
        }).update(titleWord);
        this.title.appendChild(this.titleName);

        inner.appendChild(this.title);
        this.content = new Element("div", {
            id:"wContent"
        });
        inner.appendChild(this.content);
        this.noticer = new Element("div", {
            id:"wNoticer"
        }).hide();
        inner.appendChild(this.noticer);
        if(this.optEnabled) {
            this.submitBtn = new Element("input", {
                type: "button",
                id:"wSubmit",
                value:"Submit"
            });
            this.submitBtn.onclick = PopWindow.instance.doSubmit.bind(this);
            this.cancelBtn = new Element("input", {
                type: "button",
                id:"wCancel",
                value:"Cancel"
            });
            this.cancelBtn.onclick = PopWindow.instance.doCancel.bind(this);
            this.opt = new Element("div", {
                id:"wOptions"
            });
            this.opt.appendChild(this.submitBtn);
            this.opt.appendChild(this.cancelBtn);
            inner.appendChild(this.opt);
        }
        this.window.appendChild(inner);
        var left = 0; var top = 0;
        if(this.root!=document) {
            var p = Position.cumulativeOffset(this.root);
            left = p[0];
            top = p[1];
        }

        this.window.setStyle({
            left: fixLeft(left+this.offsetX, this.width+15)+"px",
            top: fixTop(top+this.offsetY, this.window.getHeight()+15)+"px",
            zIndex: 10009,
            width: this.width+"px"
        });
        document.body.appendChild(this.window);
        // object embed overlap bug
        if(!PopWindow.shadow) {
            PopWindow.shadow = new Element("div", {
                id: "popWindowShadow"
            });
            PopWindow.hideIframe = new Element('iframe', {
                id: "popWindowHideIframe",
                width:"100%",
                height:"100%"
            });
            PopWindow.shadow.appendChild(PopWindow.hideIframe);
            PopWindow.hideIframe.setAttribute("frameBorder", "0");
            PopWindow.hideIframe.setAttribute("marginheight", "0");
            PopWindow.hideIframe.setAttribute("marginwidth", "0");
            PopWindow.hideIframe.setAttribute("scrolling", "no");
            document.body.appendChild(PopWindow.shadow);
        }
        PopWindow.shadow.setStyle({
            left: fixLeft(left+this.offsetX, this.width+15)+"px",
            top: fixTop(top+this.offsetY, this.window.getHeight()+15)+"px",
            zIndex: 10008,
            width: this.width+10+"px",
            height: this.window.getHeight()+"px"
        });
        PopWindow.shadow.show();
        if(!BrowserVersion.IE || BrowserVersion.getIEVersion()>=8){
            // movable
            document.onmousedown = this.selectmouse.bind(this);
            document.onmouseup=function(){
                this.dragEnabled=false;

            }.bind(this);
            $("wTitle").setStyle({
                "cursor":"move"
            });
        }
    },
    movemouse : function(e) {
        if(this.dragEnabled) {
            var l = !BrowserVersion.IE ? (this.offsetX + e.clientX - this.selectX) : (this.offsetX + event.clientX - this.selectX);
            var t = !BrowserVersion.IE ? (this.offsetY + e.clientY - this.selectY) : (this.offsetY + event.clientY - this.selectY);
            if(l<=0){
                l=0;
            }
            if(t<=0){
                t=0;
            }
            var maxP = Element.getDimensions(document.body);
            if((l+this.window.getWidth()) >= maxP.width){
                l = maxP.width-this.window.getWidth();
            }
            if((t+this.window.getHeight()) >= maxP.height){
                t = maxP.height-this.window.getHeight();
            }
            this.window.setStyle({
                left : l+'px',
                top : t+'px'
            });
            PopWindow.shadow.setStyle({
                left : l+'px',
                top : t+'px'
            });
            return false;
        }

    },
    selectmouse : function(e) {
        var fobj = !BrowserVersion.IE ? e.target : event.srcElement;
        if(fobj.id=="wTitle") {
            this.dragEnabled = true;
            var p = Position.cumulativeOffset(this.window);
            this.offsetX = p[0];
            this.offsetY = p[1];
            this.selectX = !BrowserVersion.IE ? e.clientX : event.clientX;
            this.selectY = !BrowserVersion.IE ? e.clientY : event.clientY;
            document.onmousemove=this.movemouse.bind(this);
            return false;
        }
    },
    show : function(options) {
        if(typeof(options)!="undefined"){
            this.offsetX = options.left || this.offsetX;
            this.offsetY = options.top || this.offsetY;
            this.root = options.root || this.root;
            if(typeof(this.root)=="string" && !this.root.blank()){
                this.root = $(this.root);
            }
            var left = 0; var top = 0;
            if(this.root!=document) {
                var p = this.root.cumulativeOffset();left = p[0];top = p[1];
            }
        }
        this.window.setStyle({
            left: fixLeft(left+this.offsetX, this.width+15)+"px",
            top: fixTop(top+this.offsetY, this.window.getHeight()+15)+"px",
            zIndex: 999,
            width: this.width+"px"
        });
        this.window.show();
        PopWindow.shadow.setStyle({
            left: fixLeft(left+this.offsetX, this.width+15)+"px",
            top: fixTop(top+this.offsetY, this.window.getHeight()+15)+"px",
            zIndex: 998,
            width: this.width+10+"px",
            height: this.window.getHeight()+"px"
        });
        PopWindow.shadow.show();
        this.content.show();
        this.noticer.hide();
        this.title.show();
        this.closeLink.show();
        if(this.optEnabled) {
            this.opt.show();
        }
    },
    hide : function() {
        this.window.hide();
        PopWindow.shadow.hide();
    },
    updateContent : function(html) {
        this.content.innerHTML=html;this.reCalShadowRange();
    },
    appendNode : function(el) {
        if(el){
            this.content.appendChild(el);this.reCalShadowRange();
        }
    },
    doSubmit : function() {
        this.submit();
    },
    doCancel : function() {
        this.hide();
        try{
            this.cancel();
        }catch(e){}
    },
    reCalShadowRange : function() {
        PopWindow.shadow.setStyle({
            height:this.window.getHeight()+"px"
        });
    },
    onLoading : function(msg) {
        msg = msg || "processing...";
        this.noticer.innerHTML = msg;
        this.noticer.className = "wLoading";
        this.noticer.show();
        this.content.hide();
        this.opt.hide();
        this.reCalShadowRange();
    },
    onComplete : function(args) {
        if(args.status=="200"){
            this.noticer.className = "wSuccess";
            msg = args.msg || "done!";
            this.noticer.innerHTML = msg;
            PopWindow.instance.hide();
        }else {
            this.noticer.className = "wFailed";
            msg = args.msg || "failed!";
            this.noticer.innerHTML = msg;
            this.noticer.show();
            this.opt.hide();
            this.content.hide();
            setTimeout("PopWindow.instance.hide()", 5000);
        }
    }
});



/*
 * Avatar Pop-up window
 * Copyright (c) A.D. & Diigo Inc.
 * Author: A.D.(allenbobo@gmail.com) 2009-8-25
 *
 * args:
 * 1. parentID: the parent element ID of avatar element. default is 'main', e.g. 'leftColumn'.
 * 2. togglerClass: in general, it's a class name of avatar
 * 3. delay: default is 500 ms
 *
 * Prerequisite:
 * 1. prototype.js
 * 2. diigo constants. e.g. _GLOBAL_VAR, BOOKMARK_HOST, GROUP_HOST, RESOURCE_HOST, DMS_HOST or MESSAGE_HOST
 * 3. cross_subdomain_ajax.js
 * 4. follow_button.js
 *
 * Usage:
 * 1. Include avatar-pop-up.js and avatar-pop-up.css in your requesting page.
 * 2. Add a classname "avatarPopup" to the avatar element, the element structure is:
 *    <a class='avatarPopup'><img src='avatar.jpg' /></a>
 * 3. Run AvatarPopup.addOnLoadListener(function(){new AvatarPopup()})
 *
 * Example:
 *   <%= javascript_include_tag "../avatar-pop-up/avatar-pop-up"%>
 *   <%= stylesheet_link_tag "../avatar-pop-up/avatar-pop-up"%>
 *   <script type="text/javascript">AvatarPopup.addOnLoadListener(function(){new AvatarPopup()});</script>
 *
 */
var AvatarPopup = Class.create({
    initialize: function(args){
        if(!args){
            args = {};
        }
        if(!args.scope){
            args.scope = "main";
        }
        if(!args.togglerClass){
            args.togglerClass = "avatarPopup";
        }
        var delay = 500;
        if(_GLOBAL_VAR["AvatarUserInfos"]==undefined){
            _GLOBAL_VAR["AvatarUserInfos"] = {};
        }

        $(args.scope).select("."+args.togglerClass).each(function(el){
            el.down().onmouseover = function(){
                clearTimeout(AvatarPopup.timeout);
                el.title = "";
                el.down().alt = "";
                var username = el.down().src.split('/').last().replace(/_\d+\.jpg/, '');
                AvatarPopup.currentUser = username;
                AvatarPopup.timeout = setTimeout(AvatarPopup.loadUserInfos.bind(el, username), delay);
            };
            el.down().onmouseout = function(){
                clearTimeout(AvatarPopup.timeout);
                AvatarPopup.currentUser = null;
                AvatarPopup.timeout = setTimeout(AvatarPopup.hideWindow, delay);
                AvatarPopup.hideLoading();
            }
        });
    }
});

// Init parameters
AvatarPopup.currentLoading = null;
AvatarPopup.currentUser = null;
AvatarPopup.timeout = null;
AvatarPopup.currentFollowUser = null;

// Retrive or create loading Element
AvatarPopup.getLoadingEl = function(){
    var elID = "avatarPopupLoading";
    var el = $(elID);

    if(!el){
        el = new Element("div", {
            "id":elID
        });
        document.body.appendChild(el);
    }

    return el;
}

AvatarPopup.showLoading = function(el){
    var loadingEl = AvatarPopup.getLoadingEl();
    var pos = el.cumulativeOffset();

    loadingEl.show();
    loadingEl.setStyle({
        "left":pos[0]+el.getWidth()+"px",
        "top":pos[1]+el.getHeight()+"px"
    });
}

AvatarPopup.hideLoading = function(){
    var loadingEl = AvatarPopup.getLoadingEl();
    loadingEl.hide();
}

// Load user's infos via AJAX
AvatarPopup.loadUserInfos = function(){
    var el = this;
    var username = $A(arguments)[0];

    // render from cache
    if(_GLOBAL_VAR["AvatarUserInfos"][username]){
        AvatarPopup.showWindow(_GLOBAL_VAR["AvatarUserInfos"][username], el);

    }else if(AvatarPopup.currentLoading==username){
        // AJAX is loading, just waiting
        AvatarPopup.showLoading(el);

    }else{
        AvatarPopup.showLoading(el);
        // AJAX load
        AvatarPopup.currentLoading = username;
        var url = BOOKMARK_HOST+"/user_mana2/load_avatar_popup_infos?username="+username;

        // Use cross sub domain AJAX in group side
        if(AvatarPopup.scenes.inGroup || AvatarPopup.scenes.inMessage) {
            CrossSubDomainAjax.baseDomain = BOOKMARK_HOST.replace(/.*\.diigo\./, 'diigo.');
            CrossSubDomainAjax.request(url, {
                asynchronous:true,
                evalScripts:false,
                onComplete:function(transport){
                    if(transport.status=='200'){
                        var userInfos = transport.responseText.evalJSON();
                        _GLOBAL_VAR["AvatarUserInfos"][userInfos["username"]] = userInfos;
                        AvatarPopup.currentLoading = null;
                        AvatarPopup.hideLoading();
                        AvatarPopup.showWindow(userInfos, el);
                    }
                }
            });
            return false;

        }else{
            new Ajax.Request(url, {
                method: 'post',
                onSuccess: function(transport) {
                    var userInfos = transport.responseText.evalJSON();
                    _GLOBAL_VAR["AvatarUserInfos"][userInfos["username"]] = userInfos;
                    AvatarPopup.currentLoading = null;
                    AvatarPopup.hideLoading();
                    AvatarPopup.showWindow(userInfos, el);
                }
            });
        }
    }
}

// Retrive or create pop-up window
AvatarPopup.getWindowEl = function(){
    var elID = "avatarPopupWindow";
    var el = $(elID);

    if(!el){
        el = new Element("div", {
            "id":elID
        });
        document.body.appendChild(el);
    }

    return el;
}

AvatarPopup.scenes = {
    inGroup: new RegExp(GROUP_HOST).test(self.location.href),
    inMessage: new RegExp((typeof(DMS_HOST)!="undefined" ? DMS_HOST : MESSAGE_HOST)).test(self.location.href),
    inIndividualGroup: new RegExp(GROUP_HOST+"/group/.+").test(self.location.href)
}

AvatarPopup.template = {
    getWindowTemp : function(){

        var content = "<div class='top'></div>"
        + "<div class='content'><div class='inner clearfix'>"
        + "<div class='navi clearfix'>";

        // dynamic prompt link
        if(AvatarPopup.scenes.inIndividualGroup){
            var groupName = self.location.href.match(/\/group\/([\d\-\w]+)/).last();
            content += "<a class='promptNaviLink' href='"+GROUP_HOST+"/group/"+groupName+"/content/user/_USERNAME_' title='View _REALNAME_&#39;s content in group'>View _REALNAME_'s content in group</a>"
        }else if(AvatarPopup.scenes.inMessage){
            content += "<a class='promptNaviLink' href='"+DMS_HOST+"/user/_CAP_USERNAME_' title='View _REALNAME_&#39;s EasyBlog'>View _REALNAME_'s EasyBlog</a>"
        }else{
            content += "<a class='promptNaviLink' href='"+BOOKMARK_HOST+"/profile/_USERNAME_' title='View _REALNAME_&#39;s profile'>View _REALNAME_'s profile</a>"
        }

        content += "<div class='moreNavi'><ul><li class='contextMenu'><a href='javascript:void(0);'>more<b>&#9660;</b></a>"
        + "<ul class='subMenu' style='display:none;width:120px;'>";

        // show profile link when prompted link is NOT profile
        if(AvatarPopup.scenes.inIndividualGroup || AvatarPopup.scenes.inMessage){
            content += "<li><a href='"+BOOKMARK_HOST+"/profile/_USERNAME_'>Profile</a></li>"
        }

        content += "<li><a href='"+BOOKMARK_HOST+"/user/_USERNAME_'>Library</a></li>"
        + "<li><a href='"+BOOKMARK_HOST+"/network/_USERNAME_'>Network</a></li>"
        + "<li><a href='"+BOOKMARK_HOST+"/friends/_USERNAME_'>Friends</a></li>"
        + "<li><a href='"+GROUP_HOST+"/user/_USERNAME_'>Groups</a></li>"
        + "<li><a href='"+BOOKMARK_HOST+"/list/_USERNAME_'>Lists</a></li>"
        + "<li><a href='"+BOOKMARK_HOST+"/cloud/_USERNAME_'>Tags</a></li>"
        + "</ul></li></ul></div></div>"
        + "<div class='leftPart'><div class='avatarFrame'><img src='"+RESOURCE_HOST+"/images/avatar/user/_USERNAME__96.jpg' /></div>"
        + "_FOLLOW_ME_BUTTON_"
        + "</div><!--leftPart-->"
        + "<div class='rightPart'><div class='realname'><b class='_ONLINE_STATUS_' title='_ONLINE_TITLE_'></b>_REALNAME_</div><div class='aboutme'>_ABOUTME_</div></div></div></div>"
        + "<div class='bottom'></div>";

        return content;
    }
}

AvatarPopup.hideContextMenu = function(delay){
    ContextMenu.clearTimeHandler();
    ContextMenu.hideTimeOut = setTimeout(ContextMenu.hideContextMenu, delay);
}

AvatarPopup.showWindow = function(userInfos, el){

    // if loaded user infos not match current mouse-hover avatar, return false.
    if(AvatarPopup.currentUser != userInfos["username"]){
        return false;
    }

    var delay = 1000;
    var windowEl = AvatarPopup.getWindowEl();

    // update template
    var content = AvatarPopup.template.getWindowTemp().replace(/_REALNAME_/g, userInfos["realname"]);
    content = content.replace(/_ABOUTME_/g, userInfos["aboutme"]);
    content = content.replace(/_CAP_USERNAME_/g, userInfos["username"].capitalize());
    content = content.replace(/_USERNAME_/g, userInfos["username"]);
    content = content.replace(/_ONLINE_STATUS_/g, userInfos["online_status"]);
    content = content.replace(/_ONLINE_TITLE_/g, userInfos["online_status"]=='on' ? 'Online' : 'Offline');

    if(userInfos["follow_me"]=="on"){
        var followButton = "<a id='followLink_"+userInfos["user_id"]+"' href='javascript:void(0);' ";
        if(userInfos["follow_status"]=="yes"){
            followButton += "class='followingMark' onclick=\"AvatarPopup.currentFollowUser='"+userInfos["username"]+"';unfollow_confirm("+userInfos["user_id"]+", '"+userInfos["realname"]+"')\" title='You are following "+userInfos["realname"]+". Click to un-follow.'>"
            + "<span><strong>Following</strong></span></a>";
        }else{
            followButton += "class='followButton' onclick=\"AvatarPopup.currentFollowUser='"+userInfos["username"]+"';follow.bind(this)("+userInfos["user_id"]+", '"+userInfos["realname"]+"')\" title='Follow "+userInfos["realname"]+"'>"
            + "<span><strong>Follow Me!</strong></span></a>";
        }
        content = content.replace(/_FOLLOW_ME_BUTTON_/, followButton);
    }else{
        content = content.replace(/_FOLLOW_ME_BUTTON_/, '');
    }

    var pos = el.cumulativeOffset();
    windowEl.update(content);
    windowEl.show();
    windowEl.setStyle({
        "left":fixLeft(pos[0]+el.getWidth()/3, windowEl.getWidth())+"px",
        "top":fixTop(pos[1]+el.getHeight()+2, windowEl.getHeight())+"px"
    });

    new ContextMenu(windowEl.id,{
        eventType:"mouseover"
    });

    var more = windowEl.select(".contextMenu")[0];
    more.onmouseout = function(){
        AvatarPopup.hideContextMenu(delay/2);
    }

    var subMenu = windowEl.select(".subMenu")[0];
    subMenu.setStyle({
        "zIndex":10008
    });
    subMenu.onmouseover = function(){
        clearTimeout(AvatarPopup.timeout);
    }
    subMenu.onmouseout = function(){
        AvatarPopup.timeout = setTimeout(AvatarPopup.hideWindow, delay);
    }
    windowEl.onmouseover = function(){
        clearTimeout(AvatarPopup.timeout);
    }
    windowEl.onmouseout = function(){
        AvatarPopup.timeout = setTimeout(AvatarPopup.hideWindow, delay);
    }
}

AvatarPopup.hideWindow = function(){
    var windowEl = AvatarPopup.getWindowEl();
    windowEl.update("");
    windowEl.hide();
}

AvatarPopup.hide = function(){
    AvatarPopup.hideWindow();
    AvatarPopup.hideLoading();
}

AvatarPopup.followCallback = function(status, follow_status){
    if(status==200){
        var userInfos = _GLOBAL_VAR["AvatarUserInfos"][AvatarPopup.currentFollowUser];
        userInfos["follow_status"] = follow_status;
    }
}