﻿var Ntalker = {
    DOC  : document.documentElement ? document.documentElement : (document.body ? document.body : null),
    UA   : navigator.userAgent.toLowerCase(),
    unKey:"imNt_uLoad_ctWind",
    ctKEY:"imNt_uRdct_msg",
    gpKEY:"imNt_uRdgp_msg",
    imKEY:"imNt_cache_IM",
    tipKEY:"imNt_stip",
    hotKEY:"imNt_hot"
};
Ntalker.version = {
    imxml_version  : "",
    software_name  : "",
    presence_flash : "2.4.2",
    buddylist_flash: "2.4.2",
    webchat_flash  : "2.4.2"
};
Ntalker.variable = {
    openHistoryWindow: false,
    presenceConnet : false,
    ExMsg : [],
    onlineChat     : 10,
    OnFocusWinParam : [],
    OnBlurWinParam  : [],
    autoFocus      : true,
    offlineChatList: [],
    siteid         : null,
    user_id        : null,
    user_name      : null,
    user_sid       : null,
    userparam      : null,
    popupWindow    : null,
    webchatURL     : "",
    scriptPath     : "",
    serverPath     : ""
};
Ntalker.temp = {
    versionValue:false,
    statusValue:false,
    menuTimer            : -1,
    loadedConfig         : false,
    flashServers         : null,
    userStatusServer     : null,
    presenceFlashGoUrl   : null,
    buddylistFlashGoUrl  : null,
    presenceFlash        : null,
    notify_id            : 0,
    userSpanArray        : null,
    resetwintop          : new Array(),
    imSid                : null
};
Ntalker.Config = {
    fSize                :"12px",
    fColor               :"#000000",
    fText                :"",
    logo                 :"",
    toolbarlogo          :"",
    buddylistlogo        :"",
    chatlogo             :"",
    startlogo            :"",
    copyrighturl         :"",
    copyrighttip         :"",
    chatWidth            :514,
    chatHeight           :534,
    IMWidth              :304,
    IMHeight             :(window.screen.height<960 ? 534 : 654),
    IMtabIndex           : 0,
    isPopupWindow        : 0,
    isPopupMode          : false,
    execIMOnlineStatus   : false,
    execRunPresence      : false,
    ConfigFileList       : /sns_5460|discuz61gbkdzy1|bbs60gbk/,
    not_showfloat_sites  : new Array("haiguinet","cnmyspace"),
    not_popupwin_sites   : new Array("bbs_game"),
    notShowFloat         : false,
    customtoolbarButtons : [],     
    General              : false,
    customparams         : [],
    entrytype            : "toolbar",
    layout               : "toolbar",
    cookieTimeout        : 600,   
    getServerURL         : null
};
Ntalker.cache = {
    image_dir: "",
    style_dir: "",
    skin:"",
    _gif:  ["skin","notifybg"],
    _png  : ["notify_userhead","tips","tipsr","notifybg","popmenu","notifybg","ico_state"],
    img:[],
    init:function(){
        try {
            document.execCommand("BackgroundImageCache", false, true);
        } catch(e){}
        return;
        if(this.image_dir.length <= 0) alert("缓存图片失败");
        for(var i=0; i<this._gif.length;i++){
            var image = new Image();image.src = this.image_dir + this._gif[i] + ".gif";this.img[this._gif[i]] = image;}
        for(var i=0; i<this._png.length;i++){
            var image = new Image();image.src = this.image_dir + this._png[i] + ".png";this.img[this._png[i]] = image;}
    }
};
var im_wdkUtil = null;
var im_chat_window_manager = null;
var wdkApplication = null;
var im_myIMWindow = null;
var im_notshow_ad = false;
var im_logger = null;
var PromptWindow = {};
var dzy = null;
var enableDebug = 9;
var IMBrowser = {
    version :(Ntalker.UA.match( /.+(?:firefox|rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
    safari  : /webkit/.test( Ntalker.UA ),
    opera   : /opera/.test( Ntalker.UA ),
    msie    : /msie/.test( Ntalker.UA ) && !/opera/.test( Ntalker.UA ),
    msie56  : parseFloat( Ntalker.UA.substring(Ntalker.UA.indexOf("msie") + 5)) >= 5.5 && parseFloat(Ntalker.UA.substring(Ntalker.UA.indexOf("msie") + 5))<7,
    msie8   : /msie 8.0/.test( Ntalker.UA ) && !/opera/.test( Ntalker.UA ), 
    mozilla : /mozilla/.test( Ntalker.UA ) && !/(compatible|webkit)/.test( Ntalker.UA ),
    firefox : /firefox/.test( Ntalker.UA ),
    firefox2: /firefox/.test( Ntalker.UA ) && ((Ntalker.UA.match( /.+(?:firefox|rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1]).indexOf("2.") > -1,
    chrome  : /chrome/.test( Ntalker.UA ),
    boxModel: document.compatMode=="BackCompat",
    oldModel: /msie/.test( Ntalker.UA ) && !/opera/.test( Ntalker.UA ) && document.compatMode=="BackCompat"
};
var IMcssTag = {
    IntAttr : ["width","height","top","bottom","left","right"],
    addClass: function( el, className ){
        if( !this.hasClass(el, className) ){
            el.className += " " + className;
        }
    },
    removeClass: function( el, className ){
        if(el && el.className.length>0 ){
            var reg = new RegExp( "\\b" + className + "\\b", "gi" );
            el.className = el.className.replace( reg, "" );
        }
    },
    replaceClass:function( el, oldclassName, className){
        this.addClass(el, className);
        this.removeClass(el, oldclassName);
    },
    hasClass: function( el, className ){
        if(!el || !el.className ){
            return false;
        }else{
            var reg = new RegExp( "\\b" + className + "\\b", "gi" );
            return reg.test(el.className);
        }
    },
    css: function (el, attr, value) {
        if(!el) return;
        if(/float/.test(attr)) attr = typeof(el.style.cssFloat)=="undefined" ? "styleFloat":"cssFloat";
        var isInt = null;var _get;
        for(var k in this.IntAttr){
            if(this.IntAttr[k] == attr){isInt=true;break;}}
        if (!value) { 
            if(el.style && el.style[attr]){
                _get = el.style[attr];
            }else{
                if (document.defaultView && document.defaultView.getComputedStyle) {
                    try{
                        var _css = document.defaultView.getComputedStyle(el, "");
                    }catch(e){
                        return;
                    }
                    _get = _css ? _css[attr] : null;
                } else if (el.currentStyle) {
                    _get = el.currentStyle[attr];
                }
            }
            return _get == 'auto' ? null : (isInt&&_get.indexOf("%")==-1 ? parseInt(_get) : _get);
        }else if(el.style){            el.style[attr] = value + (isInt && /^[+\-]?\d+(.\d+)?$/.test(value) ? "px" : "");
        }
    }
};
var IMAnimate = {
    animate:function(el, attr, par, func, curValue, JsAttribute){
        par.start = par.start!=undefined ? par.start : 100;
        par.end   = par.end!=undefined   ? par.end   : 0;
        par.step  = par.step!=undefined  ? par.step  : 10;
        par.attach= par.attach!=undefined ? par.attach: 0;
        par.buffer= par.buffer ? true  : false;
        curValue = curValue!=undefined&&curValue!=null ? curValue : par.start;       
        if(par.buffer){
            var max = par.start>par.end ? par.start : par.end; par.step  = Math.ceil((max-curValue)/5.9999999999999);
        }
        if(attr=="opacity") IMAnimate._alpha(el, curValue);
        else if(JsAttribute){eval("document.getElementById('"+el.id+"')." + attr + "=" + curValue + "");}
        else IMcssTag.css(el, attr, curValue+par.attach );
        curValue += par.step;
        if( (par.start>par.end && curValue<par.end) || (par.start<par.end && curValue>par.end) || par.step==0 ){if(func!=undefined) func();return true;}
        IMAnimate.timer(function(){IMAnimate.animate(el, attr, par, func, curValue, JsAttribute);}, 50);
    },
    _alpha:function(el, curOpa){
        try{
            el.style.MozOpacity = ''+curOpa/100;
            el.style.opacity = ''+curOpa/100;
            el.style.filter = "alpha(opacity:"+curOpa+")";
        }catch(e){}
    },
    timer:function(func,timer){return window.setTimeout(func, timer);}
};
WdkUtil = function(){
    this.Domain  = document.domain;
    this.Path    = "/";
}
_p = WdkUtil.prototype;
_p.setDomain = function(domain){
    if(domain){
        var _ed     = domain.indexOf("/");
        var _len    = domain.length;
        if(_ed>=0){
            this.Domain = domain.substr(0, _ed);
            this.Path   = domain.substr(_ed, _len);
        }else{
            this.Domain = domain.substr(0, _len);
        }
    }
}
_p.GetCookieVal = function(offset){
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}
_p.SetCookie = function(name, value){
    var expdate = new Date();
    var argv = arguments;
    var argc = arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : "/";
    var domain = (argc > 4) ? argv[4] : this.Domain;
    var secure = (argc > 5) ? argv[5]  : false;
    if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
    document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
    +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
    +((secure == true) ? "; secure" : "");
}
_p.GetCookie = function(name){
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return this.GetCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
_p.DelCookie = function(name){
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var domain = this.Domain ? this.Domain : "";
    var path = this.Path ? this.Path : "";
    var cval = this.GetCookie (name);
    document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString() +
    "; path=" + path + "; domain=" + domain;
}
_p.isFunction = function( fn ) {
    return !!fn && typeof fn != "string" && !fn.nodeName && 
        fn.constructor != Array && /function/i.test( fn + "" );
}
_p.isArray = function( o ){
    return Object.prototype.toString.apply(o) === '[object Array]';
}
_p.eventTag = function(ev, tagName, arrt){
    ev = ev || window.event;
    var target = ev.srcElement || ev.target;
    if(tagName){
        while((target.nodeType!=1 || target.tagName.toLowerCase() != tagName.toLowerCase()) && target.parentNode){
            target = target.parentNode;
        }
    }
    return target;
}
_p.Event = {
    listEvents: [],
    addEvent: function( obj, type, fn ) {        if (obj.addEventListener) {
            obj.addEventListener( type, fn, false );
            this.listEvents.push(arguments);
        }
        else{
            obj.attachEvent( "on"+type, fn);
            this.listEvents.push(arguments);
        }
    },
    removeEvent: function( obj, type, fn ){        if( obj.removeEventListener ){
            obj.removeEventListener(type, fn, false);
        }
        else{
            obj.detachEvent("on"+type, fn) ;
        }
    },
    flush : function(){
        var i, item;
        for(i = this.listEvents.length - 1; i >= 0; i = i - 1){
            item = this.listEvents[i];
            if(item[0].removeEventListener){
                item[0].removeEventListener(item[1], item[2], item[3]);
            };
            if(item[1].substring(0, 2) != "on"){
                item[1] = "on" + item[1];
            };
            if(item[0].detachEvent){
                item[0].detachEvent(item[1], item[2]);
            };
            item[0][item[1]] = null;
        };
    }
};
_p.EventMechanism = function(event) {
    var _event = this.event = event || window.event;
    this.target = (function() {var target = _event.target || _event.srcElement;while (target && target.nodeType == 3) {target = target.parentNode;}return target;})();
    this.stop = function() {return this.stopPropagation().preventDefault();}
    this.stopPropagation = function() {if (this.event.stopPropagation) this.event.stopPropagation();else this.event.cancelBubble = true;return this;}
    this.preventDefault = function() {if (this.event.preventDefault) this.event.preventDefault();else this.event.returnValue = false;return this;}
}
_p.$ = function(El){
    if(typeof(El)=='object' || !El) return El;
    return(document.getElementById ? document.getElementById(El)
            : document.all ? document.all[El]
            : null);
};
_p.$$ = function(selector, pe) {
    var q = /^\s+(\w+)$|^#(\w+)$|^\.(\w+)$|^\$(\w+)$/;var se  = selector || document;
    var a = [];pe = pe ? pe : document;
    pe = this.isArray(pe) ? pe[0] : pe;
    if ( se.nodeType ) return [se];
    else if ( typeof(se) == "string" ) {
        var all = (document.all && pe==document)? document.all : pe.getElementsByTagName("*");var m = q.exec( se );
        if (m){
            if (m[1]) return pe.getElementsByTagName(m[1]);
            else if (m[2]) return [document.getElementById(m[2])];
            else if (m[3]){var a = [];var cn = m[3].replace(/\-/g, "\\-");var reg= new RegExp("\\b" + cn + "\\b");for(var i=0; i<all.length; i++){if(reg.test(all[i].className)) a.push(all[i]);}return a;}
            else return se;
        }
        else if(se.indexOf(",")!=-1 ){
            arre = se.split(",");
            for(var i=0;i<arre.length; i++){
                if(arre[i]){
                    var ta = this.$$(arre[i], pe);
                    for(var j=0; j<ta.length; j++){
                        a.push(ta[j]);
                    }
                }
            }
            return a;
        }
        else if(se=="*") return all; else return [];
    }
}
_p.thisMovie = function(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}
_p.scroll = function(){
    var wh = this.viewRect.get(window).h;
    if(Ntalker.DOC.scrollHeight>wh)
        return true;
    else
        return false;
}
_p.ArrayToString = function(array){
    if(!this.isArray(array)) return;
    var strOut = "";for(var k in array){strOut += k + ":" + array[k] + ";";}return strOut;
}
_p.StringToArray = function(string){
    if(string=="" || typeof(string) != "string") return;
    var arrOut = [];var _atp = string.split(";");for(var i=0; i<_atp.length; i++){if(_atp[i]){var _t = _atp[i].split(":");arrOut[_t[0]] = _t[1];}}return arrOut;
}
_p.inArray = function(array, item){
    for(var i=0; i<array.length; i++){
        if(array[i]==item) return true;
    }
    return false;
}
_p.viewRect = {
    x:0,y:0,w:0,h:0,
    get: function(el, isupdate){
        el = typeof(el)=='string' ? this.getEl(el) : el;
        if( !el || el==window || el==document ){
            this._getViewPortRect();
            return {x:this.x, y:this.y, w:this.w, h:this.h};
        }
        else{
            if( (document.compatMode=="BackCompat" && IMBrowser.msie) ||
                (document.compatMode=="CSS1Compat" && IMBrowser.msie56)
              ){ 
                return {x:this.getX(el), y:this.getY(el),w:this.getW(el), h:this.getH(el)};
            }else{
                this._getViewPortRect();
                var _x = this.getX(el) + this.x;
                var _y = this.getY(el) + this.y;
                return {x:_x, y:_y,w:this.getW(el), h:this.getH(el)};
            }
        }
    },
    _getViewPortRect: function(obj){
        this.x = window.pageXOffset ? window.pageXOffset :
                                    (document.documentElement&&document.documentElement.scrollLeft ? document.documentElement.scrollLeft :
                                    (document.body ? document.body.scrollLeft : 0) );
        this.y = window.pageYOffset ? window.pageYOffset :
                                    (document.documentElement&&document.documentElement.scrollTop ? document.documentElement.scrollTop :
                                    (document.body ? document.body.scrollTop : 0) );
        this.w = window.innerWidth ? window.innerWidth :
                                    (document.documentElement&&document.documentElement.clientWidth ? document.documentElement.clientWidth :
                                    (document.body ? document.body.clientWidth : 0) );
        this.h = window.innerHeight ? window.innerHeight :
                                    (document.documentElement&&document.documentElement.clientHeight ? document.documentElement.clientHeight :
                                    (document.body ? document.body.clientHeight : 0) );
    },
    getX:function(el){
        el = typeof(el)=='string' ? this.getEl(el) : el;
        var offset=el.offsetLeft;
        if(el.offsetParent!=null) offset+=this.getX(el.offsetParent);
        return offset;
    },
    getY:function(e){
        el = typeof(e)=='string' ? this.getEl(e) : e;
        var offset=el.offsetTop;
        if(el.offsetParent!=null) offset+=this.getY(el.offsetParent);
        return offset;
    },
    getW:function(el){
        el = typeof(el)=='string' ? this.getEl(el) : el;
        return(el ? (el.offsetWidth || (el.style ? el.style.pixelWidth : 0) || 0) : 0);
    },
    getH:function(el){
        el = typeof(el)=='string' ? this.getEl(el) : el;
        return(el ? (el.offsetHeight || (el.style ? el.style.pixelHeight: 0) || 0) : 0);
    },
    getEl:function(el){
        return(document.getElementById ? document.getElementById(el)
            : document.all ? document.all[el]
            : null);
    }
};
_p.checkScript = function(scriptSrc){
    var scripts = window.document.getElementsByTagName("script");
    var r = /[a-z_0-9\-]+\.js/;var cf = r.exec(scriptSrc);
    for(var i=0; i<scripts.length; i++){
        var s = scripts[i].getAttribute("src");if(s){var f = r.exec(s);if(f && f[0] == cf) return true;}
    }
    return false;
};
_p.createScript = function(scriptSrc, charset, check){
    if( (check && this.checkScript(scriptSrc)) || typeof(scriptSrc)=='undefined' )
        return;
    var script  = window.document.createElement("script");
    document.getElementsByTagName("HEAD")[0].appendChild(script);
    script.type     = "text/javascript";
    script.language = "javascript";
    script.src      = scriptSrc;
    if(charset) script.charset  = charset;    return true;
};
_p.createCSS = function(cssFile){
    var head = document.getElementsByTagName("HEAD")[0];
    var css = document.createElement("link");
    head.appendChild(css);
    css.type= 'text/css';
    css.rel = 'stylesheet';
    css.href= cssFile;
};
_p.createDom = function(elDom, toElement){
    toElement = toElement ? toElement
                : (document.getElementsByTagName ? document.getElementsByTagName("body")[0]
                : (document.body || null));
    if(!toElement){return;}
    if(toElement.insertAdjacentHTML && arguments[2]){
        var where = arguments[2] ? arguments[2].toLowerCase() : "afterbegin";
        html  = '<' + elDom.name;
        for(var k in elDom){if(k && k!='name')  html += ' '+(k=="className" ? "class" : k)+'="' + elDom[k] + '"';}
        html  += '></'+elDom.name+'>';
        switch(where){
            case "beforebegin":
                toElement.insertAdjacentHTML('BeforeBegin', html);
                return toElement.previousSibling;
            case "afterbegin":
                toElement.insertAdjacentHTML('AfterBegin', html);
                return toElement.firstChild;
            case "beforeend":
                toElement.insertAdjacentHTML('BeforeEnd', html);
                return toElement.lastChild;
            case "afterend":
                toElement.insertAdjacentHTML('AfterEnd', html);
                return toElement.nextSibling;
            default :
                toElement.insertAdjacentHTML('AfterBegin', html);
                return toElement.firstChild;
        }
    }else if(typeof toElement.innerHTML != "undefined" && document.createElement && toElement.appendChild){
        if(/text/.test(elDom.name.toLowerCase())){
            var _El = document.createTextNode(elDom.text);
        }else{
            var _El = document.createElement(elDom.name);
            for(var k in elDom){
                if(elDom[k] && k!="name"){
                    switch(k){
                        case "className": _El.className = elDom[k];break;
                        case "style": _El.style.cssText = elDom[k];break;
                        default : _El.setAttribute(k, elDom[k]);
                        break;
                    }
                }
            }
        }
        toElement.appendChild(_El);
        return _El;
    }else{
        html  = '<' + elDom.name;
        for(var k in elDom){if(k && k!='name')  html += ' '+(k=="className" ? "class" : k)+'="' + elDom[k] + '"';}
        html  += '></'+elDom.name+'>';
        toElement.innerHTML += html;
        var _childNodes = toElement.getElementsByTagName(elDom.name);
        return _childNodes[(_childNodes.length-1)];
    }
}
_p.insertAfter = function(newElement,targetElement) {  
    var parent = targetElement.parentNode;  
    if (parent.lastChild == targetElement)
        parent.appendChild(newElement);  
    else
        parent.insertBefore(newElement,targetElement.nextSibling);  
}
_p.removeChildNodes = function(el, childNodetagName){
    if(!el) return;
    var Nodes = childNodetagName ? el.getElementsByTagName(childNodetagName) : el.childNodes;
    for(var i=0; i<Nodes.length;i++){
        var a = Nodes[i].attributes;
        for(var id in a){
            if(typeof(a[id])=="function"){
                if(IMBrowser.msie) eval("el."+id+"=null");
                else{el.removeAttribute(id);}
            }
        }
        this.removeChildNodes(Nodes[i], childNodetagName);
        el.removeChild(Nodes[i]);
    }
}
_p.insertHtml = function(where, el, html) {
    where = where.toLowerCase();
    if (el.insertAdjacentHTML) {
        switch (where) {
            case "beforebegin":el.insertAdjacentHTML('BeforeBegin', html);return el.previousSibling;
            case "afterbegin":el.insertAdjacentHTML('AfterBegin', html);return el.firstChild;
            case "beforeend":el.insertAdjacentHTML('BeforeEnd', html);return el.lastChild;
            case "afterend":el.insertAdjacentHTML('AfterEnd', html);return el.nextSibling;
        }
        throw 'Illegal insertion point -> "' + where + '"';
    }
    var range = el.ownerDocument.createRange();
    var frag;
    switch (where) {
    case "beforebegin":range.setStartBefore(el);frag = range.createContextualFragment(html);el.parentNode.insertBefore(frag, el);return el.previousSibling;
    case "afterbegin":
        if (el.firstChild) {
            range.setStartBefore(el.firstChild);frag = range.createContextualFragment(html);el.insertBefore(frag, el.firstChild);return el.firstChild;
        } else {
            el.innerHTML = html;return el.firstChild;
        }
    case "beforeend":
        if (el.lastChild) {
            range.setStartAfter(el.lastChild);frag = range.createContextualFragment(html);el.appendChild(frag);return el.lastChild;
        } else {
            el.innerHTML = html;return el.lastChild;
        }
    case "afterend":range.setStartAfter(el);frag = range.createContextualFragment(html);el.parentNode.insertBefore(frag, el.nextSibling);return el.nextSibling;
    }
    throw 'Illegal insertion point -> "' + where + '"';
}
_p.cutText = function(str, len, ext){
    var l = 0, ml =len*2, cutstr="";
    if(this.lenText(str) <= ml){
        return this.lenText(str)%2>0 ? str+" " : str;
    }else{
        for(var i=0; i<str.length; i++){
            if(str.charCodeAt(i)>255){ l += 2;}else{ l += 1;}
            if(l==ml || (ext&&l==ml-2) ){
                cutstr = str.substring(0, i+1) + (ext?"..":"");
                break;
            }else if(l>ml || (ext&&l>ml-2)){
                cutstr = str.substring(0, i)+" " + (ext?"..":"");
                break;
            }
        }
         return cutstr;
    }
}
_p.lenText = function(str){
    var t = 0;
    for(var i=0;i<str.length;i++){
        if(str.charCodeAt(i)>255) t += 2;
        else t += 1;
    }
    return t;
}
_p.EncodeSpecialChar = function(strSource){
    var strSour = strSource;
    if(strSour.length==0) return strSour;
    strSour = strSour.replace(/&/g,"＆"); 
    strSour = strSour.replace(/\'/g,"’");
    strSour = strSour.replace(/\"/g,"“");
    strSour = strSour.replace(/</g,"《");
    strSour = strSour.replace(/>/g,"》");
    strSour = strSour.replace(/%/g,"％");
    strSour = strSour.replace(/\\/g,"\\\\");
    return strSour;
}
_p.disposeFlashObj = function(flashObj){    if(!flashObj)
        return;
    for(var id in flashObj){
        if(typeof(flashObj[id]) == "function"){
            if(IMBrowser.msie)
                eval("flashObj."+id+"=null");
            else
                flashObj.removeAttribute(id);
        }
    }
};
_p.onlyOne = function(key, dtyp, timer){
    if(im_wdkUtil.GetCookie(key)===key){
        return false;
    }else{
        var d = new Date();var od = new Date();
        switch(dtyp){
            case "d": d.setDate(d.getDate() + timer);d.setHours(0);d.setMinutes(0);d.setSeconds(0);break;
            case "h": d.setHours(d.getHours() + timer);d.setMinutes(0);d.setSeconds(0);break;
            case "m": d.setMinutes(d.getMinutes() + timer);d.setSeconds(0);break;
            case "s": d.setSeconds(d.getSeconds() + timer);break;
            default : im_wdkUtil.SetCookie(key, key); return;
        }
        var t = (d.getTime() - od.getTime())/1000;
        im_wdkUtil.SetCookie(key, key, t);
        return true;
    }
};_p.createFunction = function(obj,strFunc){
      var args=[];if(!obj)obj=window;
      for(var i=2;i<arguments.length;i++)args.push(arguments[i]);
      return function(){obj[strFunc].apply(obj,args);}
};
_p.lt = function(ver, bver){
    var V,_ver   = ver+".0.0";
    var bV,_bver = bver+".0.0";
    V = _ver.split(".");
    bV= _bver.split(".");
    V[0]  = parseInt(V[0], 10); V[1] = parseInt(V[1], 10) || 0;  V[2] = parseInt(V[2], 10) || 0;
    bV[0] = parseInt(bV[0], 10);bV[1] = parseInt(bV[1], 10) || 0;bV[2] = parseInt(bV[2], 10) || 0;
    return (V[0] < bV[0] || (V[0] == bV[0] && V[1] < bV[1]) || (V[0] == bV[0] && V[1] == bV[1] && V[2] < bV[2])) ? true: false;
}
_p.ready = function(fn, dom){
    var isReady = false,d = dom ? dom : window.document,done = function(){
        if(!isReady){
            isReady = true;
            fn.apply(document,arguments);
        }
    };
    if ( d.addEventListener && !IMBrowser.opera)
        d.addEventListener( "DOMContentLoaded", done, false );
    if ( IMBrowser.msie && window == top ) (function(){
        if (isReady) return;
        try {
            d.documentElement.doScroll("left");
        } catch( e ) {
            setTimeout( arguments.callee, 0 );
            return;
        }
        done();
    })();
    if ( IMBrowser.opera )
        document.addEventListener( "DOMContentLoaded", function () {
            if (isReady) return;
            for (var i = 0; i < document.styleSheets.length; i++)
                if (document.styleSheets[i].disabled) {
                    setTimeout( arguments.callee, 0 );
                    return;
                }
            done();
        }, false);
    if ( IMBrowser.safari ) {
        var numStyles;
        (function(){
            if (isReady) return;
            if ( document.readyState != "loaded" && document.readyState != "complete" ) {
                setTimeout( arguments.callee, 0 );
                return;
            }
            if ( numStyles === undefined )
                numStyles = im_wdkUtil.$$("style, link").length;
            if ( document.styleSheets.length != numStyles ) {
                setTimeout( arguments.callee, 0 );
                return;
            }
            done();
        })();
    }
};
var IM_loadScript = function(src, charset, check, callback) {
    if(check && im_wdkUtil.checkScript(src))
        return;
    var script = document.createElement("script");
    if(script.addEventListener){
        script.addEventListener("load", callback, false);
        script.addEventListener("error", callback,false);
    }else if(script.attachEvent)
        script.attachEvent("onreadystatechange",  function(){IM_loadScript.callbackIE(callback);});
    script.src      = src;
    script.type     = "text/javascript";
    script.language = "javascript";
    if(charset) script.charset  = charset;
    document.getElementsByTagName("head")[0].appendChild(script);  
}  
IM_loadScript.callbackIE = function(callback) {  
    var target = window.event.srcElement;  
    if(target.readyState == "loaded")  
    callback.call(target);  
};
function im_initim(){
    var scriptobjs = window.document.getElementsByTagName("script");
    var scriptobj  = scriptobjs[scriptobjs.length - 1];
    var scriptpath = scriptobj.getAttribute("src");
    var _var       = Ntalker.variable;
    if(scriptpath && scriptpath.length>0){
        var pos = scriptpath.lastIndexOf("/");
        if(pos>=0)
            _var.scriptPath = scriptpath.substring(0,pos);
        else
            _var.scriptPath = "";
        var pos = scriptpath.indexOf("http://");
        if(pos>0){
            var pos2 = scriptpath.indexOf("/", pos+2);
            if(pos2>pos)
                _var.serverPath = scriptpath.substring(0,pos2);
        }
        else
            _var.serverPath = "";
    }
    else{
        _var.scriptPath = "";
        _var.scriptPath = "";
    }
    if(!Ntalker.cache.image_dir){
        Ntalker.cache.image_dir = _var.scriptPath+"/images/";
        Ntalker.cache.style_dir = _var.scriptPath+"/images/";
    }
    im_wdkUtil = new WdkUtil();
    im_wdkUtil.setDomain();
    im_wdkUtil.createCSS(_var.scriptPath+"/images/public.css");
    im_wdkUtil.createScript(_var.scriptPath+"/openimwindow_v2.js", "utf-8", true);
    im_wdkUtil.createDom({name:"div", id:"im_popMenuid", style:"left:-100px;top:-100px;"}, null, 'afterbegin');
}
im_initim();
function im_getIMOnlineStatus(siteid, webchaturl){
    createGestFlashConnet(siteid, Ntalker.Config.isPopupMode);
    if(Ntalker.temp.loadedConfig==false && !im_wdkUtil.checkScript(Ntalker.variable.scriptPath + "/configjs/config_"+siteid+".js") ){
        IM_loadScript(Ntalker.variable.scriptPath + "/configjs/config_"+siteid+".js", "utf-8", true, function(){
            if(typeof(Ntalker_Config) == 'undefined'){
                im_getIMOnlineStatus(Ntalker.variable.siteid);
            }
        });
        Ntalker.temp.loadedConfig = true;
        return;
    }
    Ntalker.Config.execIMOnlineStatus = true;
    var _cache     = Ntalker.cache;
    var _cfg       = Ntalker.Config;
    var _win       = Ntalker.win;
    var _var       = Ntalker.variable;
    if(typeof(Ntalker_Config) != 'undefined'){
        if(Ntalker_Config["style_dir"]) _cache.style_dir += Ntalker_Config["style_dir"];
        if(Ntalker_Config["image_dir"]) _cache.image_dir += Ntalker_Config["image_dir"];
        if(Ntalker_Config["image_dir"]) _cache.skin = Ntalker_Config["skin"];
        _cache.init();
        if(Ntalker_Config["Chat"]){
            _cfg.chatWidth        = Ntalker_Config["Chat"].width;
            _cfg.chatHeight       = Ntalker_Config["Chat"].height;
        }
        if(Ntalker_Config["IM"]){
            _cfg.IMWidth          = Ntalker_Config["IM"].width;
        }
        _cfg.logo             = Ntalker_Config['logo'].publiclogo ? _var.scriptPath + "/images/" + Ntalker_Config['logo'].publiclogo : _cache.image_dir + "logo.gif";
        _cfg.buddylistlogo    = Ntalker_Config['logo'].buddylistlogo? siteid+"/logo_big.png":"";
        _cfg.chatlogo         = Ntalker_Config['logo'].chatlogo? siteid+"/logo_small.png":"";
        _cfg.startlogo        = Ntalker_Config['logo'].startlogo? siteid:"ntalker_skin1";
        _cfg.toolbarlogo      = Ntalker_Config['logo'].toolbarlogo ? _var.scriptPath + "/images/" + Ntalker_Config['logo'].toolbarlogo : null;
        _cfg.copyrighturl     = Ntalker_Config['logo'].copyrighturl ? Ntalker_Config['logo'].copyrighturl : null;
        _cfg.copyrighttip     = Ntalker_Config['logo'].copyrighttip ? Ntalker_Config['logo'].copyrighttip : null;
        if( Ntalker_Config['config'] )
            _cfg.customparams     = Ntalker_Config['config'];
        if( Ntalker_Config['customButtons'] ){
            _cfg.customtoolbarButtons = Ntalker_Config['customButtons'];
        }        var _Btns = _cfg.customtoolbarButtons;
        for(var k in _Btns){
            if(_Btns[k] && _Btns[k].style){
                _Btns[k].style = _Btns[k].style.replace("{$sourcepath$}", Ntalker.variable.scriptPath + "/images/");
            }
            if(_Btns[k] && _Btns[k].url){
                _Btns[k].url = _Btns[k].url.replace("{$destid}", Ntalker.variable.user_id);
                _Btns[k].url = _Btns[k].url.replace("{$username}", Ntalker.variable.user_name);
            }
        }
    }
    else if(true){
        _cache.init();
        _cache.style_dir += "ntalker_skin1/";
        _cache.image_dir += "ntalker_skin1/";
        _cfg.startlogo    = "ntalker_skin1";
        _cfg.logo         = _cache.image_dir + "logo.gif";
        _cfg.customparams = {enblebuddyentry: 1,floatpos:"right",intact:0,show_popmenu:1,show_tooltip:1,hiddenmode:0,createblank:0,enablegroup:0,enablechat:1,enablehot:1,showtoolbar:0};
    }
    if(Ntalker.Config.customparams["hiddenmode"]) return;
    if(Ntalker.Config.customparams["enblebuddyentry"] && Ntalker.Config.customparams['showtoolbar']){
        im_wdkUtil.createCSS(Ntalker.cache.image_dir + "toolbar_"+Ntalker.Config.customparams["floatpos"]+".css");        IMToolBar.init();
    }
    if(Ntalker.Config.execRunPresence){
        var _var       = Ntalker.variable;
        im_runPresence(_var.userparam, _var.siteid, _var.user_id, _var.user_name, _var.user_sid, '', '', Ntalker.Config.customparams)
    }
    StartGetGroupEntry();
}
function im_runPresence(userparam, siteid, userid, username, sessionid, flashserver, webchatpageurl, customParams) {
    var _cache     = Ntalker.cache;
    var _cfg       = Ntalker.Config;
    var _win       = Ntalker.win;
    var _var       = Ntalker.variable;
    _var.userparam = userparam;
    _var.siteid    = siteid;
    _var.user_id   = userid;
    _var.user_name = username;
    _var.user_sid  = sessionid;
    if(customParams && typeof customParams =="object"){
        for(var k in customParams){
            if(typeof(_cfg.customparams[k]) != "undefined")
                _cfg.customparams[k] = customParams[k];
        }
    }else if(customParams && typeof customParams == "string"){
        var aParam = customParams.split(";")
        for(var i in aParam){
            if(aParam[i] && aParam[i].indexOf(":")){
                var a = aParam[i].split(":");
                k = a[0];v = a[1];
                if(typeof(_cfg.customparams[k]) != "undefined")
                    _cfg.customparams[k] = v=="false" ? false : v=="true"  ? true : v;
            }
        }
    }
    _cfg.customparams["show_tooltip"] = im_wdkUtil.onlyOne(Ntalker.tipKEY, "d", 1)&&_cfg.customparams["show_tooltip"] ? true : false;
    if(typeof(userparam)=='undefined' || !userparam || userparam.length==0){
        userparam = username;
    }
    if(!userid || userid==0 || !Ntalker.Config.execIMOnlineStatus){
        Ntalker.Config.execRunPresence = true;
        return;
    }    if( !Ntalker.Config.customparams['showtoolbar']){
        im_wdkUtil.createCSS(Ntalker.cache.image_dir + "/toolbar_"+Ntalker.Config.customparams["floatpos"]+".css");        IMToolBar.init();
    }
    im_changeFlashConnet();
    im_runPresenceStart();
}function im_csdnInit(){
    Ntalker.variable.siteid = "csdn";
    im_getIMOnlineStatus(Ntalker.variable.siteid);
    var userid = im_wdkUtil.GetCookie("UserName");
    if(!userid || userid.length==0)
        return;
    var username = userid;
    var sid = im_wdkUtil.GetCookie("_user_sid");
    im_runPresence("csdn", Ntalker.variable.siteid, userid, username, sid, "", "", ""); 
}function im_connectIM(siteid, userid, username, sessionid, userparam, customParams, param1, param2){    im_getIMOnlineStatus(siteid);
    im_runPresence(userparam, siteid, userid, username, sessionid, "", "", customParams);    
}
function createGestFlashConnet(siteid, popup){
    if(Ntalker.temp.createFlash)
        return;
    Ntalker.temp.createFlash = true;
    Ntalker.variable.siteid = siteid;
    var flashvars = "siteid=" + siteid;
    flashvars += "&ispopup=" + (popup ? "1" : "0");
    var flashurl  = Ntalker.variable.scriptPath+"/impresence.swf";
    if(window.location.pathname.indexOf("window.html")>0 ) flashurl += "?rnd="+Math.round(Math.random()*10000);
    if(IMBrowser.msie){
        var flashnodehtml = '<div id=\"wdk_mini_state\" style=\"display:none; \"></div>'
                          + '<div id="im_presence_div" style=\"position:absolute;z-index:9996; top: -200px;\">'
                          + '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28" '
                          + ' id="impresenceflash" width="1" height="1"> '
                          + '    <param name="movie" value="'+flashurl+'" /> '
                          + '    <param name="allowscriptaccess" value="always" /> '
                          + '    <param name="flashvars" value="'+flashvars+'" /> '
                          + '</object>'
                          + '</div>' ;
        if(window.location.pathname.indexOf("window.html")>0 )
            document.body.insertAdjacentHTML('BeforeEnd', flashnodehtml);
        else
            document.write(flashnodehtml);
    }
    else{
        if(window.location.pathname.indexOf("window.html")>0 ){
            im_wdkUtil.createDom({name:"div", id:"wdk_mini_state",style:"display:none;"});
            var divDOM = im_wdkUtil.createDom({name:"div", id:"im_presence_div", style:"position:absolute;z-index:9996; top: -200px;"});
            var flashDOM = document.createElement("embed");
            flashDOM.src               = flashurl;
            flashDOM.id                = "impresenceflash";
            flashDOM.width             = 1;
            flashDOM.height            = 1;
            flashDOM.setAttribute("type",              "application/x-shockwave-flash");
            flashDOM.setAttribute("pluginspage",       "http://www.macromedia.com/go/getflashplayer");
            flashDOM.setAttribute("flashvars",         flashvars);
            flashDOM.setAttribute("allowscriptaccess", "always");
            divDOM.appendChild(flashDOM);
        }else{
            var flashnodehtml = '<div id=\"wdk_mini_state\" style=\"display:none; \"></div>'
                          + '<div id="im_presence_div" style=\"position:absolute;z-index:9996; top: -200px;\">'
                          + '   <embed src="'+flashurl
                          + '" id="impresenceflash" width="1" height="1" flashvars="'+flashvars+'" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> '
                          + '   </embed>'
                          + '</div>' ;
            document.write(flashnodehtml);
        }
    }
}
function fIM_presenceFlashReady(){    IMAnimate.timer(function(){
        im_changeFlashConnet();
        StartGetUsersStatus();
        if(Ntalker.Config.isPopupWindow == 1){
            IM_initPopuWindowScript();
        }
        if(im_wdkUtil.$("impresenceflash") && im_wdkUtil.$("impresenceflash").setPageFocus){
            im_wdkUtil.$("impresenceflash").setPageFocus(true);        }
    }, 50);
    return true;
}
function fIM_setPackageVersion(packageVersion, bbsType, hotserver){    Ntalker.version.imxml_version = packageVersion;
    Ntalker.version.software_name = bbsType;
    if(!hotserver) return;
    Ntalker.temp.hotserver = hotserver + "?query=havasitehot&siteid="+Ntalker.variable.siteid;
    if(Ntalker.Config.customparams['enablehot'] && !im_wdkUtil.lt(packageVersion,"2.0.0")){
        Ntalker.temp.versionValue = true;        var serverkey = Ntalker.hotKEY+Ntalker.variable.user_id+"_ck";
        var checkKey  = im_wdkUtil.GetCookie(serverkey);
        if((checkKey=="" || checkKey==null || typeof(checkKey)=="undefined") && Ntalker.temp.statusValue){
            im_wdkUtil.SetCookie(serverkey, "1", 2*60*60);
            im_wdkUtil.createScript(Ntalker.temp.hotserver);
        }else if(checkKey=="1"){            sIM_checkCreateHot("1", "N");
        }
    }
}
function sIM_checkCreateHot(onOff, isService){
    isService = isService=="N" ? false : true;
    if( IMToolBar && onOff=="1" ) {
        IMToolBar.createHotButton();    }    if(Ntalker.temp.versionValue && Ntalker.temp.statusValue && onOff=="1" ){
        if(im_wdkUtil.onlyOne(Ntalker.hotKEY+Ntalker.variable.user_id, "d", 1)){            IMToolBar.onShowHost();
        }
    }
}
function fIM_checkPopupWin(){    if(Ntalker.Config.isPopupMode){
        im_wdkUtil.$("impresenceflash").runJSFunction("fIM_setPopupMode", true);    }
    return true;
}
function fIM_setPopupMode(isPopupMode){    IMAnimate.timer(function(){
        Ntalker.Config.isPopupMode = isPopupMode ? true : false;
        if(Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==0)
            fIM_hiddenToolBar();
        else
            fIM_visibleToolBar();
    },200);
    return true;
}
function im__mouseover(ev){
    var target = im_wdkUtil.eventTag(ev,"li");
    IMcssTag.addClass(target, 'hover');
}
function im__mouseout(ev){
    var target = im_wdkUtil.eventTag(ev,"li");
    IMcssTag.removeClass(target, 'hover');
}
function im_popMenu(obj, destuid, destnick){
    var _var = Ntalker.variable;
    if(Ntalker.temp.menuTimer>=0){
        clearTimeout(Ntalker.temp.menuTimer);
        Ntalker.temp.menuTimer = -1;
        return;
    }
    var menudiv = im_wdkUtil.$('im_popMenuid');
    if(!menudiv || !obj) return;
    var _Rect   = im_wdkUtil.viewRect.get(obj);
    var _winRect= im_wdkUtil.viewRect.get(window);
    menux = _Rect.x + _Rect.w - _winRect.x;
    menuy = _Rect.y - _winRect.y - (IMBrowser.boxModel ? 20 : 10) + (IMBrowser.msie56?_winRect.y:0);
    menuStr = '<ul class="popMenuUL">'
            + '  <li>聊天</li>'
            + '  <li>我的好友</li>'
            + '</ul>';
    menudiv.innerHTML   = menuStr;
    var _Items = im_wdkUtil.$$(" li", menudiv);
    for(var i=0;i<_Items.length;i++){
        im_wdkUtil.Event.addEvent(_Items[i], "mouseover", im__mouseover);
        im_wdkUtil.Event.addEvent(_Items[i], "mouseout", im__mouseout);
    }
    im_wdkUtil.Event.addEvent(_Items[0], "click", function(){
        var menudiv = im_wdkUtil.$('im_popMenuid');
        menudiv.style.display = 'none';
        Ntalker.temp.menuTimer = -1;
        im_openWebchatWindow(destuid, destnick, null, true);
    });
    im_wdkUtil.Event.addEvent(_Items[1], "click", function(){
        var menudiv = im_wdkUtil.$('im_popMenuid');
        menudiv.style.display = 'none';
        Ntalker.temp.menuTimer = -1;
        im_openBuddyListWindow(true);
    });
    menudiv.style.display = 'block';
    menudiv.style.left  = menux+"px";
    menudiv.style.top   = menuy+"px";
    menudiv.onmouseover = im_popMenu;
    menudiv.onmouseout  = im_beginCloseMenu;
}
function im_beginCloseMenu(obj){
    Ntalker.temp.menuTimer = setTimeout(function(){
        var menudiv = im_wdkUtil.$('im_popMenuid');
        menudiv.style.display = 'none';
        Ntalker.temp.menuTimer = -1;
    }, 100);
}
function im_onGetFlashServer(responseText, type, iscookievalue){
    if(responseText=="-1" || responseText=="-2")
        return;
    if(type=="1"){
        Ntalker.temp.presenceFlash =  im_wdkUtil.$("impresenceflash");
        Ntalker.temp.flashServers = responseText.split(",");
        if(typeof(iscookievalue)=="undefined" || !iscookievalue)
            im_wdkUtil.SetCookie("flashservers", responseText, Ntalker.Config.cookieTimeout);
    }
}
function StartGetUsersStatus(){    statusSpans = document.getElementsByTagName("SPAN");
    spanindex = 0;
    var _arrSpan      = new Array();
    Ntalker.temp.userSpanArray = new Array();
    var strUserIDList = "";
    for(i=0; i<statusSpans.length; i++){
        statusSpan = statusSpans[i];
        if(statusSpan.className=="wdk_user_status_span" && statusSpan.id){
            pos = statusSpan.id.indexOf("wdk_user_");
            if(pos>=0){
                var newStatusObj = new Object();
                newStatusObj.destuid = statusSpan.id.substring(pos+"wdk_user_".length, statusSpan.id.length);
                newStatusObj.destnick = statusSpan.title;
                newStatusObj.spanElement = statusSpan;
                _arrSpan.push(newStatusObj);
                if(_arrSpan.length>1) strUserIDList += ",";
                strUserIDList += encodeURIComponent(newStatusObj.destuid);
            }
        }
    }    var curURL = window.location.href.toLowerCase();
    var isNeedPaser = false;
    if(_arrSpan.length==0 && /tianya|tianya_v2/.test(Ntalker.variable.siteid)){
        var allowURLList = new Array("/publicforum/content/","/techforum/content/");
        for(i=0;i<allowURLList.length;i++){
            if(curURL.indexOf(allowURLList[i])>=0){
                isNeedPaser = true;
                break;
            }
        }
    }
    if(!isNeedPaser){
        var pattern = /content.*\.asp\?/i;
        if(curURL.match(pattern))
            isNeedPaser = true;
    }
    if(isNeedPaser){
        var lnks = document.links;
        for(var i=0;i<lnks.length;i++){
            match = lnks[i].href.match(/Listwriter\.asp\?(vid=(.*)&)?vwriter=(.*)&?/i);
            if(typeof match != "undefined" && match){
                var _param = {  name:"span",
                                id:"wdk_user_"+lnks[i].innerHTML,
                                className:"wdk_user_status_span",
                                title:lnks[i].innerHTML};
                var chatSpan = im_wdkUtil.createDom(_param,lnks[i].parentNode, null, "beforeend");
                var newStatusObj = new Object();
                newStatusObj.destuid = lnks[i].innerHTML;
                newStatusObj.destnick = lnks[i].innerHTML;
                newStatusObj.spanElement = chatSpan;
                _arrSpan.push(newStatusObj);
                if(_arrSpan.length>1) strUserIDList += ",";
                strUserIDList += encodeURIComponent(newStatusObj.destuid);
                if(_arrSpan.length>60)
                    break;
            }
        }
    }
    var _presenceFlash = im_wdkUtil.$("impresenceflash");
    Ntalker.temp.presenceFlash = _presenceFlash;
    Ntalker.temp.userSpanArray = _arrSpan;
    if(_arrSpan.length>0 && Ntalker.Config.customparams["enblebuddyentry"]){
        if(_presenceFlash && _presenceFlash.requestUserStatus){            _presenceFlash.requestUserStatus(strUserIDList, _arrSpan.length);
        }else{        }
    }
}
function StartGetGroupEntry() {
    if(!Ntalker.Config.customparams['enablegroup']) return;
    statusSpans = document.getElementsByTagName("SPAN");
    spanindex = 0;
    imgsrc = Ntalker.variable.scriptPath + "/images/group_24x22.png";
    for (i = 0; i < statusSpans.length; i++) {
        statusSpan = statusSpans[i];
        if (statusSpan.className == "wdk_group_chat_span" && statusSpan.id) {
            pos = statusSpan.id.indexOf("wdk_group_");
            if (pos >= 0) {
                var newGroupObj = new Object();
                newGroupObj.groupid = statusSpan.id.substring(pos + "wdk_group_".length, statusSpan.id.length);
                newGroupObj.groupnick = im_wdkUtil.EncodeSpecialChar(statusSpan.title);
                var tiptext = "点击进入" + newGroupObj.groupnick + "群聊天";
                chatLinkStr = "<a  href=\"#\" target=\"_blank\" style=\"display:inline;padding-left:7px; overflow:hidden;\" alt=\"" + tiptext + "\" onClick=\"javascript: im_openWebchatWindow('" + newGroupObj.groupid + "', '" + newGroupObj.groupnick + "', null, true, 'group'); return false;\">";
                chatLinkStr += "<img name=\"wdk_presence_image\"";
                if (spanindex == 0) {
                    chatLinkStr += " tip=\"" + tiptext + "\" style=\"left:0px;top:0px;\"";
                    if (Ntalker.Config.customparams["show_tooltip"]) chatLinkStr += " onload=\"IMTipManager.addIMTip('wdk_presence_" + newGroupObj.groupid + "', '点击这里开始聊天')\" ";
                }
                chatLinkStr += " id=\"wdk_presence_" + newGroupObj.groupid + "\" border=\"0\" style=\"display:inline;";
                chatLinkStr += "\" src=\"" + imgsrc + "\" title=\"" + tiptext + "\"/>";
                chatLinkStr += "</a>";
                statusSpan.innerHTML = chatLinkStr;
                spanindex++;
            }
        }
    }
}
function im_changeFlashConnet(){    var impresenceflash = im_wdkUtil.$("impresenceflash");
    var _var       = Ntalker.variable;
    if(!_var.user_id || _var.user_id==0){
        return;
    }
    if(impresenceflash && !Ntalker.variable.presenceConnet){
        if( impresenceflash.changeFlashConnet){
            impresenceflash.changeFlashConnet(_var.siteid, _var.user_id, _var.user_name, _var.user_sid, _var.userparam);
            Ntalker.variable.presenceConnet = true;            if(im_wdkUtil.onlyOne(Ntalker.imKEY, "d", 1) && false){                im_wdkUtil.createDom({name:"DIV",id:Ntalker.imKEY,style:"visibility:hidden;"}, null, "afterbegin");
                swfobject.embedSWF(_var.scriptPath + "/NtalkerIM.swf", Ntalker.imKEY, 1, 1, "9.0.0", _var.scriptPath+"/expressInstall.swf", {version: Ntalker.version.webchat_flash}, {}, {});
            }
        }
    }
}function fIM_onGetUserStatus(responseText){    var _cfg = Ntalker.Config;
    var _temp= Ntalker.temp;
    if(responseText=="-1" || responseText=="-2" || _cfg.customparams["hiddenmode"])
        return;
    userStatusArray = responseText.split(",");                                                                                                                                  
    Ntalker.cache.init();
    for(i=0;i<_temp.userSpanArray.length;i++){
        var imgsrc,errsrc;
        switch(userStatusArray[i]){
        case "0":
            imgsrc = Ntalker.variable.scriptPath + "/images/"+_cfg.startlogo+"/offline."+(IMBrowser.msie56?"gif":"png");
            errsrc = Ntalker.variable.scriptPath + "/images/ntalker_skin1/offline."+(IMBrowser.msie56?"gif":"png");
            break;
        case "1":
            imgsrc = Ntalker.variable.scriptPath + "/images/"+_cfg.startlogo+"/online."+(IMBrowser.msie56?"gif":"png");
            errsrc = Ntalker.variable.scriptPath + "/images/ntalker_skin1/online."+(IMBrowser.msie56?"gif":"png");
            break;
        }
        alttext="跟我聊天";
        chatLinkStr =  ' <a  href="#" target="_blank" style="display:inline;padding:0px;overflow:visible;" alt="'+alttext+'" onClick="javascript: im_openWebchatWindow(\''+_temp.userSpanArray[i].destuid+'\', \''+_temp.userSpanArray[i].destnick+'\', null, true); return false;" ';
        if(_cfg.customparams["show_popmenu"] && !_cfg.customparams["hiddenmode"])
            chatLinkStr += ' onmouseover="im_popMenu(this,\''+_temp.userSpanArray[i].destuid+'\',\''+_temp.userSpanArray[i].destnick+'\');" onmouseout="im_beginCloseMenu(this);"';
        chatLinkStr += '><img name="wdk_presence_image" style="display:inline;left:0px;top:0px;"';
        if(i==0){
            chatLinkStr += ' tip="点击这里开始聊天"';
            if(_cfg.customparams["show_tooltip"] && !_cfg.customparams["hiddenmode"])
                chatLinkStr += ' onload="IMTipManager.addIMTip(\'wdk_presence_'+_temp.userSpanArray[i].destuid+'\', \'点击这里开始聊天\')"';
        }
        chatLinkStr += " id=\"wdk_presence_"+_temp.userSpanArray[i].destuid+"\" border=\"0\" src=\""+imgsrc+"\" error=\"this.src='"+errsrc+"';\" />";
        chatLinkStr += "</a>";
        _temp.userSpanArray[i].spanElement.style.border = '';
        _temp.userSpanArray[i].spanElement.innerHTML = chatLinkStr;
    }
}
function im_openWebchatWindow(destuid, destname, chatid, isActiveOpen, chatType){
    chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");
    if(Ntalker.variable.user_id==0 || !Ntalker.variable.user_id){
        alert("您还没有登录，请先登录！");return;
    }
    if(IMToolBar && IMToolBar._disable && chatType!="bbshot"){
        alert("连接失败，请稍候重试！");return;
    }
    if(Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==0){        im_wdkUtil.$("impresenceflash").runJSFunction("fIM_openPopupChatWindow", [[destuid, destname, chatid, chatType]]);
    }else{        im_openWebchatInPage(destuid, destname, chatid, isActiveOpen, chatType);
    }
    if(IMToolBar && chatType=="group")
        IMToolBar.removeGroupMsg(destuid, destname);
}
function im_openWebchatInPage(destuid, destname, chatid, isActiveOpen, chatType){    if(Ntalker.variable.popupWindow){
        if(Ntalker.Config.isPopupWindow==0) return;
    }
    if(destuid==Ntalker.variable.user_id && chatType!="group") return;
    return im_chat_window_manager.addChatWindow(destuid, destname, chatid, true, null, null, isActiveOpen, chatType);
}
function im_openBuddyListWindow(isActiveOpen){
    if(!Ntalker.Config.isPopupMode || (Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==1)){
        IMAnimate.timer(function(){
            if(im_myIMWindow){
                im_myIMWindow.showWindow(Ntalker.Config.isPopupMode);                if(Ntalker.Config.isPopupWindow && promptwindow && !isActiveOpen)
                    promptwindow.startPrompt("好友列表", "　", true);
            }else{
                var notifystr = "%u60A8%u5C1A%u672A%u767B%u5F55%uFF0C%u8BF7%u767B%u5F55%u540E%u518D%u4F7F%u7528%u597D%u53CB%u5217%u8868%uFF01";
                alert(unescape(notifystr));
            }
        }, 100);
    }else{
        if(Ntalker.Config.isPopupWindow==0 && isActiveOpen){
            im_wdkUtil.$("impresenceflash").runJSFunction("im_openBuddyListWindow", isActiveOpen);        }
    }
    return true;
}
function IMHashtable(){
    this._hash = new Object();  
    this.add = function(key,value){
        if(typeof(key)!="undefined"){
            if(this.contains(key)==false){
                this._hash[key]=typeof(value)=="undefined"?null:value;
                return true;
            }else {
                return false;
            }
        }else {
            return false;
        }
    }
    this.remove = function(key){delete this._hash[key];}
    this.count = function(){var i=0;for(var k in this._hash){i++;} return i;}
    this.items = function(key){return this._hash[key];}
    this.contains  = function(key){ return typeof(this._hash[key])!= "undefined";}
    this.clear = function(){for(var k in this._hash){delete this._hash[k];}}
}
var IMTipManager = {
    _arrTips: new IMHashtable(),
    _curTip : null,
    _effect : true,
    getIMTip: function(key){
        return this._arrTips.items(key);
    },
    addIMTip: function(key, msg, effect){
        if(this.getIMTip(key)) return;
        this._effect = effect===false ? false : this._effect;
        this._curTip = new IMtoolTip(key, msg);
        this._arrTips.add(key, this._curTip);
        this._curTip.init(key, this._effect, !this._effect);
    },
    addIMTips:function(els, msg, effect){
        var _keys = im_wdkUtil.$$(els);
        for(k in _keys){
            if(!_keys[k].id) _keys[k].id = "Ntalker_Tip_" + Math.round(Math.random()*10000);
            this.addIMTip(_keys[k].id, msg, effect);
        }
    },
    removeIMTip: function(key){
        this._arrTips.remove(key);
    },
    closeIMTip: function(key){
        var _curTip = this.getIMTip(key);
        if(_curTip)_curTip.Element.parentNode.removeChild(_curTip.Element);
        IMTipManager.removeIMTip(key);
    }
}
var IMtoolTip = function(key, msg){
    this.key = key;
    this.msg = msg;
    this.Element = null;
}
_p = IMtoolTip.prototype;
_p.init = function(key, effect){
    this.Element = im_wdkUtil.createDom({name:"DIV",id:"imiT"+this.key,style:"position:absolute;z-index:9999;top:-100px;left:-500px;width:120px;filter:alpha(Opacity=0);-moz-opacity:0;opacity:0;"}, null, "AfterBegin");
    this.Element.innerHTML  = this.getTip();
    this.Element.style.position = "absolute";
    this.Element.style.width    = "130px";
    this.Element.style.height   = "51px";
    var _icoRect = im_wdkUtil.viewRect.get(this.key);
    var _winRect = im_wdkUtil.viewRect.get(window);
    var _tipRect = im_wdkUtil.viewRect.get(this.Element);
    var _x = _icoRect.x + _icoRect.w/2 - 12 - _winRect.x;
    if( _x+_tipRect.w + 10 > _winRect.w ){
        _x = _icoRect.x + _icoRect.w/2 - _tipRect.w + 12;
        var bA = im_wdkUtil.$('bALlOOnT'+this.key);
        if(bA){
            bA.style.left=""; bA.style.right="4px";
        }else{
            im_wdkUtil.$('NtalkerToolbarTip').className = "Ntalker_fright";
        }
    }
    var _y = _icoRect.y - _tipRect.h - (IMBrowser.msie56 ? 0: _winRect.y);
    this.Element.style.top  = _y + "px";
    this.Element.style.left = _x + "px";
    IMAnimate.animate(IMTipManager._curTip.Element,"opacity", {start:0,end:100,step:(effect ? 5 : 50)}, function(){
        if(effect) IMAnimate.timer(function(){IMTipManager.getIMTip(key).close(key);},5000);
    });
};
_p.close = function(key){
    IMAnimate.animate(IMTipManager.getIMTip(key).Element,"opacity", {start:100,end:0,step:-5}, function(){
        var _curTip = IMTipManager.getIMTip(key);
        if(_curTip)_curTip.Element.parentNode.removeChild(_curTip.Element);
        IMTipManager.removeIMTip(key);
    });
}
_p.getTip = function(){
    var _img = Ntalker.variable.scriptPath;
    var _TipHTML = 
        '<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
        '    <tr>'+
        '        <td style="background:url('+_img+'/images/tipleft.png) 0 0 no-repeat;width:6px;"></td>'+
        '        <td style="margin-left:6px;_margin-left:0px;background:url('+_img+'/images/tipmid.png) 0 0 repeat-x;height:32px;color:#333;font-size:14px;">' + this.msg + '</td>'+
        '        <td style="background:url('+_img+'/images/tipright.png) top right no-repeat;width:6px;"></td>'+
        '    </tr>'+
        '    <tr><td colspan="3">'+
        '        <div id="bALlOOnT'+this.key+'" style="position: absolute;background:url('+_img+'/images/tip_b.gif) no-repeat;width:15px;height:19px;top:31px;left:4px;"></div>'+
        '    </td></tr>'+
        '</table>';
    return _TipHTML;
}
_p.toolbarTip = function(){
    var _img = Ntalker.variable.scriptPath;
    var _TipHTML = 
        '<ul id="NtalkerToolbarTip" class="Ntalker_fleft">'+
        '    <li class="TipLeft">' + this.msg + '</li>'+
        '    <li class="TipRight"></li>'+
        '</ul>';
    return _TipHTML;
}
var NotifyManager = {
    _notifyWnds   : new IMHashtable(),
    _NotifySPAN   : im_wdkUtil.createDom({name:"div",id:"OnlineNotifyGroup"}, null, "afterbegin"),
    _maxNotify    : 3,
    _width        : 215,
    _height       : 130,
    _bottom       : 30,
    init:function(){
        var __NotifyRepos = function(){
            var list = NotifyManager.showQueue._showList;
            var _winRect = im_wdkUtil.viewRect.get(window);
            for(var k in list._hash){
                if(k && list._hash[k]._curNotifyId){
                  var _notifyWnd = im_wdkUtil.$(list._hash[k]._curNotifyId);
                  if(typeof(_notifyWnd)=="undefined"||!_notifyWnd)
                    continue;
                  var _top   = IMcssTag.css(_notifyWnd, "top");
                  _notifyWnd.style.right  = "10px";
              }
            }
        };
        im_wdkUtil.Event.addEvent(window, "resize", __NotifyRepos);
        im_wdkUtil.Event.addEvent(window, "scroll", __NotifyRepos);
    },
    clearonline:function(destuid, destname, type){
        var _Wnd, type = type? type:"online";;
        for(var k in this.showQueue._showList._hash){
            _Wnd = this.showQueue._showList.items(k);
            if(_Wnd.type=="online" && _Wnd.destuid==destuid && _Wnd.destname==destname) return true;
        }
        for(var k in this._notifyWnds._hash){
            _Wnd = this.get(k);
            if(_Wnd.type=="online" && _Wnd.destuid==destuid && _Wnd.destname==destname) return true;
        }
        return false;
    },
    add: function(destuid, destname, message, chatid, headURL, type, BtnType, sendMsg){
        if(this.clearonline(destuid, destname, type)) return;
        Ntalker.temp.notify_id++;
        var notifyWnd     = new Object();
        notifyWnd.destuid = destuid;
        notifyWnd.destname= destname;
        notifyWnd.message = message;
        notifyWnd.chatid  = chatid;
        notifyWnd.logoUrl = headURL;
        notifyWnd.type    = type? type:"online";
        notifyWnd.BtnType = BtnType;
        notifyWnd.sendMsg = sendMsg;
        notifyWnd.userid  = Ntalker.variable.user_id;
        if (!notifyWnd.userid)
            return;
        notifyWnd._curNotifyId  = 'Notify' + Ntalker.temp.notify_id + "TYPE" + notifyWnd.type;
        this._notifyWnds.add(notifyWnd._curNotifyId, notifyWnd);
        this.push();
    },
    remove: function(k){
        this._notifyWnds.remove(k);
    },
    get: function(k){
        return this._notifyWnds.items(k);
    },
    push:function(){
        var _sPush = false;var _aPush = false;
        for(var k in this._notifyWnds._hash){
            var sLen = this.showQueue._showList.count();
            var aLen = this.alertQueue._showList.count();
            var _Wnd = this.get(k);
            if(sLen<this._maxNotify && !this.showQueue._showing && _Wnd.type=="online"){
                _sPush = true;
                this.showQueue.add(k, this.get(k));this.remove(k);
            }
            if(aLen<1 && !this.alertQueue._showing && _Wnd.type=="alert"){
                _aPush = true;
                this.alertQueue.add(k, this.get(k));this.remove(k);
            }
            if(_sPush && _aPush){break;}
        }
    },
    alertQueue:{
        _showList   : new IMHashtable(),
        _showing    : false,
        add: function(key, notifyWnd){
            var alertNotifys = im_wdkUtil.$$(".ntalker_notify");
            for(var k in alertNotifys){
                if(alertNotifys[k].parentNode) alertNotifys[k].parentNode.removeChild(alertNotifys[k]);
            }            if(/confirm|request/.test(notifyWnd.BtnType) || /alert/.test(notifyWnd.type) ){
                im_chat_window_manager.OnTBFocusWindow(0);            }
            this._showList.add(key, notifyWnd);
            var _winRect= im_wdkUtil.viewRect.get(window);
            var _top    = _winRect.y + (_winRect.h - NotifyManager._height)/2;
            var _left   = _winRect.x + (_winRect.w - NotifyManager._width)/2;
            var _headURL= notifyWnd.logoUrl?notifyWnd.logoUrl:Ntalker.cache.image_dir+"notify_userhead.png";
            var _errimg = Ntalker.cache.image_dir+"notify_userhead.png";
            _curElement = im_wdkUtil.createDom({name:"DIV", id:key, className:"ntalker_notify"});
            _curElement.style.cssText = "z-index:10000;top:"+_top+"px;left:"+_left+"px;width:"+NotifyManager._width+"px;background:transparent url("+Ntalker.cache.image_dir+"notifybg."+(IMBrowser.msie?"gif":"png")+") no-repeat left top;height:130px;";
            _curElement.innerHTML = "<div style=\"background: url("+Ntalker.Config.logo+") no-repeat 1px 1px;margin:10px 10px 0 10px;height:20px;padding-top:5px;_padding-top:0px;text-align:right;\"><a href=\"javascript:NotifyManager.alertQueue.close('"+key+"','"+notifyWnd.BtnType+"','"+notifyWnd.type+"');IMToolBar.removeMsg('"+notifyWnd.destuid+"', '"+notifyWnd.type+"');\" class=\"closewin\"></a></div>"
                                  + "<div style=\"margin:10px 20px 0px 20px !imporant;margin-top:0px;margin-left:20px;cursor:pointer;\" onclick=\"im_openWebchatWindow("+notifyWnd.destuid+", '"+notifyWnd.destname+"', '"+notifyWnd.chatid+"', true);NotifyManager.alertQueue.close('"+key+"','"+notifyWnd.BtnType+"','"+notifyWnd.type+"');IMToolBar.removeMsg('"+notifyWnd.destuid+"', '"+notifyWnd.type+"');\">"
                                  + "  <div style=\"margin:4px;background:#fff;width:65px;height:65px;float:left;\"><img src=\""+_headURL+"\" error=\"this.src='"+_errimg+"'\" style=\"width:61px;_width:60px;height:61px;_height:60px;border:1px solid #ccc;margin:1px;\" /></div>"
                                  + "  <br style=\"clear: both;\" />"
                                  + "</div>"
                                  + "<div class=\"\" style=\"overflow: hidden; position: absolute; left: 95px; top: 40px; width: 105px;color:#000000;font-size:14px;font-family: 宋体;\">"
                                  + "  <B>" + im_wdkUtil.cutText(notifyWnd.destname,6,true) + "</B><br />" + (notifyWnd.BtnType&&notifyWnd.sendMsg ? "说:"+im_wdkUtil.cutText(notifyWnd.sendMsg, 6, true) : im_wdkUtil.cutText(notifyWnd.message, 6, true)) + "<br />"
                                  +      (/confirm|request/.test(notifyWnd.BtnType) ? 
                                            "<a href=\"javascript:im_Confirm('"+notifyWnd.destuid+"', '"+key+"', '"+notifyWnd.BtnType+"', 1, '"+notifyWnd.destname+"','"+notifyWnd.type+"');\" style=\"width:43px;display:block;height:20px;background:url("+Ntalker.cache.image_dir+"notifybtn.png) no-repeat 0 0;float:left;\"></a>"
                                        +   "<a href=\"javascript:im_Confirm('"+notifyWnd.destuid+"', '"+key+"', '"+notifyWnd.BtnType+"', 2, '"+notifyWnd.destname+"','"+notifyWnd.type+"');\" style=\"width:44px;display:block;height:20px;background:url("+Ntalker.cache.image_dir+"notifybtn.png) no-repeat -43px 0;float:left;\"></a>"
                                          : "")
                                  + "</div>";
            this.animate(_curElement, !(/confirm|request/.test(notifyWnd.BtnType)));
        },
        animate:function(el, autoclose){
            this._showing = true;                  NotifyManager.alertQueue._showing = false;
                if(autoclose){
                    IMAnimate.timer(function(){
                        IMAnimate.animate(el,"opacity", {start:100,end:0,step:-10}, function(){
                            if(el.parentNode)el.parentNode.removeChild(el);
                            NotifyManager.alertQueue._showList.remove(el.id);
                            IMAnimate.timer(function(){NotifyManager.push();}, 500);
                        });
                    }, 6000);
                }        },
        close:function(el, btntype,type){
            el = im_wdkUtil.$(el);                if(el.parentNode) el.parentNode.removeChild(el);
                NotifyManager.alertQueue._showList.remove(el.id);
                if(/confirm|request/.test(btntype) || /alert/.test(type)){
                    im_chat_window_manager.OnTBFocusWindow(Ntalker.variable.OnFocusWinParam[0], Ntalker.variable.OnFocusWinParam[1]);
                }        }
    },
    showQueue:{
        _showList   : new IMHashtable(),
        _showing    : false,
        add: function(key, notifyWnd){
            var _winRect = im_wdkUtil.viewRect.get(window);
            var _top     = _winRect.y + _winRect.h - NotifyManager._bottom;
            var _headURL = notifyWnd.logoUrl?notifyWnd.logoUrl:Ntalker.cache.image_dir+"notify_userhead.png";
            var _errimg  = Ntalker.cache.image_dir+"notify_userhead.png";
            this._showList.add(key, notifyWnd);
            _curElement = im_wdkUtil.createDom({name:"DIV",id:key,className:"ntalker_notify"}, NotifyManager._NotifySPAN);
            _curElement.style.cssText = "z-index:99999;top:"+_top+"px;right:10px;height:0px;width:"+NotifyManager._width+"px;background:transparent url("+Ntalker.cache.image_dir+"notifybg."+(IMBrowser.msie?"gif":"png")+") no-repeat left top;";            _curElement.innerHTML = "<div style=\"background: url("+Ntalker.Config.logo+") no-repeat 1px 1px; margin:10px 10px 0 10px;height:20px;text-align:right;\"><a href=\"javascript:NotifyManager.showQueue.close('"+key+"');\" class=\"closewin\"></a></div>"
                                  + "<div style=\"margin:0px 10px;cursor:pointer;height:85px;\" onclick=\"im_openWebchatWindow("+notifyWnd.destuid+", '"+notifyWnd.destname+"', '"+notifyWnd.chatid+"', null);NotifyManager.alertQueue.close('"+key+"');\">"
                                  + "  <div style=\"margin:10px 4px 4px 14px;_margin:10px 4px 4px 4px;background:#fff;width:65px;height:65px;float:left;\"><img src=\""+_headURL+"\" error=\"this.src='"+_errimg+"'\" style=\"width:61px;_width:60px;height:61px;_height:60px;border:1px solid #ccc;margin:1px;\" /></div>"
                                  + "  <div style=\"padding: 10px 5px 0px 0px; float: right; width: 105px; color: #000000; font-size: 14px;font-family:宋体;\">"
                                  + "    <B>" + im_wdkUtil.cutText(notifyWnd.destname, 5, true) + "</B><br />" + notifyWnd.message + ""
                                  + "  </div>"
                                  + "</div>";
            if(im_wdkUtil.$('impresenceflash') && im_wdkUtil.$('impresenceflash').playNotifySound)
                im_wdkUtil.$('impresenceflash').playNotifySound();            this.animate(_curElement);
        },
        animate:function(el){
            this._showing = true;
            var _preNodes = [];var _curEl = el;
            while(_curEl.previousSibling){_preNodes.push(_curEl.previousSibling);_curEl = _curEl.previousSibling;}
            for(var k in _preNodes){
                var _top    = IMcssTag.css(_preNodes[k], "top");
                var _newTop = _top - NotifyManager._height;
                IMAnimate.animate(_preNodes[k], "top", {start:_top,end:_newTop,step:-13});
            }
            _top = IMcssTag.css(el, "top");
            IMAnimate.animate(el, "top",{start:_top,end:(_top - NotifyManager._height), step:-13});
            IMAnimate.animate(el, "height",{start:0,end:NotifyManager._height,step:13}, function(){
                NotifyManager.showQueue._showing = false;
                IMAnimate.timer(function(){NotifyManager.push();},500);
                IMAnimate.timer(function(){
                    IMAnimate.animate(el,"opacity", {start:100,end:0,step:-10}, function(){
                        if(el.parentNode)el.parentNode.removeChild(el);
                        NotifyManager.showQueue._showList.remove(el.id);
                        NotifyManager.push();
                    });
                }, 15000);
            });
        },
        close:function(el){
            el = im_wdkUtil.$(el);
            IMAnimate.animate(el,"opacity", {start:100,end:0,step:-10}, function(){
                var _curEl = el;var _preNodes = [];
                while(_curEl.previousSibling){_preNodes.push(_curEl.previousSibling);_curEl = _curEl.previousSibling;}
                if(el.parentNode) el.parentNode.removeChild(el);
                NotifyManager.showQueue._showList.remove(el.id);
                for(var k in _preNodes){
                    var _top    = IMcssTag.css(_preNodes[k], "top");
                    var _newTop = _top + NotifyManager._height;
                    IMAnimate.animate(_preNodes[k], "top", {start:_top,end:_newTop,step:13}, function(){
                        NotifyManager.push();
                    });
                }
            });
        }
    }
};
function im_Confirm(destuid, key, alertType, strConfirm,destname, typ){
    if(alertType=="request"){
        if(strConfirm==1){
            im_openWebchatInPage(destuid, destname, null, true);        }
    }else{
        var impresence = im_wdkUtil.$('impresenceflash');
        if(impresence && impresence.addFriendConfirmResult){
            impresence.addFriendConfirmResult(destuid, strConfirm);        }
    }
    IMToolBar.removeMsg(destuid, typ);
    if(IMToolBar)
        IMToolBar.removeMsg(destuid, alertType);
    if(NotifyManager)
        NotifyManager.alertQueue.close(key, alertType, typ);
    return;
}
function fIM_presenceSetMyClientID(flashGoUrl){
    Ntalker.temp.presenceFlashGoUrl = flashGoUrl;
}
function fIM_presenceSetIMSid(imsid){
    Ntalker.variable.imsid = imsid;
}
function fIM_onPresenceReceiveChatMsg(destuid, destnick, wid, flashserver, message, chatid, isNotify, isMyFriend, isOnlineMsg, logoUrl, chatsid){
    var _cfg = Ntalker.Config;
    var _var = Ntalker.variable;    if(Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==0)
        return;
    if(isNotify){        if(IMToolBar) IMToolBar.addMsg(destuid, destnick, "请求会话", chatid, logoUrl, message, "request");
    }else{
        if(isOnlineMsg){
            if(_var.onlineChat>=0){                Ntalker.variable.autoFocus = false;
                im_chat_window_manager.addChatWindow(destuid, destnick, chatid, false, message, logoUrl);
                _var.onlineChat -= 1;
            }else{                if(IMToolBar) IMToolBar.addMsg(destuid, destnick, "请求会话", chatid, logoUrl, message, "request");
            }
        }else{
            if(_var.offlineChatList.length<6){
                im_chat_window_manager.addChatWindow(destuid, destnick, chatid, false, message, logoUrl);                var openOfflineChatWindow = true;
                for(var k in _var.offlineChatList){
                    if(_var.offlineChatList[k][0]==destuid && _var.offlineChatList[k][1]==destnick){
                        openOfflineChatWindow = false; break;
                    }
                }
                if(openOfflineChatWindow) {
                    _var.offlineChatList.push([destuid, destnick]);                }
            }else{
                var openOfflineChatWindow = false;
                for(var k in _var.offlineChatList){
                    if(_var.offlineChatList[k][0]==destuid && _var.offlineChatList[k][1]==destnick){
                        openOfflineChatWindow = true; break;
                    }
                }
                if(!openOfflineChatWindow){                    if(IMToolBar) IMToolBar.addMsg(destuid, destnick, "请求会话", chatid, logoUrl, message, "request");
                }
            }
        }
    }
    if(promptwindow){
        promptwindow.startPrompt(destnick, "请求与您会话", true);
    }
    return true;
}
function fIM_OnPresenceReceiveGroupMsg( groupId, groupName, groupIcon, srcuid, srcnick, msg, isNotify, param){    var customparams = Ntalker.Config.customparams;
    if(!customparams["enablegroup"] && !customparams["enablechat"]) return;
    if(IMToolBar) IMToolBar.addGroupMsg(groupId, groupName);
}
function fIM_onPresenceReceiveAddFriend(destuid, destnick, logoUrl, bconfirm){
    if(Ntalker.Config.isPopupMode && !Ntalker.Config.isPopupWindow)
        return;    if(bconfirm){
        if(IMToolBar) IMToolBar.addMsg(destuid, destnick, "请求加好友", 0, logoUrl, "", "confirm");
        if(promptwindow){promptwindow.startPrompt(destnick, "请求加为好友", true);}
    }else
        if(IMToolBar) IMToolBar.addMsg(destuid, destnick, "加您为好友", 0, logoUrl, "","alert");
        if(promptwindow){promptwindow.startPrompt(destnick, "加您为好友", true);}
    return;
}
function fIM_notifyMessage(destuid, destnick, logoUrl, strMessage){
    if(Ntalker.Config.isPopupMode && !Ntalker.Config.isPopupWindow)
        return;    if(IMToolBar) IMToolBar.addMsg(destuid, destnick, strMessage, 0, logoUrl, "","alert");
}
function fIM_onPresenceReceiveUserOnline(destuid, destnick, logoUrl){
    if( (Ntalker.Config.isPopupMode && !Ntalker.Config.isPopupWindow) || im_myIMWindow.isShow )
        return;    NotifyManager.add(destuid, destnick, "刚上线", 0, logoUrl, "online");
}
function URLencode(_16) {
    return escape(_16).replace(/\+/g, "%2B").replace(/\"/g, "%22").replace(/\'/g, "%27").replace(/\//g, "%2F");
}
var _p;
var WDK_IM_PACK = {};
WDK_IM_PACK.Application = function(){
    this._version = "3.0";
    this._debug = false;
    this._window = window;
    this._doc = this._window.document;
    this._body = null;
    this._FloatWindowManager = null;
};
_p = WDK_IM_PACK.Application.prototype;
_p.init = function(){
    this._FloatWindowManager = new WDK_IM_PACK.FloatWindowManager();
    this._FloatWindowManager.init();
};
_p.dispose = function(){
    this._FloatWindowManager.dispose();
    delete this._FloatWindowManager;
};
_p.createFlash = function(parent, id, src, title, w, h, mode){
    mode = mode ? mode:"Opaque";
    var obj;
    if(IMBrowser.msie){
        obj = this._doc.createElement("OBJECT");
        obj.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
        obj.setAttribute("codeBase", "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab");
        obj.setAttribute("movie", src);
    }else{
        obj = this._doc.createElement("EMBED");
        obj.setAttribute("src", src);
        obj.setAttribute("type", "application/x-shockwave-flash");
        obj.setAttribute("pluginspage","http://www.adobe.com/go/getflashplayer");
        obj.setAttribute("quality", "high");
    }
    obj.setAttribute("id", id);
    obj.setAttribute("name", id);
    obj.setAttribute("title", title);
    obj.setAttribute("width", w);
    obj.setAttribute("height", h);
    obj.style.width = w + "px";
    obj.style.height = h + "px";
    obj.setAttribute("allowScriptAccess", "always");
    obj.setAttribute("wmode", mode);
    if(obj){
        obj.style.display = "block";
        if(parent) parent.appendChild(obj);
    }else{
        var txt = "flash创建失败，请您确定浏览器设置允许播放flash，或刷新浏览器重试，如果仍然不能正常使用请重新安flash插件";
        var textNode = this._doc.createTextNode(txt);
        if(parent) parent.appendChild(textNode);
    }
    try{
        return obj;
    }finally{
        obj = null;
    }
};
WDK_IM_PACK.FloatWindow = function(){
    this._top = 0;
    this._right = 0;
    this._bottom = 0;
    this._left = 0;
    this._width = 0;
    this._height = 0;
};
_p = WDK_IM_PACK.FloatWindow.prototype;
_p.FloatWindowManager = function(inFloatPos, inOffsetX, inOffsetY){
};
_p.moveTo = function(x, y){
};
_p.resize = function(w, h){
};
_p.fooRepos = function(){
};
WDK_IM_PACK.FloatWindowManager = function(){
    this._window = window;
    this._doc = this._window.document;
    this._activeWindow = null;
    this._windows = [];
    this.dragWin = null;
    this.clientArea = null;
    this._panel = null;
    this.dragSx;
    this.dragSy;
    this.isDrag = 0;
    this.isCascadeMode = false;
    this.resizeWin = null;
    this.dir = "";
    this.resizeX;
    this.resizeY;
    this.isresize = 0;
    this._inHead = true;
};
_p = WDK_IM_PACK.FloatWindowManager.prototype;
_p.init = function(){
    if(!this._doc.body){
        this._doc.write("<body></body>");
        this._inHead = true;
    }else{
        this._inHead = false;
    }
    this._body = this._doc.documentElement.clientHeight == 0 ? this._doc.body : this._doc.documentElement;
    var _this = this;
    function __repos(ev){
        ev = ev || _this._window.event;
        for(var i = 0; i < _this._windows.length; i++){
            _this._windows[i].fooRepos(ev);
            if(ev.type=='scroll' && _this._windows[i]._flash && IMBrowser.mozilla){
                if(Ntalker.temp.resetwintop[i] != true){
                    window.setTimeout("wdkApplication._FloatWindowManager.updateWindowPos("+i+", 1)", 1000);
                    Ntalker.temp.resetwintop[i] = true;
                }
            }
        }
        return;
    }
    im_wdkUtil.Event.addEvent(this._window, "resize", __repos);
    im_wdkUtil.Event.addEvent(this._window, "scroll", __repos);
};
_p.addWindow = function(win){
    for(var i = 0; i < this._windows.length; i++){
        if(this._windows[i] == win)
          return;
    }
    this._windows.push(win);
};
_p.removeWindow = function(win){
    for(var i = 0; i < this._windows.length; i++){
        if(this._windows[i] == win){
            this._windows.splice(i,1);
            break;
        }
    }
    if(this._windows.length==0 && this._reposTimerID){
        clearTimeout(this._reposTimerID);
        this._reposTimerID = null;
    }
};
_p.startMove = function(ev, win, isCascadeMode){
    if(isCascadeMode){
        this.isCascadeMode = true;
        this.dragSx = ev.clientX;
        this.dragSy = ev.clientY;
        im_chat_window_manager.startMove();
    }
    else{
        this.isCascadeMode = false;
        this.dragSx = win._self.offsetLeft - ev.clientX;
        this.dragSy = win._self.offsetTop - ev.clientY;
    }
    this.dragWin = win;
    this.isDrag = 1;
    if(IMBrowser.msie)
        win._self.setCapture();
    else{
        this.showPanel(true);
    }
    var _this = this;
    function __mousemove(ev){_this.onmousemove(ev || _this._window.event);}
    function __mouseup(ev){_this.onmouseup(ev || _this._window.event);}
    im_wdkUtil.Event.addEvent(this._body, "mousemove", __mousemove);
    im_wdkUtil.Event.addEvent(this._body, "mouseup", __mouseup);
};
_p.startResize = function(ev, win, type){
    this.resizeWin = win;
    this.dir = type;
    if(Ntalker.Config.entrytype=="toolbar" && type.indexOf("w") == -1){
        this.resizeX = win._self.offsetLeft;
        this.resizeY = win._self.offsetTop;
    }else{
        this.resizeX = ev.clientX - win._self.offsetLeft;
        this.resizeY = ev.clientY - win._self.offsetTop;
    }
    window.resizeSx = ev.clientX;
    window.resizeSy = ev.clientY;
    this.isresize = 1;
    if(IMBrowser.msie)
        win._self.setCapture();
    else
        this.showPanel(true);
};
_p.__timerRepos = function(){
    for(var i = 0; i < this._windows.length; i++){
        if(typeof(this._windows[i].refreshFlashPos)!="undefined"){
            this._windows[i].refreshFlashPos();
        }
    }
    if(this._windows.length>0)
        setTimeout("wdkApplication._FloatWindowManager.__timerRepos()",1000);
}
_p.dispose = function(){
    this.clientArea = null;
    for(var i = 0; i < this._windows.length; i++){
        this._windows[i].dispose();
        delete this._windows[i];
    }
};
_p.getPanel = function(){
    if(!this._panel){
        var _parm = {name:"div",style:"position:absolute;z-index:2;background:#000000;"};
        var obj = im_wdkUtil.createDom(_parm, null, "afterbegin");
        obj.style.MozOpacity = "0.5";
        obj.style.opacity = "0.5";
        obj.style.filter = "alpha(opacity:50)";
        var rect = im_wdkUtil.viewRect.get(window);
        obj.style.width = rect.w + "px";
        obj.style.height = rect.h + "px";
        this._panel = obj;
    }
    return this._panel;
};
_p.showPanel = function(bShow){
    if(!this._panel)
        this.getPanel();
    var rect = im_wdkUtil.viewRect.get(window);
    this._panel.style.display = bShow ? "block" : "none";
    this._panel.style.left = rect.x + "px";
    this._panel.style.top  = rect.y + "px";
    this._panel.style.width = (rect.w-20>0?(rect.w-20):0) + "px";
    this._panel.style.height = (rect.h-20>0?(rect.h-20):0) + "px";
};
_p.onmouseup = function(ev){
    this.showPanel(false);
    if(this.dragWin != null){
        if(IMBrowser.msie)
            this.dragWin._self.releaseCapture();
        this.dragWin = null;
        this.isDrag = 0;
    }
    if(this.resizeWin != null){
        if(IMBrowser.msie)
            this.resizeWin._self.releaseCapture();
        this.resizeWin = null;
        this.dir = "";
        this.isresize = 0;
    }
    if(this.isCascadeMode)
      this.isCascadeMode = false;
};
_p.onmousemove = function(ev){
    if(this.dragWin != null){
        var rect = im_wdkUtil.viewRect.get(window);
        var _entrytype = Ntalker.Config.entrytype;
        var x = this.dragSx + ev.clientX;
        var y = this.dragSy + ev.clientY;
        if(IMBrowser.msie || IMBrowser.opera){
            var max_height = Math.max(this._doc.documentElement.scrollHeight,this._doc.body.scrollHeight)<this._doc.documentElement.clientHeight ? this._doc.documentElement.clientHeight : Math.max(this._doc.documentElement.scrollHeight,this._doc.body.scrollHeight);
        }else{
            var max_height = Math.max(this._doc.documentElement.scrollHeight ,this._doc.body.scrollHeight )
        }
        if(this.isCascadeMode){
            x = this.dragSx-ev.clientX;
            y = this.dragSy-ev.clientY;
            im_chat_window_manager.dragMove(x, y);
        }
        else if(_entrytype=="toolbar"){
            var _scroll = im_wdkUtil.scroll();
            var _r      = IMBrowser.msie ? 1 : (_scroll ? 18 : 1);
            if(!IMBrowser.oldModel){
                var _absX = x + this.dragWin._baseLeft;
                if(_absX+this.dragWin._self.offsetWidth+_r > rect.x+rect.w){
                    x = rect.x+rect.w - this.dragWin._baseLeft - this.dragWin._self.offsetWidth - _r;
                }else if(_absX > rect.x){
                    x = x;
                }else{
                    x = 0-this.dragWin._baseLeft;
                }
            }else{
                x = Math.max(Math.min(x, this._body.scrollLeft + this._doc.documentElement.offsetWidth - this.dragWin._self.offsetWidth), this._body.scrollLeft);
                x = (x+this.dragWin._self.offsetWidth)>this._body.clientWidth ? (this._body.clientWidth-this.dragWin._self.offsetWidth) : x;
            }
            y = (y+this.dragWin._self.offsetHeight)>max_height ? (max_height-this.dragWin._self.offsetHeight) : y;
            this.dragWin.moveTo(x, y);
        }
        else{
            x = Math.max(Math.min(x, this._body.scrollLeft + this._doc.documentElement.offsetWidth - this.dragWin._self.offsetWidth), this._body.scrollLeft);
            x = (x+this.dragWin._self.offsetWidth)>this._body.clientWidth ? (this._body.clientWidth-this.dragWin._self.offsetWidth) : x;
            y = (y+this.dragWin._self.offsetHeight)>max_height ? (max_height-this.dragWin._self.offsetHeight) : y;
            this.dragWin.moveTo(x, y);
        }
    }
    if(this.resizeWin != null){
        window.obj = {
            x: this.resizeWin._self.offsetLeft,
            y: this.resizeWin._self.offsetTop,
            w: this.resizeWin._self.offsetWidth,
            h: this.resizeWin._self.offsetHeight
        };
        this.resizing(ev, this.resizeWin);
    }
};
_p.resizing = function(ev, win){
    var minWidth  = win._minWidth;
    var minHeight = win._minHeight;
    var flag = this.dir;
    var obj = window.obj;
    var x = obj.x;
    var y = obj.y;
    var w = obj.w;
    var h = obj.h;
    var entrytype = Ntalker.Config.entrytype=="toolbar" && flag.indexOf("w") == -1;
    var _parentRect = im_wdkUtil.viewRect.get(this.resizeWin._self.parentNode);
    var ev_clientX = ev.clientX - (entrytype ? _parentRect.x : 0);
    var ev_clientY = ev.clientY - (entrytype ? _parentRect.y : 0);
    if(flag.indexOf("w") != -1){  
        w = obj.x + obj.w - ev_clientX + this.resizeX;
        if(w < minWidth) w = minWidth;
        x = obj.x + obj.w - w;
    }
    if(flag.indexOf("e") != -1){  
        w = ev_clientX - obj.x;
        if(w < minWidth) w = minWidth;
    }
    if(flag.indexOf("s") != -1){  
        h = ev_clientY - obj.y;
        if(h < minHeight) h = minHeight;
    }
    if(flag.indexOf("n") != -1){  
        h = obj.y + obj.h - ev_clientY + this.resizeY;
        if(h < minHeight) h = minHeight;
        y = obj.y + obj.h - h;
    }
    win.moveTo(x, y);
    win.resize(w, h);
    if(IMBrowser.msie)
        win._self.setCapture();
    ev.cancelBubble = true;  
    return false;
};
_p.updateWindowPos = function(winID, times){return;
    if(typeof(this._windows[winID].refreshFlashPos)!="undefined"){
        this._windows[winID].refreshFlashPos();
        if(times<2)
            window.setTimeout("wdkApplication._FloatWindowManager.updateWindowPos("+winID+", "+(times+1)+")", 1000);
        else
            Ntalker.temp.resetwintop[winID] = null;
    }
};
WDK_IM_PACK.IMWindow = function(){
    WDK_IM_PACK.FloatWindow.prototype.constructor();
    this._window = window;
    this._doc  = this._window.document;
    this._self = null;
    this.bxMini0;
    this.minImg = null;
    this.minDiv = null;
    this.isLoad;
    this.maxwidth    = 135;
    this.maxheight   = 226;
    this.titleHeight = 10;  
    this.borderWidth = 2;   
    this._minWidth   = Ntalker.Config.IMWidth;
    this._minHeight  = Ntalker.Config.IMHeight;
    this._width      = Ntalker.Config.IMWidth;
    this._height     = Ntalker.Config.IMHeight;
    this.m_align;
    this.m_rlLong;
    this.m_miniImgBottom;
    this.m_tataType;
    this.m_wid;
    this.m_isButtonFloat = "float";
    this.m_miniIMgSrc;
    this.m_startShow;
    this.m_miniImgEvent;
    this.m_miniImgID;
    this.m_jsSrc;
    this.m_nick;
    this.m_title;
    this.m_enableEditNick;
    this._flashID;
    this.m_flashContainerID;
    this._flashcontainer;
    this.m_miniImgDivID = "wdk_mini_state";
    this._titleid = "wdk_buddylist_title";
    this.timerID;
    this.isLocked = false;
    this.dockPos = "";  
    this._leftright = 0;
    this._isPopup = false;
    this._popupWindow = null;
    this._flash;
    this.isInited = false;
    this.imEntrySpan = null;
    this.isMiniFloat = true;
    this._isFlashLoadSuccess = false;
    this._flashLoadTime = 30000; 
    this._waitFlashAutoLoad = 5000; 
    this._checkFlashTimerid = null;
    this._waitFlashAutoLoadTimeid = null;
    this.isShow = false;
    this.created = false;
    this._baseLeft = 0;
    this._baseTop  = 0;
};
WDK_IM_PACK.IMWindow.prototype = new WDK_IM_PACK.FloatWindow();
_p = WDK_IM_PACK.IMWindow.prototype;
_p.init = function(obj){
    if(this.isInited) return;
    this.isInited = true;
    this._flashID        = "wdk_buddylist_flash";  
    this.m_miniImgBottom = this.m_miniImgBottom || "20";
    this._width = this._width || 180;
    this._height = this._height || 450;
    this.m_align = Ntalker.Config.customparams["floatpos"] || "right";
    this.m_rlLong = this.m_rlLong || "20";
    this.m_isButtonFloat  = this.m_isButtonFloat || "float";
    this.m_miniImgEvent = this.m_miniImgEvent || "mouseup";
    this.m_jsURLPath = Ntalker.variable.scriptPath;
    var _this = this;
    _this.startWork();
};
_p.moveTo = function(x, y){
    var rect = im_wdkUtil.viewRect.get(window);
    this._left = x - rect.x;
    this._top = y - rect.y;
    this._right =  rect.x+rect.w-x;
    this._bottom = rect.y+rect.h-y;
    if(IMBrowser.msie){
        this._self.style.pixelLeft = x;
        this._self.style.pixelTop  = y;
    }else{
        this._self.style.left = x + "px";
        this._self.style.top  = y + "px";
    }
};
_p.resize = function(w, h){
    this._self.style.width  = w + "px";
    this._self.style.height = h + "px";
    var ch = h - 20 - this.borderWidth;
    this._self.childNodes[8].style.width = w + "px";
    this._self.childNodes[3].style.height = ch + "px";
    this._self.childNodes[4].style.height = ch + "px";
    if(this._flash){
        var fw = Math.max(w - 2 * this.borderWidth, 0);
        var fh = Math.max(h - 2 * this.borderWidth - this.titleHeight, 0);
        this._flash.setAttribute("width", fw);
        this._flash.setAttribute("height", fh);
        this._flash.style.width  = fw + "px";
        this._flash.style.height = fh + "px";
        this._flash.style.left = this.borderWidth + "px";
    }
};
_p.fooRepos = function(ev){
    var _entrytype = Ntalker.Config.entrytype;
    var rect = im_wdkUtil.viewRect.get(window);
    if(!IMBrowser.oldModel && _entrytype=="toolbar"){
        return;
    }
    if(ev&&ev.type == "resize"){
        if(!this._self) return;
        if(_entrytype=='toolbar'){
            var left = rect.w-this._width;
            var top  = rect.h-this._height - 25;
            this._left = left;
            this._top  = top;
            left = left + rect.x;
            top  = top + rect.y;
        }else{
            var left = Math.min(rect.x+this._left, (rect.x+rect.w-this._width-this.m_rlLong) );
            var top  = Math.min(rect.y+this._top, (rect.y+rect.h-this._height) );
        }
        if(IMBrowser.msie){
            this._self.style.pixelLeft = left;
            this._self.style.pixelTop = top;
        }else{
            this._self.style.left = left + "px";
            this._self.style.top  = top + "px";
        }
        if(this._self.offsetTop + this._self.offsetHeight - this._doc.body.scrollTop >= this._doc.documentElement.offsetHeight){
            wdkApplication._FloatWindowManager.isDrag = null;
        }
    }else{
        if(this.minDiv != null && this.m_isButtonFloat == "float"){
            this.minDiv.style.bottom = "";
            if(IMBrowser.msie){
                this.minDiv.style.top = (rect.y + rect.h - this.minDiv.scrollHeight - this.minDiv.y0) + "px";
            }else{
                this.minDiv.style.top = (rect.y + rect.h - this.minDiv.offsetHeight - this.minDiv.y0) + "px";
            }
        }
        if(this._self){
            var top = rect.y + this._top;
            if(IMBrowser.msie || IMBrowser.opera){
                var max_height  = Math.max(this._doc.documentElement.scrollHeight,this._doc.body.scrollHeight)<this._doc.documentElement.clientHeight ? this._doc.documentElement.clientHeight : Math.max(this._doc.documentElement.scrollHeight,this._doc.body.scrollHeight);
            }else{
                var max_height = Math.max(this._doc.documentElement.scrollHeight,this._doc.body.scrollHeight);
            }
            top = (top + this._height)>max_height  ? (max_height-this._height) : top;
            this._self.style.top  = top + "px";        }
    }
};
_p.refreshFlashPos = function(){
    return;
    if(!this._flash  || this._curWindMode=="min")
        return;
    var moveOffset = 0;
    if(this._isMoveLeft){
        moveOffset = 1;
        this._isMoveLeft = false;
    }
    else{
        moveOffset = 0;
        this._isMoveLeft = true;
    }
    this._flash.style.left = (document.compatMode=='CSS1Compat' ? moveOffset : (this.borderWidth + moveOffset) )+"px";
}
_p.startWork = function(){
    var _cfg = Ntalker.Config;
    if(this.isLoad == 1 || _cfg.customparams["enblebuddyentry"]==0) return; 
    this.isLoad = 1;
    this.bxMini0 = this._doc.getElementById(this.m_miniImgDivID);
    var _this = this;
    if( this.m_bxMini0 == null){
        this.imEntrySpan = this._doc.getElementById("wdk_im_"+Ntalker.variable.user_id);
        if(Ntalker.variable.siteid=="cnmyspace" || Ntalker.variable.siteid=="xiaonengtest")
            var minDivStr = "<a id=\"wdk_mini_state_img\" style=\"\">在线聊天</a>";
        else{
            var minDivStr = "<img id=\"wdk_mini_state_img\" src=\""+Ntalker.Config.logo+"\"";
            if(_cfg.customparams["show_tooltip"])
                minDivStr += " tip=\"与我的好友聊天\" onload=\"IMTipManager.addIMTip('wdk_mini_state_img','点击这里开始聊天')\"";
            minDivStr += " hspace=\"3\"\/>";
        }
        if(this.imEntrySpan && (_cfg.entrytype=='logo' || _cfg.customparams["enblebuddyentry"]==2) ){ 
            this.imEntrySpan.innerHTML    = minDivStr;
            this.imEntrySpan.style.cursor = "pointer";
            this.imEntrySpan["on" + (this.m_miniImgEvent || "mouseup")] = function(){_this.showWindow(Ntalker.Config.isPopupMode);};
            this.isMiniFloat = false;
        }
        else if(_cfg.entrytype=='logo'){
            this.minDiv = im_wdkUtil.$(this.m_miniImgDivID);
            if(!this.minDiv)
                  return;
            this.minDiv.innerHTML = minDivStr;
            this.minDiv.style.cssText = "position:absolute;visibility:hidden;z-index:999;cursor:pointer;"
              + this.m_align + ":" + this.m_rlLong + "px;";
            this.minDiv.y0 = this.m_miniImgBottom;
            this.minDiv.style.visibility = this.m_startShow == "win" ? "hidden":"visible";
            this.minDiv.style.display = this.m_startShow == "win" ? "none":"block";
            this.minDiv["on" + (this.m_miniImgEvent || "mouseup")] = function(){_this.showWindow(Ntalker.Config.isPopupMode);};
            this.fooRepos();
            this.isMiniFloat = true;
            wdkApplication._FloatWindowManager.addWindow(this);  
        }
        else{
            this.fooRepos();
            this.isMiniFloat = true;
            wdkApplication._FloatWindowManager.addWindow(this);  
        }
    }else{
        this.m_bxMini0["on" + (this.m_miniImgEvent || "mouseup")] = function(){_this.showWindow(Ntalker.Config.isPopupMode);};
    }
};
_p.createWin = function(tagIndex){
    var _cfg = Ntalker.Config;
    var resizebottomheight = Number(this._height);
    var rect = im_wdkUtil.viewRect.get(window);
    var _entrytype = _cfg.entrytype;
    var _scroll = im_wdkUtil.scroll();
    var _r    = IMBrowser.msie ? 1 : (_scroll ? 18 : 1);
    this.created = true;
    if( !IMBrowser.oldModel && _entrytype=="toolbar" ){        var _TabRect   = im_wdkUtil.viewRect.get("buddylist_tab");
        this._baseLeft = _TabRect.x;
        this._baseTop  = _TabRect.y;
        this._self = im_wdkUtil.createDom({name:"DIV"}, im_wdkUtil.$("buddylist_tab"));
        this._self.style.position = "absolute";
        if(this.m_align=="left"){
            if(!this._baseLeft){
                IMcssTag.css(im_wdkUtil.$('buddylist_tab'), "display", "block");
                var _tabRect = im_wdkUtil.viewRect.get("buddylist_tab");
                this._baseLeft = _tabRect.x;
            }            this._right = this._baseLeft;
            this._bottom = 0;
            this._left   = 0 - this._baseLeft;
            this._top    = 0;
        }else{
            if(this._baseLeft+this._width+_r > rect.x+rect.w){
                this._left  = rect.x + rect.w - this._width - this._baseLeft - _r;
                this._right = 0 - this._left;
            }
            this._top    = -1;
            this._bottom = IMBrowser.msie56 ?-4:3;
        }
        this._self.style.left  = this._left + "px";
        this._self.style.bottom = this._bottom + "px";
    }else{
        this._self = im_wdkUtil.createDom({name:"DIV"},null, "AfterBegin");
        this._self.style.position = "absolute";        if(this.m_align=="left"){
            this._left   = rect.x + (_entrytype=="toolbar" ? 0 : this.m_rlLong);
            this._right  = rect.x + rect.w  - this._left - this._width - (_entrytype=="toolbar" ? _r : this.m_rlLong);
        }else{
            this._left   = rect.x + rect.w - this._width  - (_entrytype=="toolbar" ? _r : this.m_rlLong);
            this._right  = rect.x - (_entrytype=="toolbar" ? _r : this.m_rlLong);
        }
        this._top    = Math.max(0, rect.h - this._height - 28);
        this._bottom = 28;
        this._self.style.left   = this._left + "px";
        this._self.style.bottom = this._bottom + "px";
    }
    if(im_wdkUtil.$("buddylist_tab")) im_wdkUtil.$("buddylist_tab").style.display="block";
    this._self._ptr = this;   
    this._self.style.zIndex = IMBrowser.opera ? 1001 : (IMBrowser.msie ? 0 : 999);
    this.m_flashContainerID = "container_" + this._flashID;
    var bg = wdkApplication._debug ? "background-color:#000333;" : "background-image:url(" + Ntalker.cache.image_dir + "blank.gif);";
    var flashWidth = this._width - 2*this.borderWidth;
    var ww = this.borderWidth;
    var ch = this._height - 20 - this.borderWidth;
    var sb = [];
    sb.push("<div type='nw' style='position:absolute;z-index:2;top:0px;left:0px;height:13px;width:13px;font-size:0;background-repeat:no-repeat;" + bg + "'></div>");
    sb.push("<div type='n' style='position:absolute;z-index:1;top:0px;right:0px;height:" + ww + "px;width:100%;font-size:0;background-repeat:repeat-x;" + bg + "'></div>");
    sb.push("<div type='ne'style='position:absolute;z-index:2;top:0px;right:0px;height:13px;width:13px;font-size:0;background-repeat:no-repeat;" + bg + "'></div>");
    sb.push("<div type='e' style='position:absolute;z-index:1;top:20px;right:0px;height:"+ch+"px;width:" + ww + "px;'></div>");
    sb.push("<div type='w' style='position:absolute;z-index:1;left:0px;top:20px;height:"+ch+"px;width:" + ww + "px;'></div>");
    sb.push("<div type='sw' style='position:absolute;z-index:2;bottom:0px;left:0px;height:13px;width:13px;font-size:0;background-repeat:no-repeat;" + bg + "'></div>");
    sb.push("<div type='s' style='position:absolute;z-index:1;bottom:0px;right:0;height:" + ww + "px;width:100%;font-size:0;'></div>");
    sb.push("<div type='se' style='position:absolute;z-index:2;bottom:0px;right:0px;height:13px;width:13px;font-size:0;background-repeat:no-repeat;" + bg + "'></div>");
    sb.push("<div type='dlgHead' style='position:absolute;left:0px;top:" + ww + "px;width:" + this._width + "px;height:" + this.titleHeight + "px;z-index:8;'>");
    sb.push("  <div type='dlgHead' style='position:absolute;left:0px;width:9px;top:0px;height:20px;z-index:4;'></div>");
    sb.push("  <div type='dlgHead' style='position:absolute;left:6px;width:96%;top:0px;height:20px;z-index:3;'><div style='-moz-user-select: none;-khtml-user-select: none;user-select: none;font-size:"+_cfg.fSize+";color:"+_cfg.fColor+";height:20px;padding:"+(IMBrowser.oldModel ? 4 : 0)+"px 0px 0px 10px;text-align:left;overflow:hidden'></div></div>");
    sb.push("  <div type='dlgHead' style='position:absolute;right:0px;width:60px;top:0px;height:20px;z-index:5;'></div>");
    sb.push("</div>");
    sb.push("<div id='" + this.m_flashContainerID + "'><div id='" + this._flashID + "'><div style='width:"+flashWidth+"px;height:"+this._height+"px; background: #CBECC1 url("+Ntalker.cache.image_dir+"/installbg.gif) repeat-x; color:"+_cfg.fColor+";font-size:12px;line-height:"+this._height+"px; text-align:center;'><a href='http://www.adobe.com/go/getflashplayer' target='_blank'>您未安装Flash插件或版本过低,现在安装或升级.</a></div></div></div>");
    if(IMBrowser.msie)
        sb.push('<iframe style="position:absolute;z-index:-1;width:96%;height:92%;top:15px;left:2px;scrolling:no;" frameborder="0" src="about:blank"></iframe>');
    this._self.innerHTML = sb.join("");
    delete sb;
    if(IMBrowser.msie) CollectGarbage();
    this._self.style.display = "block";
    this._minBtn = this._self.childNodes[9];
    this._self.y0 = this._doc.body.clientHeight - this._self.offsetHeight;
    this._height0 = 14;
    this._flashcontainer = this._doc.getElementById(this.m_flashContainerID);
    var _this = this;
    this.createFlash(tagIndex);
    function __doEvent(e){_this.eventHandle(e || window.event);}
    this._self.onmouseover = __doEvent
    this._self.onmouseout  = __doEvent
    this._self.onmousedown = __doEvent
    this._self.onmouseup   = __doEvent;
    this.resize(this._width, this._height);
    if(!this.isMiniFloat){
        wdkApplication._FloatWindowManager.addWindow(this);  
    }
};
_p.createFlash = function(tagIndex){
    if(!this._flashcontainer)
        return;
    var swfSrc = this.m_jsURLPath+"/NtalkerIM.swf";
    var flashvars = {siteid:    encodeURIComponent(Ntalker.variable.siteid),
                     myuid:     encodeURIComponent(Ntalker.variable.user_id),
                     myname:    encodeURIComponent(Ntalker.variable.user_name),
                     sessionid: encodeURIComponent(Ntalker.variable.user_sid),
                     modurl:    this.m_jsURLPath+"/ContactMod.swf?version="+Ntalker.version.buddylist_flash,
                     rurl:      this.m_jsURLPath,
                     ps:        window.screen.height<960 ? 6 : 9,
                     skin:      Ntalker.cache.skin ? Ntalker.cache.skin : "ntalker_skin1",
                     index:     tagIndex,
                     eg:        (Ntalker.Config.customparams['enablegroup']||Ntalker.Config.customparams['enablechat']?1:0),
                     ispopup:   Ntalker.Config.isPopupWindow
                     };
    if(Ntalker.variable.userparam)
        flashvars.userparam = encodeURIComponent(Ntalker.variable.userparam);
    if(Ntalker.Config.buddylistlogo)
        flashvars.logo = Ntalker.Config.buddylistlogo;
    if(Ntalker.Config.buddylistlogo && Ntalker.Config.copyrighturl)
        flashvars.from = Ntalker.Config.copyrighturl.toLowerCase().replace("http://","");
    else
        flashvars.from = encodeURIComponent(window.location.host);
    if(typeof Ntalker.Config.customparams.introbuddy != "undefined")
        flashvars.introbuddy = Ntalker.Config.customparams.introbuddy;
    if(typeof Ntalker.Config.customparams.onlinelist != "undefined")
        flashvars.onlinelist = Ntalker.Config.customparams.onlinelist;    if(flashvars.toJSONString)
        delete flashvars.toJSONString;
    var flashWidth = this._width - 2*this.borderWidth;
    var flashmode = IMBrowser.msie ? "Opaque" : "Window";
    var params = {menu:"true", "salign":"LT", "allowScriptAccess":"always", "wmode":flashmode};
    var attributes = {};
    swfobject.embedSWF(swfSrc, this._flashID, flashWidth, this._height, "9.0.115", Ntalker.variable.scriptPath+"/expressInstall.swf", flashvars, params, attributes);
    this._flash = im_wdkUtil.$(this._flashID);
    this.setFlashStyle();
    var _this = this;
    if(this._flash){
        var __checkFlashLoad =function(){ _this.checkFlashLoad();};
        this._checkFlashTimerid = window.setTimeout(__checkFlashLoad, this._flashLoadTime);
        this._flashLoadTime = this._flashLoadTime*2; 
    }};
_p.setFlashStyle = function(){  
    var fw = this._width - 2*this.borderWidth;;
    var fh = this._height-this.titleHeight - this.borderWidth*2;
    if(this._flash){
        this._flash.style.position = "absolute";
        this._flash.style.top = (this.borderWidth + this.titleHeight) + "px";
        this._flash.style.left = this.borderWidth + "px";
        this._flash.style.right = this.borderWidth + "px";
        this._flash.style.bottom = this.borderWidth + "px";
        this._flash.style.width = fw + "px";
        this._flash.style.height = fh + "px";
        this._flashHeight        = this._flash.style.height;
    }
  }
_p.checkFlashLoad = function(){
    if(!this._isFlashLoadSuccess){
        var _this = this;
        this._restoreFlash = this._flash;
        var waitwinid = "winwdk_buddylist_wait";
        var closewinid = "btnwdk_buddylist_close";
        var reloadwinid = "btnwdk_buddylist_reload";
        var fw = this._width - 2*this.borderWidth;
        var fh = this._height - this.titleHeight - this.borderWidth*2;
        var html = '<div id="'+waitwinid+'" style="z-index:10;position: absolute;top:'+this.titleHeight+'px;background:#F6F6F6 none;height:' + fh + 'px;width:' + fw + 'px;font-size:12px;font-weight: 100;border:1px solid #8C8C8C; text-align:center;cursor:auto;">'
                 + '<div name="winlogo" style="float:left;width:70px;height:22px;background:url(' + Ntalker.Config.logo + ') bottom right no-repeat;"></div>'
                 + '<div name="wintitle" style="float:left;margin-left:25px;width:132px;height:19px;background:url(' + Ntalker.cache.image_dir + '/titleText.gif) bottom  no-repeat;"></div>'
                 + '<div id="'+closewinid+'" name="btnclose" style="z-index:12;float:right;margin-right:8px;width:26px;height:20px;background:url('+Ntalker.cache.image_dir+'/icon.gif) no-repeat;cursor:pointer;"></div>'
                 + '<div style="clear:both;height:' + (fh-20) + 'px;line-height:' + (fh-20) + 'px;"><a id="'+reloadwinid+'" href="javascript:void(0)">请点击此处重新链接...</a></div>'
                 + '</div>';
        im_wdkUtil.insertHtml("beforeend", this._flashcontainer, html);
        this._flash.style.width = "1px";
        this._flash.style.height = "1px";
        this._flash = this._flashFailedDiv = im_wdkUtil.$(waitwinid);
        var _this = this;
        var __clearClick  = function(e){var event = new im_wdkUtil.EventMechanism(e); event.stopPropagation();}
        var __closeWaitWin = function(e){_this.close();if(IMToolBar) IMToolBar.BuddylistVisible = false;}
        var __reloadFlash =function(){ _this.reloadFlash();}
        this._waitFlashAutoLoadTimeid = window.setTimeout( __reloadFlash , this._waitFlashAutoLoad);
        this._waitFlashAutoLoad = this._waitFlashAutoLoad * 2;
        im_wdkUtil.$(waitwinid).onclick = __clearClick;
        im_wdkUtil.$(closewinid).onclick=__closeWaitWin
        im_wdkUtil.$(reloadwinid).onclick = __reloadFlash;
    }else{    }
};
_p.reloadFlash = function(){
    if(this._restoreFlash){
        delete this._restoreFlash;
    }
    this._flash = null;
    if(this._flashFailedDiv){
        this._flashcontainer.removeChild(this._flashFailedDiv);
        delete this._flashFailedDiv;
    }
    this._flashcontainer.innerHTML = "<div id='" + this._flashID + "'></div>";
    if(this._waitFlashAutoLoadTimeid) clearTimeout(this._waitFlashAutoLoadTimeid);
    this.createFlash();
}
_p.onFlashLoadSuccess = function(){
    this._isFlashLoadSuccess = true;
}
_p.eventHandle = function(ev){
    var event = ev||window.event;
    var ee = event.srcElement||event.target;
    if(ee.tagName == "IFRAME"){
        return;
    }
    if(ee.getAttribute("type") == "button"){
        switch(ev.type){
        case "mouseover":
            ee.style.backgroundPosition = "0 -" + ee.offsetHeight + "px";
            break;
        case "mouseout":
            ee.style.backgroundPosition = "0 0";
            break;
        case "mousedown":
            ee.style.backgroundPosition = "0 -" + (ee.offsetHeight * 2) + "px";
            break;
        case "mouseup":
            ee.style.backgroundPosition = "0 -" + ee.offsetHeight + "px";
            var eeName = ee.getAttribute("name");
            switch(eeName){
            case "btmin"   :
            case "btclose" :
              this.close(true);
              break;
            case "btpopup" :
              this.popup();
              break;
            }
        }
    }
    var type = ee.getAttribute("type");
    if(type == "nw" || type == "n" || type == "ne" || type == "s" || type == "se" || type == "w" || type == "e"){
        switch(ev.type){
        case "mousedown":
            wdkApplication._FloatWindowManager.startResize(ev, this, type);
            break;
        case "mouseup":
            wdkApplication._FloatWindowManager.showPanel(false);
            break;
        }
    }
};
_p.updateMinButton = function(bMin){
    if(this._minBtn){    }
};
_p.minimize = function(){
    if(this.minDiv)    this.minDiv.style.visibility = "visible";
    if(this._self)    this._self.style.visibility = "hidden";
    if(this._flash) this._flash.style.visibility = "hidden";
};
_p.close = function(isShowMini){
    if(!this._self)
        return;
    if(this._flash){
        if(this._flash.asIM_closeIMBuddyList)
            this._flash.asIM_closeIMBuddyList();
        im_wdkUtil.disposeFlashObj(this._flash);
        if(!!this._flash.parentNode){
            IMcssTag.css(this._flash, "display", "none");
            this._flash.parentNode.removeChild(this._flash);
        }
    }
    this._self.onmouseover = null;
    this._self.onmouseout  = null;
    this._self.onmousedown = null;
    this._self.onmouseup   = null;
    this._self.onfocus   = null;
    this._self.onblur   = null;
    if(Ntalker.temp.buddylistFlashGoUrl){
        im_wdkUtil.createScript(Ntalker.temp.buddylistFlashGoUrl);
        Ntalker.temp.buddylistFlashGoUrl = null;
    }
    this._self.parentNode.removeChild(this._self);
    delete this._self;
    if(isShowMini && this.minDiv)
        this.minDiv.style.visibility = "visible";
    if(!this.isMiniFloat)
        wdkApplication._FloatWindowManager.removeWindow(this);
    if(im_wdkUtil.$("buddylist_tab"))
        im_wdkUtil.$("buddylist_tab").style.display = "none";
    this.isShow = false;
};
_p.showWindow = function(isPopup){
    var _var = Ntalker.variable;
    if(_var.user_id==0 || !_var.user_id){
        alert("您还没有登录，请先登录！");return;
    }
    if(IMToolBar._disable){
        return;
    }    if(this._self == null){
        this.createWin(Ntalker.Config.IMtabIndex);    }
    else{        this._self.style.visibility = "visible";
        if(this._flash) this._flash.style.visibility = "visible";
        IM_BuddyListDOM = im_wdkUtil.$("wdk_buddylist_flash");
        if(IM_BuddyListDOM && IM_BuddyListDOM.switchTabIndex)
            IM_BuddyListDOM.switchTabIndex(Ntalker.Config.IMtabIndex);
    }
    if(im_installFlashActionX==true){
        var rect = im_wdkUtil.viewRect.get(window);
        if(offsetLeft && offsetTop){
            this.moveTo(parseInt(rect.x + offsetLeft), parseInt(rect.y + offsetTop) );
        }else{
            this.moveTo(parseInt( this._left + rect.x + this.m_rlLong ), this._top+rect.y);
        }
    }
    if(this.minDiv){
        this.minDiv.style.visibility = "hidden";
        var tipEl = im_wdkUtil.$('imiTwdk_mini_state_img');
        if( tipEl )
            tipEl.visibility = "hidden";
    }
    this.isShow = true;
};
_p.saveRect = function(){
    var rect = im_wdkUtil.viewRect.get(window);
    this._left = this._self.offsetLeft - rect.x;
    this._top = this._self.offsetTop - rect.y;
    this._width = this._self.offsetWidth;
    this._height = this._self.offsetHeight;
};
_p.OnTBShowBuddylist =function(x, y, show){
    var rect = im_wdkUtil.viewRect.get(window)
    offsetLeft = this.m_align=="left" ? x-rect.x : x-rect.x-this._width;
    offsetTop  = y - rect.y - this._height; 
    if(!show){        IM_BuddyListDOM = im_wdkUtil.$("wdk_buddylist_flash");
        if(IM_BuddyListDOM && IM_BuddyListDOM.switchTabIndex)
            IM_BuddyListDOM.switchTabIndex(Ntalker.Config.IMtabIndex);
    }else if(show){
        this.showWindow(Ntalker.Config.isPopupMode);
    }
}
WDK_IM_PACK.WDKChatWindow = function(destuid, destnick, chatid, layoutmode, chatType){
    WDK_IM_PACK.FloatWindow.prototype.constructor();
    this._destuid = destuid;
    this._destnick = destnick;
    this._chatType   = chatType==""?"chat":chatType;
    this._window = window;
    this._layout = layoutmode; 
    this._doc = this._window.document;
    this._self = null;
    this._selfid = "webchat_window"+destuid+this._chatType;
    this._titleid = "webchat_title"+destuid+this._chatType;
    this._headerid = "webchat_header"+destuid+this._chatType;
    this._width = Ntalker.Config.chatWidth;
    this._height = Ntalker.Config.chatHeight;
    this._avwidth = 340; 
    this._avheight = 0;  
    this._savewidth = null;
    this._saveheight = null;
    this._titleHeight = 10;  
    this._borderWidth = 2;  
    this._minWidth  = 100;
    this._minHeight = 100;
    this._flashHeight = null;
    this._align = Ntalker.Config.customparams["floatpos"] || "right";;
    this._rightOffset = 20;
    this._bottomOffset = 20;
    this._miniImgBottom;
    this._title;
    this._isFlashTitle = false;
    this._flashID = "webchat_flash"+destuid+this._chatType;
    this._flash = null;
    this._flashContainerID = "webchat_container"+destuid+this._chatType;
    this._flashcontainer;
    this._jsURLPath = Ntalker.variable.scriptPath;
    this._presenceFlashGoUrl = null;
    this._freeChatFlashGoUrl = null;
    this._defaultZIndex = 99;
    this._focusZIndex = 999;
    this._titlespan = null;
    this._headerdiv = null;
    this._curWindMode = "default"; 
    this._flashTitleTimerID = null;
    this._iframe = null;
    this._avStatus = "";
    this._TransferState = false;
    this._top = 0;
    this._bottom = 0;
    this._left = 0;
    this._right = 0;
    this._chatid = chatid ? chatid:null;
    this.isInited = false;
    this._isFlashLoadSuccess = false;
    this._flashLoadTime = 30000; 
    this._waitFlashAutoLoad = 5000; 
    this._flashFailedDiv = null;
    this._checkFlashTimerid = null;
    this._waitFlashAutoLoadTimeid = null;
    this._entrytype = Ntalker.Config.entrytype;
    this._baseLeft = 0;
    this._baseTop  = 0;
};
WDK_IM_PACK.WDKChatWindow.prototype = new WDK_IM_PACK.FloatWindow();
_p = WDK_IM_PACK.WDKChatWindow.prototype;
_p.showWindow = function(offsetRight, offsetBottom, miniWinTabDOM){
    if(this.isInited) return;
    this.isInited = true;
    this._rightOffset = offsetRight ? offsetRight : 0;
    this._bottomOffset = offsetBottom ? offsetBottom : 0;
    var _winRect = im_wdkUtil.viewRect.get(window);
    if(miniWinTabDOM && this._entrytype=="toolbar"){
        this._self = im_wdkUtil.createDom({name:"DIV"}, miniWinTabDOM);
        this._self.style.position = "absolute";
        this._self.style.outlineStyle = "none";
        this._right  = offsetRight;
        this._bottom = offsetBottom;
        this._left   = _winRect.w - this._width - offsetRight;
        this._top    = 0 - this._height - offsetBottom;
        this._self.style.left = this._left + "px";
        this._self.style.top  = this._top + "px";    }else{
        if(this._entrytype=="toolbar" && this._rightOffset<Ntalker.Config.IMWidth){
            this._rightOffset = Ntalker.Config.IMWidth + 2;
        }
        this._self = im_wdkUtil.createDom({name:"DIV"}, null, "AfterBegin");
        this._self.style.position = "absolute";
        this._self.style.outlineStyle = "none";
        this._left = Math.max(0,_winRect.x + _winRect.w-this._width - this._rightOffset);
        this._right = this._rightOffset;
        this._bottom = IMBrowser.msie56 ?this._bottomOffset-5 : this._bottomOffset;
        this._top = Math.max(0, _winRect.h - this._height - this._bottomOffset);
        this._self.style.left = this._left + "px";
        this._self.style.top = (this._top+_winRect.y) + "px";
        this._baseLeft = this._left;
        this._baseTop  = this._top;    }
    this._self._ptr = this;
    this._self.style.zIndex = 99;
    this._self.style.width = this._width+"px";
    this._self.style.height = this._height+"px";
    this._self.tabIndex = parseInt(this._destuid);
    var bg = "background-image:url(" + Ntalker.cache.image_dir + "blank.gif);";    var ww = this._borderWidth;
    var ch = this._height - this._titleHeight - this._borderWidth;
    var fw = Math.max(this._width - this._borderWidth*2, 0);
    var fh = this._height-this._titleHeight - this._borderWidth;
    this._iframeid = this._destuid+"_iframe";
    var sb = [];
    sb.push("<div type='nw' style='position:absolute;top:0px;left:0px;height:13px;width:13px;font-size:0;background-repeat:no-repeat;" + bg + "'></div>");  
    sb.push("<div type='n' style='position:left:0px;absolute;top:0px;height:" + ww + "px;width:100%;font-size:0;background-repeat:repeat-x;" + bg + "'></div>");
    sb.push("<div type='ne'style='position:absolute;top:0px;right:0px;height:13px;width:13px;font-size:0;background-repeat:no-repeat;" + bg + "'></div>");  
    sb.push("<div type='e' style='position:absolute;top:20px;right:0px;height:"+ch+"px;width:" + ww + "px;'></div>");
    sb.push("<div type='w' style='position:absolute;top:20px;left:0px;height:"+ch+"px;width:" + ww + "px;'></div>");
    sb.push("<div type='sw' style='position:absolute;bottom:0px;left:0px;height:13px;width:13px;font-size:0;background-repeat:no-repeat;" + bg + "'></div>");  
    sb.push("<div type='s' style='left:0px;position:absolute;bottom:0px;height:" + ww + "px;width:100%;font-size:0;'></div>");
    sb.push("<div type='se' style='position:absolute;bottom:0px;right:0px;height:13px;width:13px;font-size:0;background-repeat:no-repeat;" + bg + "'></div>");
    sb.push("<div type='dlgHead'  style='position:absolute;left:0px;top:" + ww + "px;width:100%;height:" + this._titleHeight + "px;'>");
    sb.push("  <div type='dlgHead' style='position:absolute;left:0px;width:9px;top:0px;height:100%;'></div>");
    sb.push("<div type='dlgHead' style='position:absolute;left:9px;width:96%;top:0px;height:20px;'><div id='"+this._titleid+"' style='-moz-user-select: none;-khtml-user-select: none;user-select: none;color:"+Ntalker.Config.fColor+";font-size:"+Ntalker.Config.fSize+";height:auto;text-align:left;padding-left:10px;line-height:20px;'></div></div>");
    sb.push("  <div type='dlgHead' style='position:absolute;right:0px;width:60px;top:0px;height:100%;'></div>");
    sb.push("</div>");
    sb.push("<div name='btpopup' type='button' style='position:absolute;right:43px;top:5px;font-size:0;width:14px;height:14px;'></div>");
    sb.push("<div name='btmin' type='button'  style='position:absolute;right:25px;top:5px;font-size:0;width:14px;height:14px;'></div>");
    sb.push("<div name='btclose' type='button' style='position:absolute;right:7px;top:4px;font-size:0;width:14px;height:14px;'></div>");
    sb.push("<div id='" + this._flashContainerID + "' style='"+(IMBrowser.msie8 ? "":"position: absolute;")+"'><div id='" + this._flashID + "'><div style='background:#CBECC1 url("+Ntalker.cache.image_dir+"/installbg.gif) repeat-x;height:"+fh+"px;width:"+fw+"px;font-weight: 100;font-size:12px;line-height:"+fh+"px; text-align:center;'><a href='http://www.adobe.com/go/getflashplayer' target='_blank'>您未安装Flash插件或版本过低,现在安装或升级.</a></div></div></div>");
    this._self.innerHTML = sb.join("");
    delete sb;
    this._minBtn = this._self.childNodes[10];    this._headerdiv = this._doc.getElementById(this._headerid);
    this._self.y0 = this._doc.body.clientHeight - this._self.offsetHeight;
    this._height0 = 14;
    this._flashcontainer = this._doc.getElementById(this._flashContainerID);
    this.createFlash(true);
    var _this = this;
    function __doEvent(e){_this.eventHandle(e || window.event);};
    this._self.onmouseover = __doEvent;
    this._self.onmouseout = __doEvent;
    this._self.onmousedown = __doEvent;
    this._self.onmouseup = __doEvent;
    this._self.onfocus = __doEvent;
    this._self.onblur = __doEvent;
    this._self.ondblclick = __doEvent;
    this.resize(this._width, this._height);
    wdkApplication._FloatWindowManager.addWindow(this); 
};
_p.moveTo = function(x, y, isNotSavePos){
    var rect = im_wdkUtil.viewRect.get(window);    if(typeof(isNotSavePos)=="undefined" || !isNotSavePos){
        if(this._entrytype=="toolbar" && !IMBrowser.oldModel){
            this._left = x;
            this._top  = y;
            this._right = 0-x;
            this._bottom = 0-y;
        }else{
            this._left   = x - rect.x;
            this._top    = y - rect.y;
            this._right  = rect.x + rect.w - x - this._width;
            this._bottom = rect.y + rect.h - y -this._height;
        }
    }
    if(IMBrowser.msie){
        this._self.style.pixelLeft = x;
        this._self.style.pixelTop  = y;
    }else{
        this._self.style.left = x + "px";
        this._self.style.top  = y + "px";
    }
};
_p.resize = function(w, h){
    this._width = w;
    this._height = h;
    this._self.style.width  = w + "px";
    this._self.style.height = h + "px";
    this._self.childNodes[8].style.width = w + "px";
    if(this._flash){
        this.setFlashStyle();
    }
};
_p.fooRepos = function(ev){
    var rect = im_wdkUtil.viewRect.get(window)
    if(ev && ev.type == "resize"){
        if(!this._self) return;
        var x = rect.x + rect.w-this._width-this._right;
        var y = rect.y + rect.h-this._height-this._bottom;
        if(this._entrytype=='toolbar'){
            if(this._curWindMode!='hide'){
                y = this._top + (IMBrowser.msie56&&document.compatMode=="BackCompat"?rect.y:0),x=0;
                if(IMToolBar){
                    var _viewRect = IMToolBar.getMiniWindow(this._destuid, this._chatType).onFocus();
                    x = _viewRect.x;
                }
                if(this._align=="left"){
                    x = x<rect.x+Ntalker.Config.IMWidth+10 ? rect.x+Ntalker.Config.IMWidth+10 : (x+this._width>rect.x+rect.w ? rect.x+rect.w-this._width : x);
                }else{
                    x = x<rect.x ? rect.x : (x+this._width > rect.x+rect.w-Ntalker.Config.IMWidth-10 ? rect.x+rect.w-Ntalker.Config.IMWidth-10-this._width : x);
                }
            }else{
                x = -2000;
            }
        }else{
            x = x>=rect.x ? x : rect.x;
            y = y>=rect.y ? y : rect.y;
        }        this.moveTo(x, y, true);
    }
    else if(this._self){
        if(this._entrytype=='toolbar' && !IMBrowser.oldModel)
            return;
        var rect = im_wdkUtil.viewRect.get(window)
        var x = rect.x + this._left;
        var y = rect.y + this._top;
        if(this._entrytype=='toolbar'){
            y = y+this._height>rect.y+rect.h ? rect.y+rect.h-this._height-25 : y;
        }else{
            this._self.style.left = x + "px";
        }       
        this._self.style.top  = y + "px";
        if(this._flash){
            this._flash.style.left = (document.compatMode=='CSS1Compat' ? this._borderWidth : this._borderWidth )+"px";
        }
    }
};
_p.hide = function(){
    if(this._curWindMode=='default')
        this.minimize();
};
_p.show = function(offsetLeft, offsetTop){
    if(this._curWindMode=='hide'){
        this.minimize();
        if(offsetLeft && offsetTop){
            var _rect = im_wdkUtil.viewRect.get(window);            this.moveTo(_rect.x + offsetLeft, _rect.y + (offsetTop-this._height) );
        }
    }
};
_p.minimize = function(){
    var visiblestyle;
    var displaystyle;
    switch(this._curWindMode){
    case "default":
        visiblestyle = "hidden";
        displaystyle = "none";
        this._curWindMode = "min";
        this._flashcontainer.style.width = "1px";
        this._flashcontainer.style.height = "1px";
        this._flash.style.width = "1px";
        this._flash.style.height = "1px";
        if(this._avStatus=="vedio" && this._savewidth){
            this._self.style.width = this._savewidth + "px";
            this._self.childNodes[8].style.width = Math.max(this._savewidth - 2 * this._borderWidth, 0) + "px";
        }
        this._self.style.height = this._titleHeight + "px";
        if( this._layout=="toolbar" ){
            this._curWindMode = "hide";
            this.moveTo(-2000, 0, true);        }
        break;
    case "min":
        visiblestyle = "visible";
        displaystyle = "block";
        this._curWindMode = "default";
        this._self.style.width = this._width + "px";
        this._self.style.height = this._height+"px";
        this._flash.style.height = this._flashHeight;        this.stopFlashTitle();
        this.resize(this._width, this._height);
        break;
    default:
        visiblestyle = "visible";
        this._curWindMode = "default";
        break;
    }
    for(var i=3;i<8;i++){
        this._self.childNodes[i].style.visibility = visiblestyle;
        this._self.childNodes[i].style.display = displaystyle;
    }
};
_p.MinMax = function(){
    var visiblestyle;
    var displaystyle;
    switch(this._curWindMode){
    case "default":
        visiblestyle = "hidden";
        displaystyle = "none";
        this._curWindMode = "hide";
        this._flashcontainer.style.width = "1px";
        this._flashcontainer.style.height = "1px";
        this._flash.style.width = "1px";
        this._flash.style.height = "1px";
        if(this._avStatus=="vedio" && this._savewidth){
            this._self.style.width = this._savewidth + "px";
            this._self.childNodes[8].style.width = Math.max(this._savewidth - 2 * this._borderWidth, 0) + "px";
        }
        this._self.style.height = this._titleHeight + "px";
        if(IMToolBar) IMToolBar.getMiniWindow(this._destuid, this._chatType).onBlur();
        this.moveTo(-2000, 0, true);
        break;
    case "hide":
        visiblestyle = "visible";
        displaystyle = "block";
        this._curWindMode = "default";
        this._self.style.width = this._width + "px";
        this._self.style.height = this._height+"px";
        this.stopFlashTitle();
        this._flash.style.height = this._flashHeight;
        this.resize(this._width, this._height);
        var rect = im_wdkUtil.viewRect.get(window);
        var y = this._top + (IMBrowser.msie56&&document.compatMode=="BackCompat"?rect.y:0),x;
        if(IMToolBar){
            var _viewRect = IMToolBar.getMiniWindow(this._destuid, this._chatType).onFocus();
            x = _viewRect.x;
        }
        if(this._align=="left"){
            x = x<rect.x+Ntalker.Config.IMWidth+10 ? rect.x+Ntalker.Config.IMWidth+10 : (x+this._width>rect.x+rect.w ? rect.x+rect.w-this._width : x);
        }else{
            x = x<rect.x ? rect.x : (x+this._width > rect.x+rect.w-Ntalker.Config.IMWidth-10 ? rect.x+rect.w-Ntalker.Config.IMWidth-10-this._width : x);
        }        this.moveTo(x, y);
        break;
    default:
        visiblestyle = "visible";
        this._curWindMode = "default";
        break;
    }
    for(var i=3;i<8;i++){
        this._self.childNodes[i].style.visibility = visiblestyle;
        this._self.childNodes[i].style.display = displaystyle;
    }};
_p.close = function(){
    this.stopFlashTitle();
    this._flash = im_wdkUtil.$(this._flashID);
    if(this._checkFlashTimerid){
        clearTimeout(this._checkFlashTimerid);
    }
    if(this._flash){
        if(this._flash.asIM_closeChatWindow)
           this._flash.asIM_closeChatWindow();
        im_wdkUtil.disposeFlashObj(this._flash);
        IMcssTag.css(this._flash, "display", "none");
        this._flash.parentNode.removeChild(this._flash);
        delete this._flash;
    }
    this._self.onmouseover = null;
    this._self.onmouseout  = null;
    this._self.onmousedown = null;
    this._self.onmouseup   = null;
    this._self.onfocus   = null;
    this._self.onblur   = null;
    this._self.ondblclick = null;
    if(this._freeChatFlashGoUrl != null && this._freeChatFlashGoUrl != ''){
        im_wdkUtil.createScript(this._freeChatFlashGoUrl);    }
    if(this._presenceFlashGoUrl != null && this._presenceFlashGoUrl != ''){
       im_wdkUtil.createScript(this._presenceFlashGoUrl);    }
    im_chat_window_manager.removeChatWindow(this._destuid, this._chatType);
    this._self.parentNode.removeChild(this._self);
    delete this._self;
    if(IMToolBar){
        IMToolBar.removeMiniWindow(this._destuid, this._chatType);
    }
    wdkApplication._FloatWindowManager.removeWindow(this);
};
_p.startFlashTitle = function(titleText){
    if(this._flashTitleTimerID)
        return;
    this._flashTitleText = im_wdkUtil.cutText(titleText, 20, true);
    this._flashTitleTimerID = setInterval("im_chat_window_manager.flashWindowTitle('"+this._destuid+"')",1000);
};
_p.changeTitle = function(titleText){
    this._isFlashTitle = this._isFlashTitle ? false:true;
};
_p.stopFlashTitle = function(titleTxt){
    if(this._flashTitleTimerID){
        clearInterval(this._flashTitleTimerID);
        this._flashTitleTimerID = null;
        this._isFlashTitle = false;
    }
};
_p.createFlash = function(bRefresh){
    if(!this._flashcontainer)
        return;
    var swfSrc  = this._jsURLPath+"/" + (this._chatType=="bbshot"?"NtalkerHotActivity.swf":"NtalkerIM.swf");
    flashvars = { version:  Ntalker.version.webchat_flash,
                  siteid:   encodeURIComponent(Ntalker.variable.siteid),
                  myuid:    encodeURIComponent(Ntalker.variable.user_id),
                  myname:   encodeURIComponent(Ntalker.variable.user_name),
                  sessionid:encodeURIComponent(Ntalker.variable.user_sid),
                  rurl:     this._jsURLPath,
                  skin:     Ntalker.cache.skin ? Ntalker.cache.skin : "ntalker_skin1",
                  ispopup:  Ntalker.Config.isPopupWindow,
                  ismax:    0
                 };
    if(this._chatType=="group"){
        flashvars.modurl    = this._jsURLPath+"/GroupMod.swf?version="+Ntalker.version.webchat_flash;
        flashvars.groupid   = encodeURIComponent(this._destuid);
        flashvars.groupname = encodeURIComponent(this._destnick);
    }
    else if(this._chatType=="chat"){
        flashvars.modurl   = this._jsURLPath+"/ChatMod.swf?version="+Ntalker.version.webchat_flash;
        flashvars.destuid  = encodeURIComponent(this._destuid);
        flashvars.destname = encodeURIComponent(this._destnick);
    }
    if(Ntalker.variable.userparam)
        flashvars.userparam = encodeURIComponent(Ntalker.variable.userparam);
    if(Ntalker.Config.chatlogo)
        flashvars.logo      = Ntalker.Config.chatlogo;
    if(Ntalker.Config.chatlogo && Ntalker.Config.copyrighturl)
        flashvars.from = Ntalker.Config.copyrighturl.toLowerCase().replace("http://","");
    else
        flashvars.from = encodeURIComponent(window.location.host);
    if(this._chatid) 
        flashvars.chatid    = this._chatid;
    if(typeof Ntalker.Config.customparams.chataddbuddy != "undefined")
        flashvars.chataddbuddy = Ntalker.Config.customparams.chataddbuddy;    if(flashvars.toJSONString)
        delete flashvars.toJSONString;
    var flashmode = IMBrowser.msie?"Opaque":"Window";
    var flashmode = "Window";
    var params = {menu:"true", "salign":"LT", "allowScriptAccess":"always", "wmode":flashmode};
    var attributes = false;
    var fw = Math.max(this._width - this._borderWidth*2, 0);
    var fh = this._height-this._titleHeight - this._borderWidth;
    swfobject.embedSWF(swfSrc, this._flashID, fw, fh,  "9.0.115", Ntalker.variable.scriptPath+"/expressInstall.swf", flashvars, params, attributes);
    this._flash = im_wdkUtil.$(this._flashID);
    this.setFlashStyle();
    if(this._flash && this._flash.tagName.toLowerCase()=="object"){
        var _this = this;
        var __checkFlashLoad =function(){ _this.checkFlashLoad();};        this._checkFlashTimerid = window.setTimeout(__checkFlashLoad, this._flashLoadTime);
        this._flashLoadTime = this._flashLoadTime*2;
    }}
_p.setFlashStyle = function(){
    this._flashcontainer.style.top      = this._titleHeight+"px";
    this._flashcontainer.style.left     = "0px";
    this._flashcontainer.style.width    = this._width+"px";
    this._flashcontainer.style.height   = (this._height-this._titleHeight - this._borderWidth)+"px";
    this._flashcontainer.style.overflow = "hidden";
    var fw = this._width - this._borderWidth*2;
    var fh = this._height-this._titleHeight - this._borderWidth*2;
    if(this._flash){
        this._flash.style.position = "relative";
        this._flash.style.width  = fw + "px";
        this._flash.style.height = fh + "px";
        this._flash.style.left   = this._borderWidth + "px";
        this._flash.style.top    = "0px";
        this._flashHeight        = this._flash.style.height;
    }
}
_p.checkFlashLoad = function(){
    if(!this._isFlashLoadSuccess){
        var _this = this;
        this._restoreFlash = this._flash;
        var waitwinid = "win"+this._chatType+"reload"+this._destuid;
        var closewinid = "btn"+this._chatType+"close"+this._destuid;
        var reloadwinid = "btn"+this._chatType+"reload"+this._destuid;
        var fw = Math.max(this._width - this._borderWidth*2, 0);
        var fh = this._height - this._titleHeight - this._borderWidth - 4;
        var html = '<div id="'+waitwinid+'" style="background:#F6F6F6 none;height:' + fh + 'px;width:' + fw + 'px;font-size:12px;font-weight: 100;border:1px solid #8C8C8C; text-align:center;cursor:auto;">'
                 + '<div name="winlogo" style="float:left;width:70px;height:22px;background:url(' + Ntalker.Config.logo + ') bottom right no-repeat;"></div>'
                 + '<div name="wintitle" style="float:left;margin-left:170px;width:132px;height:19px;background:url(' + Ntalker.cache.image_dir + '/titleText.gif) bottom  no-repeat;"></div>'
                 + '<div id="'+closewinid+'" name="btnclose" style="float:right;margin-right:8px;width:26px;height:20px;background:url('+Ntalker.cache.image_dir+'/icon.gif) no-repeat;cursor:pointer;"></div>'
                 + '<div style="clear:both;height:' + (fh-20) + 'px;line-height:' + (fh-20) + 'px;"><a id="'+reloadwinid+'" href="javascript:void(0)">请点击此处重新链接...</a></div>'
                 + '</div>';
        im_wdkUtil.insertHtml("beforeend", this._flashcontainer, html);
        this._flash.style.width = "1px";
        this._flash.style.height = "1px";
        this._flash = im_wdkUtil.$(waitwinid);
        var _this = this;
        var __clearClick  = function(e){var event = new im_wdkUtil.EventMechanism(e); event.stopPropagation();}
        var __closeWaitWin = function(e){_this.close();}
        var __reloadFlash = function(){ _this.reloadFlash();}
        this._waitFlashAutoLoadTimeid = window.setTimeout( __reloadFlash , this._waitFlashAutoLoad);
        this._waitFlashAutoLoad = this._waitFlashAutoLoad * 2; 
        im_wdkUtil.$(waitwinid).onclick = __clearClick;
        im_wdkUtil.$(closewinid).onclick = __closeWaitWin
        im_wdkUtil.$(reloadwinid).onclick = __reloadFlash;
    }
}
_p.restoreFlash = function(){
    if(this._flashFailedDiv){
       this._flashcontainer.removeChild(this._flashFailedDiv);
       delete this._flashFailedDiv;
    }
    this._flash = this._restoreFlash;
    this.resize(this._width, this._height);
    this._flash.focus();
}
_p.reloadFlash = function(){
    if(this._restoreFlash){
        delete this._restoreFlash;
    }
    this._flash = null;
    if(this._flashFailedDiv){
        this._flashcontainer.removeChild(this._flashFailedDiv);
        delete this._flashFailedDiv;
    }
    this._flashcontainer.innerHTML = "<div id='" + this._flashID + "'></div>";
    if(this._waitFlashAutoLoadTimeid) clearTimeout(this._waitFlashAutoLoadTimeid);
    this.createFlash(true);
}
_p.onFlashLoadSuccess = function(){
    this._isFlashLoadSuccess = true;
}
_p.eventHandle = function(ev){
    var event = ev||window.event;
    var ee = event.srcElement||event.target;
    if(typeof(ee.getAttribute)=="undefined")
        return;
    if(ee.getAttribute("type") == "button"){
        switch(ev.type){
        case "mouseover":
            ee.style.backgroundPosition = "0 -" + ee.offsetHeight + "px";
            break;
        case "mouseout":
            ee.style.backgroundPosition = "0 0";
            break;
        case "mousedown":
            ee.style.backgroundPosition = "0 -" + (ee.offsetHeight * 2) + "px";
            break;
        case "mouseup":
            ee.style.backgroundPosition = "0 -" + ee.offsetHeight + "px";
            var eeName = ee.getAttribute("name");
            switch(eeName){
            case "btmin":
               if(this._layout=="cascade"){
                   if(this._curWindMode=="min")
                       this.onFocus();
                   else
                       im_chat_window_manager.minCurWindow();
               }
               else if( this._layout=="toolbar" ){
                   this.MinMax();
               }else{
                   this.minimize();
               }
               break;
            case "btclose" :
               this.close();
               break;
            case "btpopup" :
               this.popup();
               break;
            };
        }
    }
    if(ev.type=="mousedown" && ee.getAttribute("type")!="button")
        this.onFocus();
    if(ee.getAttribute("type") == "dlgHead" || (typeof(ee.parentNode.getAttribute)!="undefined" && ee.parentNode.getAttribute("type") == "dlgHead")){
        switch(ev.type){
            case "focus":
                this.onFocus();
                break;
            case "blur":
                this.onBlur();
                break;
            case "dblclick":
                if(this._layout=="cascade"){                }
                else
                    this.minimize(eeName);
                break;
        }
    }
    if(this._layout=="free"){
        var type = ee.getAttribute("type");
        if(type == "nw" || type == "n" || type == "ne" || type == "sw" || type == "s" || type == "se" || type == "w" || type == "e"){
            switch(ev.type){
                case "mousedown":
                    wdkApplication._FloatWindowManager.startResize(ev, this, type);
                    break;
                case "mouseup":
                    wdkApplication._FloatWindowManager.showPanel(false);
                    break;
            }
        }
    }
};
_p.refreshFlashPos = function(){
    return;
    if(!this._flash  || this._curWindMode=="min" || this._entrytype=="toolbar")
        return;
    var moveOffset = 0;
    if(this._isMoveLeft){
        moveOffset = 1;
        this._isMoveLeft = false;
    }
    else{
        moveOffset = 0;
        this._isMoveLeft = true;
    }
    this._flash.style.left = (document.compatMode=='CSS1Compat' ? moveOffset : (this._borderWidth + moveOffset) )+"px";
}
_p.onFocus = function(){
    this._self.style.zIndex = this._focusZIndex;
    this._flashcontainer.style.zIndex = this._focusZIndex;
    this._flash.style.zIndex = this._focusZIndex;
    this._flash.focus();
    im_chat_window_manager.focusWindow(this._destuid, this._chatType);
};
_p.onBlur = function(){
    this._self.style.zIndex = this._defaultZIndex;
    this._flashcontainer.style.zIndex = this._defaultZIndex;
    this._flash.style.zIndex = this._defaultZIndex;
    this._flash.style.visibility = "hidden";
    this._flash.style.visibility = "visible";
};
_p.popup = function(){
    var _var = Ntalker.variable;
    var prompStr = null;
    if(this._avStatus=="audio")
        prompStr = "您与对方正在进行语音会话，弹出聊窗将会中断音频会话，您确定吗？";
    else if(this._avStatus=="vedio")
        prompStr = "您与对方正在进行音视频会话，弹出聊窗将会中断音视频会话，您确定吗？";
    if(prompStr && !confirm(prompStr))
        return;
}
_p.openAV = function(isVedio){
    if(this._curWindMode=="min" && this._layout=="free")
        this.minimize();
    var calltype = "";
    if(isVedio && this._avStatus!="vedio"){
        this._avStatus = "vedio";
        calltype = "音视频会话";
    }
    else if(this._avStatus!="audio"){
        this._avStatus = "audio";
        calltype = "音频会话";
    }
    var promptTitle = "请求与你"+calltype;
    if(promptwindow)
        promptwindow.startPrompt(this._destnick, promptTitle, true);
    if(this._curWindMode=="min")
        this.startFlashTitle(promptTitle);
}
_p.FileTransferState = function(isTransfer){
    this._TransferState = isTransfer;  
    if(!isTransfer)
        return;
    if(promptwindow)
        promptwindow.startPrompt(this._destnick, "传输文件", true);
}
_p.closeAV = function(isVedio){
    this._avStatus = "";
    if(this._curWindMode=="min"){
        this.stopFlashTitle();
    }
    this._titleText = "与"+this._destnick+"对话";
    this.changeTitle(this._titleText);
}
_p.onReceiveMessage = function(message){    if(this._curWindMode=="min" || this._curWindMode=="hide"){
        var titleText = this._destnick + unescape("说：")+message;
        this.startFlashTitle(titleText);
        if(IMToolBar){
            var miniWindow = IMToolBar.getMiniWindow(this._destuid, this._chatType);            miniWindow.onReceiveMiniMessage(message);
        }
        var impresenceflash = im_wdkUtil.$('impresenceflash');
        if(impresenceflash && impresenceflash.playNotifySound){
            impresenceflash.playNotifySound();        }
    }
}
_p.onPresenceReceiveChatMsg = function(message){
    if(this._flash && this._flash.presenceReceiveChatMsg)
        this._flash.presenceReceiveChatMsg(message);
};
WDK_IM_PACK.ChatWindowManager = function(){
    this._chatWnds = new IMHashtable();
    this._chatWndsArray = new Array();
    this._popupChatWnds = new IMHashtable();
    this._creatingFlashWnds = new Array();
    this._windowWidth  = Ntalker.Config.chatWidth;
    this._windowHeight = Ntalker.Config.chatHeight;
    this._windowTitleHeight = 20;
    this._layout = Ntalker.Config.layout; 
    var rect = im_wdkUtil.viewRect.get(window)
    this._align = Ntalker.Config.customparams["floatpos"];    this._layoutRight = this._windowWidth+20;
    this._layoutBottom = 0;
    this._curLayoutTop = 0;
    this._curChatWindow = null;
    this._curWindowIndex = -1; 
}
_p = WDK_IM_PACK.ChatWindowManager.prototype;
_p.addChatWindow = function(destuid, destnick, chatid, isAutoFocus, message, logoUrl, isActiveOpen, chatType){
    chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");    var chatWindow = this.getChatWindow(destuid, chatType);
    if(chatWindow){
        this.OnTBFocusWindow(destuid, chatType);
        chatWindow.onPresenceReceiveChatMsg(message);
        return;
    }
    chatWindow = Ntalker.variable.popupWindow;
    if(chatWindow && chatWindow.document){
        chatWindow.focus();
        if(typeof(message)!="undefined" && message)
            chatWindow.onPresenceReceiveChatMsg(message);
        return;
    }    var chatWndCount = im_chat_window_manager._chatWndsArray.length;
    isAutoFocus = !isActiveOpen&&chatWndCount ? false : isAutoFocus;
    if(Ntalker.Config.isPopupWindow==1 && !isActiveOpen){
        window.focus();        if(Ntalker.Config.isPopupWindow && promptwindow) promptwindow.startPrompt("聊天窗口", "　", true);
    }
    var rect = im_wdkUtil.viewRect.get(window);
    var newChatWindow = new WDK_IM_PACK.WDKChatWindow(destuid, destnick, chatid, this._layout, chatType);
    if(this._layout=="free"){
        maxRowWindows = parseInt((rect.w-220)/newChatWindow._width);
        maxCollumWinows = parseInt((rect.h-20)/newChatWindow._height);
        curWinRows = parseInt(this._chatWnds.count()/maxRowWindows);
        curWinCollums = this._chatWnds.count()%(maxRowWindows==0 ? 1 : maxRowWindows);
        rightOffset = curWinCollums*newChatWindow._width+220;
        bottomOffset = curWinRows*newChatWindow._height+20;
        newChatWindow.showWindow(rightOffset, bottomOffset);
    }
    else if(this._layout=="cascade"){
        if(isAutoFocus && this._curWindowIndex>=0){
            this._curWindowIndex = -1;
            this.layoutWindow();
        }
        newChatWindow.showWindow(this._layoutRight, this._curLayoutTop);
        if(isAutoFocus || this._curWindowIndex==-1){
            this._curWindowIndex = this._chatWndsArray.length;
            curWindowHeight = newChatWindow._height;
        }
        else{
            newChatWindow.minimize();
            curWindowHeight = this._windowTitleHeight;
            leftPos = Math.max(0, rect.x + rect.w-this._windowWidth - this._layoutRight);
            topPos  = Math.max(0, rect.y + rect.h - this._curLayoutTop - curWindowHeight);
            newChatWindow.moveTo(leftPos, topPos);
            if(typeof(message)!="undefined" && message){
                var titleText = destnick+"说："+message;
                newChatWindow.startFlashTitle(titleText);
            }
        }
        this._curLayoutTop += curWindowHeight;
    }else if(this._layout=="toolbar" && IMToolBar){
        for(var i=0; i<this._chatWndsArray.length; i++){
            this._chatWndsArray[i].hide();
        }
        var MiniWnd   = IMToolBar.addMiniWindow(destuid, destnick, logoUrl, isAutoFocus, chatType);
        var _miniRect = MiniWnd.getPost();        var _scroll   = im_wdkUtil.scroll();
        var _r        = IMBrowser.msie ? 1 : (_scroll ? 18 : 1);
        var miniWinDOM_Tab = im_wdkUtil.$$(".miniTAG_tab", MiniWnd.Element)[0];
        rightOffset  = rect.x + rect.w - _miniRect.x - this._windowWidth;
        bottomOffset = 0;
        if(this._align=="right"){
            rightOffset = rightOffset<Ntalker.Config.IMWidth+_r ? Ntalker.Config.IMWidth+_r : rightOffset;
        }else{
            rightOffset = rect.w-rightOffset-this._windowWidth<Ntalker.Config.IMWidth ? rect.w-Ntalker.Config.IMWidth-this._windowWidth : rightOffset;
        }        if(IMBrowser.oldModel){
            newChatWindow.showWindow(rightOffset, bottomOffset+28);
        }else{
            newChatWindow.showWindow(rightOffset, bottomOffset, miniWinDOM_Tab);
        }
        if(!isAutoFocus && Ntalker.variable.OnBlurWinParam>0){
            newChatWindow.MinMax();
            this.OnTBFocusWindow(Ntalker.variable.OnBlurWinParam, chatType);
        }
    }
    this._chatWnds.add(destuid+chatType, newChatWindow);
    this._chatWndsArray.push(newChatWindow);
    if(IMToolBar) IMToolBar.updateChatWindow(this._chatWndsArray.length);
    this._curChatWindow = newChatWindow;}
_p.addPopupWindow = function(destuid, chatType, popupWindow){
    this._popupChatWnds.add(destuid+chatType, popupWindow);
}
_p.removeChatWindow = function(destuid, chatType){
    var chatWindow = this.getChatWindow(destuid, chatType);
    if(!chatWindow)
        return false;
    this._chatWnds.remove(destuid+chatType);
    var isCurWindow = false;
    var deleteWindowIndex = -1;
    for(i=0; i<this._chatWndsArray.length; i++){
        if(this._chatWndsArray[i]._destuid==destuid && this._chatWndsArray[i]._chatType==chatType){
            this._chatWndsArray.splice(i,1);
            deleteWindowIndex = i;
            if(i==this._curWindowIndex)
                isCurWindow = true;
            break;
        }
    }
    if(this._chatWndsArray.length==0){
        this._curWindowIndex = -1;
        this._curLayoutTop = this._layoutBottom;
        return;
    }
    if(isCurWindow){
        if(this._curWindowIndex==0){
            newCurWindowIndex = this._curWindowIndex;
            this._curWindowIndex = -1;
        }
        if(this._curWindowIndex>0){
            newCurWindowIndex = this._curWindowIndex-1;
            this._curWindowIndex = -1;
        }
        this.layoutWindow(this._chatWndsArray[newCurWindowIndex]._destuid);
    }
    else{
        if(deleteWindowIndex < this._curWindowIndex)
            this._curWindowIndex--;
        this.layoutWindow();
    }
}
_p.removePopupWindow = function(destuid, chatType){
    this._popupChatWnds.remove(destuid, chatType);
}
_p.focusWindow = function(destuid, chatType){
    var chatWindow = this.getChatWindow(destuid, chatType);
    if(chatWindow._curWindMode == "default")
        return;
    if(this._layout=="cascade")
        this.layoutWindow(destuid);
    else{
        for(var k in this._chatWnds._hash){
            chatWindow = this._chatWnds._hash[k];
            if(chatWindow._destuid!=destuid){
                chatWindow.onBlur();
            }
            else{
                this._curChatWindow = chatWindow;
            }
        }
    }
}
_p.layoutWindow = function(newCurWindowUid){
  if(this._layout!="cascade")
    return;
  var rect = im_wdkUtil.viewRect.get(window)
  this._curLayoutTop = this._layoutBottom;
  var newCurWindowIndex = -1;
  var chatWindow = null;
  var curWindowHeight = 0;
  for(var i=0;i<this._chatWndsArray.length; i++){
    var chatWindow = this._chatWndsArray[i];
    if(i==this._curWindowIndex){
      if(newCurWindowUid){
        curWindowHeight = this._windowTitleHeight;
          if(chatWindow._curWindMode=="default")
            chatWindow.minimize();
      }
      else
          curWindowHeight = chatWindow._height;
    }
    else if(chatWindow._destuid == newCurWindowUid){
      if(newCurWindowUid){
        newCurWindowIndex = i;
        curWindowHeight = chatWindow._height;
          if(chatWindow._curWindMode=="min"){
            chatWindow.minimize();
          }
      }
      else
          curWindowHeight = this._windowTitleHeight;
    }
    else{
      if(chatWindow._curWindMode=="default")
            chatWindow.minimize();
      curWindowHeight = this._windowTitleHeight;
    }
    leftPos = Math.max(0, rect.x + rect.w-this._windowWidth - this._layoutRight);
    topPos  = Math.max(0, rect.y + rect.h - this._curLayoutTop - curWindowHeight);
    chatWindow.moveTo(leftPos, topPos);
    this._curLayoutTop += curWindowHeight;
  }
  if(newCurWindowUid && newCurWindowIndex>=0){
    this._curWindowIndex = newCurWindowIndex;
    this._chatWndsArray[this._curWindowIndex]._flash.focus();
  }
}
_p.startMove = function(ev, obj, layout){
    this._saveLayoutRight = this._layoutRight;
    this._saveLayoutBottom = this._layoutBottom;
}
_p.dragMove = function(x, y){    
    this._layoutRight = this._saveLayoutRight + x;
    this._layoutBottom = this._saveLayoutBottom + y;
    this.layoutWindow();
}
_p.minCurWindow = function(){
  this._curWindowIndex = -1;
  this.layoutWindow();
}
_p.popinWindow = function(destuid, destnick, chatid){
    this.removePopupWindow(destuid);
    this.addChatWindow(destuid, destnick, chatid, false, null);
    return true;
}
_p.closePopupWindow = function(destuid){
   this.removePopupWindow(destuid);
}
_p.closeAll = function(){
    for(var k in this._chatWnds._hash){
        chatWindow = this._chatWnds._hash[k];
        if(chatWindow&&chatWindow.close)
            chatWindow.close();
    }
}
_p.getChatWindow = function(destuid, chatType){
    chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");
    return this._chatWnds.items(destuid + chatType);
}
_p.getPopupWindow = function(destuid, chatType){
    chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");
    return this._popupChatWnds.items(destuid + chatType);
}
_p.getCreatingFlashWindow = function(){
    if(this._creatingFlashWnds.length>0){
        var windowDestuid = this._creatingFlashWnds.shift();
        return this.getChatWindow(windowDestuid, chatType);
    }else
        return null;
}
_p.flashWindowTitle = function(destuid, chatType){
    var chatWindow = this.getChatWindow(destuid, chatType);
    if(chatWindow){
        titleText =  chatWindow ._isFlashTitle ? chatWindow ._flashTitleText : chatWindow ._titleText;
        chatWindow.changeTitle(titleText);
    }
}
_p.OnTBFocusWindow = function(destuid, chatType){    for(var i=0; i<this._chatWndsArray.length; i++){
        if(this._chatWndsArray[i]._destuid==destuid && this._chatWndsArray[i]._chatType==chatType){
            this._chatWndsArray[i]._curWindMode = "hide";
            this._chatWndsArray[i].onFocus();
            this._chatWndsArray[i].MinMax();        }else{
            if(this._chatWndsArray[i]._curWindMode == 'default'){
                this._chatWndsArray[i].MinMax();
            }
        }
    }
}
_p.hideFlash= function(){
    for(var i=0; i<this._chatWndsArray.length; i++){
        var tab = im_wdkUtil.$("miniTAG_"+this._chatWndsArray[i]._destuid+"_tab");
        if(arguments[0]){
            tab.style.left = (tab.style.pixelLeft - 1000) + "px";
            if(this._chatWndsArray[i]._curWindMode == 'default'){
                this._chatWndsArray[i]._flash.style.visibility = "hidden";
                for(var j=3;j<8;j++){
                    this._chatWndsArray[i]._self.childNodes[j].style.visibility = "hidden";
                    this._chatWndsArray[i]._self.childNodes[j].style.display = "none";
                }
            }
        }else{
            tab.style.left = (tab.style.pixelLeft + 1000) + "px";
             if(this._chatWndsArray[i]._curWindMode == 'default'){
                this._chatWndsArray[i]._flash.style.visibility = "visible";
                for(var j=3;j<8;j++){
                    this._chatWndsArray[i]._self.childNodes[j].style.visibility = "visible";
                    this._chatWndsArray[i]._self.childNodes[j].style.display = "block";
                }
            }
        }
    }
}
function fIM_CloseIMWindow(){
    if(IMToolBar) IMToolBar.BuddylistVisible = false;
    if(im_myIMWindow) im_myIMWindow.close();
}
function fIM_PopupIMWindow(){
    if(im_wdkUtil.inArray(Ntalker.Config.not_popupwin_sites, Ntalker.variable.siteid)) return;
    if(IMToolBar) IMToolBar.onPopupOut();
}
function fIM_CloseChatWindow(destuid, chatType){    if(im_chat_window_manager)
        im_chat_window_manager.getChatWindow(destuid,chatType).close();
}
function fIM_PopupChatWindow(){
    if(im_wdkUtil.inArray(Ntalker.Config.not_popupwin_sites, Ntalker.variable.siteid)) return;
    if(IMToolBar) IMToolBar.onPopupOut();
}
function fIM_MinMaxChatWindow(destuid, chatType){
    if(im_chat_window_manager)
        im_chat_window_manager.getChatWindow(destuid, chatType).MinMax();
}
function fIM_MaximunChatWindow(destuid, chatType){
    var _var = Ntalker.variable;
    if(!im_chat_window_manager || chatType!="group") return;
    var groupWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
    if(!groupWindow) return;
    var popupWindow = im_popupGroupWindow(_var.user_id, _var.user_name, _var.user_sid, _var.siteid, destuid, groupWindow._destnick, null, _var.userparam, true);
    if(popupWindow){
        im_chat_window_manager.addPopupWindow(destuid, chatType, popupWindow);
        groupWindow.close(true);
    }
}
function fIM_OnWebchatOpenAV(destuid, isVedio, chatType){    var chatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
    if(chatWindow)
        chatWindow.openAV(isVedio);
}
function fIM_OnWebchatCloseAV(destuid, isVedio, chatType){    var chatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
    if(chatWindow)
        chatWindow.closeAV(isVedio);
}
function fIM_OnFileTransferState(destuid, isTransfer, chatType){    var chatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
    if(chatWindow)
        chatWindow.FileTransferState(isTransfer);
}
function fIM_ExpandChatWindow(destuid, chatType){    if(im_chat_window_manager){
        var _ChatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
        _ChatWindow.resize( _ChatWindow._width + 150, _ChatWindow._height);
    }
}
function fIM_CollapseChatWindow(destuid, chatType){    if(im_chat_window_manager){
        var _ChatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
        _ChatWindow.resize( _ChatWindow._width - 150, _ChatWindow._height);
    }
}
function fIM_setChatGoServer(freeChatFlashGoUrl, presenceFlashGoUrl, destuid, chatid, chatType){   var chatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
   if(chatWindow){
     chatWindow._freeChatFlashGoUrl = freeChatFlashGoUrl;
     chatWindow._presenceFlashGoUrl = presenceFlashGoUrl;
     chatWindow._chatid = chatid;
   }
}
function fIM_webchatFlashReady(destuid, chatType){
    var chatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
    if(chatWindow){
        chatWindow.onFlashLoadSuccess();
    }
    return true;
}
function fIM_buddylistFlashReady(){
    var buddylistFlash = document.getElementById("wdk_buddylist_flash");
    if(buddylistFlash && buddylistFlash.setBuddylistFlashParam){
        buddylistFlash.setBuddylistFlashParam(Ntalker.variable.user_sid, Ntalker.variable.user_id, Ntalker.variable.user_name, Ntalker.variable.siteid,"buddylist");
    }
    if(im_myIMWindow)
        im_myIMWindow.onFlashLoadSuccess();
}
function fIM_setBuddylistFlashParamfunc(){
  var buddylistFlash = document.getElementById("wdk_buddylist_flash");
    if(buddylistFlash && buddylistFlash.setBuddylistFlashParam){
      buddylistFlash.setBuddylistFlashParam(Ntalker.variable.user_sid, Ntalker.variable.user_id, Ntalker.variable.user_name, Ntalker.variable.siteid, "buddylist");
    }
}
function onGetIMStatus(onlineUserNum, onlineFirendNum){
    var miniStateDiv = document.getElementById("wdk_mini_state");
    var miniStateTipDiv = document.getElementById("MiniStateTip");
    var imEntrySpan = document.getElementById("wdk_im_"+Ntalker.variable.user_id);
    if(Ntalker.Config.customparams["enblebuddyentry"])
        tipElement = miniStateDiv;
    else
        tipElement = miniStateDiv?miniStateDiv:imEntrySpan;
}
var minWindow = function(destuid, destname, headURL, isAutoFocus, chatType){
    this._align      = Ntalker.Config.customparams["floatpos"];
    this._focus      = true;
    this._destuid    = destuid;
    this._chatType   = chatType;
    this._destnick   = destname ? destname : "";
    this._headURL    = headURL;
    this.originTitle = "";
    this.Element     = null;
    this._counter    = 0;
    this.timerID     = null;
    this.autoFocus   = isAutoFocus;
};
_p = minWindow.prototype;
_p.init = function(){
    this.Element = im_wdkUtil.createDom({name:"li",id:"miniTAG_"+this._destuid+this._chatType,className:"win"}, im_wdkUtil.$("windows_gp"));
    this.originTitle = im_wdkUtil.cutText(this._destnick, 5, true);
    var imgsrc   = this._chatType=="chat" ? Ntalker.cache.image_dir+"/online.png" : Ntalker.variable.scriptPath+"/images/group_24x22.png";
    el = im_wdkUtil.createDom({name:"div",className:"ico"}, this.Element);
    var imgEl = im_wdkUtil.createDom({name:"img",className:"userHead",src:imgsrc,width:18,height:18}, el);
    imgEl.onerror = function(){imgEl.src=imgsrc;}
    el = im_wdkUtil.createDom({name:"span"}, this.Element);
    im_wdkUtil.createDom({name:"Text",text:this.originTitle}, el);
    el = im_wdkUtil.createDom({name:"div",className:"miniTAG_tab",id:"miniTAG_"+this._destuid+this._chatType+"_tab",style:"border:0px solid #f00"}, this.Element);
    if(this.autoFocus) this.onFocus();
    var _this   = this;
    var __clickWindow = function(ev){_this.onClick(ev);};    im_wdkUtil.Event.addEvent(this.Element, "click", __clickWindow);
    return this.Element;
}
_p.updateUserHead = function(strheadURL, intStatus){
    var _img = im_wdkUtil.$$(".userHead", this.Element)[0];
    _img.src = strheadURL;
    return;
}
_p.getPost = function(){
    var _Rect = im_wdkUtil.viewRect.get(this.Element);
    return {x:_Rect.x, y:_Rect.y};
}
_p.onClick = function(ev){
    var target = im_wdkUtil.eventTag(ev,"li");
    if(!target) return;
    im_chat_window_manager.OnTBFocusWindow(this._destuid, this._chatType);
}
_p.CloseChatWindow = function(ev){
    var target = im_wdkUtil.eventTag(ev, "li");
    if(!target) return;
    target.style.border = "2px solid #f00";},
_p.onFocus = function(){
    if(!IMToolBar) return;
    for(var k in IMToolBar.minWindows._hash){
        if(IMToolBar.minWindows._hash[k].onBlur)
        IMToolBar.minWindows._hash[k].onBlur();
    }
    this._focus = true;
    IMcssTag.addClass(this.Element, "selected");
    if(this._destuid) 
        Ntalker.variable.OnFocusWinParam = [this._destuid, this._chatType];
    var mRt = im_wdkUtil.viewRect.get(this.Element);
    var aRt = im_wdkUtil.viewRect.get('windows_area');
    var _x  = mRt.x-parseInt(im_wdkUtil.$('windows_area').scrollLeft), move=0;
    return {x:_x,y:mRt.y,m:move};
}
_p.onBlur = function(){
    this._focus = false;
    IMcssTag.removeClass(this.Element, "selected");
    return;
}
_p.onReceiveMiniMessage=function(message){
    var titleText = "说:"+message;
    this.startFlashTitle(titleText);
}  
_p.startFlashTitle = function(titleText){    if(this.timerID)
        return;
    this.promptMsg = im_wdkUtil.cutText(titleText,5);
    this.flashWindowTitle();
};
_p.flashWindowTitle = function(){
    if(this._focus){
        IMcssTag.removeClass(this.Element, "flash");
        clearInterval(this.timerID);
        this.timerID = null;
        this._counter = 0;
        return;
    }
    this._counter = parseInt(this._counter) + 1;
    if(this._counter%2==0){
        IMcssTag.removeClass(this.Element, "flash");
    }else{
        IMcssTag.addClass(this.Element, "flash");
    }
    var _timer     = this._counter%2==0 ? 500 : 1000;
    this.timerID = IMAnimate.timer("IMToolBar.getMiniWindow('"+this._destuid+"', '"+this._chatType+"').flashWindowTitle()", _timer);
}
var IMToolBar = {
    Element   : null,
    minWindows: new IMHashtable(),
    minWinCount: 0,
    minWidth  : IMBrowser.msie56 ? 269 : 268,
    isExpand  : true,
    arrMsg  : [],
    arrGroupMsg:[],
    cfg       : [],
    _align    : "right",
    BuddylistVisible  : false,
    _timer    : [],
    _timeOut  : [],
    _disable  : false,
    _tipMessage:"您尚未登录，请登录后使用",
    _viewRect : null,
    overMenu  : false,
    showMenu  : false,
    minChatWidth: 106,
    customButtonNum: 0,
    init:function(){
        this._align = Ntalker.Config.customparams["floatpos"];        var _copyname = Ntalker.Config.customparams["swname"]===undefined ? "Ntalker": Ntalker.Config.customparams["swname"];        
        this.cfg["ico_copyright"] = ["Powered by "+_copyname];
        this.cfg["ico_popup"]     = ["弹出"+_copyname];
        this.cfg["ico_state"]     = ["用户状态"];
        if(Ntalker.Config.customparams['enablegroup']||Ntalker.Config.customparams['enablechat'])
            this.cfg["ico_group"] = ["群消息"];
        this.cfg["ico_buddylist"] = ["打开好友列表"];        this.cfg["ico_msg"]       = ["系统消息"];
        this.cfg["ico_zoom"]      = ["收起工具条"];
        this.cfg["ico_pre"]       = ["向右滚动"];
        this.cfg["ico_next"]      = ["向左滚动"];
        var _cfgBtns = Ntalker.Config.customtoolbarButtons;
        if(Ntalker.Config.customparams["createblank"]) im_wdkUtil.createDom({name:"DIV",style:"height:30px;"});
        im_wdkUtil.createDom({name:"DIV",id:"NtalkerToolbar",className:"",style:"z-index:111112;"}, null, "afterbegin");
        this.Element = im_wdkUtil.$("NtalkerToolbar");        this.Element.innerHTML = this.toolbarHtml();
        for(var k in _cfgBtns){
            if( typeof(_cfgBtns[k])=="object" && _cfgBtns[k].float=="left" ){this.customButtonNum++;this._addCustomLeftButton(_cfgBtns[k]);}
        }
        var AreaMarginRight = 0, curBtnWidth = 0;
        if(Ntalker.Config.toolbarlogo){
            var tbLogo = im_wdkUtil.$('ico_copyright');
            IMcssTag.css(tbLogo, "background", "transparent url("+Ntalker.Config.toolbarlogo+") no-repeat scroll");
            IMcssTag.css(tbLogo, "width" , Ntalker_Config['logo'].Tlogowidth);
            IMcssTag.css(tbLogo, "heihgt", Ntalker_Config['logo'].Tlogoheight);
            IMToolBar.minWidth -= (28 -  Ntalker_Config['logo'].Tlogowidth);
            AreaMarginRight = 28 -  Ntalker_Config['logo'].Tlogowidth;
        }else{
            IMcssTag.css(tbLogo, "width" , 28);
        }
        if(Ntalker.Config.customparams['enablegroup']||Ntalker.Config.customparams['enablechat'])curBtnWidth += 53;
        IMToolBar.minWidth += curBtnWidth;
        im_wdkUtil.$("windows_area").style.marginRight = (AreaMarginRight - curBtnWidth) + "px";
        for(var k in this.cfg){
            if(typeof(this.cfg[k])!="object") continue;
            if(!Ntalker.Config.customparams['enablegroup'] && !Ntalker.Config.customparams['enablechat'] && k=="ico_group") continue;
            var btnLI  = im_wdkUtil.$(k);
            var btnDIV = im_wdkUtil.$$(" div", btnLI)[0];
            if(!btnDIV) btnDIV = im_wdkUtil.$(k);
            im_wdkUtil.Event.addEvent(btnDIV, "mouseover", IMToolBar.onOverEvent);
            im_wdkUtil.Event.addEvent(btnDIV, "mouseout",  IMToolBar.onOverEvent);
            if(/ico_state|ico_group|ico_msg/.test(k)){
                if(/ico_state/.test(k)) im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onVisibleMsgMenu);
                if(/ico_msg/.test(k))   im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onVisibleMsgMenu);
                if(/ico_msg/.test(k))   im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.initMsgMenu);
                if(/ico_group/.test(k)) im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.initGroupMsg);
                im_wdkUtil.Event.addEvent(btnLI, "mouseout", IMToolBar.onHiddenMsgMenu);
            }else if(/ico_popup/.test(k)){
                im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onPopupOut);
            }else if(/ico_buddylist/.test(k))
                im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onShowBuddylist);
            else if(/ico_zoom/.test(k))
                im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onMinimize);
            else if(/ico_copyright/.test(k)){
                if(typeof(Ntalker_Config)!='undefined'){
                    var cpurl = Ntalker_Config['logo'].copyrighturl ? Ntalker_Config['logo'].copyrighturl : "http:/"+"/www.ntalker.com";
                    if(typeof Ntalker_Config['logo'].copyrighttip == "undefined")
                        this.cfg["ico_copyright"] = ["Powered by Ntalker"];
                    else
                        this.cfg["ico_copyright"] = [Ntalker_Config['logo'].copyrighttip];
                }else
                    var cpurl = "http:/"+"/www.ntalker.com";
                btnDIV.onclick = function(){
                    if(cpurl.indexOf('http:')!=-1)
                        window.open(cpurl);
                    else
                        eval(cpurl);
                }
            }else if(/ico_pre/.test(k))
                im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onLeft);
            else if(/ico_next/.test(k))
                im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onRight);
        }
        IMToolBar._viewRect = im_wdkUtil.viewRect.get('windows_area');
        im_wdkUtil.Event.addEvent(window, "resize", IMToolBar.onResize);
        im_wdkUtil.Event.addEvent(window, "scroll", IMToolBar.onResize);
        if(!Ntalker.Config.customparams["intact"]) this.onMinimize();
        this.disable();        if(IMToolBar._align=="left") {im_wdkUtil.$("Ntalkerbody").style.borderRight = "1px solid #898989";}
        else{ im_wdkUtil.$("Ntalkerbody").style.borderLeft = IMToolBar.customButtonNum?"1px solid #898989":"none";}        var _ckEl = im_wdkUtil.$('upPanel');
        if(_ckEl && IMcssTag.css(_ckEl,"overflowY")=="scroll") {
            IMcssTag.css(this.Element, "right", 17);
        }
        if(IMBrowser.msie56){
            var backgroundImage = IMcssTag.css(document.body, "backgroundImage");
            if( backgroundImage=="none" || backgroundImage=="" ) 
                IMcssTag.css(document.body, "backgroundImage", "url(about:blank)");
        }
    },
    hidden:function(){        IMcssTag.css(IMToolBar.Element, "visibility", "hidden");
    },
    visible:function(){        IMcssTag.css(IMToolBar.Element, "visibility", "visible");
    },
    disable:function(){        this._disable = true;
        btnItems = im_wdkUtil.$$('#ico_popup,#ico_state,#ico_group,#ico_buddylist,#ico_msg,#ico_zoom,#ico_bbshot');
        for(var i=0; i<btnItems.length; i++){
            IMcssTag.addClass(im_wdkUtil.$$(" div", btnItems[i])[0], "disable");
        }
        for(var key in ["ico_zoom","ico_msg","ico_group"]) this.disableFlash(key);
    },
    enable:function(){        this._disable = false;
        btnItems = im_wdkUtil.$$('#ico_popup,#ico_state,#ico_group,#ico_buddylist,#ico_msg,#ico_zoom,#ico_bbshot');
        for(var i=0; i<btnItems.length; i++){
            IMcssTag.removeClass(im_wdkUtil.$$(" div", btnItems[i])[0], "disable");
        }
        var enablepopup = Ntalker.Config.customparams["enablepopup"];
        if(Ntalker.Config.isPopupWindow==1 || (typeof enablepopup!="undefined" && !enablepopup) ){
            var Btn = im_wdkUtil.$$(" div", im_wdkUtil.$('ico_popup'))[0];
            IMcssTag.addClass(Btn, "disable");
            im_wdkUtil.Event.removeEvent(Btn, "click", IMToolBar.onPopupOut);
        }
    },
    _addCustomLeftButton:function(btnCfg){        if(!this.Element) return;
        var Element   = im_wdkUtil.$("ico_pre");
        var _Attrib   = this._align=="left" ? "BeforeEnd" : "AfterBegin";
        var btnElement= im_wdkUtil.createDom({name:"div", id:btnCfg.id, className:"user_custom", style:btnCfg.style+"width:28px;"}, null, _Attrib);
        im_wdkUtil.createDom({name:"a", href:btnCfg.url,target:"_blank", style:"display:block;height:28px;"}, im_wdkUtil.createDom({name:"div",className:"ico_button"}, btnElement));
        Element.parentNode.insertBefore(btnElement, Element);
        IMcssTag.css(im_wdkUtil.$(btnCfg.id), "float", (this._align=="left" ? "right" : "left"));
        this.cfg[btnCfg.id] = [btnCfg.tip];
        IMToolBar.minWidth += 29;
    },
    addMiniWindow:function(descuid, destname, headURL, isAutoFocus, chatType){
        chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");
        var minWin = this.getMiniWindow(descuid, chatType);
        if( !!minWin) return;
        if(Ntalker.variable.OnFocusWinParam.length>0 && !isAutoFocus){
            Ntalker.variable.OnBlurWinParam = Ntalker.variable.OnFocusWinParam;
        }
        Ntalker.variable.OnFocusWinParam = [descuid, chatType];
        this.onMaximize();
        minWin = new minWindow(descuid, destname, headURL, isAutoFocus, chatType);
        minWin.init();
        this.minWindows.add("MiniTAG"+descuid+chatType, minWin);
        this.minWinCount = this.minWindows.count();        this.initScroll();
        return minWin;
    },
    removeMiniWindow:function(descuid, chatType){
        var focusID = "", focusType="", preID = 0, preType="", getPre = false;
        for(var k in this.minWindows._hash){
            if(this.minWindows._hash[k]._destuid == descuid && this.minWindows._hash[k]._chatType == chatType){
                getPre = true;
                if(preID){focusID = preID;focusType = preType; break;}
            }else{
                preID = this.minWindows._hash[k]._destuid;preType = this.minWindows._hash[k]._chatType;
                if(getPre){focusID = preID;focusType=preType; break;}
            }
        }
        var miniWndElement = im_wdkUtil.$("miniTAG_"+descuid+chatType);
        if(!miniWndElement) return;
        miniWndElement.parentNode.removeChild(miniWndElement);
        var minWin = this.minWindows.items("MiniTAG"+descuid+chatType);
        if( !minWin) return;
        this.minWindows.remove("MiniTAG" + descuid + chatType);
        this.onRight();
        Ntalker.variable.OnFocusWinParam = [focusID, focusType];
        im_chat_window_manager.OnTBFocusWindow(focusID, focusType);
    },
    getMiniWindow:function(descuid, chatType){
        chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");
        return this.minWindows.items("MiniTAG"+descuid + chatType);
    },
    enableflash: function(key, className, FclassName){
        var target = im_wdkUtil.$(key);
        if(this._disable) IMToolBar._timer[key] = null;
        if(!IMToolBar._timer[key]){
            IMcssTag.replaceClass(target, FclassName, className);
            return;
        }
        if(IMToolBar._timer[key]==1000){
            IMToolBar._timer[key] = 500;
            IMcssTag.replaceClass(target, FclassName, className);
        }else{
            IMToolBar._timer[key] = 1000;
            IMcssTag.replaceClass(target, className, FclassName);
        }
        IMAnimate.timer(function(){IMToolBar.enableflash(key, className, FclassName);}, IMToolBar._timer[key]);
        if( !IMToolBar._timeOut[key] ){
            IMToolBar._timeOut[key] = true;
            IMAnimate.timer(function(){IMToolBar.disableFlash(key);}, 5000);
        }
    },
    disableFlash:function(key){        IMToolBar._timer[key] = null;
        IMToolBar._timeOut[key] = false;
    },
    onMinimize:function(typ){
        if( IMToolBar._disable || !IMToolBar.isExpand) return;
        if(im_chat_window_manager) im_chat_window_manager.OnTBFocusWindow(0);
        IMToolBar.cfg["ico_zoom"]      = ["展开工具条"];
        if(im_wdkUtil.$('TOOLBARTIPico_zoom')) {im_wdkUtil.$$(".TipLeft", im_wdkUtil.$('TOOLBARTIPico_zoom'))[0].innerHTML = "<span>展开工具条</span>";}
        IMcssTag.css(im_wdkUtil.$("ico_pre"),        "display", "none");
        IMcssTag.css(im_wdkUtil.$("ico_next"),       "display", "none");
        IMToolBar.isExpand = false;        IMToolBar.updateToolbar();
        var target         = im_wdkUtil.$('ico_zoom');
        IMcssTag.replaceClass(target,"icozoom","icozoom_text");
        var chatWndCount = im_chat_window_manager ? im_chat_window_manager._chatWndsArray.length : 0;
        if(!IMToolBar._timer["ico_zoom"] && chatWndCount>0){
            IMToolBar._timer["ico_zoom"] = chatWndCount>0 ? 1000 : null;
            IMToolBar.enableflash("ico_zoom", "icozoom_text", "icozoom_flash");        }else if(chatWndCount==0){
            IMToolBar.disableFlash("ico_zoom");        }
        if(typ!="mini") IMToolBar.updateChatWindow(chatWndCount);
        var btnZoom = im_wdkUtil.$$(".ico_button", target)[0];
        im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onMinimize);
        im_wdkUtil.Event.addEvent(btnZoom,    "click", IMToolBar.onMaximize);
        IMToolBar._viewRect = im_wdkUtil.viewRect.get('windows_area');
    },
    onMaximize:function(ev){
        if(IMToolBar._disable || IMToolBar.isExpand) return;
        ev = ev || window.event;
        var _winRect = im_wdkUtil.viewRect.get(window);
        IMToolBar.cfg["ico_zoom"]      = ["收起工具条"];
        if(im_wdkUtil.$('TOOLBARTIPico_zoom')) { im_wdkUtil.$$(".TipLeft", im_wdkUtil.$('TOOLBARTIPico_zoom'))[0].innerHTML = "<span>收起工具条</span>";}
        IMcssTag.css(im_wdkUtil.$("ico_pre"),        "display", "block");
        IMcssTag.css(im_wdkUtil.$("ico_next"),       "display", "block");
        IMToolBar.isExpand = true;        IMToolBar.updateToolbar();
        IMToolBar.disableFlash("ico_zoom");
        var target         = im_wdkUtil.$('ico_zoom');
        IMcssTag.replaceClass(target,"icozoom_text", "icozoom");
        var btnZoom = im_wdkUtil.$$(".ico_button",target)[0];
        btnZoom.innerHTML = "";
        im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onMaximize);
        im_wdkUtil.Event.addEvent(btnZoom, "click", IMToolBar.onMinimize);
        IMToolBar._viewRect = im_wdkUtil.viewRect.get('windows_area');
        if(Ntalker.variable.OnFocusWinParam && ev && ev.type=="click"){
            im_chat_window_manager.OnTBFocusWindow(Ntalker.variable.OnFocusWinParam[0],Ntalker.variable.OnFocusWinParam[1]);
        }
    },
    onShowHost:function(){
        if(!Ntalker.Config.customparams['enablehot']) return;
        im_openWebchatWindow("bbshot", "坛热点", null, true, 'bbshot');
    },
    onPopupOut:function(){        if(IMToolBar._disable || im_wdkUtil.inArray(Ntalker.Config.not_popupwin_sites, Ntalker.variable.siteid)) return;
        var prompStr, chatWins = im_chat_window_manager._chatWndsArray;
        if(im_chat_window_manager && chatWins.length>0 ){
            for(var i=0; i<chatWins.length; i++){
                switch(chatWins[i]._avStatus){
                    case "audio": prompStr = "您与对方正在进行语音会话，弹出窗口将会中断音频会话，您确定吗？";break;
                    case "vedio": prompStr = "您与对方正在进行视频会话，弹出窗口将会中断视频会话，您确定吗？";break;
                }
                if(chatWins[i]._TransferState) prompStr = "您与对方正在进行文件传输，弹出窗口将会中断文件传输，您确定吗？";
            }
            if(prompStr && !confirm(prompStr))
                return;
        }
        var _var = Ntalker.variable;
        var popupWindow = im_popupToolbar(_var.user_id, _var.user_name, _var.user_sid, _var.siteid, _var.userparam, true, _var.scriptPath, Ntalker.cache.image_dir);
    },
    onPopupIn:function(){
        window.close();
    },
    onShowBuddylist:function(ev, el, index){
        if( !im_myIMWindow ) return;        if(!el) el = im_wdkUtil.eventTag(ev,"li");
        var _rect  = im_wdkUtil.viewRect.get(el);
        var _x = IMToolBar._align=="left" ? _rect.x : _rect.x+_rect.w ;
        var _y = _rect.y;
        index = index!=null ? index : 0;
        IMToolBar.BuddylistVisible = !IMToolBar.BuddylistVisible;
        Ntalker.Config.IMtabIndex = index;
        im_myIMWindow.OnTBShowBuddylist(_x, _y, IMToolBar.BuddylistVisible);
        IMToolBar.__closeMenu("ico_state");
        IMToolBar.__closeMenu("ico_group");
        IMToolBar.__closeMenu("ico_msg");
    },
    onOverEvent:function(ev, nodeName){        var current,btn;
        if(nodeName && im_wdkUtil.$(nodeName)){
            btn = im_wdkUtil.$(nodeName);
        }else{
            current = ev.currentTarget || window.event.srcElement;
            btn     = current.parentNode;
            if(!current.parentNode.id) btn = btn.parentNode;
        }
        for(var k in IMToolBar.cfg){
            if(btn.id && k == btn.id){
                if(  ( (ev&&ev.type=="mouseover") || nodeName) ){
                    var tipMsg = IMToolBar._disable&&k.indexOf("ntalkerbtn")==-1 ? IMToolBar._tipMessage : IMToolBar.cfg[k][0];
                    IMToolBar.__showTip(k, tipMsg);
                }else{
                    IMToolBar.__hiddenTip(k);
                }
                return;
            }
        }
    },
    onResize:function(ev){
        if( !IMBrowser.msie56 && !IMBrowser.oldModel )  return;
        var _winRect = im_wdkUtil.viewRect.get(window);        
        if(ev && ev.type){
            if(parseInt(_winRect.w) < parseInt(IMToolBar.minWidth) ){
                IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", IMToolBar.minWidth);
                IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", IMToolBar.minWidth);
                IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", IMToolBar.minWidth); 
            }
            else if(IMToolBar.isExpand){
                IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", IMBrowser.msie56 ? (_winRect.w-2)+"px" : "100%");
                IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", IMBrowser.msie56 ? (_winRect.w-2)+"px" : "100%");
                IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", IMBrowser.msie56 ? (_winRect.w-2)+"px" : "100%"); 
                IMcssTag.css(im_wdkUtil.$("windows_area"),   "width", (_winRect.w - IMToolBar.minWidth - 58));
            }
        }
        if( document.compatMode=="BackCompat" && IMBrowser.msie56 ){
            IMcssTag.css(IMToolBar.Element, "top",   (_winRect.y + _winRect.h - (IMBrowser.msie56 ? 28 : 32)) );
            IMcssTag.css(IMToolBar.Element, (IMToolBar._align=="left" ? "right" : "left"), 0 );
        }
    },
    onVisibleMsgMenu:function(ev, child){
        if(IMToolBar._disable) return;
        var current = (ev || window.event).currentTarget || document.activeElement;
        var target  = current.parentNode;
        target      = child ? target.parentNode : target;
        if(!target.id){
            while(target.parentNode && target.tagName.toLowerCase()!="li" && target.id.length==0){target = target.parentNode;}
        }
        if(!target) return;
        IMToolBar.__hiddenTip(target.id);
        IMToolBar.overMenu = target.id;
        IMToolBar.showMenu = true;
        var menus = im_wdkUtil.$$(".ntalkermenu");
        var _menu = im_wdkUtil.$$(".ntalkermenu", target)[0];
        if( _menu==="undefined" ) {
            while(target.className != "menu" && target.parentNode){target = target.parentNode;}_menu = target;
        }
        fIM_CloseIMWindow();
        for(var k in menus){
            if(typeof(menus[k])=="object"){
                if(_menu == menus[k])  IMcssTag.css(menus[k], "display", (IMcssTag.css(menus[k], "display")=="block"&&ev&&ev.type=="click" ? "none" : "block" ) );
                else IMcssTag.css(menus[k], "display", "none");
            }
        }
    },
    onHiddenMsgMenu:function(ev, child){
        var current = ev.currentTarget || window.event.srcElement;
        var target  = current.parentNode;
        target      = child ? target.parentNode : target;
        if(!target.id){
            while(target.parentNode && target.tagName.toLowerCase()!="li" && target.id.length==0){target = target.parentNode;}
        }
        if(!target.id) return;
        IMToolBar.overMenu = "";
        IMToolBar.menuTimer = IMAnimate.timer(function(){
            if(target.id && !IMToolBar.overMenu){
                IMToolBar.__closeMenu(target.id);
            }
        }, 800);
    },
    __closeMenu:function(parentNodeID){
        IMToolBar.menuTimer = null;
        IMToolBar.showMenu  = false;
        var _menu = im_wdkUtil.$$(".ntalkermenu", im_wdkUtil.$(parentNodeID))[0]
        IMcssTag.css(_menu, "display", "none");
    },
    __showTip:function(key, msg){
        var _tbBtn   = im_wdkUtil.$(key);
        if(!_tbBtn || IMToolBar.showMenu || !msg) return;
        var _tip   = im_wdkUtil.$("TOOLBARTIP"+key);
        if(!_tip){
            _tip   = im_wdkUtil.createDom({name:"div",className:"NtalkerToolbarTip",id:"TOOLBARTIP"+key}, _tbBtn);
        }
        var _width = im_wdkUtil.lenText(msg)*6 + (IMBrowser.msie56 ? 20 : 15);
        IMcssTag.css(_tip, "width", _width);
        var winRect = im_wdkUtil.viewRect.get(window);
        var btnRect = im_wdkUtil.viewRect.get(_tbBtn);
        var tipleft = btnRect.w/2-8;
        if(btnRect.x+tipleft+_width > winRect.x+winRect.w){
            _tip.innerHTML = '<ul id="ToolbarTip" class="Ntalker_fright"><li class="TipLeft"></li><li style="width:'+(_width-6)+'px" class="TipRight"><span>'+msg+'</span></li></ul>';
            tipleft = btnRect.w - _width - 12;
        }else{
            _tip.innerHTML = '<ul id="ToolbarTip" class="Ntalker_fleft"><li style="width:'+(_width-6)+'px" class="TipLeft"><span>'+msg+'</span></li><li class="TipRight"></li></ul>';
        }
        IMcssTag.css(_tip, "left", tipleft);
        IMcssTag.css(_tip, "display", "block");    },
    __hiddenTip:function(key){
        var _tbBtn   = im_wdkUtil.$(key);
        if(!_tbBtn) return;
        var _tip   = im_wdkUtil.$("TOOLBARTIP"+key);        if(_tip) IMcssTag.css(_tip, "display", "none");
    },
    updateChatWindow:function(chatWndCount){
        var btnZoom = im_wdkUtil.$$(".ico_button", im_wdkUtil.$('ico_zoom'))[0];
        btnZoom.innerHTML = IMToolBar.isExpand ? "" : "(" + chatWndCount + ")";
    },
    initMsgMenu: function(){        var msg    = IMToolBar.arrMsg,item;
        var btnMsg = im_wdkUtil.$("ico_msg");
        if(!btnMsg) return;
        var msgMenuUL = im_wdkUtil.$$(" ul", btnMsg)[0];
        var msgMenuItems = im_wdkUtil.$$(".act,.menuseparator", msgMenuUL);
        for(var k in msgMenuItems){
            try{ if(msgMenuItems[k].parentNode)  msgMenuItems[k].parentNode.removeChild(msgMenuItems[k]);}catch(e){}
        }
        for(var i=0; i<msg.length; i++){            if(im_wdkUtil.isArray( msg[i] ) ){
                var _class = msg[i][3]=="confirm" ? "addfir" : msg[i][3];
                Item       = im_wdkUtil.createDom({name:"LI", style:"", className:"act "+_class, destuid:msg[i][0],typ:msg[i][3] }, msgMenuUL);
                var conEl  = im_wdkUtil.createDom({name:"DIV", onclick:""}, Item);
                var txtCon = im_wdkUtil.cutText(msg[i][1], 5, true);
                var t      = 10 - im_wdkUtil.lenText(txtCon);
                for(var j=0; j<Math.floor(t/2); j++){txtCon += "　";}
                txtCon = txtCon + (t%2>0 ? "　" : " ") + im_wdkUtil.cutText(msg[i][2], 6);
                var txt    = im_wdkUtil.createDom({name:"Text",text:txtCon}, conEl);
                Item.onclick = function(event){IMToolBar.viewMsg(event);}
                Item.onmouseover = function(event){IMcssTag.addClass(this, 'hover');IMToolBar.onVisibleMsgMenu(event, true);};
                Item.onmouseout  = function(){IMcssTag.removeClass(this, 'hover');};
            }
        }
        if(msg.length==0){            Item   = im_wdkUtil.createDom({name:"LI", className:"act nomsg"}, msgMenuUL);
            var conEl = im_wdkUtil.createDom({name:"DIV"}, Item);
            var txt   = im_wdkUtil.createDom({name:"Text", text:"暂无消息"}, conEl);
        }        var _exMsg  = Ntalker.variable.ExMsg;
        var msgNum = IMToolBar.arrMsg.length;
        if(_exMsg){
            for(var i=0; i<_exMsg.length; i++){
                var Item  = im_wdkUtil.createDom({name:"LI", className:"menuseparator", style:"font-size:0px;height:7px;"}, msgMenuUL);
                var divEl = im_wdkUtil.createDom({name:"div",style:"padding:0px;background:#ccc;border-bottom:1px solid #FFF;margin:3px 5px 3px 0px;height: 0px;width: 130px;_width: 125px; float: right; font-size: 0px;line-height:0px; "}, Item);
                Item = im_wdkUtil.createDom({name:"LI", className:"act nomsg"}, msgMenuUL);
                var conEl  = im_wdkUtil.createDom({name:"DIV"}, Item);
                Item.setAttribute("url", _exMsg[i].url);
                var __func = function(){
                    IMToolBar.deleteCursorMsg(this.getAttribute("url"));
                    window.open(this.getAttribute("url"));
                };
                Item.onclick     = __func;
                Item.onmouseover = function(event){IMcssTag.addClass(this, 'hover');IMToolBar.onVisibleMsgMenu(event, true);};
                Item.onmouseout  = function(){IMcssTag.removeClass(this, 'hover');};
                conEl.innerHTML  = _exMsg[i].name+" ("+_exMsg[i].msgnumber+")";                msgNum = parseInt(msgNum) + parseInt(_exMsg[i].msgnumber);
            }
        }
        im_wdkUtil.$$(".ico_button", btnMsg)[0].innerHTML = "(" + msgNum + ")";
        return Item;
    },
    addMsg: function(destuid, destname, message, chatid, headURL, content, type, srcuid, srcnick){
        var btnMsg = im_wdkUtil.$("ico_msg");
        var msg = this.arrMsg;
        for(var i=0; i<msg.length; i++ ){
            if(msg[i][0]==destuid && msg[i][3]==type) return;
        }
        msg.push([destuid, destname, message, type, chatid, content, headURL, srcuid, srcnick]);
        var dn    = msg.length>20 ? msg.length-20 : 0;
        this.arrMsg = msg.slice(dn, msg.length);
        im_wdkUtil.$('impresenceflash').playNotifySound();
        var Item = this.initMsgMenu();
        var _chatWinCount = im_chat_window_manager._chatWndsArray.length;
        if(_chatWinCount >= 0 && type == "request") {
            this.viewMsg(null, Item);return;
        }
    },
    removeMsg: function(destuid, type){
        var msg = this.arrMsg;var nMsg = [];
        for(var i=0; i<msg.length; i++ ){
            if(!(msg[i][0]==destuid && msg[i][3]==type) ){nMsg.push(msg[i]);}
        }
        this.arrMsg = nMsg;
        this.updateMsgNum();
    },
    deleteCursorMsg:function(url){
        var cursorMsg = Ntalker.variable.ExMsg;
        for(var i=0; i<cursorMsg.length;i++){
            if(cursorMsg[i].url==url) cursorMsg[i].msgnumber=0;
        }
        Ntalker.variable.ExMsg = cursorMsg;
        this.updateMsgNum();
    },
    updateMsgNum:function(){
        var id = "ico_msg";
        if(!im_wdkUtil.$(id)) return;
        var msgNum = IMToolBar.arrMsg.length;
        for(var i=0; i<Ntalker.variable.ExMsg.length; i++){
            msgNum = parseInt(msgNum) + parseInt(Ntalker.variable.ExMsg[i].msgnumber);
        }
        im_wdkUtil.$$(".ico_button", im_wdkUtil.$(id))[0].innerHTML = "(" + msgNum + ")";    
        if(!IMToolBar._timer[id] && msgNum>0){
            IMToolBar._timer[id] = 1000;
            IMToolBar.enableflash(id, "ico_msg", "flash_msg");
        }else{
            IMToolBar.disableFlash(id);
        }
    },
    getMsg:function(destuid, type){
        var msg = this.arrMsg;
        for(var i=0; i<msg.length; i++){
            if(msg[i][0]==destuid && msg[i][3]==type) return msg[i];
        }
        return null;
    },
    loadMsg:function(){
        var key = Ntalker.ctKEY + Ntalker.variable.user_id;
        var val = im_wdkUtil.GetCookie(key);
        im_wdkUtil.SetCookie(key, "");        if(val==null||typeof(val)=='undefined'||val==""){
            this.updateMsgNum();return;
        }
        var Items = val.replace(/{/g, "").split("}");
        for(var k in Items){
            if(Items[k] && !im_wdkUtil.inArray(this.arrMsg, Items[k])) this.arrMsg.push(Items[k].split(","));
        }
        this.updateMsgNum();
    },
    saveMsg:function(){
        var msg = this.arrMsg;
        var key = Ntalker.ctKEY + Ntalker.variable.user_id;
        var val = im_wdkUtil.GetCookie(key)==null ? "" : im_wdkUtil.GetCookie(key);
        for(var i=0; i<msg.length; i++){
            val += msg[i].join(",") + (i+1<msg.length ? "}{" : "}");
        }
        val = val?"{"+val : "";        im_wdkUtil.SetCookie(key, val, 3600);
    },
    viewMsg:function(ev, Element){
        if(!Element) var Element = im_wdkUtil.eventTag(ev, "li");
        var destuid = Element.getAttribute("destuid");
        var type    = Element.getAttribute("typ");        if(!destuid || !type) return;
        IMToolBar.overMenu = "";
        this.__closeMenu("ico_msg");
        var msg = this.getMsg(destuid, type);
        var notifyWnd     = new Object();
        notifyWnd.destuid = msg[0];
        notifyWnd.destname= msg[1];
        notifyWnd.message = msg[2];
        notifyWnd.type    = msg[3];
        notifyWnd.chatid  = msg[4];
        notifyWnd.sendMsg = msg[5];
        notifyWnd.logoUrl = msg[6];
        notifyWnd.srcuid  = msg[7];
        notifyWnd.srcnick = msg[8];
        notifyWnd.userid  = Ntalker.variable.user_id;
        notifyWnd._curNotifyId  = 'Notify' + Ntalker.variable.user_id + "TYPE" + notifyWnd.type;
        if(type == "confirm"){
            notifyWnd.BtnType = "confirm";            NotifyManager.alertQueue.add(notifyWnd._curNotifyId, notifyWnd);
        }else  if(type == "request"){
            notifyWnd.BtnType = "request";            NotifyManager.alertQueue.add(notifyWnd._curNotifyId, notifyWnd);
        }else  if(type == "group"){
            notifyWnd.BtnType = "group";            im_openWebchatWindow(notifyWnd.destuid, notifyWnd.destname, null, true, 'group');
            IMToolBar.removeMsg(notifyWnd.destuid, "group");
        }else{
            notifyWnd.BtnType = "alert";            NotifyManager.alertQueue.add(notifyWnd._curNotifyId, notifyWnd);
        }
    },
    initGroupMsg: function(ev){        if(!Ntalker.Config.customparams['enablegroup'] && !Ntalker.Config.customparams['enablechat']) return;
        var id = "ico_group";
        var G_Msg = IMToolBar.arrGroupMsg;
        var btnMsg = im_wdkUtil.$(id);
        var msgMenuUL = im_wdkUtil.$$(" ul", btnMsg)[0];
        var msgMenuItems = im_wdkUtil.$$(".act", msgMenuUL);
        for(var k in msgMenuItems){ try{ if(msgMenuItems[k].parentNode)  msgMenuItems[k].parentNode.removeChild(msgMenuItems[k]);}catch(e){}}
        var Item; 
        for(var i=0; i<G_Msg.length; i++){
            if(im_wdkUtil.isArray( G_Msg[i] ) ){
                Item       = im_wdkUtil.createDom({name:"LI", className:"act group", groupId:G_Msg[i][0],groupName:G_Msg[i][1] }, msgMenuUL);
                var conEl  = im_wdkUtil.createDom({name:"DIV"}, Item);
                var txt    = im_wdkUtil.createDom({name:"Text",text:G_Msg[i][1]}, conEl);
                Item.onclick = function(event){IMToolBar.viewGroupMsg(event);}
                Item.setAttribute("onmouseover", "IMcssTag.addClass(this, 'hover');IMToolBar.onVisibleMsgMenu(event, true);");
                Item.setAttribute("onmouseout",  "IMcssTag.removeClass(this, 'hover');");
            }
        }
        if(G_Msg.length>0 && ev){            IMToolBar.onVisibleMsgMenu(ev);
        }else if( ev ){            IMToolBar.onShowBuddylist(null, "ico_buddylist", 2);
        }
        return Item;
    },
    updateGroupNum:function(){
        var id  = "ico_group";
        var msg = IMToolBar.arrGroupMsg;
        if(!im_wdkUtil.$(id)) return;
        im_wdkUtil.$$(".ico_button", im_wdkUtil.$(id))[0].innerHTML = "(" + msg.length + ")";
        if(!IMToolBar._timer[id] && msg.length>0){
            IMToolBar._timer[id] = 1000;
            IMToolBar.enableflash(id, "ico_group", "flash_group");
        }else{
            IMToolBar.disableFlash(id);
        }
    },
    addGroupMsg:function(groupId, groupName){
        var btnGroup = im_wdkUtil.$("ico_group");
        var G_Msg = this.arrGroupMsg;
        for(var i=0; i<G_Msg.length; i++ ){
            if(G_Msg[i][0]==groupId && G_Msg[i][1]==groupName) return; 
        }
        G_Msg.push([groupId, groupName]);
        var sn    = G_Msg.length>20 ? G_Msg.length-20 : 0;
        this.arrGroupMsg = G_Msg.slice(sn, G_Msg.length);
        im_wdkUtil.$$(".ico_button", btnGroup)[0].innerHTML = "(" + G_Msg.length + ")";
        this.updateGroupNum();
    },
    removeGroupMsg:function(groupId){
        var G_Msg = this.arrGroupMsg;var new_GMsg = [];
        for(var i=0; i<G_Msg.length; i++ ){ if( G_Msg[i][0] != groupId ){new_GMsg.push(G_Msg[i]);} }
        this.arrGroupMsg = new_GMsg;
        im_wdkUtil.$$(".ico_button", im_wdkUtil.$("ico_group"))[0].innerHTML = "(" + new_GMsg.length + ")";
        if(new_GMsg.length == 0)
            IMToolBar.disableFlash("ico_group");
    },
    getGroupMsg:function(groupId){
        var G_Msg = this.arrGroupMsg;
        for(var i=0; i<G_Msg.length; i++){ if(G_Msg[i][0]==groupId) return G_Msg[i]; }
        return null;
    },
    loadGroupMsg:function(){
        var key = Ntalker.gpKEY + Ntalker.variable.user_id;
        var val = im_wdkUtil.GetCookie(key);
        im_wdkUtil.SetCookie(key, "");        if(val==null||typeof(val)=='undefined'||val==""){  return; }
        var Items = val.replace(/{/g, "").split("}");
        for(var k in Items){
            if(Items[k] && !im_wdkUtil.inArray(this.arrGroupMsg, Items[k])) this.arrGroupMsg.push(Items[k].split(","));
        }
        this.updateGroupNum();
    },
    saveGroupMsg:function(){
        var G_Msg = this.arrGroupMsg;
        var key = Ntalker.gpKEY + Ntalker.variable.user_id;
        var val = im_wdkUtil.GetCookie(key)==null ? "" : im_wdkUtil.GetCookie(key);
        for(var i=0; i<G_Msg.length; i++){ val += G_Msg[i].join(",") + (i+1<G_Msg.length ? "}{" : "}");} val = val?"{"+val : "";        im_wdkUtil.SetCookie(key, val, 3600);
    },
    viewGroupMsg:function(ev, Element){
        var id = "ico_group";
        if(!Element) var Element = im_wdkUtil.eventTag(ev, "li");
        var groupId = Element.getAttribute("groupId");
        var groupName = Element.getAttribute("groupName");        IMToolBar.overMenu = "";
        this.__closeMenu(id);
        im_openWebchatWindow(groupId, groupName, null, true, 'group');
    },
     updateUserStatus:function(statusValue, message){
        var _status = "";
        var btnState = im_wdkUtil.$("ico_state");
        if(!btnState) return;
        var Items = im_wdkUtil.$$(".act", im_wdkUtil.$$(" ul", btnState)[0]);
        for(var i = 0; i < Items.length; i++){
            if(statusValue==Items[i].getAttribute("val"))
                IMcssTag.addClass(Items[i], "selected");
            else
                IMcssTag.removeClass(Items[i], "selected");
        }
        if(/9|10/g.test(statusValue)){IMToolBar._tipMessage = "服务器链接中，请等待...";}
        else if(message!=null) IMToolBar._tipMessage = message=="验证用户失败！" ? "验证用户失败，请刷新页面！" : message;
        IMToolBar.cfg['ico_state'][0] = statusValue==2 ? "您处于隐身状态" : "用户状态";
        switch(statusValue){
            case 1:_status = "ico_online";this.enable(); break;
            case 2:_status = "ico_invisible";this.enable();
                IMToolBar.onOverEvent(null, 'ico_state');
                IMAnimate.timer(function(){IMToolBar.__hiddenTip('ico_state');}, 4000);
                break;
            case 3:_status = "ico_busy";this.enable();break;
            case 4:_status = "ico_leave";this.enable();break;
            case 9,10:_status = "ico_unline";this.disable();break;
            default:_status = "ico_unline";this.disable();break;
        }
        btnState.getElementsByTagName("DIV")[0].className = _status;
    },
    saveStatus:function(statusValue){
        IMToolBar.overMenu = "";
        this.__closeMenu("ico_state");        IMToolBar.updateUserStatus(statusValue);
        var _presenceFlash = im_wdkUtil.$("impresenceflash");
        if(_presenceFlash && _presenceFlash.switchUserStatus){            _presenceFlash.switchUserStatus(statusValue);
        }
    },
    updateUserNumber:function(onlineUser, totalUser){
        if(im_wdkUtil.$("buddylist_span")) 
            im_wdkUtil.$("buddylist_span").innerHTML = "(" + onlineUser + "/" + totalUser + ")";
    },
    toolbarHtml: function(){
        var _html = '';
        _html += '<div class="NtalkerBg" id="NtalkerBg"></div>';
        _html += '<div class="ntbody" id="Ntalkerbody">';
        _html += '<iframe style="border: 0pt none ; margin: 0pt; padding: 0pt; position: absolute; top: 0pt; left: 0pt; height: 100%; width: 100%; z-index: -1;" src="" scrolling="no" frameborder="0"></iframe>';
        _html += '    <div id="btnICON">';
        _html += '        <ul style="list-style:none;margin:0px;padding:0px;">';
        _html += '            <li id="ico_copyright"><div class="ico_button"></div></li>';
        _html += '            <li id="ico_popup"><div class="ico_button"></div></li >';
        _html += '            <li id="ico_state">';
        _html += '                <div class="ico_button ico_unline">&nbsp;</div>';
        _html += '                <div class="ntalkermenu" style="display:none;" onmouseover="IMToolBar.onVisibleMsgMenu(event);" onmouseout="IMToolBar.onHiddenMsgMenu(event);">';
        _html += '                   <div class="topfillet"></div>';
        _html += '                    <ul style="list-style:none;margin:0px;padding:0px;">';
        _html += '                        <li class="act online" val="1" onclick="IMToolBar.saveStatus(1);"    onmouseover="IMcssTag.addClass(this, \'hover\');" onmouseout="IMcssTag.removeClass(this, \'hover\');"><div>在线</div></li>';
        _html += '                        <li class="act busy" val="3" onclick="IMToolBar.saveStatus(3);"      onmouseover="IMcssTag.addClass(this, \'hover\');" onmouseout="IMcssTag.removeClass(this, \'hover\');"><div>忙碌</div></li>';
        _html += '                        <li class="act leave" val="4" onclick="IMToolBar.saveStatus(4);"     onmouseover="IMcssTag.addClass(this, \'hover\');" onmouseout="IMcssTag.removeClass(this, \'hover\');"><div>离开</div></li>';
        _html += '                        <li class="act invisible" val="2" onclick="IMToolBar.saveStatus(2);" onmouseover="IMcssTag.addClass(this, \'hover\');" onmouseout="IMcssTag.removeClass(this, \'hover\');"><div>隐身</div></li>';
        _html += '                   </ul>';
        _html += '                   <div class="bottomfillet"></div>';
        _html += '                </div>';
        _html += '            </li>';
        if(Ntalker.Config.customparams['enablegroup'] || Ntalker.Config.customparams['enablechat']){
            _html += '            <li id="ico_group" class="ico_group">';
            _html += '                <div class="ico_button">(0)</div>';
            _html += '                <div class="ntalkermenu" style="display:none;" onmouseover="IMToolBar.onVisibleMsgMenu(event);" onmouseout="IMToolBar.onHiddenMsgMenu(event);">';
            _html += '                   <div class="topfillet"></div>';
            _html += '                   <ul style="list-style:none;margin:0px;padding:0px;">';
            _html += '                        <li class="act group"><div>五字群名称(0)</div></li>';
            _html += '                   </ul>';
            _html += '                   <div class="bottomfillet"></div>';
            _html += '                </div>';
            _html += '            </li>';
        }
        _html += '            <li id="ico_buddylist">';
        _html += '                <div id="buddylist_span" class="ico_button">&nbsp;</div>';
        _html += '                <div id="buddylist_tab"></div>';
        _html += '            </li>';
        _html += '            <li id="ico_msg" class="ico_msg">';
        _html += '                <div class="ico_button">&nbsp;</div>';
        _html += '               <div class="ntalkermenu" style="display:none;" onmouseover="IMToolBar.onVisibleMsgMenu(event);" onmouseout="IMToolBar.onHiddenMsgMenu(event);">';
        _html += '                   <div class="topfillet"></div>';
        _html += '                   <ul style="list-style:none;margin:0px;padding: 0px 0px 0px 5px !imporant; _padding:0px;">';
        _html += '                   </ul>';
        _html += '                   <div class="bottomfillet"></div>';
        _html += '               </div>';
        _html += '            </li>';
        _html += '            <li id="ico_zoom" class="icozoom"><div class="ico_button">&nbsp;</div></li>';
        _html += '        </ul>';
        _html += '    </div>';
        _html += '    <div id="ico_pre" class="ico_pre_flash"><div class="ico_button"></div></div>';
        _html += '    <div id="ico_next" class="ico_next_flash"><div class="ico_button"></div></div>';
        _html += '    <div id="windows_area">';
        _html += '        <div id="bodylist">';
        _html += '            <ul id="windows_gp" style="list-style:none;margin:0px;padding:0px;">';
        _html += '            </ul>';
        _html += '            <div class="clearFolat"></div>';
        _html += '        </div>';
        _html += '    </div>';
        _html += '</div>';
        return _html;
    },
    createHotButton:function(){
        if(!Ntalker.Config.customparams['enablehot'] || Ntalker.temp.CHot) return;
        IMToolBar.cfg["ico_bbshot"]    = ["坛热点"];
        Ntalker.temp.CHot = true;
        IMToolBar.minWidth += 32;
        var _html, _marginRight = parseInt(IMcssTag.css(im_wdkUtil.$("windows_area"), "marginRight"));
        im_wdkUtil.$("windows_area").style.marginRight = (_marginRight - 32) + "px";
        _html  = '<li id="ico_bbshot" class="ico_msg">';
        _html += '  <div class="ico_button">&nbsp;</div>';
        _html += '      <div class="ntalkermenu" style="display:none;" onmouseover="IMToolBar.onVisibleMsgMenu(event);" onmouseout="IMToolBar.onHiddenMsgMenu(event);">';
        _html += '          <div class="topfillet"></div>';
        _html += '          <ul style="list-style:none;margin:0px;padding: 0px 0px 0px 5px !imporant; _padding:0px;">';
        _html += '          </ul>';
        _html += '      <div class="bottomfillet"></div>';
        _html += '  </div>';
        _html += '</li>';
        im_wdkUtil.insertHtml("beforebegin", im_wdkUtil.$('ico_msg'), _html);
        this.updateToolbar();
        var btnDIV = im_wdkUtil.$$(".ico_button", im_wdkUtil.$('ico_bbshot'))[0];
        if(btnDIV){
            im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onShowHost);
            im_wdkUtil.Event.addEvent(btnDIV, "mouseover", IMToolBar.onOverEvent);
            im_wdkUtil.Event.addEvent(btnDIV, "mouseout",  IMToolBar.onOverEvent);
        }
    },
    updateToolbar:function(){
        var _winRect = im_wdkUtil.viewRect.get(window);
        var winArea  = im_wdkUtil.$("windows_area");
        if(!this.isExpand){
            if(IMBrowser.msie56){
                IMcssTag.css(winArea, "width", 1);
                IMcssTag.css(winArea, "height", 1);
            }else{
                IMcssTag.css(winArea, "visibility", "hidden");
            }
            IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", IMToolBar.minWidth - (IMBrowser.msie56&&!IMBrowser.boxModel ? 1 : 0));
            IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", IMToolBar.minWidth - (IMBrowser.msie56&&!IMBrowser.boxModel ? 1 : 0));
            IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", IMToolBar.minWidth - (IMBrowser.msie56&&!IMBrowser.boxModel ? 1 : 0));
        }else{
            IMcssTag.css(winArea, "visibility", "visible");
            if(IMBrowser.msie56){
                IMcssTag.css(winArea, "height", 28);
                IMcssTag.css(winArea, "width", (_winRect.w - IMToolBar.minWidth - 58));
            }
            if(IMBrowser.firefox2 || IMBrowser.safari || IMBrowser.chrome)
                IMcssTag.css(winArea, "margin", "0px");
            IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", IMBrowser.msie56 ? (_winRect.w-2)+"px" : "100%");
            IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", IMBrowser.msie56 ? (_winRect.w-2)+"px" : "100%");
            IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", IMBrowser.msie56 ? (_winRect.w-2)+"px" : "100%");       
        }
    },
    onLeft:function(){
        var Element= im_wdkUtil.$('windows_area');
        var _sLeft = Element.scrollLeft;
        if(IMToolBar.minWinCount*IMToolBar.minChatWidth - _sLeft > IMToolBar._viewRect.w){
            IMAnimate.animate(Element, "scrollLeft", {start:_sLeft,end:_sLeft+IMToolBar.minChatWidth,step:22}, function(){
                IMToolBar.initScroll();
            }, null, true);
        }
    },
    onRight:function(){
        var Element= im_wdkUtil.$('windows_area');
        var _sLeft = Element.scrollLeft;
        IMAnimate.animate(Element, "scrollLeft", {start:_sLeft,end:_sLeft-IMToolBar.minChatWidth,step:-22}, function(){
            IMToolBar.initScroll();
        }, null, true);
    },
    initScroll:function(){
        var Element= im_wdkUtil.$('windows_area');
        var _sLeft = Element.scrollLeft;
        if(IMToolBar.minWinCount*IMToolBar.minChatWidth <= IMToolBar._viewRect.w){
            IMcssTag.addClass(im_wdkUtil.$('ico_pre'),  "ico_pre_flash");
            IMcssTag.addClass(im_wdkUtil.$('ico_next'), "ico_next_flash");
        }else{
            if(_sLeft > 0 ){
                IMcssTag.removeClass(im_wdkUtil.$('ico_next'), "ico_next_flash");
            }else{
                IMcssTag.addClass(im_wdkUtil.$('ico_next'), "ico_next_flash");
            }            if(IMToolBar.minWinCount*IMToolBar.minChatWidth - _sLeft > IMToolBar._viewRect.w){
                IMcssTag.removeClass(im_wdkUtil.$('ico_pre'), "ico_pre_flash");
            }else{
                IMcssTag.addClass(im_wdkUtil.$('ico_pre'), "ico_pre_flash");
            }
        }
    }
};
function fIM_updateUserHead(destuid, strheadURL, intStatus, chatType){
    chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");    IMAnimate.timer(function(){
        var miniWin = IMToolBar.getMiniWindow(destuid, chatType);
        if(miniWin) miniWin.updateUserHead(strheadURL, intStatus);
    }, 50);
}
function fIM_updateUserStatus(statusValue,message){    IMAnimate.timer(function(){
        IMToolBar.updateUserStatus(statusValue, message);
        if(statusValue!=0){
            im_openHistoryChatWindow();
            if(Ntalker.Config.customparams['enablehot']){
                var hotserver = Ntalker.temp.hotserver;                Ntalker.temp.statusValue = true;
                var serverkey = Ntalker.hotKEY+Ntalker.variable.user_id+"_ck";
                var checkKey  = im_wdkUtil.GetCookie(serverkey);
                if( (checkKey=="" || checkKey==null || typeof(checkKey)=="undefined") && Ntalker.temp.versionValue){
                    im_wdkUtil.SetCookie(serverkey, "1", 2*60*60);
                    im_wdkUtil.createScript(hotserver);
                }else if(checkKey=="1"){                    sIM_checkCreateHot("1", "N");
                }
            }
        }
    }, 50);
}
function fIM_updateUserNumber(onlineUser, totalUser){    IMAnimate.timer(function(){
        IMToolBar.updateUserNumber(onlineUser, totalUser);
        if(Ntalker.Config.isPopupWindow==1 && Ntalker.temp.OpenBuddyListWindow != true){
            Ntalker.temp.OpenBuddyListWindow = true;
            im_openBuddyListWindow(true);
        }
    }, 50);
}
var im_sendOpenChatWindowList = [];
function fIM_hiddenToolBar(){
    if(Ntalker.Config.isPopupWindow==1) return;    var chatWins = im_chat_window_manager._chatWndsArray;
    if(Ntalker.variable.user_id && im_chat_window_manager && chatWins.length>0){
        for(var i=0; i<chatWins.length; i++){
            im_sendOpenChatWindowList.push([chatWins[i]._destuid, chatWins[i]._destnick, null, chatWins[i]._chatType]);
        }        im_wdkUtil.$("impresenceflash").runJSFunction("fIM_openPopupChatWindow", im_sendOpenChatWindowList, true);
    }
    fIM_CloseIMWindow();
    im_chat_window_manager.closeAll();
    IMToolBar.hidden();
}
function fIM_visibleToolBar(){    IMToolBar.visible();
}
function fIM_openPopupChatWindow(arrWin, isActiveOpen){    if(Ntalker.Config.isPopupWindow==0) return;
    IMAnimate.timer(function(){
        for(var i=0; i<arrWin.length; i++){            im_openWebchatInPage(arrWin[i][0], arrWin[i][1], arrWin[i][2], isActiveOpen, arrWin[i][3]);
        }
    }, 50);
}
function fIM_disconnects(){    var impresenceflash = im_wdkUtil.$('impresenceflash');
    if(impresenceflash && impresenceflash.runJSFunction){        impresenceflash.runJSFunction("fIM_disconnect");
    }
}
function fIM_disconnect(){    var impresenceflash = im_wdkUtil.$('impresenceflash');
    if(impresenceflash && impresenceflash.disconnect){        impresenceflash.disconnect();
    }
}
function im_openHistoryChatWindow(){
    if(Ntalker.variable.openHistoryWindow) return;
    Ntalker.variable.openHistoryWindow = true;
    IMToolBar.loadMsg();
    IMToolBar.loadGroupMsg();    var k = Ntalker.unKey + Ntalker.variable.user_id;
    var v = im_wdkUtil.GetCookie(k);im_wdkUtil.SetCookie(k, "");
    var curid = 0;
    var curtype = "chat";
    if(!v) return;
    v = v.replace(/{/g, "").split("}");
    for(var k in v){
        if(v[k]){
            IMToolBar.onMaximize();
            chatWindow = im_wdkUtil.StringToArray(v[k]);
            if(typeof(chatWindow)=='undefined'|| !chatWindow)
              continue; 
            im_openWebchatWindow(chatWindow["_destuid"], chatWindow["_destnick"], null, false, chatWindow["_chatType"]);
            Ntalker.variable.onlineChat -= 1;
            if(chatWindow["current"]=="default"){
                curid = chatWindow["_destuid"];
                curtype = chatWindow["_chatType"];
            }        }
    }
    if(im_chat_window_manager){
        im_chat_window_manager.OnTBFocusWindow(curid, curtype);
    }
}
function im_onUnload(){
    var _cfg = Ntalker.Config;
    var _var = Ntalker.variable;
    var _temp= Ntalker.temp;
    var chatWins = im_chat_window_manager._chatWndsArray;    if(_var.user_id && im_chat_window_manager && chatWins.length>0 && Ntalker.Config.isPopupWindow==0 ){
        var val="";var curval=""; 
        for(var i=0; i<chatWins.length; i++){
            if(/group|chat/.test(chatWins[i]._chatType)) val += "{_destuid:" + chatWins[i]._destuid+";_destnick:"+chatWins[i]._destnick+";_chatType:"+chatWins[i]._chatType+";current:"+chatWins[i]._curWindMode+";}";
        }
        if(!val) return;
        im_wdkUtil.SetCookie(Ntalker.unKey + _var.user_id, val);
    }
    var flashobj = im_wdkUtil.$('impresenceflash');
    if(flashobj){
        if(flashobj.closePresence) flashobj.closePresence();
        im_wdkUtil.disposeFlashObj(flashobj);
        flashobj.parentNode.removeChild(flashobj);
    }
    im_wdkUtil.Event.flush();
    IMToolBar.saveMsg();
    IMToolBar.saveGroupMsg();
    if(_temp.presenceFlashGoUrl) im_wdkUtil.createScript(_temp.presenceFlashGoUrl);
    if(im_chat_window_manager) im_chat_window_manager.closeAll();
    if(im_myIMWindow) im_myIMWindow.close();
}
function startGetMyIMStatus(imStatusUrl){
  if(imStatusUrl && Ntalker.variable.user_id)
    im_wdkUtil.createScript(imStatusUrl+"?query=onlinenum&sitid="+Ntalker.variable.siteid+"&uid="+Ntalker.variable.user_id+"&imsid="+Ntalker.variable.imsid);
}
function im_runPresenceStart() {
    if(!Ntalker.variable.user_id || Ntalker.variable.user_id==0) return;    var flashServersText = null,_cfg = Ntalker.Config,_var = Ntalker.variable;
    im_wdkUtil.Event.addEvent(window, "unload", im_onUnload);
    wdkApplication = new WDK_IM_PACK.Application();
    wdkApplication.init();
    NotifyManager.init();
    if(typeof(_cfg.not_showfloat_sites)!="undefined" && _cfg.not_showfloat_sites){
        for(var i=0;i<_cfg.not_showfloat_sites.length;i++){
            if(_cfg.not_showfloat_sites[i].toLowerCase()==_var.siteid.toLowerCase()){
                _cfg.customparams["enblebuddyentry"] = 0;
            }
        }
    }
    im_myIMWindow = new  WDK_IM_PACK.IMWindow();
    im_myIMWindow.init();
    im_chat_window_manager = new WDK_IM_PACK.ChatWindowManager();
    window.chatWindowManager = im_chat_window_manager;}
function IM_initPopuWindowScript(){
    Ntalker.Config.isPopupWindow = 1;
    var btnPopup = im_wdkUtil.$$(" div", im_wdkUtil.$("ico_popup"))[0];
    btnPopup.onclick = null;}
function im_showSiteMessage(siteMsgInfoArray)
{
    Ntalker.variable.ExMsg = [];
    for(var j=0; j<siteMsgInfoArray.length; j++){
        Ntalker.variable.ExMsg.push(siteMsgInfoArray[j]);
    }
    if(IMToolBar)
        IMToolBar.updateMsgNum();
}
im_wdkUtil.createScript(Ntalker.variable.scriptPath+"/promptwindow.js", "utf-8", true);
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}try{X.removeChild(aa);}catch(e){}Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
var im_flashVersion = swfobject.getFlashPlayerVersion().major;
var im_installFlashActionX = im_flashVersion<9 ? true : false;