var Ntalker = {
    DOC  : (document.documentElement || document.body || null),
    UA   : navigator.userAgent.toLowerCase(),
    unKey:"imNt_uLoad_ctWind",
    ctKEY:"imNt_uRdsys_",
    gpKEY:"imNt_uRdgroup_",
    tipKEY:"imNt_stip",
    hotKEY:"imNt_hot",
    tbModelKEY:"imNt_Session_tbMode",
    tbClosedKEY:"imNt_Session_tbClosed",
    guestUserNoKEY:"imNt_guestNo"
};
Ntalker.version = {
    imxml_version  : "",
    software_name  : "",
    presence_flash : "2.9.0",
    buddylist_flash: "2.9.2",
    webchat_flash  : "2.9.2",
    group_flash    : "2.9.2",
    hot_flash      : "2.9.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     : "",
    buddylistTag   : null
};
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            :"",
    grouplogo            :"",
    chatroomlogo         :"",
    copyrighturl         :"",
    copyrighttip         :"",
    chatWidth            :380,
    chatHeight           :416,
    groupWidth           :456,
    groupHeight          :532,
    hotWidth             :514,
    hotHeight            :534,
    IMWidth              :304,
    IMHeight             :536,
    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.room = {
	roomid:null,
	roomname: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;}
    }
};
Ntalker.smileyRegexps = [/:\)/g,/:\(/g,/:D/g, /:\]/g,/;-\)/g,/:O/g,/:\-7/g,/\|\-D/g,/:\-x/g,/:\-O/g,/:9/g,/\(:\-/g,/\|\-\)/g,/:~\)/g,/:\-8/g];
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 = 1;
var IMBrowser     = new Object();
IMBrowser.version = (Ntalker.UA.match( /.+(?:firefox|rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1];
IMBrowser.safari  = /webkit/.test( Ntalker.UA );
IMBrowser.opera   = /opera/.test( Ntalker.UA );
IMBrowser.msie    = /msie/.test( Ntalker.UA ) && !/opera/.test( Ntalker.UA );
IMBrowser.msie56  = parseFloat( Ntalker.UA.substring(Ntalker.UA.indexOf("msie") + 5)) >= 5.5 && parseFloat(Ntalker.UA.substring(Ntalker.UA.indexOf("msie") + 5))<7;
IMBrowser.msie8   = /msie 8.0/.test( Ntalker.UA ) && !/opera/.test( Ntalker.UA );
IMBrowser.mozilla = /mozilla/.test( Ntalker.UA ) && !/(compatible|webkit)/.test( Ntalker.UA );
IMBrowser.firefox = /firefox/.test( Ntalker.UA );
IMBrowser.firefox2= /firefox/.test( Ntalker.UA ) && ((Ntalker.UA.match( /.+(?:firefox|rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1]).indexOf("2.") > -1;
IMBrowser.chrome  = /chrome/.test( Ntalker.UA );
try{IMBrowser.maxthon = external&&external.max_version!=undefined;}catch(e){}
IMBrowser.boxModel= document.compatMode=="BackCompat";
IMBrowser.oldModel= /msie/.test( Ntalker.UA ) && !/opera/.test( Ntalker.UA ) && document.compatMode=="BackCompat";
var IMcssTag = {
	intAttributeReg: /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 || !attr) return;
        if(/float/.test(attr)) attr = typeof(el.style.cssFloat)=="undefined" ? "styleFloat":"cssFloat";
        var isInt = null;var _get;
        if(this.intAttributeReg.test(attr)){
        	isInt=true;
        }
        if (value==undefined) {
            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 = attr=="opacity"&&el.currentStyle[attr]==undefined ? 1 : 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;}
        return IMAnimate.timer(function(){IMAnimate.animate(el, attr, par, func, curValue, JsAttribute);}, 50);
    },
    _alpha:function(el, curOpa){
        try{
        	el.style.display    = 'block';
            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);}
};
function createDelayedMethod(b, c, a) {
    var d = function() {
        this[b] = createDelayedMethod.delayBind(this, c, a);
        this[b].apply(this, arguments)
    };
    d.cancel = function() {};
    return d
}
createDelayedMethod.delayBind = function(c, d, a) {
    var b = function() {
        clearTimeout(b.m_timeout);
        b.m_args = arguments;
        b.m_timeout = setTimeout(b.run, a || 0)
    };
    b.run = function() {
        b.cancel();
        d.apply(c, b.m_args)
    };
    b.cancel = function() {
        clearTimeout(b.m_timeout)
    };
    return b
};
WdkUtil = function(){
    this.setDomain();
    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);
        }
    }else{
    	var domain = /([^\.]+(\.com(\.cn)?|\.net(\.cn)?|\.org(\.cn)?|\.cn))$/.exec(document.domain);
    	this.Domain = domain ? domain[0] : document.domain;
    }
    return this.Domain;
}
_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 = event || window.event;
    this.event = _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 = {
    get: function(el){
    	function $(e){
	        return(document.getElementById ? document.getElementById(e) : document.all ? document.all[e] : null);
	    }
        el = typeof(el)=='string' ? $(el) : el;
        if( !el || el==window || el==document ){
            return this.getDocumentPosition();
        }
        else{
        	var c = this.getElementPosition(el),b = document,a = Ntalker.UA,b={l:0,r:0,t:0,b:0};        	b.l = IMcssTag.css(document.body,"borderLeftWidth");
        	b.t = IMcssTag.css(document.body,"borderTopWidth");
        	b.l = b.l?parseInt(b.l):0;
        	b.t = b.t?parseInt(b.t):0;
        	if(b.l) c.x += b.l;
        	if(b.t) c.y += b.t;
            if( (document.compatMode=="BackCompat" && IMBrowser.msie) || (document.compatMode=="CSS1Compat" && IMBrowser.msie56) ){ 
                return c;
            }else{
                var d = this.getDocumentPosition();
                c.x += d.x;
                c.y += d.y;
                return c;
            }
        }
    },
    getElementPosition: function(b, a){
	    var d = {x: 0,y: 0,w: 0,h: 0};
	    if (b) {
	        d.w = b.offsetWidth || b.style.pixelWidth;
	        d.h = b.offsetHeight || b.style.pixelHeight;
	    }
	    var c = b;
	    while (c) {
	        if (c === a) { break; }
	        d.x += c.offsetLeft;
	        d.y += c.offsetTop;
	        if (c != b) {
	            d.x -= c.scrollLeft;
	            d.y -= c.scrollTop;
	        }
	        c = c.offsetParent;
	    }
	    d.left = d.x;
	    d.top = d.y;
	    return d;
    },
    getDocumentPosition: function(obj){
    	var d = {x: 0,y: 0,w: 0,h: 0};
        d.x = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
        d.y = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
        d.w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0;
        d.h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
        return d;
    }
};
_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";
        var htmlContent  = '<' + elDom.name;
        for(var k in elDom){if(k && k!='name')  htmlContent += ' '+(k=="className" ? "class" : k)+'="' + elDom[k] + '"';}
        htmlContent  += '></'+elDom.name+'>';
        switch(where){
            case "beforebegin":
                toElement.insertAdjacentHTML('BeforeBegin', htmlContent);
                return toElement.previousSibling;
            case "afterbegin":
                toElement.insertAdjacentHTML('AfterBegin', htmlContent);
                return toElement.firstChild;
            case "beforeend":
                toElement.insertAdjacentHTML('BeforeEnd', htmlContent);
                return toElement.lastChild;
            case "afterend":
                toElement.insertAdjacentHTML('AfterEnd', htmlContent);
                return toElement.nextSibling;
            default :
                toElement.insertAdjacentHTML('AfterBegin', htmlContent);
                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{
        var htmlContent  = '<' + elDom.name;
        for(var k in elDom){if(k && k!='name')  htmlContent += ' '+(k=="className" ? "class" : k)+'="' + elDom[k] + '"';}
        htmlContent  += '></'+elDom.name+'>';
        toElement.innerHTML += htmlContent;
        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="",cl=this.lenText(str);
    if(cl <= ml){
        return cl%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, s = str?str:"";
    for(var i=0;i<s.length;i++){
        if(s.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.clearHTML = function(strSource){
	if(!strSource)
		return "";
	else{
		strSource = strSource.replace(/&lt;/g,"<");
		strSource = strSource.replace(/&gt;/g,">");
		return strSource.replace(/<[^>].*?>/g,"");
	}
};
_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)==="1"){
        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, "1"); return;
        }
        var t = (d.getTime() - od.getTime())/1000;
        im_wdkUtil.SetCookie(key, "1", 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();
        })();
    }
};
_p.u2c = function(str) { 
	if(''==str || str==null ) return('');
	var st, t, i 
	st = ''; 
	for (i = 1; i <= str.length/4; i ++){ 
		t = str.slice(4*i-4, 4*i-2); 
		t = str.slice(4*i-2, 4*i).concat(t); 
		st = st.concat('%u').concat(t); 
	} 
	st = unescape(st); 
	return(st); 
};
_p.c2u = function(str) { 
	if ('' != str) { 
		var st, t, i; 
		st = ''; 
		for (i = 1; i <= str.length; i ++){ 
			t = str.charCodeAt(i - 1).toString(16); 
			if (t.length < 4) 
				while(t.length <4) 
					t = '0'.concat(t); 
			t = t.slice(2, 4).concat(t.slice(0, 2)) 
			st = st.concat(t); 
		} 
		return(st.toUpperCase()); 
	} 
	else { 
		return(''); 
	} 
};
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.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 sprintf() {
    if (!arguments || arguments.length < 1 || !RegExp || !arguments[0]) {
        return
    }
    var b = arguments[0], l = arguments.length;
    for (var a = 1;a < l;a++) {
        b = b.replace(new RegExp("%" + a, "g"), arguments[a] || "")
    }
    return b
}
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"]; else _cache.style_dir += siteid+"/";
        if(Ntalker_Config["image_dir"]) _cache.image_dir += Ntalker_Config["image_dir"]; else _cache.image_dir += siteid+"/";        switch(Ntalker_Config["skin"])
        {
        	case "ntalker_skin1":_cache.skin = "hue=0";break;
        	case "ntalker_skin2":_cache.skin = "hue=92.92";break;
        	case "ntalker_skin3":_cache.skin = "hue=2.31,saturation=0.61,hue=101.19,saturation=0.75";break;
        	case "ntalker_skin4":_cache.skin = "hue=-155.31";break;
        	case "ntalker_skin5":_cache.skin = "hue=-79.78,light=9.26";break;
        	case "ntalker_skin6":_cache.skin = "hue=149.96";break;
        	case "ntalker_skin7":_cache.skin = "saturation=0";break;
        	case "ntalker_skin8":_cache.skin = "hue=-22.5,light=10.61";break;
        	case "ntalker_skin9":_cache.skin = "hue=67.5";break;
        	case "ntalker_skin10":_cache.skin = "hue=-114.81";break;
        	default:_cache.skin = Ntalker_Config["skin"];break;
        }
        _cache.init();
        if(Ntalker_Config["Chat"]){
            _cfg.chatWidth        = Ntalker_Config["Chat"].width;
            _cfg.chatHeight       = Ntalker_Config["Chat"].height;
        }
        if(Ntalker_Config["groupChat"]){
            _cfg.groupWidth       = Ntalker_Config["groupChat"].width;
            _cfg.groupHeight      = Ntalker_Config["groupChat"].height;
        }
        if(Ntalker_Config["hotChat"]){
            _cfg.hotWidth         = Ntalker_Config["hotChat"].width;
            _cfg.hotHeight        = Ntalker_Config["hotChat"].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":"ntalker_skin1/logo_big.png";
        _cfg.chatlogo         = Ntalker_Config['logo'].chatlogo     ? siteid+"/logo_small.png"   :"ntalker_skin1/logo_small.png";
        _cfg.startlogo        = Ntalker_Config['logo'].startlogo    ? _var.scriptPath + "/images/" + siteid+"/":_cache.image_dir;
        _cfg.grouplogo        = Ntalker_Config['logo'].grouplogo    ? _var.scriptPath + "/images/"+siteid+"/grouplogo.png":_var.scriptPath + "/images/group.png";
        _cfg.chatroomlogo     = Ntalker_Config['logo'].chatroomlogo ? _var.scriptPath + "/images/"+siteid+"/chatroomlogo.png":_var.scriptPath + "/images/group.png";        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){
            _Btns[k].style = sprintf(_Btns[k].style, _var.scriptPath + "/images/");
            if(typeof(k)=="string" && _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{
        _cache.init();
        _cache.skin       = "hue=0";
        _cache.style_dir += "ntalker_skin1/";
        _cache.image_dir += "ntalker_skin1/";
        _cfg.buddylistlogo= "ntalker_skin1/logo_big.png";
        _cfg.chatlogo     = "ntalker_skin1/logo_small.png";
        _cfg.startlogo    = _cache.image_dir;
        _cfg.logo         = _cache.image_dir + "logo.gif";
        _cfg.grouplogo    = _var.scriptPath + "/images/group.png";
        _cfg.chatroomlogo = _var.scriptPath + "/images/group.png";
        _cfg.customparams = {enblebuddyentry: 1,floatpos:"right",intact:0,show_popmenu:1,show_tooltip:1,hiddenmode:0,createblank:0,enablegroup:1,enableroom:1,enablehot:1,sys_enableguest:0,introbuddy:1,onlinelist:1,chataddbuddy:1,enablepopup:1,disablegrouptip:1,head:1,ad:1,search:1,imagelist:1,playsound:1};
    }
    _cfg.customparams["playsound"] = typeof _cfg.customparams["playsound"]=="undefined" || _cfg.customparams["playsound"] ? 1 : 0;
    if(Ntalker.Config.customparams["hiddenmode"]) return;
    if(!Ntalker.Config.execRunPresence){
        var _var       = Ntalker.variable;
        im_runPresence(_var.userparam, _var.siteid, _var.user_id, _var.user_name, _var.user_sid, '', '', _cfg.customparams, _cfg.showToolBar)
    }
    StartGetGroupEntry();}
function im_runPresence(userparam, siteid, userid, username, sessionid, flashserver, webchatpageurl, customParams, showToolBar) {
    var _cache = Ntalker.cache;
    var _cfg   = Ntalker.Config;
    var _win   = Ntalker.win;
    var _var   = Ntalker.variable;
    if( (userid==0||userid==''||username==''||sessionid=='') && Ntalker.Config.customparams["sys_enableguest"] ){
    	var userNO = im_wdkUtil.GetCookie(Ntalker.guestUserNoKEY);
    	if(!userNO || userNO===null){
    		var t = String(new Date().getTime());
    		userNO     = t.substr(t.length-8,8) + Math.round(Math.random()*1000);
			userid     = "guest"+userNO;
			username   = "\u6E38\u5BA2"+userNO;
		}else{
			userid     = "guest"+userNO;
			username   = "\u6E38\u5BA2"+userNO;
		}
		sessionid      = 'NtalkerGuestUserSessionID';		im_wdkUtil.SetCookie(Ntalker.guestUserNoKEY, userNO, 3600*24*7);
	}
    _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;
    _cfg.showToolBar = typeof(showToolBar)=="undefined" || showToolBar ? true : false;
    if(typeof(userparam)=='undefined' || !userparam || userparam.length==0){
        userparam = username;
    }	if(!Ntalker.Config.execIMOnlineStatus) return;
	Ntalker.Config.execRunPresence = true;    im_wdkUtil.createCSS(Ntalker.cache.image_dir + "/toolbar_"+Ntalker.Config.customparams["floatpos"]+".css");
    if(Ntalker.variable.user_sid && Ntalker.variable.user_name) IMToolBar.init();
    im_changeFlashConnet();
    im_runPresenceStart();
}function im_connectIM(siteid, userid, username, sessionid, userparam, customParams, param1, param2){    im_getIMOnlineStatus(siteid);
    im_runPresence(userparam, siteid, userid, username, sessionid, "", "", customParams, param1);    
}
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");
    flashvars += "&rurl=" + Ntalker.variable.scriptPath;
    var flashurl  = Ntalker.variable.scriptPath+"/fs/impresence.swf";
    if(window.location.pathname.indexOf("window.html")>0 ) flashurl += "?rnd="+new Date().getTime();
    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+"&uid="+Ntalker.variable.user_id+"&sid="+Ntalker.variable.user_sid;
    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, 1);
    });
    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( Ntalker.Config.customparams["enblebuddyentry"]){ 
        if(_presenceFlash && _presenceFlash.requestUserStatus){
            _presenceFlash.requestUserStatus(strUserIDList, _arrSpan.length);
        }
    }
}
function StartGetGroupEntry() {
	var enablegroup = Ntalker.Config.customparams['enablegroup'];
    statusSpans = document.getElementsByTagName("SPAN");
    spanindex = 0;
    imgsrc = Ntalker.Config.grouplogo;
    for (i = 0; i < statusSpans.length; i++) {
        statusSpan = statusSpans[i];
        if (statusSpan.className == "wdk_group_chat_span" && statusSpan.id) {
        	var cursorGroupType = statusSpan.getAttribute("ischatroom");
            pos = statusSpan.id.indexOf("wdk_group_");
            if (pos >= 0 && cursorGroupType=="true" ) {
            	var newGroupObj = new Object();
                newGroupObj.groupid   = statusSpan.id.substring(pos + "wdk_group_".length, statusSpan.id.length);
                newGroupObj.groupnick = im_wdkUtil.EncodeSpecialChar(statusSpan.title);
                newGroupObj.roomtype  = 1;
              	im_conncetChatRoom(newGroupObj.groupid, newGroupObj.groupnick);
                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, 1, 'group', "+newGroupObj.roomtype+"); return false;\">";
                chatLinkStr += "<img name=\"wdk_presence_image\" tip=\"" + tiptext + "\" style=\"left:0px;top:0px;\" id=\"wdk_presence_" + newGroupObj.groupid + "\" border=\"0\" style=\"display:inline;";
                chatLinkStr += "\" src=\"" + imgsrc + "\" title=\"" + tiptext + "\"/></a>";
                statusSpan.innerHTML = chatLinkStr;
            }else 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, 1, '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 + "', '"+tiptext+"')\" ";}
                }
                chatLinkStr += " id=\"wdk_presence_" + newGroupObj.groupid + "\" border=\"0\" style=\"display:inline;";
                chatLinkStr += "\" src=\"" + imgsrc + "\" title=\"" + tiptext + "\"/></a>";
                statusSpan.innerHTML = chatLinkStr;
                spanindex++;
            }
        }
    }
}
function im_changeFlashConnet(){
    var impresenceflash = im_wdkUtil.$("impresenceflash");
    var _var       = Ntalker.variable;
    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;
        }
    }
}function fIM_onGetUserStatus(responseText){
	if(!Ntalker.Config.showToolBar)  return;
    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 = _cfg.startlogo+"/offline."+(IMBrowser.msie56?"gif":"png");
            errsrc = Ntalker.variable.scriptPath + "/images/ntalker_skin1/offline."+(IMBrowser.msie56?"gif":"png");
            break;
        case "1":
            imgsrc = _cfg.startlogo+"/online."+(IMBrowser.msie56?"gif":"png");
            errsrc = Ntalker.variable.scriptPath + "/images/ntalker_skin1/online."+(IMBrowser.msie56?"gif":"png");
            break;
        }
        alttext="跟我聊天";
        chatLinkStr =  ' <a  href="javascript:void(0);" style="display:inline;padding:0px;overflow:visible;" alt="'+alttext+'"';
		chatLinkStr += 'onClick="javascript: im_openWebchatWindow(\''+_temp.userSpanArray[i].destuid+'\', \''+_temp.userSpanArray[i].destnick+'\', null, 1); 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+"\" onerror=\"this.src='"+errsrc+"';\" />";
        chatLinkStr += "</a>";
        _temp.userSpanArray[i].spanElement.style.border = '';
        _temp.userSpanArray[i].spanElement.innerHTML = chatLinkStr;
    }
}
function im_openWebchatWindow(destuid, destname, chatid, OpenType, chatType, roomtype){
	if(!Ntalker.Config.showToolBar)  return;
    chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");
    if( !Ntalker.variable.user_sid || !Ntalker.variable.user_name ){
    	if( chatType=="group" && roomtype==1 && Ntalker.Config.customparams["sys_enableguest"]){
	    	im_popupGroupWindow(null, null, null, Ntalker.variable.siteid, destuid, destname, null, '', 0, 1);
	    	return;
	    }else{
        	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, roomtype]], OpenType);
    }else if(IMToolBar && IMToolBar.tbClosed){    	var _var       = Ntalker.variable;
    	im_popupGroupWindow(_var.user_id, _var.user_name, _var.user_sid, _var.siteid, destuid, destname, null, _var.userparam, roomtype);
    }else{
        im_openWebchatInPage(destuid, destname, chatid, OpenType, chatType, roomtype);
    }
    if(IMToolBar && chatType=="group")
        IMToolBar.removeGroupMsg(destuid, destname);
}
function im_openWebchatInPage(destuid, destname, chatid, OpenType, chatType, roomtype){
	if(!Ntalker.Config.showToolBar)  return;
	OpenType = OpenType===true||OpenType===1 ? 1 : (OpenType===-1 ? -1 : 0);
    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, OpenType, chatType, roomtype);
}function im_openBuddyListWindow(OpenType, program){
    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 && !OpenType)
                    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 && OpenType){
        	if(program) return;
            im_wdkUtil.$("impresenceflash").runJSFunction("im_openBuddyListWindow", OpenType, true);        }
    }
    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,
    getIMTip: function(key){
        return this._arrTips.items(key);
    },
    addIMTip: function(key, msg, param, room){
    	if(!im_wdkUtil.isArray(msg) || msg.length==0){    		msg = [{msg:"\u8bf7\u70b9\u51fb\u8fd9\u91cc\u5f00\u59cb\u7fa4\u804a",user:"\u7ba1\u7406\u5458"}];
    	}
    	var menuDisplay = IMcssTag.css(im_wdkUtil.$$(".ntalkermenu", im_wdkUtil.$("ico_group"))[0], "display");
    	for(var i=0; i<Ntalker.smileyRegexps.length;i++)
    		msg[0].msg = msg[0].msg.replace(Ntalker.smileyRegexps[i],"[\u8868\u60c5]");    	if(msg[0].msg.indexOf('[\u56fe\u7247]')!=-1) msg[0].msg = '[\u56fe\u7247]';
    	if(msg[0].msg.replace(/(^\s*)|(\s*$)/g, "").length==0 || menuDisplay=="block")return;
    	var _curTip = this.getIMTip(key);
        if(_curTip){			if(_curTip.message.length>=3) return;
        	_curTip.add(msg, room);
        	_curTip.show();
        }else{
	        this._curTip = new IMtoolTip(key, param);
	        this._curTip.init(msg, room);
	        this._arrTips.add(key, this._curTip);
        }
    },
    addIMTips:function(els, msg, param){
        var _keys = im_wdkUtil.$$(els);
        for(k in _keys){
            if(!_keys[k].id) _keys[k].id = "imNt_tooltip_" + Math.round(Math.random()*10000);
            this.addIMTip(_keys[k].id, msg, param);
        }
    },
    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, param){
    this.key = key;
    this.id  = "imNt_tooltip_"+key;
    this.message = [];
    this.param = !param ? {step:5, wait:5000, nextwait:5000} : param;
    this.curNum = 0;
    this.Element = null;
    this.parentNode = null;
    this.isshow  = false;
}
_p = IMtoolTip.prototype;
_p.init = function(msg, room){
	if(im_wdkUtil.$(this.id)) return;
	this.add(msg, room);
	var _param = this.param, _key = this.key, _this = this;
	if(_param.wait>0){
		this.parentNode = null;
    	this.Element = im_wdkUtil.createDom({name:"DIV",id:this.id,style:"padding:0px;margin:0px;cursor:auto;position:absolute;z-index:9999;top:-100px;left:-500px;width:130px;height:51px;text-align:left;filter:alpha(Opacity=0);-moz-opacity:0;opacity:0;"}, this.parentNode, "AfterBegin");
    	this.Element.innerHTML  = this.getTip();
    }else{
    	if(_key.indexOf("wdk_group_")>-1 )
    		this.parentNode = null;
    	else
    		this.parentNode = im_wdkUtil.$(_key);
    	this.Element = im_wdkUtil.createDom({name:"DIV",id:this.id,style:"padding:0px;margin:0px;cursor:pointer;position:absolute;z-index:9999;top:0px;left:-200px;width:204px;height:47px;text-align:left;filter:alpha(Opacity=0);-moz-opacity:0;opacity:0;line-height:16px;background:url("+Ntalker.cache.image_dir+"/imNt_tips_r.gif) no-repeat;"}, this.parentNode, "beforeend");
    	this.Element.innerHTML  = this.toolbarTip(0);
    	if( _key.indexOf("wdk_group_")>-1 ){
    		var usercount = 0;
    		if(this.message.length>0 && this.message[0].usercount)
    		   usercount = parseInt(this.message[0].usercount);
    		if(im_wdkUtil.$(_key)) im_wdkUtil.insertHtml("beforeend", im_wdkUtil.$(_key), "<span style=\"font-size:12px;\">("+usercount+")</span>");
    	}
    }
    var _icoRect = im_wdkUtil.viewRect.get(_key);
    var _winRect = im_wdkUtil.viewRect.get(window);
    var _tipRect = im_wdkUtil.viewRect.get(this.Element);
    if(_param.wait>0 || _key.indexOf("wdk_group_")>-1){
		var _x = _icoRect.x + _icoRect.w/2 - 12;
		var _y = _icoRect.y - _tipRect.h  - (IMBrowser.msie56 ? 0 : _winRect.y);
	    if( _x+_tipRect.w + 10 > _winRect.x+_winRect.w ){
	        var bA = im_wdkUtil.$('bALlOOnT'+_key);
	        if(bA){bA.style.left=""; bA.style.right="4px";}
	        _x = _icoRect.x + _icoRect.w/2 - _tipRect.w + 12;
	        _y = _icoRect.y - _tipRect.h - (IMBrowser.msie56 ? 0: _winRect.y);
	    }
	    if( _param.wait<=0 ){
	    	this.Element.style.backgroundImage = "url("+Ntalker.cache.image_dir+"/imNt_tips_l.gif)";
	    	_x += 0;
	    	_y -= 10;
	    }
	}else{
		var _y = 0 - _tipRect.h;
		if( Ntalker.Config.customparams["floatpos"]=="right" ){
			var _x = _icoRect.x + _icoRect.w/2 + 12;
			if(_x+_tipRect.w>_winRect.x+_winRect.w){
				var _x = 0 - _tipRect.w + _icoRect.w/2 + 8;
				this.Element.style.backgroundImage = "url("+Ntalker.cache.image_dir+"/imNt_tips_r.gif)";
			}else{
				this.Element.style.backgroundImage = "url("+Ntalker.cache.image_dir+"/imNt_tips_l.gif)";
			}
		}else{
			var _x = _icoRect.w/2 - 12;
			this.Element.style.backgroundImage = "url("+Ntalker.cache.image_dir+"/imNt_tips_l.gif)";
		}
	}
    this.Element.style.top  = _y + "px";
    this.Element.style.left = _x + "px";
	IMAnimate.animate(IMTipManager._curTip.Element,"opacity", {start:0,end:100,step:_param.step}, function(){
		_this.isshow = true;
        if(_param.wait>0)
        	IMAnimate.timer(function(){IMTipManager.getIMTip(_key).close();}, _param.wait);
        else
        	IMAnimate.timer(function(){
        	var _curTip = IMTipManager.getIMTip(_key);if(_curTip)_curTip.next(_key, _param.nextwait);}, _param.nextwait);
    });
};
_p.show = function(){
	if(this.isshow) return;
	var _param    = this.param, _key   = this.key, _this = this;
	IMAnimate.animate(IMTipManager._curTip.Element,"opacity", {start:0,end:100,step:_param.step}, function(){
        if(_param.wait>0)
        	IMAnimate.timer(function(){IMTipManager.getIMTip(_key).close();}, _param.wait);
        else
        	IMAnimate.timer(function(){
	        	var _curTip = IMTipManager.getIMTip(_key);
	        	if(_curTip)
	        		_curTip.next(_key, _param.nextwait);
        	}, _param.nextwait);
    });
};
_p.add = function(msg, room){
	var _message = im_wdkUtil.isArray(msg) ? msg : [{msg:msg,user:""}];
	room = room ? room : {roomid:0,roomname:'',roomtype:0,usercount:0};
	if(this.message.length>3) return;
	try{
		room.roomtype = room.roomtype?room.roomtype:0;
		this.message.push({msg:_message[0].msg,user:_message[0].user,roomid:room.roomid,roomname:room.roomname,roomtype:room.roomtype,usercount:room.usercount});
	}catch(e){}
}
_p.close = function(){
	var _param = this.param, _key   = this.key;
	var _curTip = IMTipManager.getIMTip(_key);
	if(!_curTip) return;
	this.curNum = 0;
	this.isshow = false;
    IMAnimate.animate(_curTip.Element,"opacity", {start:100,end:0,step:(0-_param.step)}, function(){    	if(_curTip){    		_curTip.Element.style.display = "none";
    	}
    });
}
_p.next = function(key, wait){
	if(!this.Element) return;
	this.curNum++;
	if( this.curNum >= this.message.length ){
		this.curNum = 0;
		IMTipManager.getIMTip(key).close();
		return;
	}
	this.Element.innerHTML = this.toolbarTip(this.curNum);
	IMAnimate.timer(function(){var _curTip = IMTipManager.getIMTip(key);if(_curTip)_curTip.next(key, wait);}, wait);
}
_p.getTip = function(){
    var _img = Ntalker.variable.scriptPath;
    var _message = this.message[0].user + " " + this.message[0].msg;
    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;text-align:center;">' + _message + '</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(k){
	var tipTitle   = im_wdkUtil.cutText(this.message[k].roomname,7, false)+' - '+im_wdkUtil.cutText(this.message[k].user, 5, false);
	var tipContent = im_wdkUtil.cutText(im_wdkUtil.clearHTML(this.message[k].msg), 11, true);
	var _TipHTML   = '<span style="display:block;margin:8px 0 0 25px;color:#016722;">'+tipTitle+'</span>'
				   + '<div id="imNt_tooltip_con" style="display:block;margin:0 0 0 25px;">' + tipContent + '</div>';
    var _msg = this.message[k];
    var _key = this.key;
    this.Element.onclick = function(ev){
    	var event = new im_wdkUtil.EventMechanism(ev); event.stopPropagation();
    	IMTipManager.getIMTip(_key).close();
    	if(IMToolBar)
    		IMToolBar.viewGroupMsg(null, null, _msg.roomid, _msg.roomname, _msg.roomtype);
    	else{
    		im_openWebchatWindow(_msg.roomid, _msg.roomname, null, 1, 'group', _msg.roomtype);
    	}
    };
    return(_TipHTML ? _TipHTML : null);
}
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);
    },
    checkonline: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;
    },
    clearonline:function(type){
        type = type ? type : "online";        for(var k in this._notifyWnds._hash){
            if(this.get(k).type==type) this.remove(k);
        }
    },
    add: function(destuid, destname, message, chatid, headURL, type, BtnType, sendMsg){
        if(this.checkonline(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+"', 1);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+"\" onerror=\"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+"', 1);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+"\" onerror=\"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 && Ntalker.Config.customparams["playsound"])
                im_wdkUtil.$('impresenceflash').playNotifySound();            this.animate(_curElement);
        },
        animate:function(el){
        	if(im_myIMWindow){        		if(im_myIMWindow.isShow) return;
        	}
            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(isMyFriend!=2 && _cfg.customparams["ignoreChatInvite"])
    	return;
    if(!Ntalker.Config.showToolBar)  
    	return;
    if(Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==0)
        return;
    if(isNotify){        if(IMToolBar) IMToolBar.addMsg(destuid, destnick, "请求会话", chatid, logoUrl, message, "request");
    }else{
    	try{
    		var _autoFocus = im_chat_window_manager._chatWndsArray.length>0 ? false : true;
    	}catch(e){}
        if(isOnlineMsg){
            if(_var.onlineChat>=0){                im_chat_window_manager.addChatWindow(destuid, destnick, chatid, _autoFocus, 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, _autoFocus, 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){
    if(!Ntalker.Config.showToolBar)  return;
    var customparams = Ntalker.Config.customparams;
    if(!customparams["enablegroup"] && !customparams["enableroom"]) return;
    if(!groupId || groupId=="") return;
    if(IMToolBar) IMToolBar.addGroupMsg(groupId, groupName, srcuid, srcnick, msg);
}
function fIM_onPresenceReceiveAddFriend(destuid, destnick, logoUrl, bconfirm){
    if(Ntalker.Config.isPopupMode && !Ntalker.Config.isPopupWindow)
        return;
    if(!Ntalker.Config.showToolBar)  
    	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(!Ntalker.Config.showToolBar)  
    	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;
    if(!Ntalker.Config.showToolBar)  
    	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, true);
        }
        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, true);
        }
    }
    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, true);
    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._FlashReloadCount = 0;
    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);
    var _scroll = im_wdkUtil.scroll();
    var _r    = IMBrowser.msie ? (IMBrowser.msie56 ? 2 : 1) : (_scroll ? 18 : 1);
    if(!IMBrowser.oldModel && _entrytype=="toolbar"){
        return;
    }
    if(ev&&ev.type == "resize"){
        if(!this._self) return;
        if(_entrytype=='toolbar'){
            var _tabRect = im_wdkUtil.viewRect.get(Ntalker.variable.buddylistTag);
            if(this.m_align=="left"){
                this._left = rect.x + rect.w - this._width - _tabRect.x - _r;
            }else{
                this._left = rect.x + rect.w - this._width - _tabRect.x - _r;
            }
            var left = this._left;
            var top  = this._top;
        }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 = 0-this._height + (IMBrowser.oldModel ? 4 : 0);
            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 _var = Ntalker.variable    var rect = im_wdkUtil.viewRect.get(window);
    var _entrytype = _cfg.entrytype;
    var _scroll = im_wdkUtil.scroll();
    var _r    = IMBrowser.msie ? (IMBrowser.msie56 ? 2 : 1) : (_scroll ? 18 : 1);
    this.created = true;
    if( _entrytype=="toolbar" ){
        IMcssTag.css(_var.buddylistTag, "display", "block");
        var _TabRect   = im_wdkUtil.viewRect.get(_var.buddylistTag);
        this._baseLeft = _TabRect.x;
        this._baseTop  = _TabRect.y;
        this._self = im_wdkUtil.createDom({name:"DIV", id:"buddylist_tag_con"}, _var.buddylistTag);
        this._self.style.position = "absolute";
        if(this.m_align=="left"){            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    = 0 - this._height + (IMBrowser.oldModel ? 4 : 0);
            this._bottom = IMBrowser.oldModel ? -4 : (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.y + rect.h - this._height - 28);
        this._bottom = 28;
        this._self.style.left   = this._left + "px";
        this._self.style.bottom = this._bottom + "px";
    }
    IMcssTag.css(_var.buddylistTag, "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 - this.titleHeight - 2*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;cursor:move;'>");
    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:"+ch+"px; background: #CBECC1 url("+Ntalker.cache.image_dir+"/installbg.gif) repeat-x; color:"+_cfg.fColor+";font-size:12px;line-height:"+ch+"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, cust;
    cust = Ntalker.Config.customparams;
    swfSrc = this.m_jsURLPath+"/fs/ContactMod.swf?version="+Ntalker.version.buddylist_flash;
    var flashvars = {v : Ntalker.version.buddylist_flash,
    				 r : this.m_jsURLPath,
    				 k : Ntalker.cache.skin,
    				 t : encodeURIComponent(Ntalker.variable.siteid),
                     s : encodeURIComponent(Ntalker.variable.user_sid),
                     u : encodeURIComponent(Ntalker.variable.user_id), 
                     n : encodeURIComponent(Ntalker.variable.user_name),
                     l : Ntalker.Config.buddylistlogo ? Ntalker.Config.buddylistlogo : 0,
                     i : tagIndex,
                     g : (cust.enablegroup ? "1" : "0")+(cust.enableroom?"1":"0"),
                     w : Ntalker.Config.isPopupWindow,
                     b : typeof cust.introbuddy=='undefined' || cust.introbuddy ? 1 : 0,
                     o : typeof cust.onlinelist=='undefined' || cust.onlinelist ? 1 : 0,
                     h : typeof cust.head=='undefined' || cust.head ? 1 : 0,
                     ad: typeof cust.ad=='undefined' || !cust.ad ? 0 : 1,
                     se: typeof cust.search=='undefined' || cust.search ? 1 : 0,
                     il: typeof cust.imagelist=='undefined' || cust.imagelist ? 1 : 0,
                     ps: 6,
                     sp: typeof cust.simple=='undefined' || !cust.simple ? 0 : 1
                     };
    if(Ntalker.variable.userparam)
        flashvars.p = encodeURIComponent(Ntalker.variable.userparam);
    if(Ntalker.Config.buddylistlogo && Ntalker.Config.copyrighturl)
        flashvars.f = Ntalker.Config.copyrighturl.toLowerCase().replace("http://","");
    else
        flashvars.f = encodeURIComponent(window.location.host);    if(flashvars.toJSONString)
        delete flashvars.toJSONString;
    var flashWidth = this._width - 2*this.borderWidth;
    var flashmode = "Window";
    var params = {menu:"true", "salign":"LT", "allowScriptAccess":"always", "wmode":flashmode, "allowFullScreen": true};
    var attributes = {};
    swfobject.embedSWF(swfSrc, this._flashID, flashWidth, this._height, "9.1.115", Ntalker.variable.scriptPath+"/fs/expressInstall.swf", flashvars, params, attributes);
    this._flash = im_wdkUtil.$(this._flashID);
    this.setFlashStyle();
    var _this = this;
    if(this._flash && !im_installFlashActionX){
        var __checkFlashLoad =function(){ _this.checkFlashLoad();};
        this._checkFlashTimerid = window.setTimeout(__checkFlashLoad, this._flashLoadTime);
        this._flashLoadTime = this._flashLoadTime*2; 
    }
};
_p.setFlashStyle = function(){  
    var fw = Math.max(this._width - 2 * this.borderWidth, 0);
    var fh = Math.max(this._height - 2 * this.borderWidth - this.titleHeight, 0);
    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.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();}		if(this._FlashReloadCount>=2){
	        this._waitFlashAutoLoadTimeid = window.setTimeout( __reloadFlash , this._waitFlashAutoLoad);
	        this._waitFlashAutoLoad = this._waitFlashAutoLoad;
	    }
        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(Ntalker.variable.buddylistTag)
        Ntalker.variable.buddylistTag.style.display = "none";
    this.isShow = false;
    var siteid = Ntalker.variable.siteid;
    var uid    = Ntalker.variable.user_id;
    var destid = 0;
    var groupid= 0;
    var type   = 7;
    var desc   = "关闭好友列表";
    var mode   = 0;
    var source = 0;
    var action = "";
    im_wdkUtil.createScript(Ntalker.variable.scriptPath + "/func/statistic.php?siteid="+siteid+"&uid="+uid+"&destid="+destid+"&groupid="+groupid+"&type="+type+"&mode="+mode+"&source="+source+"&desc="+encodeURIComponent(desc)+"&rnd="+new Date().getTime(),"utf-8");
};
_p.showWindow = function(isPopup){
    var _var = Ntalker.variable;
    if(_var.user_id==0 || !_var.user_id){
        alert("您还没有登录，请先登录！");return;
    }
    if(IMToolBar._disable || this.isShow){
        return;
    }
    if(IMToolBar._ExpandMode==0){    	IMToolBar.onNatural();
    }    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){
    }
    if(this.minDiv){
        this.minDiv.style.visibility = "hidden";
        var tipEl = im_wdkUtil.$('imiTwdk_mini_state_img');
        if( tipEl )
            tipEl.visibility = "hidden";
    }
    this.isShow = true;
    if(NotifyManager) NotifyManager.clearonline("online");
    var siteid = Ntalker.variable.siteid;
    var uid    = Ntalker.variable.user_id;
    var destid = 0;
    var groupid= 0;
    var type   = 6;
    var desc   = "打开好友列表";
    var mode   = 1;
    var source = 1;
    var action = "";
    im_wdkUtil.createScript(Ntalker.variable.scriptPath + "/func/statistic.php?siteid="+siteid+"&uid="+uid+"&destid="+destid+"&groupid="+groupid+"&type="+type+"&mode="+mode+"&source="+source+"&desc="+encodeURIComponent(desc)+"&rnd="+new Date().getTime(),"utf-8");
};
_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, switchTab){
    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(switchTab && this.isShow){
        IM_BuddyListDOM = im_wdkUtil.$("wdk_buddylist_flash");
        if(IM_BuddyListDOM && IM_BuddyListDOM.switchTabIndex)
            IM_BuddyListDOM.switchTabIndex(Ntalker.Config.IMtabIndex);
    }else{
        this.showWindow(Ntalker.Config.isPopupMode);
    }
}
WDK_IM_PACK.WDKChatWindow = function(destuid, destnick, chatid, layoutmode, chatType, roomtype){
    WDK_IM_PACK.FloatWindow.prototype.constructor();
    this._destuid = destuid;
    this._destnick = destnick;
    this._chatType   = chatType==""?"chat":chatType;
    this._roomType   = roomtype ? 1 : 0;
    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  = (this._chatType=="group" ? Ntalker.Config.groupWidth : (this._chatType=="chat"?Ntalker.Config.chatWidth:Ntalker.Config.hotWidth));
    this._height = (this._chatType=="group" ? Ntalker.Config.groupHeight : (this._chatType=="chat"?Ntalker.Config.chatHeight:Ntalker.Config.hotHeight));
    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._FlashReloadCount = 0;
    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;
        if(IMToolBar && IMToolBar._ExpandMode==0){
        	if(this._align=="right")
        		this._left   = IMToolBar.minChatWidth*IMToolBar.minWinCount - this._width + this._borderWidth;
        	else
        		this._left   = _winRect.w - this._width - offsetRight;
        }else{
        	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 = offsetBottom;
        this._top    = _winRect.y + _winRect.h - this._height - offsetBottom;
        this._self.style.left = this._left + "px";
        this._self.style.top  = this._top + "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;cursor:auto;'>");
    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 + "'><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);};
    function __clearClick(e){var event = new im_wdkUtil.EventMechanism(e); event.stopPropagation();};
    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._self.onclick = __clearClick;
    this.resize(this._width, this._height);
    wdkApplication._FloatWindowManager.addWindow(this); 
};
_p.moveTo = function(x, y, isSavePos){
    var rect = im_wdkUtil.viewRect.get(window);
    if(isSavePos){
        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 _wRt = im_wdkUtil.viewRect.get(window)
    if(ev && ev.type == "resize"){
        if(!this._self) return;
        var _mRt = IMToolBar.getMiniWindow(this._destuid, this._chatType).getPost();
        var x = _mRt.x;
        var y = _wRt.y + _wRt.h-this._height-this._bottom;
        if(this._entrytype=='toolbar'){
            if(this._curWindMode!='hide'){
                y = IMBrowser.oldModel ? y : this._top;
                y = _wRt.h-28+y<0 ? 0-_wRt.h+28 : y;
                if(IMToolBar._ExpandMode>0){
	                if(this._align=="left"){
	                	var _scroll   = im_wdkUtil.scroll();
        				var _r        = IMBrowser.msie ? 1 : (_scroll ? 18 : 1);
	                    x = x<_wRt.x+Ntalker.Config.IMWidth+10 ? _wRt.x+Ntalker.Config.IMWidth+10 : (x+this._width>_wRt.x+_wRt.w-_r ? _wRt.x+_wRt.w-this._width-_r : x);
	                }else{
	                    x = x<_wRt.x ? _wRt.x+10 : (x+this._width > _wRt.x+_wRt.w-Ntalker.Config.IMWidth-10 ? _wRt.x+_wRt.w-Ntalker.Config.IMWidth-10-this._width : x );
	                }
	            }else{
            		x = _mRt.rx-this._width;
            		var _aRt = im_wdkUtil.viewRect.get("windows_area");
		        	x = x+_aRt.x<_wRt.x ? _wRt.x-_aRt.x : x;
	            }
            }else{
                x = -2000;
            }
        }else{
            x = x>=_wRt.x ? x : _wRt.x;
            y = y>=_wRt.y ? y : _wRt.y;
        }        this.moveTo(x, y);
    }
    else if(this._self){
        if(this._entrytype=='toolbar' && !IMBrowser.oldModel)
            return;
        var rect = im_wdkUtil.viewRect.get(window)
        var x = _wRt.x + this._left;
        var y = _wRt.y + this._top;
        if(this._entrytype=='toolbar'){
            y = y+this._height>_wRt.y+_wRt.h ? _wRt.y+_wRt.h-this._height-28 : 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 _wRt = im_wdkUtil.viewRect.get(window);            this.moveTo(_wRt.x + offsetLeft, _wRt.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);        }
        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);
        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 _scroll   = im_wdkUtil.scroll();
        var _r        = IMBrowser.msie ? 1 : (_scroll ? 18 : 1);
        var _wRt = im_wdkUtil.viewRect.get(window);
        var x = this._left,y = this._top;
        if(IMToolBar){
            var _mRt = IMToolBar.getMiniWindow(this._destuid, this._chatType).onFocus();
            x = _mRt.x;
            if(IMBrowser.oldModel){
            	y = _mRt.y-this._height + 5;
            }else{
            	y = 0-this._height;
            }
            if(IMToolBar._ExpandMode>0){
	            if(this._align=="left"){
		            x = x<_wRt.x+Ntalker.Config.IMWidth+5 ? _wRt.x+Ntalker.Config.IMWidth+5 : (x+this._width>_wRt.x+_wRt.w-_r ? _wRt.x+_wRt.w-this._width-_r : x);
		        }else{
		            x = x<_wRt.x ? _wRt.x : (x+this._width > _wRt.x+_wRt.w-Ntalker.Config.IMWidth-_r ? _wRt.x+_wRt.w-Ntalker.Config.IMWidth-_r-this._width : x);
		        }
            }else{
            	var _aRt = im_wdkUtil.viewRect.get("windows_area");
	            if(this._align=="left"){
		            x = _mRt.x>_wRt.x+_wRt.w-this._width-_r ? _wRt.x+_wRt.w-this._width-_r : _mRt.x;
		        }else{
		        	x = 0 - this._width + _mRt.rx;
		        	x = x+_aRt.x<_wRt.x ? _wRt.x-_aRt.x : 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(){	wdkApplication._FloatWindowManager.removeWindow(this);
    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);
    }
    var siteid = Ntalker.variable.siteid;
    var uid    = Ntalker.variable.user_id;
    var destid = /bbshot|group/.test(this._chatType) ? 0 : this._destuid;
    var groupid= /bbshot|group/.test(this._chatType) ? this._destuid : 0;
    var type;  switch(this._chatType){case "bbshot":type=5;break;case "group":type=3;break;default:type=1;};
    var desc;  switch(this._chatType){case "bbshot":desc="关闭坛热点";break;case "group":desc="关闭群聊窗";break;default:desc="关闭一对一聊窗";};
    var mode   = 0;
    var source = 0;
    var action = "";
    im_wdkUtil.createScript(Ntalker.variable.scriptPath + "/func/statistic.php?siteid="+siteid+"&uid="+uid+"&destid="+destid+"&groupid="+groupid+"&type="+type+"&mode="+mode+"&source="+source+"&desc="+encodeURIComponent(desc)+"&rnd="+new Date().getTime(),"utf-8");
};
_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,c;
    c = Ntalker.Config;
    cust = c.customparams;
    flashvars = { v : Ntalker.version.webchat_flash,
                  r : this._jsURLPath,   
                  k : Ntalker.cache.skin,
                  t : encodeURIComponent(Ntalker.variable.siteid),
                  s : encodeURIComponent(Ntalker.variable.user_sid),
                  u : encodeURIComponent(Ntalker.variable.user_id),
                  n : encodeURIComponent(Ntalker.variable.user_name),
                  d : encodeURIComponent(this._destuid),
                  dn: encodeURIComponent(this._destnick),
                  l : c.chatlogo || "", 
                  sp: typeof cust.simple=='undefined' || !cust.simple ? 0 : 1,
                  w : c.isPopupWindow,
                  m : 0,
                  av: typeof cust.avroom == 'undefined' || !cust.avroom ? 0 : 1,
                  rt: this._roomType ? 1 : 0, 
                  ad: typeof cust.ad == 'undefined' || !cust.ad ? 0 : 1
                 };
	switch(this._chatType){
		case "chat":
			swfSrc = this._jsURLPath+"/fs/ChatMod.swf?version="+Ntalker.version.webchat_flash;
			flashvars.v  = Ntalker.version.webchat_flash;
			break;
		case "bbshot":
			swfSrc = this._jsURLPath+"/fs/NtalkerHotActivity.swf?version="+Ntalker.version.hot_flash;
			flashvars.v  = Ntalker.version.hot_flash;
			break;
		case "group":
			swfSrc = this._jsURLPath+"/fs/GroupMod.swf?version="+Ntalker.version.group_flash;
			flashvars.v  = Ntalker.version.group_flash;
			break;
	}
	switch(Ntalker.variable.user_name){
		case "china007":  flashvars.checkcode = '114a80bbeac8183efaf63912a7b15a4f';
		case "common":    flashvars.checkcode = '52dd020e9947b5e60d6db6a346bea503';
		case "dpsing":    flashvars.checkcode = '7cf49c376df8cf71190447a7694079a2';
		case "yangfeng":  flashvars.checkcode = '6bc5964847e6cccc1f511ea5ac6804ca';
	}
    if(Ntalker.variable.userparam)
        flashvars.p = encodeURIComponent(Ntalker.variable.userparam);
    if(Ntalker.Config.chatlogo && Ntalker.Config.copyrighturl)
        flashvars.f = Ntalker.Config.copyrighturl.toLowerCase().replace("http://","");
    else
        flashvars.f = encodeURIComponent(window.location.host);
    if(this._chatid)  flashvars.c    = this._chatid;    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, "allowFullScreen": true};
    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+"/fs/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;
    }}
_p.setFlashStyle = function(){
	this._flashcontainer.style.position = "absolute";
    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:60px;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);
		this._FlashReloadCount++;
        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();}		if(this._FlashReloadCount>=2){
	        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;
    try{
    	this._flash.focus();
    }catch(e){}
    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 && Ntalker.Config.customparams["playsound"]){
            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  = 0;
    this._windowHeight = 0;
    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, OpenType, chatType, roomtype){
    chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");
	this._windowWidth  = (chatType=="group" ? Ntalker.Config.groupWidth : (chatType=="chat"?Ntalker.Config.chatWidth:Ntalker.Config.hotWidth));
    this._windowHeight = (chatType=="group" ? Ntalker.Config.groupHeight : (chatType=="chat"?Ntalker.Config.chatHeight:Ntalker.Config.hotHeight));    var chatWindow = this.getChatWindow(destuid, chatType);
    if(chatWindow){        this.OnTBFocusWindow(destuid, chatType);
        chatWindow.onPresenceReceiveChatMsg(message);
        return;
    }else{
    	this.OnTBFocusWindow(0);
    }
    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 = !OpenType&&chatWndCount ? false : isAutoFocus;
    if(Ntalker.Config.isPopupWindow==1 && !(OpenType===1) ){
        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, roomtype);
    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 _mRt = 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];
        bottomOffset = 0;
        if(IMBrowser.oldModel){
            rightOffset  = rect.x + rect.w - _mRt.x - this._windowWidth;
            if(this._align=="right"){
                rightOffset = rightOffset<Ntalker.Config.IMWidth+_r ? Ntalker.Config.IMWidth+_r : rightOffset;
            }
            newChatWindow.showWindow(rightOffset, bottomOffset+28 );
        }else{
        	rightOffset = rect.x + rect.w - _mRt.x - this._windowWidth;
            if(this._align=="right"){
                rightOffset = rightOffset<Ntalker.Config.IMWidth+_r ? Ntalker.Config.IMWidth+_r : rightOffset;
            }else{
            	if(IMToolBar._ExpandMode!=0){
                	rightOffset = rightOffset>rect.w-Ntalker.Config.IMWidth-this._windowWidth ? rect.w-Ntalker.Config.IMWidth-this._windowWidth : (rightOffset<_r ? _r : rightOffset);
                }
            }
            newChatWindow.showWindow(rightOffset, bottomOffset, miniWinDOM_Tab);
        }
        if(!isAutoFocus && Ntalker.variable.OnBlurWinParam.length>0){
            newChatWindow.MinMax();
            var _destuid = Ntalker.variable.OnBlurWinParam[0];
            var _chatType= Ntalker.variable.OnBlurWinParam[1];
            this.OnTBFocusWindow(_destuid, _chatType);
        }
    }
    this._chatWnds.add(destuid+chatType, newChatWindow);
    this._chatWndsArray.push(newChatWindow);
    this._curChatWindow = newChatWindow;
    var siteid = Ntalker.variable.siteid;
    var uid    = Ntalker.variable.user_id;
    var destid = /bbshot|group/.test(chatType) ? 0 : destuid;
    var groupid= /bbshot|group/.test(chatType) ? destuid : 0;
    var type; switch(chatType){case "bbshot":type=4;break;case "group":type=2;break;default:type=0;}
    var oT;   switch(OpenType){case 1:oT="(主)";break;case -1:oT="(携)";break;default:oT="(被)";}
    var desc; switch(chatType){case "bbshot":desc="坛热点"+oT;break;case "group":desc="群聊窗"+oT;break;default:desc="一对一聊窗"+oT;}
    var mode; switch(OpenType){case 1:mode=1;break;case -1:mode=3;break;default:mode=2;};
    var source = 0;
    var action = "";
    im_wdkUtil.createScript(Ntalker.variable.scriptPath + "/func/statistic.php?siteid="+siteid+"&uid="+uid+"&destid="+destid+"&groupid="+groupid+"&type="+type+"&mode="+mode+"&source="+source+"&desc="+encodeURIComponent(desc)+"&rnd="+new Date().getTime(),"utf-8");
}
_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].MinMax();
            this._chatWndsArray[i].onFocus();
        }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,roomtype){
    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, roomtype);
    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;
    this.minChatWidth= 115;
};
_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);
    switch(this._chatType)
    {
    	case "chat":
    		var imgsrc = Ntalker.variable.scriptPath+"/images/chat.png";
    		break;
    	case "group":
    		var imgsrc = Ntalker.variable.scriptPath+"/images/group.png";
    		break;
    	case "bbshot":
    		var imgsrc = Ntalker.variable.scriptPath+"/images/hot."+(IMBrowser.msie56?"gif":"png");
    		break;
    }
    var icoNode   = im_wdkUtil.createDom({name:"div",className:"ico"}, this.Element);
    var imageNode = im_wdkUtil.createDom({name:"img",className:"userHead",src:imgsrc}, icoNode);
    var textSpan  = im_wdkUtil.createDom({name:"span",className:""}, this.Element);
    var textNode  = im_wdkUtil.createDom({name:"Text",text:this.originTitle}, textSpan);
    var closeNode = im_wdkUtil.createDom({name:"div",className:"", style:"line-height:0px;position:relative;width:15px;height:24px;display:block;left:96px;top:-23px;",onmouseover:"this.className='ntalker_opacity50';",onmouseout:"this.className='';"}, this.Element)
    var windowNode= 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 __imageError     = function(ev){imageNode.src=imgsrc;}
    var __clickMinWindow = function(ev){_this.onClick(ev);};
    var __overMinWindow  = function(ev){
    	current = ev.currentTarget || window.event.srcElement;
    	if( current.className.indexOf("win")==-1 ) current = current.parentNode;
    	if( current.className.indexOf("win")!=-1 ) IMcssTag.addClass(current, "hover");
    };
    var __outMinWindow   = function(ev){
    	current = ev.currentTarget || window.event.srcElement;
    	if( current.className.indexOf("win")==-1 ) current = current.parentNode;
    	if( current.className.indexOf("win")!=-1 ) IMcssTag.removeClass(current, "hover", "");
    };
    var __closeMinWindow = function(ev){
    	var event = new im_wdkUtil.EventMechanism(ev); event.stopPropagation();    	var aRt = im_wdkUtil.viewRect.get('windows_area');
    	var show_areaWidth = aRt.w;
    	var scrollLeft     = im_wdkUtil.$('windows_area').scrollLeft;
    	var preCountWind   = 1;
    	if(IMToolBar){
	    	for(var k in IMToolBar.minWindows._hash){
		        if(IMToolBar.minWindows._hash[k]._destuid == _this._destuid && IMToolBar.minWindows._hash[k]._chatType == _this._chatType)
		            break;
		        else
		        	preCountWind++;
		    }
	    }
    	var cur_allWidth   = _this.minChatWidth*preCountWind;    	if( show_areaWidth > (cur_allWidth - scrollLeft))
    		fIM_CloseChatWindow(_this._destuid, _this._chatType);
    };
    im_wdkUtil.Event.addEvent(imageNode,    "error",     __imageError);
    im_wdkUtil.Event.addEvent(this.Element, "click",     __clickMinWindow);
   	im_wdkUtil.Event.addEvent(this.Element, "mouseover", __overMinWindow);
   	im_wdkUtil.Event.addEvent(this.Element, "mouseout",  __outMinWindow);
   	if(IMBrowser.msie56){
	   	im_wdkUtil.Event.addEvent(icoNode,      "mouseover", __overMinWindow);
	   	im_wdkUtil.Event.addEvent(icoNode,      "mouseout",  __outMinWindow);
	   	im_wdkUtil.Event.addEvent(textSpan,     "mouseover", __overMinWindow);
	   	im_wdkUtil.Event.addEvent(textSpan,     "mouseout",  __outMinWindow);
	   	im_wdkUtil.Event.addEvent(closeNode,    "mouseover", __overMinWindow);
	   	im_wdkUtil.Event.addEvent(closeNode,    "mouseout",  __outMinWindow);
   	}
    im_wdkUtil.Event.addEvent(closeNode,    "click",     __closeMinWindow);
    return this.Element;
}
_p.updateUserHead = function(strheadURL, intStatus){
    var _img = im_wdkUtil.$$(".userHead", this.Element)[0];
    _img.src = strheadURL;
    var _width,_height;
    _img.onload = function(){
    	if(this.width>this.height){
    		_width = 18;
    		_height= 18/this.width*this.height;
    	}else{
    		_height= 18;
    		_width = 18/this.height*this.width;
    	}
    	this.width  = _width;
    	this.height = _height;
    };
    return;
}
_p.getPost = function(){
	var AreaElemt  = im_wdkUtil.$('windows_area');
	var scrollLeft = AreaElemt ? AreaElemt.scrollLeft : 0;
    var mRt = im_wdkUtil.viewRect.get(this.Element);
    var aRt = im_wdkUtil.viewRect.get('windows_area');
    var _x  = mRt.x-(IMBrowser.msie56 ? 2 : 0) - scrollLeft;
    var _rx = mRt.x+mRt.w-aRt.x+(IMBrowser.msie56 ? 2 : 0) - scrollLeft;
    return {x:_x, y:mRt.y, w:mRt.w, h:mRt.h,rx:_rx};
}
_p.onClick = function(ev, target){
	if(!target){
    	target = im_wdkUtil.eventTag(ev,"li");
    }
    if(!target) return;
    this.onFocus();    im_chat_window_manager.OnTBFocusWindow(this._destuid, this._chatType);
}
_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];
    return this.getPost();
}
_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( IMToolBar._ExpandMode == 2){    }
    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 = {
	tbClosed  : false,
    Element   : null,
    minWindows: new IMHashtable(),
    minWinCount: 0,
    _tbWidth:[],
    _ExpandMode:2,
    arrMsg  : [],
    arrGroupMsg:[],
    groupCountNum:[],
    cfg       : [],
    _align    : "right",    _timer    : [],
    _flashNum : [],
    _stopFlash: [],
    _waitTimeOut: [],
    _statusValue:0,
    _viewRect : null,
    overMenu  : false,
    showMenu  : false,
    minChatWidth: 115,
    customButtonNum: 0
};
IMToolBar.init = function(){
	if(!Ntalker.Config.showToolBar)  
		return;
    this._align   = Ntalker.Config.customparams["floatpos"];
    if(im_wdkUtil.GetCookie(Ntalker.tbModelKEY)==null)
    	var _initMode = Ntalker.Config.customparams["intact"] ? 2 : 1;
    else
    	var _initMode = im_wdkUtil.GetCookie(Ntalker.tbModelKEY);    this.cfg["ico_state"]     = ["用户状态"];
    if(Ntalker.Config.customparams['enablegroup']||Ntalker.Config.customparams['enableroom'])
        this.cfg["ico_group"] = ["群消息"];
    this.cfg["ico_buddylist"] = ["打开好友列表"];
    this.cfg["ico_msg"]       = ["系统消息"];
    this.cfg["ico_zoom"]      = ["收起工具条"];
    this.cfg["ico_close"]     = ["关闭工具条"];
    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:""}, null, "afterbegin");
    this.Element = im_wdkUtil.$("NtalkerToolbar");
    this.Element.innerHTML = this.toolbarHtml();
    if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
    	this._tbWidth = [[30,55], (IMBrowser.msie56 ? 62 : 60), 0];
    	Ntalker.variable.buddylistTag = im_wdkUtil.$("group_tab");
    }else{
		this._tbWidth = [[30,55], (IMBrowser.msie56 ? 202 : 200), 0];
		Ntalker.variable.buddylistTag = im_wdkUtil.$("buddylist_tab");
	}
    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.customparams['enablegroup']||Ntalker.Config.customparams['enableroom'])curBtnWidth += 62;
    IMToolBar._tbWidth[1] += curBtnWidth;
    for(var k in this.cfg){
        if(typeof(this.cfg[k])!="object") continue;
        if(!Ntalker.Config.customparams['enablegroup'] && !Ntalker.Config.customparams['enableroom'] && k=="ico_group") continue;
        var btnLI  = im_wdkUtil.$(k);
        var btnDIV = im_wdkUtil.$$(" div", btnLI)[0];
        if(!btnDIV) btnDIV = im_wdkUtil.$(k);
        if(btnDIV){
        	im_wdkUtil.Event.addEvent(btnDIV, "mouseover", IMToolBar.onOverEvent);
        	im_wdkUtil.Event.addEvent(btnDIV, "mouseout",  IMToolBar.onOverEvent);
        }
        if(/ico_group|ico_msg/.test(k) && btnDIV){
            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);
            if(btnLI) im_wdkUtil.Event.addEvent(btnLI, "mouseout", IMToolBar.onHiddenMsgMenu);
        }else if(/ico_buddylist/.test(k) && btnDIV){
            im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onShowBuddylist);
    	}else if(/ico_zoom/.test(k) && btnDIV){
            im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onMinimize);
        }else if(/ico_pre/.test(k) && btnDIV){
            im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onLeft);
        }else if(/ico_next/.test(k) && btnDIV){
            im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.onRight);
        }else if(/ico_close/.test(k) && btnLI){
            im_wdkUtil.Event.addEvent(btnDIV, "click", IMToolBar.close);
        }
    }
    IMToolBar._viewRect = im_wdkUtil.viewRect.get('windows_area');
    im_wdkUtil.Event.addEvent(window, "resize", IMToolBar.onResize);
    im_wdkUtil.Event.addEvent(window, "scroll", IMToolBar.onScroll);
    switch( parseInt(_initMode) ){
    	case 0:
    		this.onMinimize();
    		break;
    	case 1:
    		this.onNatural();
    		break;
    }
    if( (im_wdkUtil.GetCookie(Ntalker.tbClosedKEY)=="1" || (!Ntalker.Config.customparams['enablegroup'] && !Ntalker.Config.customparams['enableroom'] && !Ntalker.Config.customparams['enablehot'])) && Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
    	this.close();
    }    var _ckEl = im_wdkUtil.$('upPanel');
    if(_ckEl && IMcssTag.css(_ckEl,"overflowY")=="scroll") {
        IMcssTag.css(this.Element, "right", 17);
    }
    if(IMBrowser.msie56){
        if( document.body.currentStyle.backgroundImage=="none"||document.body.currentStyle.backgroundImage=="" ) {
            IMcssTag.css(Ntalker.DOC, "backgroundImage", "url(about:blank)");
            IMcssTag.css(Ntalker.DOC, "backgroundAttachment", "fixed");
        }
    }
};
IMToolBar.close = function(){
	IMcssTag.css(IMToolBar.Element, "visibility", "hidden");
	im_wdkUtil.SetCookie(Ntalker.tbClosedKEY, "1");
	var _presenceFlash = im_wdkUtil.$('impresenceflash');
	im_wdkUtil.disposeFlashObj(_presenceFlash);
	_presenceFlash.parentNode.removeChild(_presenceFlash);
	if(im_chat_window_manager) im_chat_window_manager.closeAll();
	IMToolBar.tbClosed = true;
};
IMToolBar.hidden = function(){    IMcssTag.css(IMToolBar.Element, "visibility", "hidden");
};
IMToolBar.visible = function(){    IMcssTag.css(IMToolBar.Element, "visibility", "visible");
};
IMToolBar._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._tbWidth[1] += 30;
};
IMToolBar.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];
    minWin = new minWindow(descuid, destname, headURL, isAutoFocus, chatType);
    minWin.init();
    this.minWindows.add("MiniTAG"+descuid+chatType, minWin);
    this.minWinCount = this.minWindows.count();
    var _winRect = im_wdkUtil.viewRect.get(window);
    var minToolbarWidth = this.minChatWidth * this.minWinCount + 30;
    if(this._ExpandMode!=0 || (this._ExpandMode==0 && minToolbarWidth>_winRect.w) )
    	this.onMaximize();
    else{
    	this._tbWidth[0][0] += this.minChatWidth;
    	this._tbWidth[0][1] += this.minChatWidth;
    	this.updateToolbar();
    }    this.initScroll();
    return minWin;
};
IMToolBar.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.minWinCount = this.minWindows.count();
    this.onRight();
    Ntalker.variable.OnFocusWinParam = [focusID, focusType];
    im_chat_window_manager.OnTBFocusWindow(focusID, focusType);
    this._tbWidth[0][0] -= this.minChatWidth;
    this._tbWidth[0][1] -= this.minChatWidth;
    if( this._ExpandMode!=0 && this.minWinCount == 0 )
    	this.onNatural();
    else
    	this.updateToolbar();
};
IMToolBar.getMiniWindow = function(descuid, chatType){
    chatType = chatType=="group"?"group":(chatType=="bbshot"?"bbshot":"chat");
    return this.minWindows.items("MiniTAG"+descuid + chatType);
};
IMToolBar.enableflash = function(key, className, FclassName, auto){
    var target = im_wdkUtil.$(key);
    if( (IMToolBar._stopFlash[key]==true || IMToolBar._flashNum[key]>=3)){
        IMcssTag.replaceClass(target, FclassName, className);
        IMToolBar._stopFlash[key] = false;
        IMToolBar._flashNum[key] = null;
        return;
    }
    if(IMToolBar._timer[key] == 500){
        IMToolBar._timer[key] = 1000;
        IMcssTag.replaceClass(target, className, FclassName);
    }else{
        IMToolBar._timer[key] = 500;
        IMcssTag.replaceClass(target, FclassName, className);
        if(!IMToolBar._flashNum[key])
            IMToolBar._flashNum[key] = 1;
        else
            IMToolBar._flashNum[key] += 1;
    }
    IMAnimate.timer(function(){IMToolBar.enableflash(key, className, FclassName, true);}, IMToolBar._timer[key]);
};
IMToolBar.disableFlash = function(key){
    IMToolBar._waitTimeOut[key] = null;
    IMToolBar._stopFlash[key]   = true;
};
IMToolBar.onMinimize = function(ev){
	var tbcloseWidth = 0;
	var _wRt = im_wdkUtil.viewRect.get(window);
	if(Ntalker.Config.isPopupWindow==1){
		IMToolBar.onMaximize();
		return;
	}
	if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
		tbcloseWidth = 30;
	}
	if(IMToolBar._ExpandMode == 0 || (IMToolBar.minWinCount*IMToolBar.minChatWidth+55+tbcloseWidth) > _wRt.w ) return;
	if(im_chat_window_manager){
		im_chat_window_manager.OnTBFocusWindow(0);
	}
    IMToolBar.cfg["ico_zoom"]      = ["展开工具条"];
    var TipSpanClass = IMToolBar._align=="right" ? ".TipRight" : ".TipLeft";
    if(im_wdkUtil.$('TOOLBARTIPico_zoom')) {im_wdkUtil.$$(TipSpanClass, 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._ExpandMode = 0;
    IMToolBar._tbWidth[0][0] = IMToolBar.minWinCount*IMToolBar.minChatWidth + 30;
    IMToolBar._tbWidth[0][1] = IMToolBar.minWinCount*IMToolBar.minChatWidth + 55;
    IMToolBar.updateToolbar();
    var target         = im_wdkUtil.$('ico_zoom');
    var btnZoom = im_wdkUtil.$$(".ico_button", target)[0];
    if(btnZoom){
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onMinimize);
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onNatural);
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onMaximize);
    	im_wdkUtil.Event.addEvent(btnZoom,    "click", IMToolBar.onNatural);
    }
    if(im_chat_window_manager){
    	var focusID   = Ntalker.variable.OnFocusWinParam[0];
    	var focusType = Ntalker.variable.OnFocusWinParam[1];
		im_chat_window_manager.OnTBFocusWindow(focusID, focusType);
	}
};
IMToolBar.onNatural = function(ev){
	if(Ntalker.Config.isPopupWindow==1 || IMToolBar.minWinCount>0){
		IMToolBar.onMaximize();
		return;
	}
	if(IMToolBar._ExpandMode == 1) return;
    IMToolBar._ExpandMode = 1;
   	IMToolBar.updateToolbar();
	IMToolBar.cfg["ico_zoom"]      = ["收起工具条"];
	var TipSpanClass = IMToolBar._align=="right" ? ".TipRight" : ".TipLeft";
	if(im_wdkUtil.$('TOOLBARTIPico_zoom')) { im_wdkUtil.$$(TipSpanClass, im_wdkUtil.$('TOOLBARTIPico_zoom'))[0].innerHTML = "<span>收起工具条</span>";}
	IMcssTag.css(im_wdkUtil.$("ico_pre"),        "display", "none");
    IMcssTag.css(im_wdkUtil.$("ico_next"),       "display", "none");
    var target = im_wdkUtil.$('ico_zoom');
    var btnZoom = im_wdkUtil.$$(".ico_button", target)[0];
    if(btnZoom){
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onMinimize);
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onNatural);
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onMaximize);
    	im_wdkUtil.Event.addEvent(btnZoom,    "click", IMToolBar.onMinimize);
    }};
IMToolBar.onMaximize = function(ev){
    var _winRect = im_wdkUtil.viewRect.get(window);
    IMToolBar.cfg["ico_zoom"]      = ["收起工具条"];
    var TipSpanClass = IMToolBar._align=="right" ? ".TipRight" : ".TipLeft";
    if(im_wdkUtil.$('TOOLBARTIPico_zoom')) { im_wdkUtil.$$(TipSpanClass, im_wdkUtil.$('TOOLBARTIPico_zoom'))[0].innerHTML = "<span>收起工具条</span>";}
    IMcssTag.css(im_wdkUtil.$("ico_pre"),        "display", "block");
    IMcssTag.css(im_wdkUtil.$("ico_next"),       "display", "block");
    if(im_chat_window_manager){
    	im_chat_window_manager.OnTBFocusWindow(0);
    }
  	IMToolBar._ExpandMode = 2;
   	IMToolBar.updateToolbar();
    var target = im_wdkUtil.$('ico_zoom');
    var btnZoom = im_wdkUtil.$$(".ico_button",target)[0];
    if(btnZoom){
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onMinimize);
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onNatural);
    	im_wdkUtil.Event.removeEvent(btnZoom, "click", IMToolBar.onMaximize);
    	im_wdkUtil.Event.addEvent(btnZoom,    "click", IMToolBar.onMinimize);
    }
    if(im_chat_window_manager){
    	var focusID   = Ntalker.variable.OnFocusWinParam[0];
    	var focusType = Ntalker.variable.OnFocusWinParam[1];
		im_chat_window_manager.OnTBFocusWindow(focusID, focusType);
	}
    IMToolBar._viewRect = im_wdkUtil.viewRect.get('windows_area');
};
IMToolBar.updateToolbar = function(){
    var tbcloseWidth=0,_wRt = im_wdkUtil.viewRect.get(window);
    var winArea  = im_wdkUtil.$("windows_area");    IMcssTag.css(winArea, "margin", "0px");
    if(IMToolBar._ExpandMode == 0){
    	if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
    		tbcloseWidth = 30;
    	}
    	if(IMToolBar.minWinCount==0){
    		IMcssTag.css(winArea, "visibility", "hidden");
    		if(IMBrowser.msie56 || IMBrowser.oldModel || IMBrowser.maxthon){
    			IMcssTag.css(winArea, "height", 1);
    			IMcssTag.css(winArea, "width", 1);
    			IMcssTag.css(im_wdkUtil.$('bodylist'), "width", 1);
    		}
    		im_wdkUtil.$("Ntalkerbody").style.borderLeft = "none";
    	}else{
    		IMcssTag.css(winArea, "visibility", "visible");
    		im_wdkUtil.$('windows_area').scrollLeft = 0;
    		if(IMBrowser.msie56 || IMBrowser.oldModel || IMBrowser.maxthon){
    			IMcssTag.css(winArea, "height", 28);
    			IMcssTag.css(winArea, "width", IMToolBar._tbWidth[0][1]-55-(IMBrowser.msie56?3:0));
    			IMcssTag.css(im_wdkUtil.$('bodylist'), "width", 2500);
    		}
    	}
    	var _sysMsgNum    = IMToolBar.arrMsg.length;
        if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' || _sysMsgNum==0 ){
        	IMcssTag.removeClass(im_wdkUtil.$("ico_zoom"),"ico_minZoom");
        	IMcssTag.replaceClass(im_wdkUtil.$("ico_zoom"),"ico_maxZoom", "ico_minZoom_null");
        	im_wdkUtil.$$(" div", im_wdkUtil.$("ico_zoom"))[0].innerHTML = "";
        	var _tbWidth = IMToolBar._tbWidth[0][0]+tbcloseWidth;
        }else{
        	IMcssTag.removeClass(im_wdkUtil.$("ico_zoom"),"ico_minZoom_null");
        	IMcssTag.replaceClass(im_wdkUtil.$("ico_zoom"),"ico_maxZoom", "ico_minZoom");
        	im_wdkUtil.$$(" div", im_wdkUtil.$("ico_zoom"))[0].innerHTML = "("+_sysMsgNum+")";
        	var _tbWidth = IMToolBar._tbWidth[0][1]+tbcloseWidth;
        }
        IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", _tbWidth);
        IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", _tbWidth);
        IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", _tbWidth);
        IMcssTag.css(im_wdkUtil.$('ico_buddylist'), "display", "none");
        IMcssTag.css(im_wdkUtil.$('ico_group'),     "display", "none");
        IMcssTag.css(im_wdkUtil.$('ico_msg'),       "display", "none");
        IMcssTag.css(im_wdkUtil.$('ico_bbshot'),    "display", "none");
        var usercustoms = im_wdkUtil.$$(".user_custom", im_wdkUtil.$("Ntalkerbody"));
        for(var i=0; i<usercustoms.length; i++){
        	IMcssTag.css(usercustoms[i], "display", "none");
        }
	    for(var k in IMToolBar.minWindows._hash){
	    	var __minWnd = IMToolBar.minWindows._hash[k];
	        if(__minWnd._focus){
	        	__minWnd.onClick(null, __minWnd.Element);
	        }
	    }    	if(im_myIMWindow) im_myIMWindow.close();
        im_wdkUtil.SetCookie(Ntalker.tbModelKEY, IMToolBar._ExpandMode);
    }else if(IMToolBar._ExpandMode == 1){
        IMcssTag.css(winArea, "visibility", "hidden");
        if(IMBrowser.msie56 || IMBrowser.oldModel || IMBrowser.maxthon){
            IMcssTag.css(winArea, "width",  1);
            IMcssTag.css(winArea, "height", 1);
            IMcssTag.css(im_wdkUtil.$('bodylist'), "width", 1);
        }
        var __width = 0;
        if(Ntalker.variable.user_sid=="NtalkerGuestUserSessionID"){
        	__width = IMBrowser.maxthon ? -3 : (IMBrowser.msie56 ? -1 : 0);
        }
        if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
        	IMcssTag.css(im_wdkUtil.$('ico_buddylist'), "display", "none");
        	IMcssTag.css(im_wdkUtil.$('ico_msg'),       "display", "none");
        }else{
        	IMcssTag.css(im_wdkUtil.$('ico_buddylist'), "display", "block");
        	IMcssTag.css(im_wdkUtil.$('ico_msg'),       "display", "block");
        }
        IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", IMToolBar._tbWidth[1] - __width);
        IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", IMToolBar._tbWidth[1] - __width);
        IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", IMToolBar._tbWidth[1] - __width);
        IMcssTag.css(im_wdkUtil.$('ico_group'),     "display", "block");
        IMcssTag.css(im_wdkUtil.$('ico_bbshot'),    "display", "block");
        var usercustoms = im_wdkUtil.$$(".user_custom", im_wdkUtil.$("Ntalkerbody"));
        for(var i=0; i<usercustoms.length; i++){
        	IMcssTag.css(usercustoms[i], "display", "block");
        }
        IMcssTag.removeClass(im_wdkUtil.$("ico_zoom"), "ico_minZoom_null");
        IMcssTag.replaceClass(im_wdkUtil.$("ico_zoom"),"ico_minZoom", "ico_maxZoom");
        im_wdkUtil.$$(" div", im_wdkUtil.$("ico_zoom"))[0].innerHTML = "";
        if(IMToolBar._align=="left"){
        	im_wdkUtil.$("Ntalkerbody").style.borderRight = "1px solid #898989";
    	}else{
    		im_wdkUtil.$("Ntalkerbody").style.borderLeft = "1px solid #898989";
    	}
    	im_wdkUtil.SetCookie(Ntalker.tbModelKEY, IMToolBar._ExpandMode);
    }else{
        IMcssTag.css(winArea, "visibility", "visible");
        if(IMBrowser.msie56 || IMBrowser.oldModel || IMBrowser.maxthon){
        	IMcssTag.css(winArea, "height", 28);
        	IMcssTag.css(winArea, "width", (_wRt.w - IMToolBar._tbWidth[1] - 35));
        	IMcssTag.css(im_wdkUtil.$('bodylist'),       "width", 2500);
        }
        IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", IMBrowser.msie56 ? (_wRt.w-3)+"px" : "100%");
        IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", IMBrowser.msie56 ? (_wRt.w-3)+"px" : "100%");
        IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", IMBrowser.msie56 ? (_wRt.w-3)+"px" : "100%");
        if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
        	IMcssTag.css(im_wdkUtil.$('ico_buddylist'), "display", "none");
        	IMcssTag.css(im_wdkUtil.$('ico_msg'),       "display", "none");
        }else{
        	IMcssTag.css(im_wdkUtil.$('ico_buddylist'), "display", "block");
        	IMcssTag.css(im_wdkUtil.$('ico_msg'),       "display", "block");
        }
        IMcssTag.css(im_wdkUtil.$('ico_group'),     "display", "block");
        IMcssTag.css(im_wdkUtil.$('ico_bbshot'),    "display", "block");
        var usercustoms = im_wdkUtil.$$(".user_custom", im_wdkUtil.$("Ntalkerbody"));
        for(var i=0; i<usercustoms.length; i++){
        	IMcssTag.css(usercustoms[i], "display", "block");
        }
        IMcssTag.removeClass(im_wdkUtil.$("ico_zoom"),"ico_minZoom_null");
        IMcssTag.replaceClass(im_wdkUtil.$("ico_zoom"),"ico_minZoom","ico_maxZoom");
        im_wdkUtil.$$(" div", im_wdkUtil.$("ico_zoom"))[0].innerHTML = "";
	    for(var k in IMToolBar.minWindows._hash){
	    	var __minWnd = IMToolBar.minWindows._hash[k];
	        if(__minWnd._focus){
	        	im_chat_window_manager.OnTBFocusWindow(__minWnd._destuid,__minWnd._chatType);
	        }
	    }
        im_wdkUtil.SetCookie(Ntalker.tbModelKEY, 1);
    }
};
IMToolBar.onShowHost = function(){
    if(!Ntalker.Config.customparams['enablehot']) return;
    im_openWebchatWindow("bbshot", "坛热点", null, 1, 'bbshot');
};
IMToolBar.onPopupOut = function(){    if( 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);
};
IMToolBar.onPopupIn = function(){
    window.close();
};
IMToolBar.onShowBuddylist = function(ev, el, index){
    if( !im_myIMWindow ) return;
    if(!el) el = im_wdkUtil.eventTag(ev,"li");
    var _wRt  = im_wdkUtil.viewRect.get(el);
    var _x = IMToolBar._align=="left" ? _wRt.x : _wRt.x+_wRt.w ;
    var _y = _wRt.y;
    index = index!=null ? index : 0;    Ntalker.Config.IMtabIndex = index;
    im_myIMWindow.OnTBShowBuddylist(_x, _y, true);
    IMToolBar.__closeMenu("ico_state");
    IMToolBar.__closeMenu("ico_group");
    IMToolBar.__closeMenu("ico_msg");
};
IMToolBar.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){
        	var effectsBtn = im_wdkUtil.$$(".ico_button", im_wdkUtil.$(k))[0];
            if(  ( (ev&&ev.type=="mouseover") || nodeName) ){
            	if(effectsBtn) IMcssTag.addClass(effectsBtn, "hover");
                IMToolBar.__showTip(k, IMToolBar.cfg[k][0]);
            }else{
            	if(effectsBtn) IMcssTag.removeClass(effectsBtn, "hover", "");
                IMToolBar.__hiddenTip(k);
            }
            return;
        }
    }
};
IMToolBar.onResize = function(ev){
    if( !IMBrowser.msie56 && !IMBrowser.oldModel )  return;
    var _wRt = im_wdkUtil.viewRect.get(window); 
    if(ev && ev.type){
        if(parseInt(_wRt.w) < parseInt(IMToolBar._tbWidth[1]) ){
            IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", IMToolBar._tbWidth[1]);
            IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", IMToolBar._tbWidth[1]);
            IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", IMToolBar._tbWidth[1]); 
        }
        else if(IMToolBar._ExpandMode==2){
            IMcssTag.css(im_wdkUtil.$('Ntalkerbody'),    "width", IMBrowser.msie56 ? (_wRt.w-2)+"px" : "100%");
            IMcssTag.css(im_wdkUtil.$('NtalkerBg'),      "width", IMBrowser.msie56 ? (_wRt.w-2)+"px" : "100%");
            IMcssTag.css(im_wdkUtil.$('NtalkerToolbar'), "width", IMBrowser.msie56 ? (_wRt.w-2)+"px" : "100%"); 
            if(IMBrowser.msie56) IMcssTag.css(im_wdkUtil.$("windows_area"),   "width", (_wRt.w - IMToolBar._tbWidth[1] - 35));
        }
    }
    var _winRect = im_wdkUtil.viewRect.get(window);
    var minToolbarWidth = IMToolBar.minChatWidth * IMToolBar.minWinCount + 30;
    if(IMToolBar._ExpandMode==0 && minToolbarWidth>_winRect.w){
    	IMToolBar.onMaximize();
    	return;
    }
};
IMToolBar.onScroll = function(ev){
	if(IMBrowser.msie56){
		createDelayedMethod("onScroll", 
		function(){
			var _wRt = im_wdkUtil.viewRect.get(window); 
			IMcssTag.css(IMToolBar.Element, "top",   (_wRt.y + _wRt.h - 28) );
        	IMcssTag.css(IMToolBar.Element, (IMToolBar._align=="left" ? "right" : "left"), 0 );
		}, 250);
	}
};
IMToolBar.onVisibleMsgMenu = function(ev, child){
    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", im_wdkUtil.$('btnICON'));
    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");
        }
    }
    return;
};
IMToolBar.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);
};
IMToolBar.__closeMenu = function(parentNodeID){
    IMToolBar.menuTimer = null;
    IMToolBar.showMenu  = false;
    var _menu = im_wdkUtil.$$(".ntalkermenu", im_wdkUtil.$(parentNodeID))[0]
    IMcssTag.css(_menu, "display", "none");
};
IMToolBar.__showTip = function(key, msg){
    var _tbBtn   = im_wdkUtil.$(key);
    if(/pre_disable|next_disable/.test(_tbBtn.className) ) return;
    if(!_tbBtn || IMToolBar.showMenu || !msg || im_wdkUtil.$('imNt_tooltip_'+key)) 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");
};
IMToolBar.__hiddenTip = function(key){
    var _tbBtn   = im_wdkUtil.$(key);
    if(!_tbBtn) return;
    var _tip   = im_wdkUtil.$("TOOLBARTIP"+key);    if(_tip) IMcssTag.css(_tip, "display", "none");
};IMToolBar.initMsgMenu = function(){
    var msg    = IMToolBar.arrMsg,addElementId='',MsgMenuHtml = '';
    var btnMsg = im_wdkUtil.$("ico_msg");
    if(!btnMsg) return;
    var msgMenuUL   = im_wdkUtil.$$(" ul", btnMsg)[0];
    for(var i=0; i<msg.length; i++){
        if(im_wdkUtil.isArray( msg[i] ) ){
            var _class   = msg[i][3]=="confirm" ? "addfir" : msg[i][3];
            var _destuid = msg[i][0], _type = msg[i][3];
            var txtCon = im_wdkUtil.cutText(msg[i][1], 5, true);
            if(!txtCon) continue;
            var t      = 10 - im_wdkUtil.lenText(txtCon);
            for(var j=0; j<Math.floor((10-im_wdkUtil.lenText(txtCon))/2); j++){txtCon += "　";}
            txtCon = txtCon + (t%2>0 ? "　" : " ") + im_wdkUtil.cutText(msg[i][2], 6);
            addElementId = _destuid+_type;
            MsgMenuHtml += '<LI id="'+addElementId+'" onclick="IMToolBar.viewMsg(event);" class="act '+_class+'" destuid="'+_destuid+'" typ="'+_type+'"><DIV><a href="javascript:void(0);">' + txtCon + '</a></DIV></LI>';
        }
    }
    if(msg.length==0){
		MsgMenuHtml += '<LI class="act nomsg"><DIV><a href="javascript:void(0);">暂无消息</a></DIV></LI>';
    }
    var _exMsg  = Ntalker.variable.ExMsg;
    var msgNum  = IMToolBar.arrMsg.length;
    if(_exMsg){
        for(var i=0; i<_exMsg.length; i++){
        	MsgMenuHtml += '<LI class="menuseparator" style="font-size:0px;height:7px;background:none;"><DIV style="padding:0px;background:#ccc;border:none;margin:3px 5px 3px 0px;height: 1px;width: 130px;_width: 125px; float: right; font-size: 0px;line-height:0px;"></DIV></LI>';
            MsgMenuHtml += '<LI onclick="window.open(this.getAttribute(\'url\'));IMToolBar.deleteCursorMsg(this.getAttribute(\'url\'));" class="act nomsg" url="' + _exMsg[i].url + '"><DIV><a href="javascript:void(0);">' + _exMsg[i].name + ' (' + _exMsg[i].msgnumber + ')</a></DIV></LI>';
            msgNum = parseInt(msgNum) + (isNaN(_exMsg[i].msgnumber) ? 0 : parseInt(_exMsg[i].msgnumber) );
        }
    }
    msgMenuUL.innerHTML = MsgMenuHtml;
    im_wdkUtil.$$(".ico_button", btnMsg)[0].innerHTML = "(" + msgNum + ")";
    if(IMToolBar._ExpandMode==0){
    	IMToolBar.updateToolbar();
    }
    return im_wdkUtil.$(addElementId);
};IMToolBar.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);
	var impresenceflash = document.getElementById('impresenceflash');
    if(impresenceflash && impresenceflash.playNotifySound && Ntalker.Config.customparams["playsound"]){
    	impresenceflash.playNotifySound();
    }
    var addElement = this.initMsgMenu();
    var _chatWinCount = im_chat_window_manager._chatWndsArray.length;
    if(_chatWinCount >= 0 && type == "request" && addElement) {
        this.viewMsg(null, addElement);return;
    }
};
IMToolBar.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();
};
IMToolBar.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();
};
IMToolBar.updateMsgNum = function(){
    var id = "ico_msg";
    if(!im_wdkUtil.$(id)) return;
    var _sysMsgNum = IMToolBar.arrMsg.length;
    for(var i=0; i<Ntalker.variable.ExMsg.length; i++){
    	var exMsg  = Ntalker.variable.ExMsg[i].msgnumber;
    	var msgNum = isNaN(exMsg) ? 0 : parseInt(exMsg);
        _sysMsgNum = parseInt(_sysMsgNum) + msgNum;
    }
    if(IMToolBar._ExpandMode==0){
    	IMToolBar.updateToolbar();
    }
    im_wdkUtil.$$(".ico_button", im_wdkUtil.$("ico_msg"))[0].innerHTML  = "(" + _sysMsgNum + ")";
    if(_sysMsgNum>0){
        IMToolBar.enableflash(id, "ico_msg", "flash_msg");
    }else{
        IMToolBar.disableFlash(id);
    }
};
IMToolBar.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;
};
IMToolBar.loadMsg = function(){
    var key = Ntalker.ctKEY + Ntalker.variable.user_id;
    var val = im_wdkUtil.u2c(im_wdkUtil.GetCookie(key));
    im_wdkUtil.DelCookie(key);
    if(val==null||typeof(val)=='undefined'||val==""){
        this.updateMsgNum();return;
    }
    var Items = val.replace(/{/g, "").split("}");
    for(var k in Items){
        if(typeof(k)=="string" && Items[k] && !im_wdkUtil.inArray(this.arrMsg, Items[k])) this.arrMsg.push(Items[k].split(","));
    }
    this.updateMsgNum();
};
IMToolBar.saveMsg = function(){
    var msg = this.arrMsg;
    var key = Ntalker.ctKEY + Ntalker.variable.user_id;
    var val = im_wdkUtil.GetCookie(key)==null ? "" : im_wdkUtil.c2u(im_wdkUtil.GetCookie(key));
    for(var i=0; i<msg.length; i++){
        val += msg[i].join(",") + (i+1<msg.length ? "}{" : "}");
    }
    val = val?"{"+val : "";
    if(val.length>0){
    	im_wdkUtil.SetCookie(key, im_wdkUtil.c2u(val), 3600);
    }
};
IMToolBar.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, 1, 'group');
        IMToolBar.removeMsg(notifyWnd.destuid, "group");
    }else{
        notifyWnd.BtnType = "alert";        NotifyManager.alertQueue.add(notifyWnd._curNotifyId, notifyWnd);
    }
};
IMToolBar.initGroupMsg = function(ev){
    if(!Ntalker.Config.customparams['enablegroup'] && !Ntalker.Config.customparams['enableroom']) return;
    var id = "ico_group";
    var groupMessages = IMToolBar.arrGroupMsg;
    var btnMsg        = im_wdkUtil.$(id);
    var msgMenuUL     = im_wdkUtil.$$(" ul", btnMsg)[0];
    var msgMenuItems  = im_wdkUtil.$$(".act", msgMenuUL);    var groupMenuHtml = '';
    for(var i=0; i<groupMessages.length; i++){
        if(im_wdkUtil.isArray( groupMessages[i] ) ){
        	var gid    = im_wdkUtil.c2u(groupMessages[i][0]);
        	var gname  = im_wdkUtil.c2u(groupMessages[i][1]);
        	groupMenuHtml += '<LI class="act group" groupId="'+gid+'" groupName="'+gname+'" onclick="IMToolBar.viewGroupMsg(event);" onmouseover="IMToolBar.onVisibleMsgMenu(event, true);"><DIV><a href="javascript:void(0);">'+groupMessages[i][1]+'</a></DIV></LI>';
        }
    }
    msgMenuUL.innerHTML = groupMenuHtml;
    var _btip = IMTipManager.getIMTip(id);
    if(typeof _btip != "undefined") _btip.Element.style.display = "none";
    if(groupMessages.length>0 && ev){
        IMToolBar.onVisibleMsgMenu(ev);
    }else if( ev ){
        IMToolBar.onShowBuddylist(null, "ico_buddylist", 2);
    }
    return;
};
IMToolBar.updateGroupNum = function(){
    var id  = "ico_group";
    var countNum = 0;
    if(!im_wdkUtil.$(id)) return;
    for(var k in IMToolBar.groupCountNum){
    	countNum = countNum + (!isNaN(IMToolBar.groupCountNum[k])?IMToolBar.groupCountNum[k]:0);
    }
    countNum = countNum>99 ? "99+" : countNum;
    im_wdkUtil.$$(".ico_button", im_wdkUtil.$(id))[0].innerHTML = "(" + countNum + ")";
    if(IMToolBar.arrGroupMsg.length>0){
        IMToolBar.enableflash(id, "ico_group", "flash_group");
    }else{
        IMToolBar.disableFlash(id);
    }
};
IMToolBar.addGroupMsg = function(groupId, groupName, srcuid, srcnick, msg){
	var cust = Ntalker.Config.customparams;
    var btnGroup = im_wdkUtil.$("ico_group");
    var groupMessages = this.arrGroupMsg;
    this.groupCountNum[groupId] = this.groupCountNum[groupId]===undefined ? 0 : this.groupCountNum[groupId];
    this.groupCountNum[groupId] = this.groupCountNum[groupId] + 1;
    if(IMTipManager && !cust['disablegrouptip']){
    	try{
    		var groupdisplay = IMcssTag.css(im_wdkUtil.$("ico_group"),"display");
    		groupspan = groupdisplay=="none" ? "ico_zoom" : "ico_group";
    		IMTipManager.addIMTip(groupspan, [{user:srcnick,msg:msg}], {step:5, wait:0, nextwait:3000},{roomid:groupId, roomname:groupName,usercount:"-"});
    	}catch(e){}
    }
    for(var i=0; i<groupMessages.length; i++ ){
        if(groupMessages[i][0]==groupId){
            this.updateGroupNum();
            return; 
        }
    }
    groupMessages.push([groupId, groupName]);
    var sn    = groupMessages.length>20 ? groupMessages.length-20 : 0;
    this.arrGroupMsg = groupMessages.slice(sn, groupMessages.length);
    im_wdkUtil.$$(".ico_button", btnGroup)[0].innerHTML = "(" + groupMessages.length + ")";
    this.updateGroupNum();
};
IMToolBar.removeGroupMsg = function(groupId){
    var groupMessages = this.arrGroupMsg;var new_GMsg = [];
    for(var i=0; i<groupMessages.length; i++ ){ if( groupMessages[i][0] != groupId ){new_GMsg.push(groupMessages[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");
};
IMToolBar.getGroupMsg = function(groupId){
    var groupMessages = this.arrGroupMsg;
    for(var i=0; i<groupMessages.length; i++){ if(groupMessages[i][0]==groupId) return groupMessages[i]; }
    return null;
};
IMToolBar.loadGroupMsg = function(){
    var key = Ntalker.gpKEY + Ntalker.variable.user_id;
    var val = im_wdkUtil.u2c(im_wdkUtil.GetCookie(key));
    im_wdkUtil.DelCookie(key);
    if(val==null||typeof(val)=='undefined'||val==""){  return; }
    var Items = val.replace(/{/g, "").split("}");
    for(var k in Items){
        if(typeof(k)=="string" && Items[k] && !im_wdkUtil.inArray(this.arrGroupMsg, Items[k])){
        	var item = Items[k].split(",");
        	this.arrGroupMsg.push(item);
        	this.groupCountNum[item[0]] = this.groupCountNum[item[0]]===undefined ? 0 : this.groupCountNum[item[0]];
        	this.groupCountNum[item[0]] = this.groupCountNum[item[0]] + 1;
        }
    }
    this.updateGroupNum();
};
IMToolBar.saveGroupMsg = function(){
    var groupMessages = this.arrGroupMsg;
    var key = Ntalker.gpKEY + Ntalker.variable.user_id;
    var val = im_wdkUtil.GetCookie(key)==null ? "" : im_wdkUtil.u2c(im_wdkUtil.GetCookie(key));
    for(var i=0; i<groupMessages.length; i++){ 
        val += groupMessages[i].join(",") + (i+1<groupMessages.length ? "}{" : "}");
    }
    val = val!=""?"{"+val : "";
    if(val.length>0){
    	im_wdkUtil.SetCookie(key, im_wdkUtil.c2u(val), 3600);
    }
};
IMToolBar.viewGroupMsg = function(ev, Element){
    var id = "ico_group";
    if(arguments.length>=4){
    	var groupId = arguments[2];
    	var groupName = arguments[3];
    }else if(!Element){
    	var Element   = im_wdkUtil.eventTag(ev, "li");
    	var groupId   = im_wdkUtil.u2c(Element.getAttribute("groupId"));
    	var groupName = im_wdkUtil.u2c(Element.getAttribute("groupName"));
    }
    if(!groupId || !groupName) return;
    IMToolBar.overMenu = "";
    this.groupCountNum[groupId] = 0;
    if(IMTipManager){
    	var curTip = IMTipManager.getIMTip(id);
    	if(curTip) curTip.message = [];
    }
    this.__closeMenu(id);
    im_openWebchatWindow(groupId, groupName, null, 1, 'group');
};
IMToolBar.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;    }
    this._statusValue = statusValue>0&&statusValue<=4 ? statusValue : 0;
    btnState.getElementsByTagName("DIV")[0].className = _status;
    IMcssTag.addClass(btnState.getElementsByTagName("DIV")[0], "ico_button");
};
IMToolBar.saveStatus = function(statusValue){
    IMToolBar.overMenu = "";
    this.__closeMenu("ico_state");
    IMToolBar.updateUserStatus(statusValue);
    var _presenceFlash = im_wdkUtil.$("impresenceflash");
    if(_presenceFlash && _presenceFlash.switchUserStatus){        _presenceFlash.switchUserStatus(statusValue);
    }
};
IMToolBar.updateUserNumber = function(onlineUser, totalUser){
    if(im_wdkUtil.$("buddylist_span")) 
        im_wdkUtil.$("buddylist_span").innerHTML = "好友(" + onlineUser + "/" + totalUser + ")";
};
IMToolBar.toolbarHtml = function(){
    var _html = '';
    _html += '<div class="NtalkerBg" id="NtalkerBg"></div>';
    _html += '<div class="ntbody" id="Ntalkerbody">';
    _html += '<iframe style="border: 0pt none;display: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;">';
    if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
    	_html += '            <li id="ico_close" class="ico_close"><div class="ico_button"></div></li>'; 
    }
    _html += '            <li id="ico_zoom" class="ico_maxZoom"><div class="ico_button"></div></li>'; 
    _html += '            <li id="ico_buddylist">';
    _html += '                <div id="buddylist_span" class="ico_button">(0)</div>';
    _html += '                <div id="buddylist_tab" class="buddylist_tab"></div>';
    _html += '            </li>';
    if(Ntalker.Config.customparams['enablegroup'] || Ntalker.Config.customparams['enableroom']){
        _html += '            <li id="ico_group" class="ico_group">';
        _html += '                <div class="ico_button">(0)</div>';
        _html += '                <div id="group_tab" class="buddylist_tab"></div>';
        _html += '                <div class="ntalkermenu" style="display:none;" onmouseover="IMToolBar.onVisibleMsgMenu(event);" onmouseout="IMToolBar.onHiddenMsgMenu(event);">';
        _html += '                   <ul style="list-style:none;margin:0px;padding:0px;">';
        _html += '                        <li class="act group"><div>(0)</div></li>';
        _html += '                   </ul>';
        _html += '                   <div class="bot_line"></div>';
        _html += '                </div>';
        _html += '            </li>';
    }
    _html += '            <li id="ico_msg" class="ico_msg">';
    _html += '                <div class="ico_button">(0)</div>';
    _html += '                <div class="ntalkermenu" style="display:none;" onmouseover="IMToolBar.onVisibleMsgMenu(event);" onmouseout="IMToolBar.onHiddenMsgMenu(event);">';
    _html += '                   <ul style="list-style:none;margin:0px;padding: 0px 0px 0px 5px !imporant; _padding:0px;">';
    _html += '                   </ul>';
    _html += '                   <div class="bot_line"></div>';
    _html += '               </div>';
    _html += '            </li>';
    _html += '        </ul>';
    _html += '    </div>';
    _html += '    <div id="ico_pre" class="pre_enable"><div class="ico_button"></div></div>';
    _html += '    <div id="ico_next" class="next_enable"><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;
};
IMToolBar.createHotButton = function(){
	var btnMsg = im_wdkUtil.$('ico_msg');
    if(!Ntalker.Config.customparams['enablehot'] || Ntalker.temp.CHot || !btnMsg) return;
    IMToolBar.cfg["ico_bbshot"]    = ["坛热点"];
    Ntalker.temp.CHot = true;
    IMToolBar._tbWidth[1] += 38;
    var _html;
    _html  = '<li id="ico_bbshot" style="'+(IMToolBar._ExpandMode>0 ? "display:block;" : "display:none;")+'">';
    _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>';
    if(btnMsg) im_wdkUtil.insertHtml("afterend", btnMsg, _html);
    if(IMToolBar._ExpandMode>0) 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);
    }
};
IMToolBar.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);
    }
};
IMToolBar.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);
};
IMToolBar.initScroll = function(){
    var Element= im_wdkUtil.$('windows_area');
    var _sLeft = Element.scrollLeft;
    if(IMToolBar.minWinCount*IMToolBar.minChatWidth <= IMToolBar._viewRect.w){
        IMcssTag.replaceClass(im_wdkUtil.$('ico_pre') , "pre_enable" ,  "pre_disable");
        IMcssTag.replaceClass(im_wdkUtil.$('ico_next'), "next_enable",  "next_disable");
    }else{
        if(_sLeft > 0 ){            IMcssTag.replaceClass(im_wdkUtil.$('ico_next'),  "next_disable", "next_enable");
        }else{            IMcssTag.replaceClass(im_wdkUtil.$('ico_next'), "next_enable",  "next_disable");
        }        if(IMToolBar.minWinCount*IMToolBar.minChatWidth - _sLeft > IMToolBar._viewRect.w){            IMcssTag.replaceClass(im_wdkUtil.$('ico_pre'),  "pre_disable", "pre_enable");
        }else{            IMcssTag.replaceClass(im_wdkUtil.$('ico_pre'), "pre_enable",  "pre_disable");
        }
    }
};
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(){        if(statusValue>0 && statusValue<=4){
            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){
        im_sendOpenChatWindowList = [];
        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, -1);
    }
    fIM_CloseIMWindow();
    im_chat_window_manager.closeAll();
    IMToolBar.hidden();
}
function fIM_visibleToolBar(){
    if( (im_wdkUtil.GetCookie(Ntalker.tbClosedKEY)=="1" || (!Ntalker.Config.customparams['enablegroup'] && !Ntalker.Config.customparams['enableroom'] && !Ntalker.Config.customparams['enablehot'])) && Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' )
        return;
    IMToolBar.visible();
}
function fIM_openPopupChatWindow(arrWin, OpenType){    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], OpenType, 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 cookie_key   = Ntalker.unKey + Ntalker.variable.user_id;
    var cookie_value = im_wdkUtil.u2c(im_wdkUtil.GetCookie(cookie_key));
    im_wdkUtil.DelCookie(cookie_key);    if(!cookie_value) return;
    var curid = 0,curtype = "chat";
    cookie_value = cookie_value.replace(/{/g, "").split("}");
    for(var k in cookie_value){
        if(typeof(k)=="string" && cookie_value[k]){
            if(IMToolBar._ExpandMode==1){
            	IMToolBar.onMaximize();
            }
            chatWindow = im_wdkUtil.StringToArray(cookie_value[k]);
            if(typeof(chatWindow)=='undefined'|| !chatWindow) continue; 
            im_openWebchatWindow(chatWindow["uid"], chatWindow["nick"], null, -1, chatWindow["type"]);
            Ntalker.variable.onlineChat -= 1;
            if(chatWindow["current"]=="default"){
                curid = chatWindow["uid"];
                curtype = chatWindow["type"];
            }
        }
    }
    if(im_chat_window_manager){        im_chat_window_manager.OnTBFocusWindow(curid, curtype);
    }
}
function im_onUnload(){
	var user_id = Ntalker.variable.user_id;
    var _presenceFlashGoUrl = Ntalker.temp.presenceFlashGoUrl;
    var chatWins = im_chat_window_manager._chatWndsArray;
    var cookie_value= "";
    if(user_id && im_chat_window_manager && chatWins.length>0 && Ntalker.Config.isPopupWindow==0 ){
        for(var i=0; i<chatWins.length; i++){
            if(/group|chat/.test(chatWins[i]._chatType) && chatWins[i]._isFlashLoadSuccess){
            	cookie_value += "{uid:" + chatWins[i]._destuid+";nick:"+chatWins[i]._destnick+";type:"+chatWins[i]._chatType+";current:"+chatWins[i]._curWindMode+";}";
            }
        }
        if(cookie_value){
        	im_wdkUtil.SetCookie(Ntalker.unKey+user_id, im_wdkUtil.c2u(cookie_value));
        }
    }
    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(_presenceFlashGoUrl) im_wdkUtil.createScript(_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() {    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();
}
function im_conncetChatRoom(roomid, roomname)
{
    if( !roomid || !roomname || Ntalker.room.exec) return;
    var presenceFlash = im_wdkUtil.$("impresenceflash");
    try{
        if(presenceFlash && typeof(presenceFlash.conncetChatRoom)!='undefined'){
            Ntalker.room.exec = true;
            presenceFlash.conncetChatRoom(Ntalker.variable.siteid, roomid, roomname);
        }
    }catch(e){}
}
function fIM_onGetChatroomStatus(chatroominfo)
{
	if(typeof(chatroominfo) == "string")
    	chatroominfo   = eval('('+chatroominfo+')');
    var parentNode = im_wdkUtil.$("wdk_group_"+chatroominfo.roomid);
    if( parentNode && parentNode.className=="wdk_group_chat_span" && parentNode.innerHTML != "")
        var parentNodeId = "wdk_group_"+chatroominfo.roomid    IMTipManager.addIMTip(parentNodeId, chatroominfo.messages, {step:5, wait:0, nextwait:3000},{roomid:chatroominfo.roomid, roomname:chatroominfo.roomname,usercount:chatroominfo.usercount});
}
function IM_removeStatisticElement(){
	var head = document.getElementsByTagName("HEAD")[0];
	var scriptElements = head.getElementsByTagName("script");
	for(var i=0; i<scriptElements.length; i++)
	{
		if( scriptElements[i].src.indexOf("statistic.php") != -1 ){
			scriptElements[i].parentNode.removeChild(scriptElements[i]);
		}
	}
}
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;