﻿if( typeof(gLang) == 'undefined' ){
	var gLang = new Array();
}
gLang['zh_CN'] = new (function () {
	this.zhBlank = "　";
	this.userIdHead = "guest";
	this.userNameHead = "游客";
	this.guestSessionId = "NtalkerGuestUserSessionID";
	this.pageGroupsEntranceTip = ["打开%1", "点击进入%1聊天", "点击这里开始聊天"];
	this.pageStatusTip  = "跟我聊天";
	this.toolbarGroupTip = "请点击这里开始群聊";
	this.adminUserName= "管理员";
	this.replaceExpression  = ["[表情]", "[图片]"];
	this.requestChat = ["请求会话", "请求与您会话"];
	this.requestAddFriend = ["请求加好友", "加您为好友"];
	this.onlineText = "刚刚上线";
	this.requestSessionTitle = "请求与你 %1";
	this.audioSession = "音视频会话";
	this.videoSession = "音频会话";
	this.fileTransfer = "传输文件";
	this.receiveMessageTitle  = "%1 说：%2";
	this.popupWindowTitle  = "聊天窗口";
	this.promptTitle = "【%1】%2 - %3";
	this.createFlashFailure = "flash创建失败，请您确定浏览器设置允许播放flash，或刷新浏览器重试，如果仍然不能正常使用请重新安flash插件.";
	this.endAudioSession = "您与对方正在进行语音会话，弹出聊窗将会中断音频会话，您确定吗？";
	this.endVideoSession = "您与对方正在进行音视频会话，弹出聊窗将会中断音视频会话，您确定吗？";
	this.endFiletrans = "您与对方正在进行文件传输，弹出窗口将会中断文件传输，您确定吗？";
	this.noInstallFlash = "Flash插件未安装或版本过低,请重新安装.";
	this.loadFlashFailure = "Flash装载失败，请点击此处重新连接...";
	this.notLogin = "您还没有登录，请先登录！";
	this.connectErr = "连接失败，请稍候重试！";
	this.buddylistWindowTitle  = "好友列表";
	this.buddylistNotLoginAlter   = "您尚未登录，请登录后再使用好友列表！";
	this.sd_Buddylist = "好友列表";
	this.sd_closeGroupWindow = "关闭群聊窗";
	this.sd_closeNQuanWindow = "关闭能圈";
	this.sd_closeChatWindow  = "关闭一对一聊窗";
	this.sd_eventOpen   = "打开";
	this.sd_eventClose  = "关闭";
	this.sd_GroupWindow = "群聊窗";
	this.sd_NQuanWindow = "能圈";
	this.sd_ChatWindow  = "一对一聊窗";
	this.sd_eventType = ["(主)","(被)","(携)"];
	this.sd_superPromotionMessage = "收到superuser推广的nquan消息";
	this.sd_openSystemMessageBoxDesc = "打开消息盒子系统消息标签";
	this.minWindowTitle = "与 %1 对话";
	this.sayContent = "说 %1";
	this.messageBoxTitle = "通知";
	this.CONST_siteApplication = "站内应用";
	this.LoadingText = "载入中...";
	this.buddylistButtonText = ["联系人(%1/%2)", "好友(%1/%2)"];
	this.groupButtonText = "群组(%1)";
	this.systemButtonText = "通知";
	this.scrollButtonText = ["向前滚动", "向后滚动"];
	this.myAppButtonText = "我的中心";
	this.hotFocusButtonText = ["热点聚焦", "最新贴", "最热贴"];
	this.systemMessageBoxText = ["动态消息", "系统消息"];
	this.spanSwitchButtonText = ["显示工具栏", "隐藏工具栏"];
	this.spanConfigurationText = "设置";
	this.configurationMenuDynamicMessages = ["动态消息","接收原创消息","接收评论消息"];
	this.configurationMenuGroupSetting = ["群组设置","使用群组自身消息设置","屏蔽所有群组消息"];
	this.configurationMenuOtherSettings = ["其它设置","好友上线提示","允许接收陌生人消息","系统声音提示"];
	this.configurationMenuLinkText = "查看所的聊天记录";
	this.nullMessage = ["暂无%1","暂无%1消息"];
	this.viewPhotoTitle = "图片浏览";
})();
var Ntalker = {
    unKey:"imNt_uLoad_ctWind",
    ctKEY:"systemMessage",
    gpKEY:"groupMessage",
    guestUserNoKEY:"imNt_guestNo",
    tbModelKEY:"toolbarMode" 
};
Ntalker.version = {
	script_version: "2010-8-12 17:50",
    presence_flash : "3.2.11",
    buddylist_flash: "3.2.11",
    webchat_flash : "3.2.11",
    group_flash : "3.2.11",
    nquan_flash : "3.2.11"
};
Ntalker.variable = {
    openHistoryWindow: false,
    presenceConnet: false,
    ExMsg: [],
    myApp:[],
    applicationOpened: false,
    onlineChat: 10,
    OnFocusWinParam: [],
    OnBlurWinParam: [],
    autoFocus: true,
    offlineChatList: [],
    siteid: null,
    user_id: null,
    user_name: null,
    user_sid: null,
    userparam: null,
    popupWindow: null,
    scriptPath: "",
    buddylistTag: null
};
Ntalker.temp = {
	chatDataFlashReady:false,
    presenceFlashGoUrl: null,
    buddylistFlashGoUrl: null,
    notify_id: 0,
    userSpanArray: null,
    resetwintop: new Array(),
    pageId: null,
    imSid: null
};
Ntalker.Config = {
    services: "http://" + "down2.ntalker.com/res",
    IMXMLURL: "",
    publicDIR: "",
    imagesDIR: "",
    customDIR: "",
    skin:"",
    bColor:"",
    bgColor:"",
    logo: "",
    toolbarlogo:"",
    buddylistlogo:"",
    chatlogo:"",
    nquanlogo:"",
    grouplogo:"",
    chatroomlogo:"",
    startlogo:"",
    groupstartlogo:"",
    chatWidth:384,
    chatHeight:416,
    groupWidth:460,
    groupHeight:532,
    hotWidth:510,
    hotHeight:520,
    IMWidth:248,
    IMHeight:532,
    IMtabIndex: 0,
    isPopupWindow: 0,
    isPopupMode: false,
    customtoolbarButtons: [],     
    application:[], 
    customparams: []
};
Ntalker.room = {
    roomid:null,
    roomname:null
};
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_chat_window_manager = null;
var promptwindow = null;
var wdkApplication = null;
var im_myIMWindow = null;
var IMToolBar = null;
var im_flashGoUrl = null;
var NtLang = null;
var NtExecCommandTimer = 0;
var $$O, $$selector, $$B, $$A, $$F, $$D, $$E, $$S, $$C, $$J;
(function(){
var O, select, B, A, F, D, E, S, C, J;
O = function(id){return document.getElementById(id)||null;};
select = function(selector){
	if (document.querySelector){
		return selector.indexOf(',') == -1 ? document.querySelector(selector) : document.querySelectorAll(selector);
	}else{
		var head = document.documentElement.firstChild;
        var styleTag = document.createElement("STYLE");
        head.appendChild(styleTag);
        document.__qsResult = [];
        styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsResult.push(this))}";
        window.scrollBy(0, 0);
        head.removeChild(styleTag);
        var result = [];
        for (var i in document.__qsResult)
            result.push(document.__qsResult[i]);
        return result;
	}
};
B = (function(ua){
    var b = {
        msie: /msie/.test(ua) && !/opera/.test(ua),
        opera: /opera/.test(ua),
        safari: /webkit/.test(ua) && !/chrome/.test(ua),
        mozilla: /mozilla/.test(ua) && !/(compatible|webkit)/.test(ua),
        firefox: /firefox/.test(ua),
        chrome: /chrome/.test(ua),
        maxthon3: /maxthon/.test(ua) && /safari/.test(ua)
    };
    var vMark = "";
    for (var i in b) {
        if (b[i]) { vMark = "safari" == i ? "version" : i; break; }
    }
    b.version = vMark && RegExp("(?:" + vMark + ")[\\/: ]([\\d.]+)").test(ua) ? RegExp.$1 : "0";
    b.safari2 = b.safari && parseInt(b.version) < 522 && !/adobeair/i.test(ua);
    b.ie = b.msie;
    b.ie6 = b.msie && parseInt(b.version) == 6;
    b.ie7 = b.msie && parseInt(b.version) == 7;
    b.ie8 = b.msie && parseInt(b.version) == 8;
    b.QuirksModel = b.msie && document.compatMode=="BackCompat";
    b.StrictMode = document.compatMode=="CSS1Compat";
    try{
        b.maxthon = external&&external.max_version!=undefined;
    }catch(e){}
    return b;
})(window.navigator.userAgent.toLowerCase());
A = function(){
    var ret = {
        isArray: function( b ) {
            return b instanceof Array;
        },
        indexOf: function( array, elt, from ){
            if (array.indexOf) {
                return isNaN(from) ? array.indexOf(elt) : array.indexOf(elt, from);
            } else {
                var len = array.length;
                from = isNaN(from) ? 0 : (from < 0) ? Math.ceil(from) + len : Math.floor(from);
                for ( ; from < len; from++ ) { if ( array[from] === elt ) return from; }
                return -1;
            }
        },
        lastIndexOf: function( array, elt, from ){
            if (array.lastIndexOf) {
                return isNaN(from) ? array.lastIndexOf(elt) : array.lastIndexOf(elt, from);
            } else {
                var len = array.length;
                from = isNaN(from) || from >= len - 1 ? len - 1
                    : from < 0 ? Math.ceil(from) + len : Math.floor(from);
                for ( ; from > -1; from-- ) { if ( array[from] === elt ) return from; }
                return -1;
            }
        },
        each: function( array, callback){
        	if ( array.length == undefined ){
	            for ( var name in array ){
	                callback.apply(this, [array[name], name]);
	            }
	        } else {
	            for ( var i = 0, len = array.length; i < len; i++ ) {
                    callback.apply(this, [array[i], i]);
	            }
	        }
        }
    };
    return ret;
}();
F = {
    isFunction:function(fn){
        return typeof(fn) == "function";
    }
};
D = {
    eachAttributes:function(obj,func){
        if(typeof obj!='object' || typeof func!='function') return null;
        for(var key in obj){
            func(key);
        }
        return obj;
    },
    create: function(tagName, arrt, par, where){
        var doc,htmls=[], elem;
        doc = document;
        par = par || doc.body || doc.documentElement || null;
        if(par.insertAdjacentHTML && where){
            htmls.push('<' + tagName);
            for(var k in arrt) 
                k && htmls.push(' '+(k=="className" ? "class" : k)+'="' + arrt[k] + '"');
            htmls.push('></'+tagName+'>');
            htmls = htmls.join('');
            where = where? where.toLowerCase() : "afterbegin";
            switch(where){
                case "beforebegin":
                    par.insertAdjacentHTML('BeforeBegin', htmls);return par.previousSibling;
                case "beforeend":
                    par.insertAdjacentHTML('BeforeEnd', htmls);return par.lastChild;
                case "afterend":
                    par.insertAdjacentHTML('AfterEnd', htmls);return par.nextSibling;
                default :
                    par.insertAdjacentHTML('AfterBegin', htmls);return par.firstChild;
            }
        }else {
            if( tagName.toLowerCase() == 'text' )
                elem = doc.createTextNode(arrt.text);
            else{
                elem = doc.createElement(tagName);
                for(var k in arrt){
                    switch(k){
                        case "className": elem.className = arrt[k];break;
                        case "style": elem.style.cssText = arrt[k];break;
                        default : elem.setAttribute(k, arrt[k]);
                    }
                }
            }
            par.appendChild(elem);
            return elem;
        }
    },
    insert: function(elem, h, where) {
        where = where ? where.toLowerCase() : 'afterbegin';
        if (elem.insertAdjacentHTML) {
            switch (where) {
                case "beforebegin":elem.insertAdjacentHTML('BeforeBegin', h);return elem.previousSibling;
                case "afterbegin": elem.insertAdjacentHTML('AfterBegin', h);return elem.firstChild;
                case "afterend":elem.insertAdjacentHTML('AfterEnd', h); return elem.nextSibling;
                default :elem.insertAdjacentHTML('BeforeEnd', h);return elem.lastChild;
            }
            throw 'Illegal insertion point -> "' + where + '"';
        }
        var range = elem.ownerDocument.createRange();
        var frag;
        switch (where) {
        case "beforebegin":range.setStartBefore(elem);frag = range.createContextualFragment(h);elem.parentNode.insertBefore(frag, elem);return elem.previousSibling;
        case "afterbegin":
            if (elem.firstChild) {
                range.setStartBefore(elem.firstChild);frag = range.createContextualFragment(h);elem.insertBefore(frag, elem.firstChild);return elem.firstChild;
            } else {
                elem.innerHTML = h;return elem.firstChild;
            }
        case "beforeend":
            if (elem.lastChild) {
                range.setStartAfter(elem.lastChild);frag = range.createContextualFragment(h);elem.appendChild(frag);return elem.lastChild;
            } else {
                elem.innerHTML = h;return elem.lastChild;
            }
        case "afterend":range.setStartAfter(elem);frag = range.createContextualFragment(h);elem.parentNode.insertBefore(frag, elem.nextSibling);return elem.nextSibling;
        }
        throw 'Illegal insertion point -> "' + where + '"';
    },
    getScrollTop: function(elem){
        var doc = elem==document||!elem ? document : elem.ownerDocument;
        return Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
    },
    getScrollLeft: function(elem){
        var doc = elem==document||!elem ? document : elem.ownerDocument;
        return Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
    },
    contains: function(a, b){
        return (this.contains = a.compareDocumentPosition
                ? function (a, b) { return !!(a.compareDocumentPosition(b) & 16); }
                : function (a, b) { return a != b && a.contains(b); }
            )(a, b);
    },
    rect: function(elem){
        var parent       = elem.parentNode, 
            offsetChild  = elem,
            offsetParent = elem.offsetParent,
            doc          = elem.ownerDocument,
            fixed        = D.css(elem, "position") == "fixed";
        var left = 0, top = 0, right = 0, bottom = 0, width = 0, height = 0, x = 0, y = 0;
        if ( elem.getBoundingClientRect ) {
            var box = elem.getBoundingClientRect();
            left = box.left + this.getScrollLeft(elem);
            top  = box.top + this.getScrollTop(elem);
            left -= doc.documentElement.clientLeft;
            top -= doc.documentElement.clientTop;
        }else{
            left = elem.offsetLeft;
            top  = elem.offsetTop;
            while (offsetParent) { 
                left += offsetParent.offsetLeft; 
                top  += offsetParent.offsetTop; 
                if ( B.mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || B.safari && !B.safari2 ){
                    left += (parseInt(D.css(offsetParent, "borderLeftWidth")) || 0 ); 
                    top  += (parseInt(D.css(offsetParent, "borderLeftTop")) || 0 ); 
                }
                if ( !fixed && D.css(offsetParent, "position") == "fixed" )
                    fixed = true;
                offsetChild  = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
                offsetParent = offsetParent.offsetParent;
            };
            while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
                if ( !/^inline|table.*$/i.test(D.css(parent, "display")) ){
                    left -= parent.scrollLeft; top  -= parent.scrollTop;
                }
                if ( B.mozilla && D.css(parent, "overflow") != "visible" ){
                    left += (parseInt(D.css(parent, "borderLeftWidth")) || 0 ); 
                    top  += (parseInt(D.css(parent, "borderLeftTop")) || 0 ); 
                }
                parent = parent.parentNode;
            }
            if ( (B.safari2 && (fixed || D.css(offsetChild, "position") == "absolute")) || 
                (B.mozilla && D.css(offsetChild, "position") != "absolute") ){
                    left -= doc.body.offsetLeft; top  -= doc.body.offsetTop;
            }
            if ( fixed ){
                left += this.getScrollLeft(elem); top  += this.getScrollTop(elem);
            }
            right = left + elem.offsetWidth; 
            bottom = top + elem.offsetHeight;
        };
        try{
            width = elem.offsetWidth || 0;
            height = elem.offsetHeight || 0;
        }catch(e){}
        return {
            left: left,
            top: top,
            right: right,
            bottom: bottom,
            w: width,
            h: height
        };
    },
    clientRect: function(elem){
        elem = typeof elem=='string' ? O(elem) : elem;
        var rect = this.rect(elem), 
            sLeft = this.getScrollLeft(elem), 
            sTop = this.getScrollTop(elem);
        rect.left -= sLeft; 
        rect.top -= sTop; 
        rect.right -= sLeft;
        rect.bottom -= sTop;
        return rect;
    },
    windowRect: function(obj){
        var d = {x: 0,y: 0,w: 0,h: 0,_w: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;
    	d._w = d.w;
        return d;
    },
    curStyle: function(elem){
        return (this.curStyle = document.defaultView
                ? function (elem) { return document.defaultView.getComputedStyle(elem, null); }
                : function (elem) { return elem.currentStyle; }
            )(elem);
    },
    css: function(elem, name, value){
        if(!elem) return;
        if(typeof value != 'undefined'){
            if (typeof name == "string") { var s = name; style = {}; style[s] = value; }
            for (var name in style) {
                var value = style[name];
                switch(name.toLowerCase()){
                    case "float": elem.style[ B.ie ? "styleFloat" : "cssFloat" ] = value;break;
                    case "scrollleft":elem.scrollLeft = value;break;
                    case "scrolltop":elem.scrollTop = value;break;
                    case "opacity": 
                        if( B.ie ){
                            elem.style.filter = (elem.currentStyle.filter || "").replace( /alpha\([^)]*\)/, "" ) + "alpha(opacity=" + value * 100 + ")";
                            break;
                        }
                    default: 
                    	if( elem.style ) elem.style[S.camelize( name )] = value;
                }
            };
        }else{
            if( 'scrollleft' == name.toLowerCase() )
                return elem.scrollLeft || 0;
            else if( 'scrolltop' == name.toLowerCase() )
                return elem.scrollTop || 0;
            else if(document.defaultView){
                var style = document.defaultView.getComputedStyle(elem, null);
                return name in style ? style[ name ] : style.getPropertyValue( name );
            }else{
                var style = elem.currentStyle;
                if (name == "opacity") {
                    if ( /alpha\(opacity=(.*)\)/i.test(style.filter) ) {
                        return parseFloat(RegExp.$1)/100 || 1;
                    }
                    return 1;
                }
                if (name == "float") { name = "styleFloat"; }
                var ret = style[ name ] || style[S.camelize( name )];
                if ( !/^\-?\d+(px)?$/i.test( ret ) && /^\-?\d/.test( ret ) ) {
                    style = elem.style; left = style.left; rsLeft = elem.runtimeStyle.left;
                    elem.runtimeStyle.left = elem.currentStyle.left;
                    style.left = ret || 0;
                    ret = style.pixelLeft + "px";
                    style.left = left;
                    elem.runtimeStyle.left = rsLeft;
                }
                return ret;
            }
        }
    },
    addClass: function( elem, className ){
        if( !this.include(elem, className) ){
            elem.className = elem.className.split(/\s+/).join(" ") + " " + className;
        }
    },
    removeClass: function( elem, className ){
        if(elem && elem.className.length>0 ){
            var reg = new RegExp( "\\b" + className + "\\b", "gi" );
            elem.className = elem.className.replace( reg, "" );
        }
    },
    replaceClass:function( elem, oldclassName, className){
        this.addClass(elem, className);
        this.removeClass(elem, oldclassName);
    },
    include: function( elem, className ){
        if(!elem || !elem.className ){
            return false;
        }else{
            var reg = new RegExp( "\\b" + className + "\\b", "gi" );
            return reg.test(elem.className);
        }
    },
    filter: function(Nodes, where){
        var reg, className, cNodes = [], Ns = [];
        for(var i=0; i<Nodes.length; i++){
            Nodes[i].tagName && Nodes[i].nodeType!=8 && cNodes.push(Nodes[i]);
        }
        if( where != undefined ){
            var m = /^\s*?(\w+)$|^\.(\w+)$/.exec( where );
            if (m[1]){
                for(var i=0; i<cNodes.length; i++){
                    cNodes[i].tagName.toLowerCase()==m[1].toString().toLowerCase() && Ns.push(cNodes[i]);
                }
                cNodes = Ns;
            }
            else if (m[2]){
                className = m[2].replace(/\-/g, "\\-");
                reg = new RegExp("\\b" + className + "\\b");
                for(var i=0; i<cNodes.length; i++){
                    reg.test(cNodes[i].className) && Ns.push(cNodes[i]);
                }
                cNodes = Ns;
            }
        }
        cNodes.first = function(){
            return !cNodes.length ? null : cNodes[0];
        };
        cNodes.last = function(){
            return !cNodes.length ? null : cNodes.slice(-1)[0];
        };
        return cNodes;
    },
    animate: function(elements, prams, speed, easing, callback ) {
        var elements = !A.isArray( elements ) ? [elements] : elements;
        var opt = {
            complete: callback || !callback && easing || $$F.isFunction(speed) && speed,
            duration: speed,
            easing: callback && easing || easing && easing.constructor != Function && easing
        };
        opt.duration = (opt.duration && opt.duration.constructor == Number ? 
            opt.duration : 
            { slow: 600, fast: 200 }[opt.duration]) || 400;
        var self = this;
        A.each(elements, function(elem){
            if( !D.queue.add(elem) || elem.nodeType != 1){
                return false;
            }
            for ( var p in prams ){
                if ( p == "height" || p == "width" ){
                    opt.display = $$D.css(elem, "display");
                    opt.overflow = $$D.css(elem, "overflow");
                }
                if ( A.isArray( prams[p] ) ) {
                    (opt.specialEasing = opt.specialEasing || {})[p] = prams[p][1];
                    opt[p] = prams[p] = prams[p][0];
                }
            }
            opt.curAnim = prams;
            A.each(prams, function(val, name){
                var obj = new D.animExt( elem,  opt, name);
                var parts = val.toString().match(/^([+-]=?)?([\d+-.]+)(.*)$/),
                    start = parseFloat( $$D.css(elem, name) ) || 0;
                if( name == 'opacity' ){
                	start = B.msie ? start : start*100;
                }
                if( parts ){
                    var end = parseFloat(parts[2]),
                        unit = parts[3] || "px";
                    if( parts[1] )
                    	end = ((parts[1].indexOf('-')>-1 ? -1 : 1) * end) + (parts[1].indexOf('=')>-1 ? 0 : start);
                    obj.custom(start, end, unit);
                }
                else
                    obj.custom(start, val, "");
            });
        });
    },
    easing: {
        linear: function( p, n, firstNum, diff ) {
            return firstNum + diff * p;
        },
        swing: function( p, n, firstNum, diff ) {
            return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
        },
        easeInQuad: function (x, t, b, c, d) {
            return c*(t/=d)*t + b;
        },
        easeOutQuad: function (x, t, b, c, d) {
            return -c *(t/=d)*(t-2) + b;
        },
        easeInOutQuad: function (x, t, b, c, d) {
            if ((t/=d/2) < 1) return c/2*t*t + b;
            return -c/2 * ((--t)*(t-2) - 1) + b;
        },
        easeInCubic: function (x, t, b, c, d) {
            return c*(t/=d)*t*t + b;
        },
        easeOutCubic: function (x, t, b, c, d) {
            return c*((t=t/d-1)*t*t + 1) + b;
        },
        easeInOutCubic: function (x, t, b, c, d) {
            if ((t/=d/2) < 1) return c/2*t*t*t + b;
            return c/2*((t-=2)*t*t + 2) + b;
        },
        easeInQuart: function (x, t, b, c, d) {
            return c*(t/=d)*t*t*t + b;
        },
        easeOutQuart: function (x, t, b, c, d) {
            return -c * ((t=t/d-1)*t*t*t - 1) + b;
        },
        easeInOutQuart: function (x, t, b, c, d) {
            if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
            return -c/2 * ((t-=2)*t*t*t - 2) + b;
        },
        easeInQuint: function (x, t, b, c, d) {
            return c*(t/=d)*t*t*t*t + b;
        },
        easeOutQuint: function (x, t, b, c, d) {
            return c*((t=t/d-1)*t*t*t*t + 1) + b;
        },
        easeInOutQuint: function (x, t, b, c, d) {
            if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
            return c/2*((t-=2)*t*t*t*t + 2) + b;
        },
        easeInSine: function (x, t, b, c, d) {
            return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
        },
        easeOutSine: function (x, t, b, c, d) {
            return c * Math.sin(t/d * (Math.PI/2)) + b;
        },
        easeInOutSine: function (x, t, b, c, d) {
            return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
        },
        easeInExpo: function (x, t, b, c, d) {
            return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
        },
        easeOutExpo: function (x, t, b, c, d) {
            return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
        },
        easeInOutExpo: function (x, t, b, c, d) {
            if (t==0) return b;
            if (t==d) return b+c;
            if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
            return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
        },
        easeInCirc: function (x, t, b, c, d) {
            return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
        },
        easeOutCirc: function (x, t, b, c, d) {
            return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
        },
        easeInOutCirc: function (x, t, b, c, d) {
            if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
            return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
        },
        easeInElastic: function (x, t, b, c, d) {
            var s=1.70158;var p=0;var a=c;
            if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
            if (a < Math.abs(c)) { a=c; var s=p/4; }
            else var s = p/(2*Math.PI) * Math.asin (c/a);
            return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
        },
        easeOutElastic: function (x, t, b, c, d) {
            var s=1.70158;var p=0;var a=c;
            if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
            if (a < Math.abs(c)) { a=c; var s=p/4; }
            else var s = p/(2*Math.PI) * Math.asin (c/a);
            return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
        },
        easeInOutElastic: function (x, t, b, c, d) {
            var s=1.70158;var p=0;var a=c;
            if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
            if (a < Math.abs(c)) { a=c; var s=p/4; }
            else var s = p/(2*Math.PI) * Math.asin (c/a);
            if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
            return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
        },
        easeInBack: function (x, t, b, c, d, s) {
            if (s == undefined) s = 1.70158;
            return c*(t/=d)*t*((s+1)*t - s) + b;
        },
        easeOutBack: function (x, t, b, c, d, s) {
            if (s == undefined) s = 1.70158;
            return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
        },
        easeInOutBack: function (x, t, b, c, d, s) {
            if (s == undefined) s = 1.70158; 
            if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
            return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
        },
        easeInBounce: function (x, t, b, c, d) {
            return c - D.easing.easeOutBounce (x, d-t, 0, c, d) + b;
        },
        easeOutBounce: function (x, t, b, c, d) {
            if ((t/=d) < (1/2.75)) {
                return c*(7.5625*t*t) + b;
            } else if (t < (2/2.75)) {
                return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
            } else if (t < (2.5/2.75)) {
                return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
            } else {
                return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
            }
        },
        easeInOutBounce: function (x, t, b, c, d) {
            if (t < d/2) return D.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
            return D.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
    },
    queue: {
        queue: [],
        add: function(obj){
            var Q = this.queue;
            for(var i = 0; i < Q.length; i++ ){
                if ( Q[i] == obj ) return false;
            }
            Q.push(obj);
            return true;
        },
        remove:function(obj){
            var Q = this.queue, NQ = [];
            for(var i = 0; i < Q.length; i++ ){
                 Q[i] != obj && NQ.push(Q[i]);
            }
            this.queue = NQ;
        }
    },
    timers: [],
    timerId: null,
    animExt: function( elem, options, prop ){
        this.options = options;
        this.elem = elem;
        this.prop = prop;
    },
    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 && !$$B.opera)
            d.addEventListener( "DOMContentLoaded", done, false );
        if ( $$B.ie && window == top ) (function(){
            if (isReady) return;
            try {
                d.documentElement.doScroll("left");
            } catch( e ) {
                setTimeout( arguments.callee, 0 );
                return;
            }
            done();
        })();
        if ( $$B.opera )
            document.addEventListener( "DOMContentLoaded", function () {
                if (isReady) return;
                var l = document.styleSheets.length;
                for (var i = 0; i < l; i++)
                    if (document.styleSheets[i].disabled) {
                        setTimeout( arguments.callee, 0 );
                        return;
                    }
                done();
            }, false);
        if ( $$B.safari ) {
            var numStyles;
            (function(){
                if (isReady) return;
                if ( document.readyState != "loaded" && document.readyState != "complete" ) {
                    setTimeout( arguments.callee, 0 );
                    return;
                }
                if ( numStyles === undefined )
                    numStyles = NtUtil.$$(" style, link").length;
                if ( document.styleSheets.length != numStyles ) {
                    setTimeout( arguments.callee, 0 );
                    return;
                }
                done();
            })();
        }
    }
};
D.Doc = document.documentElement || document.body;
E = (function(){
    var addEvent, removeEvent, guid = 1;
    if ( window.addEventListener ) {
        addEvent = function( elem, type, handler ){
            elem.addEventListener(type, handler, false);
        };
        removeEvent = function( elem, type, handler ){
            elem.removeEventListener(type, handler, false);
        };
    } else {
        addEvent = function( elem, type, handler ){
            elem.attachEvent( "on"+type, handler);
        };
        removeEvent = function( elem, type, handler ){
            elem.detachEvent("on"+type, handler) ;
        };
    }
    function fixEvent(event) {
        if (event && event.target) return event;
        event = window.event;
        event.pageX = event.clientX + D.getScrollLeft();
        event.pageY = event.clientY + D.getScrollTop();
        event.target = event.srcElement;
        event.stopPropagation = stopPropagation;
        event.preventDefault = preventDefault;
        switch (event.type) {
            case "mouseout" :
                event.relatedTarget = event.toElement; break;
            case "mouseover" :
                event.relatedTarget = event.fromElement; break;
        };
        return event;
    };
    function stopPropagation() { this.cancelBubble = true; };
    function preventDefault() { this.returnValue = false; };
    return {
        "addEvent": addEvent,
        "removeEvent": removeEvent,
        "fixEvent": fixEvent
    };
})();
S = {
    isDefined: function(a){
        return typeof a != "undefined";
    },
    camelize: function(s){
        return s.replace(/-([a-z])/ig, function(all, letter) { return letter.toUpperCase(); });
    },
    toArray: function(s){
        var a=[],ta=[],tta=[],l;
        ta = s.split(";");l  = ta.length;
        for(i=0; i<l; i++){
            if(ta[i]){
                tta = ta[i].split(':');
                a[tta[0]] = tta[1];
            }
        }
        return a;
    },
    len: function(s){
        if(!s) return 0;
        var c = 0, l = s.length;
        for(var i=0; i<l; i++){
            if(s.charCodeAt(i)>255) c += 2;else c += 1;
        }
        return c;
    },
    cut: function(s,l,e){
        if(!s) return 0;
        var c = 0, ml = l*2, l = s.length, cl = S.len(s);
        var cs = "";
        if(cl<=ml)
            return cl%2>0 ? s+" " : s;
        else{
            for(var i=0; i<l; i++){
                if(s.charCodeAt(i)>255){ c += 2;}else{ c += 1;}
                if(c==ml || (e&&c==ml-2) ){
                    cs = s.substring(0, i+1) + (e?"..":"");
                    break;
                }else if(c>ml || (e&&c>ml-2)){
                    cs = s.substring(0, i)+" " + (e?"..":"");
                    break;
                }
            }
            return cs;
        }
    }
};
C = {
    include: function(src, type){
        var t = type || 'SCRIPT',arrt = t=='SCRIPT' ? 'src' : 'href';
        var targets = window.document.getElementsByTagName(t);
        A.each(targets, function(target){
            var attr = target.getAttribute(arrt);
            if( attr && attr.indexOf(src) > -1 ) return true;
        });
        return false;
    },
    script: function(src, charset, remove, callback){
        if( typeof src == 'undefined' ) 
            return;
        var head = document.getElementsByTagName("HEAD")[0], 
            elem = document.createElement("SCRIPT"), 
            done = false;
        elem.setAttribute('language', 'javascript');
	    elem.setAttribute('type', 'text/javascript');
	    if( charset ) elem.setAttribute('charset', charset);
	    elem.setAttribute('src',src);
        elem.onload = elem.onreadystatechange = elem.onerror = function(){
            if ( !done && ( !this.readyState || /loaded|complete/.test(this.readyState) ) ) {
                done = true;
                if( F.isFunction(callback) ) callback();
                if( remove !== false ){
                	try{
                    	head.removeChild( elem );
                    }catch(e){}
                }
            }
        };
        head.appendChild(elem);
        return elem;
    },
	ready: function(srcElement, callback){
		var done = false;
		if( !srcElement ){
			return;
		}
		srcElement.onload = srcElement.onreadystatechange = srcElement.onerror = function(){
            if ( !done && ( !this.readyState || /loaded|complete/.test(this.readyState) ) ) {
            	done = true;
            	if( F.isFunction(callback) ) callback();
            }
    	};
	},
    link: function(src){
        var css = document.createElement("LINK");
        css.type= 'text/css';
        css.rel = 'stylesheet';
        css.href= src;
        document.getElementsByTagName("HEAD")[0].appendChild(css);
        return css;
    },
    addSheet:function(cssCode,styleElement){
        var doc = document;
        cssCode = cssCode + "\n";
        var headElement = doc.getElementsByTagName("head")[0];
        styleElement = styleElement || doc.createElement('STYLE');
        styleElement.setAttribute("type", "text/css");
        headElement.appendChild(styleElement);
        if(styleElement.styleSheet){    
            styleElement.styleSheet.cssText += cssCode;
        }else if(doc.getBoxObjectFor){
            styleElement.innerHTML += cssCode;
        }else{
            styleElement.appendChild(doc.createTextNode(cssCode));
        }
        return styleElement;
    },
    image: function(url, callback){
    	this.img = new Image();
		this.img.src = url; 
		var self = this;
		if (this.img.complete) {
			if ( typeof callback == 'function' ) callback.call(self.img, self.img); 
			return self.img;
		} 
		this.img.onload = function () {
			if ( typeof callback == 'function' ) callback.call(self.img, self.img); 
		}; 
		return this.img;
    }
};
J = (function(){
	function f(n) {
        return n < 10 ? '0' + n : n;
    }
    if (typeof String.prototype.toJSON !== 'function') {
        Date.prototype.toJSON = function (key) {
            return this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z';
        };
        String.prototype.toJSON =
        Number.prototype.toJSON =
        Boolean.prototype.toJSON = function (key) {
            return this.valueOf();
        };
    }
    var toJSONString, parseJSON, gap, indent, rep, 
        cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        meta = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'};
    function quote(string) {
        escapable.lastIndex = 0;
        return escapable.test(string) ?
            '"' + string.replace(escapable, function (a) {
                var c = meta[a];
                return typeof c === 'string' ? c :
                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            }) + '"' :
            '"' + string + '"';
    }
    function str(key, holder) {
        var i, k, v, length, partial,
            mind = gap,
            value = holder[key];
        if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }
        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }
        switch (typeof value) {
        case 'string':
            return quote(value);
        case 'number':
            return isFinite(value) ? String(value) : 'null';
        case 'boolean':
        case 'null':
            return String(value);
        case 'object':
            if (!value) {
                return 'null';
            }
            gap += indent;
            partial = [];
            if (Object.prototype.toString.apply(value) === '[object Array]') {
                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }
                v = partial.length === 0 ? '[]' :
                    gap ? '[\n' + gap +
                            partial.join(',\n' + gap) + '\n' +
                                mind + ']' :
                          '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }
            if (rep && typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    k = rep[i];
                    if (typeof k === 'string') {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {
                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }
            v = partial.length === 0 ? '{}' : 
                   gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : 
                   '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }
    toJSONString = function(value, replacer, space){
        var i, gap = '', indent = '';
        if (typeof space === 'number') {
            for (i = 0; i < space; i += 1) {
                indent += ' ';
            }
        } else if (typeof space === 'string') {
            indent = space;
        }
        rep = replacer;
        if (replacer && typeof replacer !== 'function' &&
                (typeof replacer !== 'object' ||
                 typeof replacer.length !== 'number')) {
            throw new Error('JSON.toString');
        }
        return str('', {'': value});
    };
    parseJSON = function(text, reviver){
        var j;
        function walk(holder, key) {
            var k, v, value = holder[key];
            if (value && typeof value === 'object') {
                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = walk(value, k);
                        if (v !== undefined) {
                            value[k] = v;
                        } else {
                            delete value[k];
                        }
                    }
                }
            }
            return reviver.call(holder, key, value);
        }
        text = String(text);
        cx.lastIndex = 0;
        if (cx.test(text)) {
            text = text.replace(cx, function (a) {
                return '\\u' +
                    ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            });
        }
        if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
                           .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
                           .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
            j = eval('(' + text + ')');
            return typeof reviver === 'function' ?
                walk({'': j}, '') : j;
        }
        throw new SyntaxError('JSON.toJSON');
    };
    return {
        'toJSONString': toJSONString,
        'parseJSON': parseJSON
    };
})();
if (B.ie6) {
    try {
        document.execCommand("BackgroundImageCache", false, true);
    } catch(e) {}
};
$$O = O; $$selector = select; $$B = B; $$A = A; $$F = F; $$D = D; $$E = E; $$S = S; $$C = C, $$J = J;
})();
$$D.animExt.prototype = {
    update: function(){
        switch(this.prop.toLowerCase()){
            case "scrollleft":
                this.elem.scrollLeft = this.now;break;
            case "scrolltop":
                this.elem.scrollTop = this.now;break;
            case "opacity":
                if ( $$B.msie ) 
                    this.elem.style.filter = "alpha(opacity:"+(this.now)+")";
                else if ( $$B.mozilla ) 
                    this.elem.style.MozOpacity = this.now/100;
                else{
                    this.elem.style.opacity = this.now/100;
                }
                break;
            default: this.elem.style[this.prop] = this.now + this.unit;
        }
    },
    custom: function(from, to, unit){
        this.startTime = (new Date()).getTime();
        this.start = from;
        this.end = to;
        this.unit = unit || "px";
        this.now = this.start;
        this.pos = this.state = 0;
        this.update();
        var self = this;
        function t(gotoEnd){
            return self.step(gotoEnd);
        }
        t.elem = this.elem;
        if ( t() && $$D.timers.push(t) && $$D.timerId == null ) {
            $$D.timerId = setInterval(function(){
                var timers = $$D.timers;
                for ( var i = 0; i < timers.length; i++ ){
                    if ( !timers[i]() )
                        timers.splice(i, 1);
                }
                if ( !timers.length ) {
                    clearInterval( $$D.timerId );
                    $$D.timerId = null;
                }
            }, 13);
        }
    },
    step: function(gotoEnd){
        var t = (new Date()).getTime();
        if( gotoEnd || t > this.options.duration + this.startTime ){
            this.now = this.end;
            this.pos = this.state = 1;
            this.update();
            this.options.curAnim[ this.prop ] = true;
            var done = true;
            for ( var i in this.options.curAnim )
                if ( this.options.curAnim[i] !== true )
                    done = false;
            $$D.queue.remove(this.elem);
            if ( done && typeof( this.options.complete )=='function' ){
                this.options.complete.apply(this, [this.elem] );
            }
            return false;
        }
        else{
            var n = t - this.startTime;
            this.state = n / this.options.duration;
            var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
            var defaultEasing = this.options.easing || ($$D.easing.swing ? "swing" : "linear");
            this.pos = $$D.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
            this.now = this.start + ((this.end - this.start) * this.pos);
            this.update();
        }
        return true;
    }
};
NtUtil = {};
NtUtil.setCookie = function(a, f, d, c) {
    if (typeof d != "number" && !(d instanceof Date)) {
        d = (1 * 24 * 60 * 60 * 1000);
    }
    var b, e;
    if (d instanceof Date) {
        b = d;
        e = b ? "expires=" + b.toGMTString() + "; ": "";
    } else {
    	if ( d == 0 ){
    		b = 0;
    		e = "expires=0; ";
        }else if (d > 0) {
            b = new Date();
            b.setTime(b.getTime() + d);
            e = b ? "expires=" + b.toGMTString() + "; ": "";
        }
    }
    var k = a + "=" + encodeURIComponent(f) + "; ";
    var g = /([^\.]+(\.com(\.cn)?|\.net(\.cn)?|\.org(\.cn)?|\.gov(\.cn)?|\.cn|\.mobi|\.tel|\.asia|\.me|\.info|\.hk|\.cc|\.biz|\.tv))$/i.exec(document.domain);
    g = c || (g ? g[0] : document.domain);
    var c = "domain=" + g + "; ";
    var h = "path=/; ";
    document.cookie = k + e + c + h;
    return f;
};
NtUtil.delCookie = function(b, a) {
    return NtUtil.setCookie(b, "", new Date(), a);
};
NtUtil.getCookie = function(b) {
    var c = document.cookie;
    if (c.length) {
        var a = new RegExp("(?:^|;)\\s*" + b + "=(.*?)(?:;|$)").exec(c);
        if (a && a.length) {
            return decodeURIComponent(a[1]);
        }
    }
    return null;
};
NtUtil.saveValue = function(userId, key, value){
	var impresenceflash = $$O('impresenceflash');
	if( impresenceflash && impresenceflash.write ){
		impresenceflash.write(userId, key, value);
	}
};
NtUtil.loadValue = function(userId, key){
	var impresenceflash = $$O('impresenceflash');
	if( impresenceflash && impresenceflash.write ){
		return impresenceflash.read(userId, key);
	}
	return '';
};
NtUtil.$$ = function(selector, pe) {
    var q = /^\s+(\w+)$|^#(\w+)$|^\.(\w+)$|^\$(\w+)$/;var se  = selector || document;
    var a = [];pe = pe ? pe : document;
    pe = $$A.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 ){
            var query = se.split(","), l = query.length;
            for(var i=0;i<l; i++){
                if(query[i]){
                    var ta = this.$$(query[i], pe), tl = ta.length;
                    for(var j=0; j<tl; j++){
                        a.push(ta[j]);
                    }
                }
            }
            return a;
        }
        else if(se=="*") return all; else return [];
    }
};
NtUtil.scrollWidth = function(){
    if($$B.ie6 && document.getElementsByTagName('body')[0].currentStyle["overflowY"] == 'hidden'){
        return 18;
    }else if( ( !$$B.msie && $$D.Doc.scrollHeight>$$D.windowRect().h) || $$B.mozilla && document.defaultView.getComputedStyle(document.getElementsByTagName('html')[0], null)["overflowY"]=="scroll"){
        return 18;
    }else if($$B.ie6){
        return 2;
    }else{
        return 1;
    }
};
NtUtil.insertAfter = function(newElement,targetElement) {
    var parent = targetElement.parentNode;  
    if (parent.lastChild == targetElement)
        parent.appendChild(newElement);  
    else
        parent.insertBefore(newElement,targetElement.nextSibling);  
};
NtUtil.removeChildNodes = function(elem, childNodetagName){
    if(!elem) return;
    var Nodes = childNodetagName ? elem.getElementsByTagName(childNodetagName) : elem.childNodes;
    var l = Nodes.length;
    for(var i=0; i<l;i++){
        var a = Nodes[i].attributes;
        for(var id in a){
            if(typeof(a[id])=="function"){
                if($$B.ie) eval("elem."+id+"=null");
                else{elem.removeAttribute(id);}
            }
        }
        this.removeChildNodes(Nodes[i], childNodetagName);
        elem.removeChild(Nodes[i]);
    }
};
NtUtil.EncodeSpecialChar = function(a){
    if (!a || !a.length) {
        return a;
    }
    a = a.replace(/&quot;/g, '"');
    a = a.replace(/&lt;/g, "<");
    a = a.replace(/&gt;/g, ">");
    a = a.replace(/&apos;/g, "'");
    a = a.replace(/&#39;/g, "'");
    a = a.replace(/&amp;/g, "&");
    return a;
};
NtUtil.clearHTML = function(strSource){
    if(!strSource)
        return "";
    else{
        strSource = strSource.replace(/&lt;/g,"<");
        strSource = strSource.replace(/&gt;/g,">");
        return strSource.replace(/<[^>].*?>/g,"");
    }
};
NtUtil.disposeFlashObj = function(flashObj){
    if(!flashObj || !$$B.ie)
        return;
    for(var id in flashObj){
        if(typeof(flashObj[id]) == "function"){
            if($$B.ie){
                eval("flashObj."+id+"=null");
            }
        }
    }
};
NtUtil.onlyOne = function(key, dtyp, timer){
    if(NtUtil.getCookie(key)==="1"){
        return false;
    }else{
        var d = new Date(), 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 : NtUtil.setCookie(key, "1"); return;
        }
        var t = d.getTime() - od.getTime();
        NtUtil.setCookie(key, "1", t);
        return true;
    }
};
NtUtil.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;
};
(function(){
	var path, scripts = window.document.getElementsByTagName("script");
    for(var i = 0; i<scripts.length; i++ ){
    	var src = scripts[i].getAttribute("src");
    	var mts = /(.*?)\/+imfunction(_utf8)?\.js/gi.exec(src);
    	if( mts && mts[1] ) path = mts[1];
    }
    if( !path ) path = 'http://download.ntalker.com/res';
    Ntalker.variable.scriptPath = path;
    Ntalker.Config.publicDIR = path+"/images/";
})();
var sTime, sTime1;
function im_connectIM(siteid, userid, username, sessionid, userparam, customParams, param1, param2){
	sTime = new Date().getTime();
	var _C = Ntalker.Config, _DIR, 
        _CP = Ntalker.Config.customparams,
        _V = Ntalker.variable;
    debug('im_connectIM start');
    Ntalker.temp.pageId = String(new Date().getHours()) + String(new Date().getMinutes()) + String(new Date().getUTCSeconds()) + String(Math.floor(Math.random()*100));
    _V['siteid']    = siteid;
    _V['user_id']   = userid;
    _V['user_name'] = username;
    _V['user_sid']  = sessionid;
    _V['userparam'] = userparam;
    if( siteid == 'ntalkerpreview' && customParams['previewsiteid'] ){
    	var configJsURL = _C['services'] + "/configjs/config_"+customParams['previewsiteid']+".js?rnd="+new Date().getTime();
    }else{
    	var configJsURL = _C['services'] + "/configjs/config_"+siteid+".js";
    }
    debug("create load configjs before>");
    $$C.script(configJsURL, 'utf-8', false, function(){
    	debug("loaded configjs>");
    	sTime1 = new Date().getTime();
   		if(typeof(Ntalker_Config) != 'undefined'){
    		_C['customDIR'] = _C['services'] + "/images/" + siteid+"/";
    		if( Ntalker_Config['dir'] ){
    			_DIR = Ntalker_Config['dir'];
    			_C['imagesDIR'] = _C['publicDIR'] + _DIR;
    		}else{
    			_DIR = siteid+"/";
    			_C['imagesDIR'] = _C['services'] + _DIR;
    		}
        	var skinConfig = [[]];
        	skinConfig.push(['#86D09C', '#B5DDC3', 'hue=0']);
        	skinConfig.push(['#B9CCEC', '#DCDFEA', 'hue=92.92']);
        	skinConfig.push(['#C3C6D5', '#D8E4E7', 'hue=101.19,saturation=0.75']);
        	skinConfig.push(['#E3BFEF', '#DFD4E5', 'light=-13.78,hue=164.07']);
        	skinConfig.push(['#DCD3AC', '#E5E0D5', 'hue=-79.78,light=9.26']);
        	skinConfig.push(['#D4C1EA', '#D6D3E4', 'hue=149.96']);
        	skinConfig.push(['#D5D5D5', '#C9C9C9', 'saturation=0']);
        	skinConfig.push(['#BCDCB5', '#E0E6D6', 'hue=-22.5,light=10.61']);
        	skinConfig.push(['#B0DDD6', '#D5E5E1', 'hue=36.73']);
        	skinConfig.push(['#E9C5B7', '#E4D3D3', 'hue=-114.81']);
        	for(var i=1; i<skinConfig.length; i++){
        		if( Ntalker_Config["skin"] == 'ntalker_skin'+i ){
        			_C['bColor'] = skinConfig[i][0];
        			_C['bgColor'] = skinConfig[i][1];
        			_C['skin'] = skinConfig[i][2];
        		}else if( Ntalker_Config["skin"] == skinConfig[i][2] ){
        			_C['bColor'] = skinConfig[i][0];
        			_C['bgColor'] = skinConfig[i][1];
        			_C['skin'] = skinConfig[i][2];
        		}
        	}
	        if( Ntalker_Config['config'] ){
	            _C['customparams'] = Ntalker_Config['config'];
	        }
	        if( _C['customparams'] ){
	        	_C['IMWidth'] = _C['customparams']['IMWidth'];
	            _C['IMHeight'] = _C['customparams']['IMHeight'];
	            _C['chatWidth'] = _C['customparams']['chatWidth'];
	            _C['chatHeight'] = _C['customparams']['chatHeight'];
	            _C['groupWidth'] = _C['customparams']['groupWidth'];
	            _C['groupHeight'] = _C['customparams']['groupHeight'];
	        }
	        var _L = Ntalker_Config['logo'];
	        if( _L ){
	        	_C['buddylistlogo'] = _L['buddylistlogo'] ? (_C['customparams']['favicon'] ? _C['customparams']['favicon'] : siteid+"/logo_big.png") : "/buddylistlogo.png";
		        _C['chatlogo'] = _L['chatlogo'] ? siteid+"/logo_small.png" :  "/buddylistlogo.png";
		        _C['nquanlogo'] = _L['nquanlogo'] ? siteid+"/nquanlogo.png" : "/nquanlogo.png";
		        _C['grouplogo'] = _L['grouplogo'] ? siteid+"/grouplogo.png" : "/nquanlogo.png";
		        _C['chatroomlogo'] = _L['chatroomlogo'] ? siteid+"/chatroomlogo.png":"/nquanlogo.png";
		        if( !_L['buddylistlogo'] ){
		        	_C['logo'] = _C['imagesDIR'] + "buddylistlogo." + ($$B.ie6 ? 'gif' : 'png');
		        }else if( _C['customparams']['favicon'] ){
		        	_C['logo'] = _C['services'] + "/images/" + _C['customparams']['favicon'];
		        }else{
		        	_C['logo'] = _C['customDIR'] + "/logo_big.png";
		        }
	        }
        	_C['startlogo'] = _L['startlogo'] ? _C['customDIR']+'%1.png' : _C['publicDIR']+'%1.'+($$B.ie6?'gif':'png');
	        _C['groupstartlogo']= _C['publicDIR'] + "/group."+($$B.ie6 ? 'gif' : 'png');
	        if( Ntalker_Config['customButtons'] ){
	            _C['customtoolbarButtons'] = Ntalker_Config['customButtons'];
	        }
	        var _B = _C['customtoolbarButtons'];
	        for(var k in _B){
	            if(typeof(k)=="string" && _B[k] && _B[k].style){
	                _B[k].style = sprintf(_B[k].style, _C.services + "/images/");
	            }
	            if(typeof(k)=="string" && _B[k] && _B[k].url){
	                _B[k].url = sprintf(_B[k].url, _V['user_id'], _V['user_name']);
	            }
	        }
        	var _A = _C['application'] = Ntalker_Config['application'];
	        for(var k in _A){
	        	_A[k]['ico'] = sprintf(_A[k]['ico'], _C.services + "/images/");
	        }
	    }
	    else{
			_C['IMWidth'] = 248;
            _C['IMHeight'] = 531;
	    	_C['chatWidth'] = 384;
            _C['chatHeight'] = 416;
            _C['groupWidth'] = 460;
            _C['groupHeight'] = 531;
	        _C['skin'] = "hue=0";
	        _C['bColor'] = "#86D09C";
	        _C['bgColor'] = "#B7DDC4";
	        _C['imagesDIR'] = _C['publicDIR'] + "ntalker_skin1/";
	        _C['customDIR'] = _C['services'] + siteid+"/";
	        _C['logo'] = _C['publicDIR'] + "buddylistlogo."+($$B.ie6 ? 'gif' : 'png');
	        _C['groupstartlogo']= _C['publicDIR'] + "/group."+($$B.ie6 ? 'gif' : 'png');
	        _C['buddylistlogo']= "/buddylistlogo.png";
	        _C['nquanlogo'] = "/nquanlogo.png";
	        _C['grouplogo'] ="/nquanlogo.png";
	        _C['chatroomlogo'] = "/nquanlogo.png";
	        _C['startlogo'] = _C['publicDIR'] + '%1.' + ($$B.ie6?'gif':'png');
	        _C['customparams'] = {
	        	lstupdated: new Date().getTime(),
		        floatpos: "right",
		        intact: 0,
		        hiddenmode: 0,
		        sys_enableguest: 1,
		        introbuddy: 1,
		        onlinelist: 1,
		        disablegrouptip: 0,
		        search: 1,
		        avroom: 0,
		        entrytype: "toolbar",
		        imversion: "1.0",
		        order: "1",
		        roomtype: 0,
		        localeChain: "zh_CN",
		        siteurl: "http://www.ntalker.com",
		        enablebuddyentry: 1,
		        showmode: "show",
		        build: "",
		        favicon: "",
		        enablegroup: 0,
		        enableroom: 1,
		        softwaretype: "other",
		        quanflag:1
	        };
	    }
	    if(_C['customparams'].hiddenmode) return;
	    NtLang = gLang[_C['customparams']['localeChain']];
	    debug("loaded configjs variable>");
    	$$C.link(_C['imagesDIR'] + 'ntalkerToolbar.css');
	    debug("create css element>");
	    if(typeof customParams=='object'){
	        for(var k in customParams){
	            Ntalker.Config.customparams[k] = customParams[k];
	        }
	    }
    	debug("get customParams>");
	    im_runPresence(_V['userparam'], _V['siteid'], _V['user_id'], _V['user_name'], _V['user_sid'], '', '', _CP);
	    debug("<b>complete</b>>" + (parseInt(new Date().getTime()) - parseInt(sTime)));
    });
}
function im_runPresence(userparam, siteid, userid, username, sessionid, flashserver, webchatpageurl, customParams) {
	var _C = Ntalker.Config,
        _CP = Ntalker.Config.customparams,
        _V = Ntalker.variable;
    if( userid=='0' || userid==0 || userid=='' || sessionid=='' ){
        if( !_CP["sys_enableguest"] ){
            return;
        }
        var userNO = NtUtil.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     = NtLang['userIdHead']   + userNO;
            username   = NtLang['userNameHead'] + userNO;
        }else{
            userid     = NtLang['userIdHead']   + userNO;
            username   = NtLang['userNameHead'] + userNO;
        }
        sessionid      = NtLang['guestSessionId'];
        NtUtil.setCookie(Ntalker.guestUserNoKEY, userNO, 1000*3600*24*7);
        _V['user_id']   = userid;
    	_V['user_name'] = username;
    	_V['user_sid']  = sessionid;
    }
    if( !username || username=='' ){
    	_V['user_name'] = 'name';
    }
    debug("get user info complete>");
   	createGestFlashConnet(siteid, _C['isPopupMode']);
    im_runPresenceStart();
    debug("<b>create toolbar before</b>>" + (parseInt(new Date().getTime()) - parseInt(sTime1)));
    if(_V['user_sid'] && _V['user_name'] && _V['user_id']){
    	_CP['showmode'] = _CP['showmode'] == 'hidden' ? 'hidden' : 'show';
        if( (_CP['softwaretype'] || '').toLowerCase() == 'phpwind' && $$O('startbar') && _CP['entrytype']=='pwtoolbar' ){
            _CP['layout'] = 'pwtoolbar';
            IMToolBar = new NtPHPwindTbar();
            IMToolBar.init( $$O('startbar') );
        }
        else if( $$O('ntalker') && _CP['entrytype'] == 'topcascade' ){
            _CP['layout'] = 'topcascade';
            IMToolBar = new NtTopTbar();
            IMToolBar.init($$O('ntalker'));
        }
        else{
            _CP['layout'] = 'dztoolbar';
            IMToolBar = new NtDiscuzTbar();
            IMToolBar.init();
        }
    }
}
function fIM_presenceFlashReady(){
    setTimeout(function(){
        StartGetUsersStatus();
        StartGetGroupEntry();
        if(Ntalker.Config.isPopupWindow == 1){
            IM_initPopuWindowScript();
        }
        if($$O("impresenceflash") && $$O("impresenceflash").setPageFocus){
            $$O("impresenceflash").setPageFocus(true);
        }
    }, 50);
    return true;
}
function fIM_chatDataFlashReady(){
	Ntalker.temp.chatDataFlashReady = true;
}
function createGestFlashConnet(siteid, popup){
    var flashvars = [], _C = Ntalker.Config,
    	_CP= Ntalker.Config.customparams,
        _V = Ntalker.variable;
    _V['siteid'] = siteid;
    flashvars.push("siteid=" + siteid + "&ispopup=" + (popup ? "1" : "0"));
    flashvars.push('&rurl=' + _V['scriptPath']);
    flashvars.push('&surl=' + _C['services']);
    flashvars.push('&pageId=' + Ntalker.temp.pageId);
    flashvars.push('&u=' + encodeURIComponent(_V['user_id']));
    flashvars.push('&n=' + encodeURIComponent(_V['user_name']));
    flashvars.push('&s=' + encodeURIComponent(_V['user_sid']));
    flashvars.push('&p=' + _V['userparam']);
    flashvars.push('&lst=' + _CP['lstupdated']);
    var flashurl  = _V['scriptPath']+"/fs/impresence.swf?version=" + Ntalker.version.presence_flash;
    if($$B.ie){
        var flashnode = [];
        flashnode.push('<div id=\"wdk_mini_state\" style=\"display:none;\"></div>');
        flashnode.push('<div id="im_presence_div" style=\"position:absolute;z-index:9996; top: -200px;\">');
        flashnode.push('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28" ');
        flashnode.push(' id="impresenceflash" width="1" height="1"> ');
        flashnode.push('    <param name="movie" value="'+flashurl+'" /> ');
        flashnode.push('    <param name="allowscriptaccess" value="always" /> ');
        flashnode.push('    <param name="flashvars" value="'+flashvars.join('')+'" /> ');
        flashnode.push('</object>');
        flashnode.push('</div>');
        debug("createGestFlashConnet insert.before>");
        $$D.insert(document.body.firstChild, flashnode.join(''), 'beforebegin');
        debug("createGestFlashConnet insert.complete>");
    }
    else{
        var flashnode = [];
        flashnode.push('<div id=\"wdk_mini_state\" style=\"display:none; \"></div>');
        flashnode.push('<div id="im_presence_div" style=\"position:absolute;z-index:9996; top: -200px;\">');
        flashnode.push(    '<embed src="' + flashurl + '" id="impresenceflash" width="1" height="1" flashvars="'+flashvars.join('')+'" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" >');
        flashnode.push(    '</embed>');
        flashnode.push('</div>');
        $$D.insert(document.body.firstChild, flashnode.join(''), 'beforebegin');
    }
}
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] || "").toString() );
    }
    return b;
}
function searchTag(target, tagName){
    if(!tagName || !target) return target;
    while((target.nodeType!=1 || target.tagName.toLowerCase() != tagName.toLowerCase()) && target.parentNode){ target = target.parentNode;}
    return target;
}
function fIM_setPackageVersion(packageVersion, bbsType, hotserver){
    return;
}
function fIM_checkPopupWin(){
    if(Ntalker.Config.isPopupMode){
        $$O("impresenceflash").runJSFunction("fIM_setPopupMode", true);
    }
    return true;
}
function fIM_setPopupMode(isPopupMode){
    var _C = Ntalker.Config;
    setTimeout(function(){
        _C['isPopupMode'] = isPopupMode ? true : false;
        if(_C['isPopupMode'] && _C['isPopupWindow'] == 0)
            fIM_hiddenToolBar();
        else
            fIM_visibleToolBar();
    },200);
    return true;
}
function StartGetUsersStatus(){
    statusSpans = document.getElementsByTagName("SPAN");
    spanindex = 0;
    var _arrSpan      = new Array();
    Ntalker.temp.userSpanArray = new Array();
    var strUserIDList = "", l = statusSpans.length;
    for(i = 0; i < l; i++){
        var 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 _presenceFlash = $$O("impresenceflash");
    Ntalker.temp.userSpanArray = _arrSpan;
    if( Ntalker.Config.customparams["enablebuddyentry"]){
        if(_presenceFlash && _presenceFlash.requestUserStatus){
            _presenceFlash.requestUserStatus(strUserIDList, _arrSpan.length);
        }
    }
}
function StartGetGroupEntry() {
    var _C = Ntalker.Config, _CP= Ntalker.Config.customparams;
    var enablegroup = _CP['enablegroup'];
    var statusSpans = document.getElementsByTagName("SPAN");
    var spanindex = 0, l = statusSpans.length;
    for (i = 0; i < l; i++){
        var 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 = NtUtil.EncodeSpecialChar(statusSpan.title);
                newGroupObj.roomtype  = 1;
                  im_conncetChatRoom(newGroupObj.groupid, newGroupObj.groupnick);
                var tiptext = sprintf(NtLang['pageGroupsEntranceTip'][0], newGroupObj.groupnick);
                chatLinkStr = "<a  href=\"#\" target=\"_blank\" style=\"display:inline;padding-left:7px; overflow:hidden;\" alt=\"" + tiptext + "\"";
                chatLinkStr += " onClick=\"javascript: im_openWebchatWindow('" + newGroupObj.groupid + "', '" + newGroupObj.groupnick + "', null, 1, 'room', "+newGroupObj.roomtype+",'pageStateEntrance'); 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=\"" + _C['groupstartlogo'] + "\" 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 = NtUtil.EncodeSpecialChar(statusSpan.title);
                var tiptext = sprintf(NtLang['pageGroupsEntranceTip'][1], newGroupObj.groupnick);
                chatLinkStr = "<a  href=\"#\" target=\"_blank\" style=\"display:inline;padding-left:7px; overflow:hidden;\" alt=\"" + tiptext + "\"";
                chatLinkStr += " onClick=\"javascript: im_openWebchatWindow('" + newGroupObj.groupid + "', '" + newGroupObj.groupnick + "', null, 1, 'group',0,'pageStateEntrance'); return false;\">";
                chatLinkStr += "<img name=\"wdk_presence_image\" id=\"wdk_presence_" + newGroupObj.groupid + "\" border=\"0\" style=\"display:inline;";
                chatLinkStr += "\" src=\"" + _C['groupstartlogo'] + "\" title=\"" + tiptext + "\"/></a>";
                statusSpan.innerHTML = chatLinkStr;
		        $$O("wdk_presence_"+newGroupObj.groupid).onerror = function(){
		        	$$O("wdk_presence_"+newGroupObj.groupid).src = errsrc;
		        	$$O("wdk_presence_"+newGroupObj.groupid).onerror = null;
		    	};
                spanindex++;
            }
        }
    }
}
function fIM_onGetUserStatus(responseText){
    var _C = Ntalker.Config,
        _CP= Ntalker.Config.customparams,
        _V = Ntalker.variable;
    var _temp= Ntalker.temp;
    if(responseText=="-1" || responseText=="-2" || _CP["hiddenmode"])
        return;
    var userStatusArray = responseText.split(",");
    var l = _temp.userSpanArray.length;
    for(i = 0;i < l; i++){
        var imgsrc = errsrc = '';
        switch(userStatusArray[i]){
        case "0":
            imgsrc = sprintf(_C['startlogo'], "offline");
            errsrc = _C['publicDIR'] + "/offline."+($$B.ie6?"gif":"png");
            break;
        case "1":
            imgsrc = sprintf(_C['startlogo'], "online");
            errsrc = _C['publicDIR'] + "/online."+($$B.ie6?"gif":"png");
            break;
        }
        chatLinkStr =  '<a  href="javascript:void(0);" style="display:inline;padding:0px;overflow:visible;" alt="' + NtLang['pageStatusTip'] + '"';
        chatLinkStr += "onClick=\"javascript: im_openWebchatWindow('" + _temp.userSpanArray[i].destuid+"', '" + _temp.userSpanArray[i].destnick + "', null, 1, 'chat',0,'pageStateEntrance'); return false;\" >";
        chatLinkStr += '<img name="wdk_presence_image" style="display:inline;left:0px;top:0px;" id="wdk_presence_'+_temp.userSpanArray[i].destuid+'" border="0" src="'+imgsrc+'" />';
        chatLinkStr += '</a>';
        _temp.userSpanArray[i].spanElement.style.border = '';
        _temp.userSpanArray[i].spanElement.innerHTML = chatLinkStr;
        var spanId = "wdk_presence_"+_temp.userSpanArray[i].destuid;
        $$O(spanId).onerror = function(){
        	$$O(spanId).src = errsrc;
        	$$O(spanId).onerror = null;
    	};
    }
}
function im_openWebchatWindow(destuid, destname, chatid, OpenType, chatType, roomtype, befrom){
    var _C = Ntalker.Config,_CP= Ntalker.Config.customparams,_V = Ntalker.variable;
    var OpenType = OpenType===true||OpenType===1 ? 1 : (OpenType===-1 ? -1 : 0);
    chatType = /^(chat|group|room|nquan)$/.test(chatType) ? chatType : 'chat';
    if( !_V['user_sid'] || !_V['user_name'] ){
        if( chatType=="room" && roomtype==1 && _CP["sys_enableguest"]){
            im_popupGroupWindow(null, null, null, _V['siteid'], destuid, destname, null, '', 0, 1);
            return;
        }else{
            alert(NtLang.notLogin);
            return;
        }
    }
    if( IMToolBar && IMToolBar._disable){
        alert(NtLang['connectErr']);return;
    }
    if( _C['isPopupMode'] && _C['isPopupWindow'] == 0){
        $$O("impresenceflash").runJSFunction("fIM_openPopupChatWindow", [[destuid, destname, chatid, chatType, roomtype]], OpenType);
    }else if(IMToolBar && IMToolBar.tbClosed){
        im_popupGroupWindow(_V['user_id'], _V['user_name'], _V['user_sid'], _V['siteid'], destuid, destname, null, _V['userparam'], 0, roomtype);
    }else{
        im_openWebchatInPage(destuid, destname, chatid, OpenType, chatType, roomtype, '', befrom);
    }
    if(IMToolBar && /^(group|room|nquan)$/.test(chatType) && IMToolBar.removeGroupMessage){
        IMToolBar.removeGroupMessage('group'+destuid);
    }
}
function im_openWebchatInPage(destuid, destname, chatid, OpenType, chatType, roomtype, userinfo, befrom){
    var _C = Ntalker.Config,_V = Ntalker.variable;
    if( _V['popupWindow'] ){
        if(_C['isPopupWindow'] == 0) return;
    }
    if(destuid==_V['user_id'] && !/^(group|room|nquan)$/.test(chatType)){
    	return;
    }
    return im_chat_window_manager.addChatWindow(destuid, destname, chatid, true, null, null, OpenType, chatType, roomtype, userinfo, befrom);
}
function im_openBuddyListWindow(OpenType, program){
    var _C = Ntalker.Config;
    if(!_C.isPopupMode || (_C.isPopupMode && _C.isPopupWindow==1)){
        setTimeout(function(){
            if(im_myIMWindow){
                im_myIMWindow.showWindow(_C.isPopupMode);
                if(_C.isPopupWindow && promptwindow && !OpenType)
                    promptwindow.startPrompt(NtLang['buddylistWindowTitle'], NtLang['zhBlank'], true);
            }else{
                alert(NtLang['buddylistNotLoginAlter']);
            }
        }, 100);
    }else{
        if(_C.isPopupWindow==0 && OpenType){
            if(program) return;
            $$O("impresenceflash").runJSFunction("im_openBuddyListWindow", OpenType, true);
        }
    }
    return true;
}
function fIM_readCookie(userId, key, value){
	var _CP = Ntalker.Config.customparams;
	switch(key){
		case Ntalker['ctKEY']:
			var strSystemMessage = value;
			if( strSystemMessage == null || strSystemMessage == '' ){
				return;
			}
			var jsonSystemMessage = $$J.parseJSON(strSystemMessage);
			for(var k in jsonSystemMessage){
				var JSON = jsonSystemMessage[k];
				if( _CP['entrytype'] == 'topcascade' ){
					IMToolBar.addSystemMessage(JSON.destuid, JSON.destname, JSON.message, JSON.chatid, JSON.headURL, JSON.content, JSON.type, JSON.srcuid, JSON.srcnick,JSON.chattype );
				}else{
					try{
						if( IMToolBar && IMToolBar.addMessageBox ){
						IMToolBar.addMessageBox(JSON.id, JSON.name, JSON.content, JSON.opentype, JSON.iconurl, JSON.msgtype,JSON.activitytype,JSON.activityid,JSON.activityname,JSON.activityicon,JSON.profileurl,JSON.chatid,JSON.isRead,JSON.msgid,JSON.srcuid,JSON.msgtime);
						}else if( IMToolBar && IMToolBar.addSystemMessage ){
							IMToolBar.addSystemMessage(JSON.destuid, JSON.destname, JSON.message, JSON.chatid, JSON.headURL, JSON.content, JSON.type, JSON.srcuid, JSON.srcnick, JSON.chattype );
						}
					}catch(e){
					}
				}
			}
			break;
		case Ntalker['gpKEY']:
			var strGroupMessage = value;
			if( strGroupMessage == null || strGroupMessage == '' ){
				return;
			}
			var jsonGroupMessage = $$J.parseJSON(strGroupMessage);
			for(var k in jsonGroupMessage){
				var JSON = jsonGroupMessage[k];
				IMToolBar&&JSON.groupid && IMToolBar.addGroupMessage(JSON.groupid, JSON.groupname, '', '', '', JSON.chattype);
			}
			break;
	}
	NtUtil.saveValue(userId, key, null);
}
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(Ntalker.Config.customparams['disablegrouptip']) return;
        if(!$$A.isArray(msg) || msg.length==0){
            msg = [{msg:NtLang['toolbarGroupTip'],user:NtLang['adminUserName']}];
        }
        var menuDisplay = $$D.css(NtUtil.$$(".ntalkermenu", $$O("ico_group"))[0], "display"),
        l = Ntalker.smileyRegexps.length;
        for(var i=0; i<l;i++)
            msg[0].msg = msg[0].msg.replace(Ntalker.smileyRegexps[i], NtLang.replaceExpression[0]);
        if(msg[0].msg.indexOf(NtLang['replaceExpression'][1])!=-1)
            msg[0].msg = NtLang['replaceExpression'][1];
        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);
        }
    },
    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){
    var elem, _param = this.param, 
        _key = this.key, 
        self = this, 
        _C = Ntalker.Config,
        _CP = Ntalker.Config.customparams;
    if( $$O(this.id) )
        return;
    this.add(msg, room);
    if(_param.wait>0){
        this.parentNode = null;
        elem = this.Element = $$D.create('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");
        elem.innerHTML  = this.getTip();
    }else{
        if(_key.indexOf("wdk_group_")>-1 )
            this.parentNode = null;
        else
            this.parentNode = $$O(_key);
        elem = this.Element = $$D.create('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("+_C['publicDIR']+"/imNt_tips_r.gif) no-repeat;"}, this.parentNode, "beforeend");
        elem.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($$O(_key)) $$D.insert($$O(_key), "<span style=\"font-size:12px;\">("+usercount+")</span>");
        }
    }
    var wRt = $$D.windowRect();
    var _icoRect = $$D.clientRect(_key);
    var _tipRect = $$D.clientRect(elem);
    if(_param.wait>0 || _key.indexOf("wdk_group_")>-1){
        var _x = _icoRect.left + _icoRect.w/2 - 12;
        var _y = _icoRect.top - _tipRect.h  + wRt.y;
        if( _x+_tipRect.w + 10 > wRt.x+wRt.w ){
            var bA = $$O('bALlOOnT'+_key);
            if(bA){bA.style.left=""; bA.style.right="4px";}
            _x = _icoRect.left + _icoRect.w/2 - _tipRect.w + 12;
            _y = _icoRect.top - _tipRect.h + wRt.y;
        }
        if( _param.wait<=0 ){
            elem.style.backgroundImage = "url("+_C['publicDIR']+"/imNt_tips_l.gif)";
            _x += 0;
            _y -= 10;
        }
    }else{
        var _y = 0 - _tipRect.h;
        if( 'topcascade'==_CP['layout'] ){
            var _x = _icoRect.w/2 - 12;
            elem.style.backgroundImage = "url("+_C['publicDIR']+"/imNt_tips_l.gif)";
        }
        else if( Ntalker.Config.customparams["floatpos"]=="right" ){
            var _x = _icoRect.w/2 + 12 + _icoRect.left;
            if(_x+_tipRect.w>wRt.x+wRt.w){
                var _x = 0 - _tipRect.w + _icoRect.w/2 + 8;
                elem.style.backgroundImage = "url("+_C['publicDIR']+"/imNt_tips_r.gif)";
            }else{
                elem.style.backgroundImage = "url("+_C['publicDIR']+"/imNt_tips_l.gif)";
            }
        }else{
            var _x = _icoRect.w/2 - 12;
            elem.style.backgroundImage = "url("+_C['publicDIR']+"/imNt_tips_l.gif)";
        }
    }
    elem.style.top  = _y + "px";
    elem.style.left = _x + "px";
    var elem = IMTipManager._curTip.Element;
    $$D.animate(elem, {opacity:"+=100"}, 400, "swing", function(){
        self.isshow = true;
        if(_param.wait>0)
            setTimeout(function(){
                IMTipManager.getIMTip(_key).close();
            }, _param.wait);
        else
            setTimeout(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, 
    	self = this,
    	elem = IMTipManager._curTip.Element;
    $$D.css(elem, "display", "block");
    $$D.animate(elem, {opacity:100}, 400, "swing", function(){
        if(param.wait>0)
            setTimeout(function(){IMTipManager.getIMTip(key).close();}, param.wait);
        else
            setTimeout(function(){
                var curTip = IMTipManager.getIMTip(key);
                if(curTip){
                    curTip.next(key, param.nextwait);
                }
            }, param.nextwait);
    });
};
_p.add = function(msg, room){
    var m = $$A.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;
        room.chattype = room.chattype?room.chattype:'group';
        this.message.push({
        	msg:m[0].msg,
        	user:m[0].user,
        	roomid:room.roomid,
        	roomname:room.roomname,
        	roomtype:room.roomtype,
        	chattype:room.chattype,
        	usercount:room.usercount
        });
    }catch(e){}
};
_p.close = function(){
    var _param = this.param, 
    	self = this;
    var curTip = IMTipManager.getIMTip(self.key);
    if(!curTip) {
    	return;
    }
    this.curNum = 0;
    this.isshow = false;
    $$D.animate(curTip.Element, {opacity:10}, 400, "swing", function(){
    	try{
        	$$D.css(curTip.Element, "display", "none");
        }catch(e){}
    });
};
_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);
    setTimeout(function(){var _curTip = IMTipManager.getIMTip(key);if(_curTip)_curTip.next(key, wait);}, wait);
};
_p.getTip = function(){
    var _C = Ntalker.Config;
    var m = this.message[0].user + " " + this.message[0].msg;
    var _TipHTML = 
        '<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
        '    <tr>'+
        '        <td style="background:url('+_C['publicDIR']+'/images/tipleft.png) 0 0 no-repeat;width:6px;"></td>'+
        '        <td style="margin-left:6px;_margin-left:0px;background:url('+_C['publicDIR']+'/images/tipmid.png) 0 0 repeat-x;height:32px;color:#333;font-size:14px;text-align:center;">' + m + '</td>'+
        '        <td style="background:url('+_C['publicDIR']+'/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('+_C['publicDIR']+'/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   = $$S.cut(this.message[k].roomname,7, false)+' - '+$$S.cut(this.message[k].user, 5, false);
    var tipContent = $$S.cut(NtUtil.clearHTML(this.message[k].msg), 11, true);
    var _TipHTML   = '<span style="display:block;margin:2px 0 0 25px;color:#016722;line-height:160%">'+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(e){
        $$E.fixEvent(e).stopPropagation();
        IMTipManager.getIMTip(_key).close();
        if(IMToolBar && IMToolBar.viewGroupMessage){
        	try{
            	IMToolBar.viewGroupMessage(null, null, _msg.roomid, _msg.roomname, _msg.roomtype, _msg.chattype);
            }catch(e){}
        }else{
            im_openWebchatWindow(_msg.roomid, _msg.roomname, null, 1, chattype, _msg.roomtype, 'groupMsgMenu');
        }
    };
    return(_TipHTML ? _TipHTML : null);
};
var NotifyManager = {
    _notifyWnds : new IMHashtable(),
    _NotifySPAN : $$D.create('div', {id:"OnlineNotifyGroup"}, null, "afterbegin"),
    _maxNotify : 3,
    _width : 215,
    _height : 130,
    _bottom : 30,
    scroltimerID: null,
    addScrollEvent: false,
    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;
        var _V = Ntalker.variable;
        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  = _V['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, _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 = NtUtil.$$(".ntalker_notify"),
                _C = Ntalker.Config,
                _CP= Ntalker.Config.customparams,
                _V = Ntalker.variable;
            for(var k in alertNotifys){
                if(alertNotifys[k].parentNode) alertNotifys[k].parentNode.removeChild(alertNotifys[k]);
            }
            if( (/^(confirm|request)$/.test(notifyWnd.BtnType) || notifyWnd.type == 'alert') && 
                _CP['layout'].indexOf('toolbar') != -1 ){
                   im_chat_window_manager.OnTBFocusWindow(0);
            }
            this._showList.add(key, notifyWnd);
            var wRt = $$D.windowRect();
            var _width, _height, className;
            if( notifyWnd.chattype === 'nquan' ){
                _width = 275;
                _height = 150;
                className = 'nt_notify_nquan';
            }else{
                _width = NotifyManager._width;
                _height = NotifyManager._height;
                className = 'nt_notify';
            }
            var _top = wRt.y + (wRt.h - _height)/2,
                _left = wRt.x + (wRt.w - _width)/2,
                _headURL = notifyWnd.logoUrl ? notifyWnd.logoUrl:_C['imagesDIR']+"notify_userhead.png",
                _errimg = _C['imagesDIR']+"notify_userhead.png";
            var _openChatWindow = function(){
                im_openWebchatWindow(notifyWnd.destuid, notifyWnd.destname, notifyWnd.chatid, 1, notifyWnd.chattype, 0, 'groupMsgMenu');
                NotifyManager.alertQueue.close( key, notifyWnd.BtnType, notifyWnd.type );
                IMToolBar.removeSystemMessage( notifyWnd.type + notifyWnd.destuid );
            };
            var _Ht = [];
            _Ht.push('<div id="' + key + '" class="ntalker_notify ' + className + '" style="z-index:10000;left:' + _left + 'px;top:' + _top + 'px;width:' + _width + 'px;height:' + _height + 'px;">');
            _Ht.push(    '<div style="background: url(' + _C['logo'] + ') no-repeat 1px center;margin:8px 8px 0 8px;height:28px;padding:0;text-align:right;">');
            _Ht.push(        '<a href="javascript:NotifyManager.alertQueue.close(\''+key+'\', \'' + notifyWnd.BtnType+'\', \''+notifyWnd.type + '\');IMToolBar.removeSystemMessage(\'' + notifyWnd.type+notifyWnd.destuid + '\');" class="nt_close"></a>');
            _Ht.push(    '</div>');
            _Ht.push(    '<div id="' + key + '_IMG" style="margin:10px 20px 0px 20px !imporant;margin-top:0px;margin-left:20px;cursor:pointer;">');
            _Ht.push(    '  <div style="margin:4px;background:#fff;width:65px;height:65px;float:left;"><img src="' + _headURL + '" style="width:61px;_width:60px;height:61px;_height:60px;border:1px solid #ccc;margin:1px;" /></div>');
            _Ht.push(    '  <br style="clear: both;" />');
            _Ht.push(    '</div>');
            _Ht.push(    '<div style="overflow: hidden; position: absolute; left: 95px; top: 40px; width: ' + (notifyWnd.chattype === 'nquan' ? 165 : 105) + 'px;color:#000000;font-size:12px;">');
            if( notifyWnd.BtnType && notifyWnd.sendMsg )
                _Ht.push(    '<span style="height: 55px; display: block;"><B>' + $$S.cut(notifyWnd.destname,6,true) + '</B><br />' + sprintf(NtLang['sayContent'], $$S.cut(notifyWnd.sendMsg, 6, true) ) + '</span>' );
            else if(notifyWnd.chattype === 'nquan')
                _Ht.push(    '<span style="height: 80px; display: block;"><B>' + $$S.cut(notifyWnd.destname,6,true) + '</B><br />' + $$S.cut( notifyWnd.message, 40, true) + '</span>' );
            else
                _Ht.push(    '<B>' + $$S.cut(notifyWnd.destname,6,true) + '</B><br />' + $$S.cut( notifyWnd.message, 12, true) + '<br />' );
            if( /^(confirm|request)$/.test(notifyWnd.BtnType) ){
                _Ht.push(    '<a href="javascript:im_Confirm(\'' + notifyWnd.destuid + '\', \'' + key + '\', \'' + notifyWnd.BtnType + '\', 1, \'' + notifyWnd.destname + '\',\'' + notifyWnd.type + '\');" style="width:43px;display:block;height:20px;background:url(' + _C['imagesDIR'] + '/notifybtn.png) no-repeat 0 0;float:left;"></a>');
                _Ht.push(    '<a href="javascript:im_Confirm(\'' + notifyWnd.destuid + '\', \'' + key + '\', \'' + notifyWnd.BtnType + '\', 2, \'' + notifyWnd.destname + '\',\'' + notifyWnd.type + '\');" style="width:44px;display:block;height:20px;background:url(' + _C['imagesDIR'] + '/notifybtn.png) no-repeat -43px 0;float:left;"></a>');
            }
            if(notifyWnd.chattype === 'nquan'){
                _Ht.push(    '<a id="' + key + '_VIEW" href="javascript:void(0);" style="display:block;float:right;width:60px;height:20px;background:url(' + _C['imagesDIR'] + '/nquan_viewbtn.png)"></a>');
            }
            _Ht.push(    '</div>');
            _Ht.push('</div>');
            _curElement = $$D.insert(document.body, _Ht.join(''));
            $$E.addEvent($$O(key + '_IMG'), 'click', _openChatWindow);
            $$O(key + '_VIEW') && $$E.addEvent($$O(key + '_VIEW'), 'click', _openChatWindow);
            this.animate(_curElement, false);
        },
        animate:function(elem, autoclose){
            this._showing = true;
            NotifyManager.alertQueue._showing = false;
            if(autoclose){
                setTimeout(function(){
                    $$D.animate(elem, {opacity:10}, 400, "swing", function(){
                        if(elem.parentNode)elem.parentNode.removeChild(elem);
                        NotifyManager.alertQueue._showList.remove(elem.id);
                        setTimeout(function(){NotifyManager.push();}, 500);
                    });
                }, 6000);
            }
        },
        close:function(id, btntype,type){
            var _CP= Ntalker.Config.customparams,
                _V = Ntalker.variable;
            elem = $$O(id);
            $$D.animate(elem, {opacity:0}, 400, "swing", function(){
                if(elem.parentNode) elem.parentNode.removeChild(elem);
                NotifyManager.alertQueue._showList.remove(elem.id);
                if( (/^(confirm|request)$/.test(btntype) || type == 'alert') &&
                    _CP['layout'].indexOf('toolbar') != -1 ){
                    im_chat_window_manager.OnTBFocusWindow(_V['OnFocusWinParam'][0], _V['OnFocusWinParam'][1]);
                }
            });
        }
    },
    showQueue:{
        _showList   : new IMHashtable(),
        _showing    : false,
        add: function(key, notifyWnd){
            var wRt = $$D.windowRect();
            var _C = Ntalker.Config,
                _top = wRt.y + wRt.h - NotifyManager._bottom,
                _headURL = notifyWnd.logoUrl?notifyWnd.logoUrl:_C['imagesDIR']+"notify_userhead.png",
                _errimg  = _C['imagesDIR'] + "notify_userhead.png";
            this._showList.add(key, notifyWnd);
            _curElement = $$D.create('div', {id:key,className:"ntalker_notify nt_notify"}, NotifyManager._NotifySPAN);
            _curElement.style.cssText = "z-index:99999;"+($$B.ie6 ? 'position:absolute;top:'+_top+'px;' : 'position:fixed;bottom:'+NotifyManager._bottom+'px;')+"right:10px;height:1px;width:"+NotifyManager._width+"px;background:transparent url("+_C['imagesDIR']+"notifybg."+($$B.ie?"gif":"png")+") no-repeat left top;";
            var htmls = ["<div style=\"background: url("+_C['logo']+") no-repeat 1px center; margin:8px 8px 0 8px;height:28px;padding:0;text-align:right;\"><a href=\"javascript:NotifyManager.showQueue.close('"+key+"');\" class=\"nt_close\"></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 id=\""+key+"_IMAGES\" src=\""+_headURL+"\" 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>" + $$S.cut(notifyWnd.destname, 5, true) + "</B><br />" + notifyWnd.message + "",
                        "</div>",
                        "</div>"].join('');
            _curElement.innerHTML = htmls;
            if( $$O(key + '_IMAGES') ){
            	$$O(key + '_IMAGES').onerror = function(){
            		$$O(key + '_IMAGES').src = _C['imagesDIR']+"notify_userhead.png";
            		$$O(key + '_IMAGES').onerror = null;
            	};
            }
            var __notifyRepos = function(){
            	clearTimeout(NotifyManager.scroltimerID);
			    NotifyManager.scroltimerID = setTimeout(function(){
				    var count = NotifyManager.showQueue._showList.count();
				    if( count == 0 ){
				    	$$E.removeEvent(window, 'resize', __notifyRepos);
	        			$$E.removeEvent(window, 'scroll', __notifyRepos);
	        			NotifyManager.addScrollEvent = false;
				    	debug('NotifyManager removeEvent scroll&&resize ');
				    }
				    var list = NotifyManager.showQueue._showList._hash;
				    var wRt = $$D.windowRect();
				    for(var k in list){
				    	var key = list[k]._curNotifyId;
				    	var notifyRect = $$D.clientRect(key);
	            		var top = wRt.y + wRt.h - notifyRect.h - NotifyManager._bottom;
				    	$$D.animate($$O(key), {top:top}, 'fast', 'easeInOutBounce', function(){});
				    }
			    }, 400);
	        };
	        if( !NotifyManager.addScrollEvent && $$B.ie6 ){
            	$$E.addEvent(window, 'resize', __notifyRepos);
	        	$$E.addEvent(window, 'scroll', __notifyRepos);
	        	NotifyManager.addScrollEvent = true;
	        	debug('NotifyManager addEvent scroll&&resize ');
            }
            if($$O('impresenceflash') && $$O('impresenceflash').playNotifySound){
                $$O('impresenceflash').playNotifySound();
            }
            this.animate(_curElement);
        },
        animate:function(elem){
        	var newY;
            if(im_myIMWindow){
                if(im_myIMWindow.isShow) return;
            }
            this._showing = true;
            var _preNodes = [];var _curEl = elem;
            while(_curEl.previousSibling){
            	_preNodes.push(_curEl.previousSibling);
            	_curEl = _curEl.previousSibling;
            }
            function callback(){
            	NotifyManager.showQueue._showing = false;
                setTimeout(function(){NotifyManager.push();},500);
                setTimeout(function(){
                    if(elem.parentNode)elem.parentNode.removeChild(elem);
                    NotifyManager.showQueue._showList.remove(elem.id);
                    NotifyManager.push();
                }, 15000);
            }
            for(var i=0; i<_preNodes.length; i++ ){
            	if( $$B.ie6 ){
	                newY = parseInt($$D.css(_preNodes[i], "top")) - NotifyManager._height;
	                $$D.animate(_preNodes[i], {top:newY}, 400, "easeOutQuart");
            	}else{
	                newY = parseInt($$D.css(_preNodes[i], "bottom")) + NotifyManager._height;
	                $$D.animate(_preNodes[i], {bottom:newY}, 400, "easeOutQuart");
            	}
            }
            if( $$B.ie6 ){
            	newY = parseInt($$D.css(elem, "top")) - NotifyManager._height;
            	$$D.animate(elem, {top:newY, height:NotifyManager._height}, 400, "easeOutQuart", callback);
            }else{
	            $$D.animate(elem, {height:NotifyManager._height}, 400, "easeOutQuart", callback);
            }
        },
        close:function(elem){
            elem = $$O(elem);
            var _curEl = elem; var _preNodes = [];
            while(_curEl.previousSibling){
            	_preNodes.push(_curEl.previousSibling);
            	_curEl = _curEl.previousSibling;
            }
            if(elem.parentNode) 
            	elem.parentNode.removeChild(elem);
            NotifyManager.showQueue._showList.remove(elem.id);
            for(var i=0; i<_preNodes.length; i++){
            	if( $$B.ie6 ){
	            	newY = parseInt($$D.css(_preNodes[i], "top")) + NotifyManager._height;
	            	$$D.animate(_preNodes[i], {top:newY}, 400, "easeOutQuart", function(){
	                    NotifyManager.push();
	                });
	            }else{
		            newY = parseInt($$D.css(_preNodes[i], "bottom")) - NotifyManager._height;
		            $$D.animate(_preNodes[i], {bottom:newY}, 400, "easeOutQuart", function(){
	                    NotifyManager.push();
	                });
	            }
            }
        }
    }
};
function im_Confirm(destuid, key, alertType, strConfirm, destname, typ){
    if(alertType=="request"){
        if(strConfirm==1){
            im_openWebchatInPage(destuid, destname, null,   1);
        }
    }else{
        var impresence = $$O('impresenceflash');
        if(impresence && impresence.addFriendConfirmResult){
            impresence.addFriendConfirmResult(destuid, strConfirm);
        }
    }
    if(IMToolBar && IMToolBar.removeSystemMessage){
        IMToolBar.removeSystemMessage(typ+destuid);
        IMToolBar.removeSystemMessage(alertType+destuid);
    }
    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 setMyClientID(flashGoUrl){
     im_flashGoUrl  = flashGoUrl;
}
function fIM_onPresenceReceiveChatMsg(destuid, destnick, wid, flashserver, message, chatid, isNotify, isMyFriend, isOnlineMsg, logoUrl, chatsid){
    var _C = Ntalker.Config,
        _CP= Ntalker.Config.customparams,
        _V = Ntalker.variable;
    if(isMyFriend!=2 && _CP["ignoreChatInvite"])
        return;
    if(Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==0)
        return;
    if(isNotify){
        if( IMToolBar && IMToolBar.addMessageBox ){
        IMToolBar.addMessageBox(destuid,destnick,destnick+NtLang['requestChat'][0],"chat",logoUrl,"request","","","","","",chatid,false,'');
    	}else if( IMToolBar && IMToolBar.addSystemMessage ){
    		IMToolBar.addSystemMessage(destuid, destnick, destnick+NtLang['requestChat'][0], chatid, logoUrl, message, "request", '','','chat');
    	}
    }else{
    	var _autoFocus;
    	if( isMyFriend == -1 ){
    		_autoFocus = false;
    	}else{
    		try{
    			var chatWndsArray = im_chat_window_manager._chatWndsArray, 
	        		chatWndCount = chatWndsArray.length;
	        	if( !chatWndCount ){
	        		_autoFocus = true;
	        	}else{
	        		for(var i = 0; i < chatWndCount; i++ ){
		        		if( chatWndsArray[i]._curWindMode != 'hide' ){
		        			_autoFocus = false;
		        			break;
		        		}
		        	}
		        	_autoFocus = true;
	        	}
    		}catch(e){}
    	}
    	if( _V['applicationOpened'] ) _autoFocus = false;
        if(isOnlineMsg){
            if(_V['onlineChat']>=0){
                im_chat_window_manager.addChatWindow(destuid, destnick, chatid, _autoFocus, message, logoUrl, 0, 'chat', 0);
                _V['onlineChat'] -= 1;
            }else if(IMToolBar && IMToolBar.addMessageBox){
                IMToolBar.addMessageBox(destuid,destnick,destnick+NtLang['requestChat'][0],"chat",logoUrl,"request","","","","","",chatid,false,'');
            }else if( IMToolBar && IMToolBar.addSystemMessage ){
            	IMToolBar.addSystemMessage(destuid, destnick, destnick+NtLang['requestChat'][0], chatid, logoUrl, message, "request", '','','chat');
            }
        }else{
            if(_V['offlineChatList'].length<6){
                im_chat_window_manager.addChatWindow(destuid, destnick, chatid, _autoFocus, message, logoUrl, 0, 'chat', 0);
                var openOfflineChatWindow = true;
                for(var k in _V['offlineChatList']){
                    if(_V['offlineChatList'][k][0]==destuid && _V['offlineChatList'][k][1]==destnick){
                        openOfflineChatWindow = false; break;
                    }
                }
                if(openOfflineChatWindow) {
                    _V['offlineChatList'].push([destuid, destnick]);
                }
            }else{
                var openOfflineChatWindow = false;
                for(var k in _V['offlineChatList']){
                    if(_V['offlineChatList'][k][0]==destuid && _V['offlineChatList'][k][1]==destnick){
                        openOfflineChatWindow = true; break;
                    }
                }
                if(!openOfflineChatWindow){
	                if( IMToolBar && IMToolBar.addMessageBox ){
	                IMToolBar.addMessageBox(destuid,destnick,destnick+NtLang['requestChat'][0],"chat",logoUrl,"request","","","","","",chatid,false,'');
                	}else if( IMToolBar && IMToolBar.addSystemMessage ){
                		IMToolBar.addSystemMessage(destuid, destnick, destnick+NtLang['requestChat'][0], chatid, logoUrl, message, "request", '','','chat');
                	}
                }
            }
        }
    }
    if(promptwindow){
        promptwindow.startPrompt(destnick, NtLang['requestChat'][1], true);
    }
    return true;
}
function fIM_OnPresenceReceiveGroupMsg( groupId, groupName, groupIcon, srcuid, srcnick, msg, isNotify, chattype){
    var _CP = Ntalker.Config.customparams;
    if( (!_CP["enablegroup"] && !_CP["enableroom"]) || !groupId || groupId=="" ){
    	return;
    }
    chattype = /^(room|group|nquan)$/.test(chattype) ? chattype : 'group';
    if(IMToolBar && IMToolBar.addGroupMessage){
        IMToolBar.addGroupMessage(groupId, groupName, srcuid, srcnick, msg, chattype);
    }
}
function fIM_onPresenceReceiveAddFriend(destuid, destnick, logoUrl, bconfirm){
	if( bconfirm ){
	if(IMToolBar && IMToolBar.addMessageBox){
			IMToolBar.addMessageBox(destuid,destnick,destnick+NtLang['requestAddFriend'][0],"chat",logoUrl,"confirm","","","","","","",false,'');
		}else if(IMToolBar && IMToolBar.addSystemMessage){
			IMToolBar.addSystemMessage(destuid, destnick, destnick+NtLang['requestAddFriend'][0], 0, logoUrl, "","confirm");
		}
		if(promptwindow){promptwindow.startPrompt(destnick, NtLang['requestAddFriend'][0], true);}
	}else{
		if(IMToolBar && IMToolBar.addMessageBox){
			IMToolBar.addMessageBox(destuid,destnick,destnick+NtLang['requestAddFriend'][1],"chat",logoUrl,"alert","","","","","","",false,'');
		}else if(IMToolBar && IMToolBar.addSystemMessage){
			IMToolBar.addSystemMessage(destuid, destnick, destnick+NtLang['requestAddFriend'][1], 0, logoUrl, "","alert");
		}
		if(promptwindow){promptwindow.startPrompt(destnick, NtLang['requestAddFriend'][1], true);}
	}
}
function fIM_notifyMessage(destuid, destnick, logoUrl, strMessage){
    if(Ntalker.Config.isPopupMode && !Ntalker.Config.isPopupWindow)
        return;
    if(IMToolBar && IMToolBar.addSystemMessage){
    	IMToolBar.addSystemMessage(destuid, destnick, strMessage, 0, logoUrl, "","alert", '','','chat');
    }
}
function fIM_onPresenceReceiveUserOnline(destuid, destnick, logoUrl){
    if( (Ntalker.Config.isPopupMode && !Ntalker.Config.isPopupWindow) || im_myIMWindow.isShow )
        return;
    NotifyManager.add(destuid, destnick, NtLang['onlineText'], 0, logoUrl, "online");
}
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;
};
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 = 0 ;
    this.dragSy = 0;
    this.isDrag = 0;
    this.isCascadeMode = false;
    this.resizeWin = null;
    this.dir = "";
    this.resizeX = 0;
    this.resizeY = 0;
    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 self = this;
    function __repos(ev){
        ev = ev || self._window.event;
        var l = self._windows.length;
        for(var i = 0; i < l; i++){
            self._windows[i].fooRepos(ev);
            if(ev.type=="scroll" && self._windows[i]._flash && !$$B.msie){
                if(Ntalker.temp.resetwintop[i] != true){
                    setTimeout("wdkApplication._FloatWindowManager.updateWindowPos("+i+", 1)", 200);
                    Ntalker.temp.resetwintop[i] = true;
                }
            }
        }
        return;
    };
    $$E.addEvent(this._window, 'resize', __repos);
};
_p.addWindow = function(win){
    var l = this._windows.length;
    for(var i = 0; i < l; i++){
        if(this._windows[i] == win)
          return;
    }
    this._windows.push(win);
};
_p.removeWindow = function(win){
    var l = this._windows.length;
    for(var i = 0; i < l; 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($$B.ie)
        win._self.setCapture();
    else{
        this.showPanel(true);
    }
    var self = this;
    function __mousemove(ev){self.onmousemove(ev || self._window.event);}
    function __mouseup(ev){self.onmouseup(ev || self._window.event);}
    $$E.addEvent(this._body, "mousemove", __mousemove);
    $$E.addEvent(this._body, "mouseup", __mouseup);
};
_p.startResize = function(ev, win, type){
    this.resizeWin = win;
    this.dir = type;
    var _CP = Ntalker.Config.customparams;
    if(_CP['layout'] == "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($$B.ie)
        win._self.setCapture();
    else
        this.showPanel(true);
};
_p.__timerRepos = function(){
    var l = this._windows.length;
    for(var i = 0; i < l; 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(){
    var l = this._windows.length;
    this.clientArea = null;
    for(var i = 0; i < l; i++){
        this._windows[i].dispose();
        delete this._windows[i];
    }
};
_p.getPanel = function(){
    if(!this._panel){
        var obj = $$D.create('div', {style:"position:absolute;z-index:2;background:#000000;"}, null, "afterbegin");
        obj.style.MozOpacity = "0.5";
        obj.style.opacity = "0.5";
        obj.style.filter = "alpha(opacity:50)";
        var wRt = $$D.windowRect();
        obj.style.width = wRt.w + "px";
        obj.style.height = wRt.h + "px";
        this._panel = obj;
    }
    return this._panel;
};
_p.showPanel = function(bShow){
    if(!this._panel)
        this.getPanel();
    var wRt = $$D.windowRect();
    this._panel.style.display = bShow ? "block" : "none";
    this._panel.style.left = wRt.x + "px";
    this._panel.style.top  = wRt.y + "px";
    this._panel.style.width = (wRt.w-20>0?(wRt.w-20):0) + "px";
    this._panel.style.height = (wRt.h-20>0?(wRt.h-20):0) + "px";
};
_p.onmouseup = function(ev){
    this.showPanel(false);
    if(this.dragWin != null){
        if($$B.ie)
            this.dragWin._self.releaseCapture();
        this.dragWin = null;
        this.isDrag = 0;
    }
    if(this.resizeWin != null){
        if($$B.ie)
            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 wRt = $$D.windowRect();
        var _CP = Ntalker.Config.customparams;
        var x = this.dragSx + ev.clientX;
        var y = this.dragSy + ev.clientY;
        if($$B.ie || $$B.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(_CP['layout']=="toolbar"){
            var _r = NtUtil.scrollWidth();
            if(!$$B.QuirksModel){
                var _absX = x + this.dragWin._baseLeft;
                if(_absX+this.dragWin._self.offsetWidth+_r > wRt.x+wRt.w){
                    x = wRt.x+wRt.w - this.dragWin._baseLeft - this.dragWin._self.offsetWidth - _r;
                }else if(_absX > wRt.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.left;
    var y = obj.top;
    var w = obj.w;
    var h = obj.h;
    var _CP = Ntalker.Config.customparams;
    var layout = _CP['layout']=="toolbar" && flag.indexOf("w") == -1;
    var _parentRect = $$D.clientRect(this.resizeWin._self.parentNode);
    var ev_clientX = ev.clientX - (layout ? _parentRect.left : 0);
    var ev_clientY = ev.clientY - (layout ? _parentRect.top : 0);
    if(flag.indexOf("w") != -1){  
        w = obj.left + obj.w - ev_clientX + this.resizeX;
        if(w < minWidth) w = minWidth;
        x = obj.left + obj.w - w;
    }
    if(flag.indexOf("e") != -1){  
        w = ev_clientX - obj.left;
        if(w < minWidth) w = minWidth;
    }
    if(flag.indexOf("s") != -1){  
        h = ev_clientY - obj.top;
        if(h < minHeight) h = minHeight;
    }
    if(flag.indexOf("n") != -1){  
        h = obj.top + obj.h - ev_clientY + this.resizeY;
        if(h < minHeight) h = minHeight;
        y = obj.top + obj.h - h;
    }
    win.moveTo(x, y, true);
    win.resize(w, h);
    if($$B.ie)
        win._self.setCapture();
    ev.cancelBubble = true;  
    return false;
};
_p.updateWindowPos = function(winID, times){
    var _CP = Ntalker.Config.customparams;
    if(this._windows[winID] && typeof(this._windows[winID].refreshFlashPos)!="undefined"){
        this._windows[winID].refreshFlashPos();
        if(times<2)
            setTimeout("wdkApplication._FloatWindowManager.updateWindowPos("+winID+", "+(times+1)+")", 200);
        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 = 0;
    this.isLoad = 0;
    this.titleHeight = 0;
    this.borderWidth = 0;
    this._minWidth = Ntalker.Config.IMWidth;
    this._minHeight = Ntalker.Config.IMHeight;
    this._width = Ntalker.Config.IMWidth;
    this._height = Ntalker.Config.IMHeight;
    this.m_align = 0;
    this.m_rlLong = 0;
    this.m_miniImgBottom = 0;
    this.m_isButtonFloat = "float";
    this.m_miniImgEvent = null;
    this._flashID = '';
    this.m_flashContainerID = '';
    this._flashcontainer = '';
    this.m_miniImgDivID = "wdk_mini_state";
    this._titleid = "wdk_buddylist_title";
    this.timerID = null;
    this.isLocked = false;
    this.dockPos = "";  
    this._leftright = 0;
    this._isPopup = false;
    this._popupWindow = null;
    this._flash = null;
    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._left = 0;
    this._bottom = 0;
    this._right = 0;
    this._top = 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;
    this.m_funcURLPath = Ntalker.Config.services;
    var self = this;
    self.startWork();
};
_p.moveTo = function(x, y){
    var wRt = $$D.windowRect();
    this._left = x - wRt.x;
    this._top = y - wRt.y;
    this._right =  wRt.x+wRt.w-x;
    this._bottom = wRt.y+wRt.h-y;
    var _CP = Ntalker.Config.customparams;
    if($$B.ie){
        this._self.style.pixelLeft = x;
        if($$B.ie6 || _CP['layout'] == 'toolbar')
            this._self.style.pixelTop  = y;
    }else{
        this._self.style.left = x + "px";
    }
};
_p.resize = function(w, h){
    this._self.style.width  = w + "px";
    this._self.style.height = h + "px";
    var ch = h - 20 - this.borderWidth;
    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 wRt = $$D.windowRect();
    var _r = NtUtil.scrollWidth();
    var _C = Ntalker.Config,
        _CP = Ntalker.Config.customparams,
        _V  = Ntalker.variable;
    if( !$$B.QuirksModel && _CP['layout'] == "toolbar" ){
        return;
    }
    if(ev&&ev.type == "resize"){
        if(!this._self || _CP['layout']=='dztoolbar'){
        	return;
    	}
        if(_CP['layout']=='toolbar'){
            var _tabRect = $$D.clientRect(_V['buddylistTag']);
            if(this.m_align=="left"){
                this._left = wRt.x + wRt.w - this._width - _tabRect.left - _r;
            }else{
                this._left = wRt.x + wRt.w - this._width - _tabRect.left - _r;
            }
            var left = this._left;
            var top  = this._top;
        }else{
            var left = wRt.x+wRt.w-this._width-this.m_rlLong;
            var top  = wRt.y+wRt.h-this._height;
        }
        if($$B.ie){
            this._self.style.pixelLeft = left;
            if(_CP['layout']=='toolbar' )
                this._self.style.pixelTop = top;
        }else{
            this._self.style.left = left + "px";
            if(_CP['layout']=='toolbar')
                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._self){
            if( _CP['layout'] == 'topcascade' ){
                wRt = $$D.windowRect();
                y = wRt.y + wRt.h - this._height;
                if($$B.ie6) {
                	this._self.style.top  = y + "px";
                }
            }else{
                var top = 0-this._height + ($$B.QuirksModel ? 4 : 0);
                if($$B.ie || $$B.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(){
    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 = ($$B.StrictMode ? moveOffset : (this.borderWidth + moveOffset) )+"px";
};
_p.startWork = function(){
    var _C = Ntalker.Config;
    var _CP = Ntalker.Config.customparams;
    if(this.isLoad == 1) return;
    this.isLoad = 1;
    if($$B.ie6 || $$B.chrome || $$B.maxthon3){
        this.isMiniFloat = true;
        wdkApplication._FloatWindowManager.addWindow(this);  
    }
    return;
};
_p.createWin = function(tagIndex){
    var wRt  = $$D.windowRect();
    var _r = NtUtil.scrollWidth();
    var _C = Ntalker.Config,
        _CP = Ntalker.Config.customparams,
        _V = Ntalker.variable;
    this.created = true;
    var cacheDom = document.createDocumentFragment();
    if( _CP['layout']=='topcascade' ) {
        var x = wRt.x + wRt.w - this._width - 20;
        var y = wRt.y + wRt.h - this._height;
        this._top    = y;
        this._self = $$D.create('div', {style:"background:#fafafa;"}, cacheDom, "AfterBegin");
        if($$B.ie6){
            _pos = 'absolute';
            this._self.style.top = y + 'px';
        }else{
            _pos = 'fixed';
            this._self.style.bottom = '0px';
        }
        this._self.style.position = _pos;
        this._self.style.left   = x + "px";
    }else if( _CP['layout']=='dztoolbar' ){
        $$D.css(_V['buddylistTag'], "display", "block");
        var _TabRect = $$D.clientRect(_V['buddylistTag']);
        this._self = $$D.create('div', {id:"buddylist_tag_con", style:"background:#fafafa;"}, cacheDom);
        this.left = _TabRect.w - 10 - this._width;
        this.bottom = 0;
        this._self.style.position = "absolute";
        this._self.style.left   = this._left+'px';
        this._self.style.bottom = this._bottom+'px';
    }else{
        $$D.css(_V['buddylistTag'], "display", "block");
        var _TabRect = $$D.clientRect(_V['buddylistTag']);
        this._self = $$D.create('div', { id:"buddylist_tag_con", style:"background:#fafafa;"}, cacheDom);
        if(this.m_align=="left"){
            this._right = _TabRect.left;
            this._bottom = 0;
            this._left = 0 - _TabRect.left;
            this._top = 0;
        }else{
            if(_TabRect.left+this._width+_r > wRt.x+wRt.w){
                this._left = wRt.x + wRt.w - this._width - _TabRect.left - _r;
                this._right = 0 - this._left;
            }
            this._top = 0 - this._height + ($$B.QuirksModel ? 4 : 0);
            this._bottom = 0;
        }
        this._self.style.position = "absolute";
        this._self.style.left   = this._left+'px';
        this._self.style.bottom = this._bottom+'px';
    }
    this._self.style.zIndex = 9999;
    this.m_flashContainerID = "container_" + this._flashID;
    var flashWidth = this._width - 2*this.borderWidth;
    var flashHeight = this._height - this.titleHeight - 2*this.borderWidth;
    var bWidth = this.borderWidth;
    var sb = [];
    sb.push("<div id='" + this.m_flashContainerID + "' style='overflow:hidden;width:"+flashWidth+"px;height:"+flashHeight+"px;'>");
    sb.push(    "<div id='infoTextSpan' style='display:none;cursor:auto;width:"+flashWidth+"px;height:"+flashHeight+"px;line-height:" + flashHeight + "px;background:url(" + _C['publicDIR'] + "/loading.gif) no-repeat center center;text-align:center;border:0px solid "+_C['bColor']+"'></div>");
    sb.push(    "<div id='" + this._flashID + "' style=''></div>");
    sb.push("</div>");
    $$B.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;
    (_V['buddylistTag'] || document.body).appendChild(cacheDom);
    this._self.style.display = "block";
    this._flashcontainer = this._doc.getElementById(this.m_flashContainerID);
    var self = this;
    this.createFlash(tagIndex);
    function __doEvent(e){self.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);  
    }
    $$D.css(self._self, 'bottom', '0px');
};
_p.createFlash = function(tagIndex){
    if(!this._flashcontainer)
        return;
    var swfSrc,
        _C = Ntalker.Config,
        _CP = Ntalker.Config.customparams,
        _V = Ntalker.variable;
    swfSrc = this.m_jsURLPath+"/fs/ContactMod.swf?version=" + Ntalker.version.buddylist_flash;
    var flashvars = {v : Ntalker.version.buddylist_flash,
                     r : this.m_jsURLPath,
                     su: this.m_funcURLPath,
                     k : _C['skin'] || "",
                     t : encodeURIComponent(_V['siteid']),
                     s : encodeURIComponent(_V['user_sid']),
                     u : encodeURIComponent(_V['user_id']), 
                     n : encodeURIComponent(_V['user_name']),
                     l : Ntalker.Config.buddylistlogo ? Ntalker.Config.buddylistlogo : 0,
                     i : tagIndex,
                     w : Ntalker.Config.isPopupWindow,
                     lst: _CP['lstupdated'],
                     localeChain: _CP['localeChain'],
                     ps: 6
                     };
    if(_V['userparam'])
        flashvars.p = encodeURIComponent(_V['userparam']);
    if(_C['buddylistlogo'] && _CP['siteurl'])
        flashvars.f = _CP['siteurl'].toLowerCase().replace("http://","");
    else
        flashvars.f = encodeURIComponent(window.location.host);
    if(_CP['previewsiteid']){
	    flashvars.previewsiteid = _CP['previewsiteid'];
	}
    if(flashvars.toJSONString)
        delete flashvars.toJSONString;
    var flashmode = "Window";
    var params = {menu:"true", "salign":"LT", "allowScriptAccess":"always", "wmode":flashmode, "allowFullScreen": true};
    var attributes = {};
    var flashWidth = this._width - 2 * this.borderWidth;
	var flashHeight = this._height - 2 * this.borderWidth - this.titleHeight;
    if( parseInt(swfobject.getFlashPlayerVersion().major) < 6 ){
    	$$D.css(this._flash, 'display', 'none');
    	$$D.css($$O('infoTextSpan'), 'background', 'none');
    	$$O('infoTextSpan').innerHTML = '<a href="http://www.adobe.com/go/getflashplayer" target="_blank">' + NtLang['noInstallFlash'] + '</a>';
    	return;
    }else{
		swfobject.embedSWF(swfSrc, this._flashID, flashWidth, flashHeight, "9.1.115", _V['scriptPath']+"/fs/expressInstall.swf", flashvars, params, attributes);
    	var self = this;
    	setTimeout(function(){
    		self.LoadFailure();
    	}, self._flashLoadTime);
    }
    self._flash = $$O(self._flashID);
   	self.setFlashStyle();
   	$$D.css($$O('infoTextSpan'), 'display', 'none');
};
_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";
        if( !$$B.ie6 ) this._flash.style.top = (this.borderWidth + this.titleHeight) + "px";
        if( !$$B.ie6 ) 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.reloadFlash = function(){
    if(this._restoreFlash){
        delete this._restoreFlash;
    }
    this._flash = null;
    var _Ht = [];
    var flashWidth = this._width - 2 * this.borderWidth;
	var flashHeight = this._height - 2 * this.borderWidth - this.titleHeight;
    _Ht.push("<div id='infoTextSpan' style='display:none;cursor:auto;width:"+flashWidth+"px;height:"+flashHeight+"px;line-height:" + flashHeight + "px;text-align:center;'></div>");
    _Ht.push(    "<div id='" + this._flashID + "' style=''></div>");
    this._flashcontainer. innerHTML = _Ht.join('');
    if(this._waitFlashAutoLoadTimeid) clearTimeout(this._waitFlashAutoLoadTimeid);
    this.createFlash();
};
_p.LoadFailure = function(){
    if(this._isFlashLoadSuccess){
    	return;
    }
    var self = this, _C = Ntalker.Config;
        this._restoreFlash = this._flash;
    var flashWidth = this._width - 2*this.borderWidth;
    var flashHeight = this._height - this.titleHeight - this.borderWidth*2;
    if(self._flash){
        $$D.css(this._flash, "display", "none");
        try{
        	this._flash.parentNode.removeChild(this._flash);
    	}catch(e){
    		this._flash.style.width = 1 + 'px';
    		this._flash.style.height = 1 + 'px';
    	}
    }
    var closeButtonId = 'CloseIMWindowButton';
    var reLoadButtonId = 'reLoadFlashButton';
    $$D.css($$O('infoTextSpan'), 'backgroundImage', 'none');
    $$D.css($$O('infoTextSpan'), 'display', 'block');
    var _Ht = [];
    _Ht.push('<div>');
    _Ht.push(    '<div name="winlogo" style="float:left;width:70px;height:20px;background:url(' + _C['logo'] + ') center center no-repeat;"></div>');
    _Ht.push(    '<div name="wintitle" style="float:left;width:132px;height:20px;background:url(' + _C['publicDIR'] + 'titleText.gif) center center no-repeat;"></div>');
	_Ht.push(    '<div id="'+closeButtonId+'" name="btnclose" style="z-index:12;float:right;margin-right:8px;width:26px;height:20px;background:url('+_C['publicDIR'] + 'closewin.gif) center top no-repeat;cursor:pointer;"></div>');
	_Ht.push('</div>');
	_Ht.push('<div style="clear:both;height:' + (flashHeight-20) + 'px;line-height:' + (flashHeight-20) + 'px;">');
	_Ht.push(    '<a id="'+reLoadButtonId+'" href="javascript:void(0)">' + NtLang['loadFlashFailure'] + '</a>');
	_Ht.push('</div>');
    $$D.insert($$O('infoTextSpan'), _Ht.join(''));
        var self = this;
        var __clearClick  = function(e){$$E.fixEvent(e).stopPropagation();};
    var __closeWaitWin = function(e){ self.close();};
        var __reloadFlash =function(){ self.reloadFlash();};
    if(this._FlashReloadCount < 2 && !this._isFlashLoadSuccess){
    	this._FlashReloadCount++;
        this._waitFlashAutoLoadTimeid = setTimeout( __reloadFlash, this._waitFlashAutoLoad);
    }
    if( $$O('infoTextSpan') ) $$O('infoTextSpan').onclick   = __clearClick;
    if( $$O(closeButtonId) ) $$O(closeButtonId).onclick  = __closeWaitWin;
    if( $$O(reLoadButtonId) ) $$O(reLoadButtonId).onclick = __reloadFlash;
};
_p.onFlashLoadSuccess = function(){
    this._isFlashLoadSuccess = true;
};
_p.eventHandle = function(ev){
    var event = ev||window.event;
    var ee = event.srcElement||event.target;
    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){
};
_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){
    var self = this, _V = Ntalker.variable;
    if(!self._self)
        return;
	if(self._flash){
        if(self._flash.asIM_closeIMBuddyList){
            self._flash.asIM_closeIMBuddyList();
        }
        if(self._flash){
        	try{
            	self._flash.parentNode.removeChild(self._flash);
        	}catch(e){
       		}
    	}
	}
	self.isShow = false;
    self._self.onmouseover = null;
    self._self.onmouseout  = null;
    self._self.onmousedown = null;
    self._self.onmouseup   = null;
    self._self.onfocus   = null;
    self._self.onblur   = null;
    if(Ntalker.temp.buddylistFlashGoUrl){
        $$C.script(Ntalker.temp.buddylistFlashGoUrl);
        Ntalker.temp.buddylistFlashGoUrl = null;
    }
    self._self.parentNode.removeChild(self._self);
    delete self._self;
    if(!self.isMiniFloat)
        wdkApplication._FloatWindowManager.removeWindow(self);
    if(_V['buddylistTag']){
        _V['buddylistTag'].style.display = "none";
    }
    var siteid = _V['siteid'];
    var uid    = _V['user_id'];
    var destid = 0;
    var groupid= 0;
    var type   = 7;
    var desc   = NtLang.sd_eventClose + NtLang.sd_Buddylist;
    var mode   = 0;
    var source = 0;
    var action = "";
    $$C.script(Ntalker.Config.services + "/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(){
    var _C  = Ntalker.Config,
        _CP = Ntalker.Config.customparams,
        _V = Ntalker.variable;
    if(_V['user_id']==0 || !_V['user_id']){
        alert(NtLang.notLogin);return;
    }
    if( this.isShow ){
        return;
    }
    if( IMToolBar.currentToolbarMode == 2 ){
    	IMToolBar.setToolBarMode(1, true);
    }
    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 = $$O("wdk_buddylist_flash");
        if(IM_BuddyListDOM && IM_BuddyListDOM.switchTabIndex)
            IM_BuddyListDOM.switchTabIndex(Ntalker.Config.IMtabIndex);
    }
    this.isShow = true;
    if(NotifyManager) {
        NotifyManager.clearonline("online");
    }
    var siteid = _V['siteid'];
    var uid    = _V['user_id'];
    var destid = 0;
    var groupid= 0;
    var type   = 6;
    var desc   = NtLang.sd_evOpen + NtLang.sd_Buddylist;
    var mode   = 1;
    var source = 1;
    var action = "";
    $$C.script(_C['services'] + "/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 wRt = $$D.windowRect();
    this._left = this._self.offsetLeft - wRt.x;
    this._top = this._self.offsetTop - wRt.y;
    this._width = this._self.offsetWidth;
    this._height = this._self.offsetHeight;
};
_p.OnTBShowBuddylist =function(switchTab){
    if(switchTab && this.isShow){
        IM_BuddyListDOM = $$O("wdk_buddylist_flash");
        if(IM_BuddyListDOM && IM_BuddyListDOM.switchTabIndex)
            IM_BuddyListDOM.switchTabIndex(Ntalker.Config.IMtabIndex);
    }else{
        this.showWindow();
    }
};
WDK_IM_PACK.WDKChatWindow = function(destuid, destnick, chatid, layoutmode, chatType, roomtype, OpenType, userinfo, befrom){
    WDK_IM_PACK.FloatWindow.prototype.constructor();
    this._destuid = destuid;
    this._destnick = destnick;
    this._chatType = /^(chat|room|group|nquan)$/.test(chatType) ? chatType : "chat";
    this._roomType = roomtype ? 1 : 0;
    this._openType = OpenType;
    this._userInfo = userinfo;
    this._befrom = befrom;
    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  = (/^(room|group|nquan)$/.test(this._chatType) ? Ntalker.Config.groupWidth : Ntalker.Config.chatWidth);
    this._height = (/^(room|group|nquan)$/.test(this._chatType) ? Ntalker.Config.groupHeight : Ntalker.Config.chatHeight);
    this._avwidth = 340; 
    this._avheight = 0;  
    this._savewidth = null;
    this._saveheight = null;
    this._curHeight = this._height;
    this._titleHeight = layoutmode=='topcascade' ? 20 : 0;  
    this._borderWidth = 0;  
    this._minWidth  = 100;
    this._minHeight = 100;
    this._flashHeight = null;
    this._align = Ntalker.Config.customparams["floatpos"] || "right";
    this._rightOffset = 20;
    this._bottomOffset = 20;
    this._isFlashTitle = false;
    this._flashID = "webchat_flash"+destuid+this._chatType;
    this._flash = null;
    this._flashContainerID = "webchat_container"+destuid+this._chatType;
    this._infoTextSpanID = "infoTextSpan" + destuid + this._chatType;
    this._flashcontainer = '';
    this._jsURLPath = Ntalker.variable.scriptPath;
    this.m_funcURLPath = Ntalker.Config.services;
    this._presenceFlashGoUrl = null;
    this._freeChatFlashGoUrl = null;
    this._defaultZIndex = -9;
    this._focusZIndex = -1;
    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;
};
WDK_IM_PACK.WDKChatWindow.prototype = new WDK_IM_PACK.FloatWindow();
_p = WDK_IM_PACK.WDKChatWindow.prototype;
_p.showWindow = function(offset, miniWinTabDOM){
    if(this.isInited) return;
    var cacheDom = document.createDocumentFragment();
    this.isInited = true;
    var wRt = $$D.windowRect();
    var _C  = Ntalker.Config,
        _CP = Ntalker.Config.customparams, 
        _V  = Ntalker.variable;
    if( miniWinTabDOM && ( _CP['layout'] == 'pwtoolbar' ) )
    {
        this._self = $$D.create('div', {style:'background:#fafafa;'}, cacheDom);
        this._self.style.position = "absolute";
        this._self.style.outlineStyle = "none";
           this._left   = 0;
        this._top    = 0 - this._height;
        this._self.style.left = this._left + "px";
        this._self.style.top  = this._top + "px";
    }
    else if( _CP['layout'] == 'dztoolbar' ){
        this._self = $$D.create('div', {style:'background:#fafafa;'}, cacheDom);
        this._self.style.position = "absolute";
        this._self.style.outlineStyle = "none";
        this._left   = offset.left;
        this._top    = 0 - this._height - offset.bottom;
        this._self.style.left = this._left + "px";
        this._self.style.top  = this._top + "px";
    }
    else if(miniWinTabDOM && _CP['layout'] == "toolbar"){
        this._self = $$D.create('div', {style:'background:#fafafa;'}, cacheDom);
        this._self.style.position = "absolute";
        this._self.style.outlineStyle = "none";
        if(IMToolBar && IMToolBar._Pattern==0){
            if(this._align=="right")
                this._left   = IMToolBar.minChatWidth*IMToolBar.minWinCount - this._width + this._borderWidth;
            else
                this._left   = wRt.w - this._width - offset.right;
        }else{
            this._left   = wRt.w - this._width - offset.right;
        }
        this._top    = 0 - this._height - offset.bottom;
        this._self.style.left = this._left + "px";
		this._self.style.top  = this._top + "px";
    }else{
    	this._defaultZIndex = 1;
    	this._focusZIndex = 1;
        this._self = $$D.create('div', {style:'background:#fafafa;'}, cacheDom);
        this._self.style.position     = $$B.ie6 ? "absolute" : 'fixed';
        this._self.style.outlineStyle = "none";
           this._left   = offset.left;
        this._top    = offset.top;
        this._self.style.left = (offset.left + wRt.x) + "px";
        if($$B.ie6)
            this._self.style.top  = (offset.top + wRt.y) + "px";
        else{
            this._bottom = offset.bottom;
            this._self.style.bottom  = this._bottom + "px";
            this._self.style.top  = "auto";
        }
    }
    this._self._ptr = this;
    this._self.style.zIndex = this._defaultZIndex;
    this._self.style.width = this._width+"px";
    this._self.style.height = this._height+"px";
    this._self.tabIndex = parseInt(this._destuid);
    var titleWidth,popBtnLeft,minBtnLeft,closeBtnLeft;
    if(this._layout == 'topcascade'){
        if(this._chatType != 'chat' )
            this._titleText = this._destnick;
        else
            this._titleText = sprintf(NtLang['minWindowTitle'], this._destnick);
        titleWidth    = Ntalker.Config.chatWidth;
        minBtnLeft    = titleWidth - 39;
        closeBtnLeft  = titleWidth - 21;
    }else{
        this._titleText = sprintf(NtLang['minWindowTitle'], this._destnick);
        titleWidth    = this._width;
        minBtnLeft    = titleWidth - 39;
        closeBtnLeft  = titleWidth - 21;
    }
    var bWidth = this._borderWidth;
    var flashWidth = this._width - this._borderWidth*2;
    var flashHeight = this._height - this._borderWidth*2;
    var sb = [];
    sb.push("<div type='dlgHead'  style='position:absolute;left:0px;top:" + bWidth + "px;width:" + titleWidth + "px;height:" + this._titleHeight + "px;cursor:auto;background:url(" + _C['imagesDIR'] + "win_tit_bg.gif);'>");
    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;font-size:"+_C['fSize']+";height:auto;text-align:left;padding-left:30px;line-height:20px;'>" + (_CP['layout']=='topcascade' ? this._titleText : '') + "</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='btmin'   type='button' style='position:absolute;left:" + minBtnLeft + "px;top:5px;font-size:0;width:14px;height:14px;" + (_CP['layout']=='topcascade' ? "background:url(" + _C['imagesDIR'] + "im_btmin.gif) no-repeat;" : "") + "'></div>");
    sb.push("<div name='btclose' type='button' style='position:absolute;left:" + closeBtnLeft + "px;top:4px;font-size:0;width:14px;height:14px;" + (_CP['layout']=='topcascade' ? "background:url(" + _C['imagesDIR'] + "im_btclose.gif) no-repeat;" : "") + "'></div>");
    sb.push("<div id='" + this._flashContainerID + "' style='overflow:hidden; width:"+flashWidth+"px;height:"+flashHeight+"px;'>");
    sb.push(    "<div id='" + this._infoTextSpanID + "' style='cursor:auto;width:"+flashWidth+"px;height:"+flashHeight+"px;line-height:" + flashHeight + "px;background:url(" + _C['publicDIR'] + "/loading.gif) no-repeat center center;text-align:center;border:0px solid "+_C['bColor']+"'></div>");
    sb.push(    "<div id='" + this._flashID + "'></div>");
    sb.push("</div>");
    this._self.innerHTML = sb.join("");
    delete sb;
    (miniWinTabDOM || document.body).appendChild(cacheDom);
    this._minBtn = this._self.childNodes[1];
    this._titlespan = this._doc.getElementById(this._titleid).lastChild;
    this._headerdiv = this._doc.getElementById(this._headerid);
    this._flashcontainer = this._doc.getElementById(this._flashContainerID);
    this.createFlash();
    var self = this;
    function __doEvent(e){self.eventHandle(e || window.event);};
    function __clearClick(e){$$E.fixEvent(e).stopPropagation();};
    this._self.onmousedown = __doEvent;
    this._self.onmouseup = __doEvent;
    this._self.onfocus = __doEvent;
    this._self.onblur = __doEvent;
    this._self.ondblclick = __doEvent;
    this._self.onclick = __clearClick;
    if( this._layout=="topcascade" ){
        this.resize_NoTitle(this._width, this._height);
    }else{
        this.resize(this._width, this._height);
    }
    wdkApplication._FloatWindowManager.addWindow(this); 
};
_p.moveTo = function(x, y, isSavePos, curHeight){
    var wRt = $$D.windowRect();
    if( isNaN(x) || isNaN(y) )
    	return;
    if(isSavePos){
        if(this._layout == 'toolbar' && !$$B.QuirksModel){
            this._left = x;
            this._top  = y;
            this._right = 0-x;
            this._bottom = 0-y;
        }else{
            this._left   = x - wRt.x;
            this._top    = y - wRt.y;
            this._right  = wRt.x + wRt.w - x - this._width;
            this._bottom = wRt.y + wRt.h - y - ($$S.isDefined(curHeight) ? curHeight : this._height);
        }
    }
    if($$B.msie){
        this._self.style.pixelLeft = x;
        if($$B.ie6)
            this._self.style.pixelTop  = y;
        else
            this._self.style.bottom  = this._bottom + "px";
    }else{
        this._self.style.left = x + "px";
        this._self.style.bottom  = this._bottom + "px";
    }
};
_p.resize = function(w, h){
    this._width = w;
    this._height = h;
    this._self.style.width  = w + "px";
    this._self.style.height = h + "px";
    if(this._flash){
        this.setFlashStyle();
    }
};
_p.resize_NoTitle = function(w, h){
    this._width = w;
    this._height = h;
    this._self.style.width  = w + "px";
    this._self.style.height = h + "px";
    if(this._flash){
        this.setFlashStyle_NoTitle();
    }
};
_p.fooRepos = function(ev){
    var wRt = $$D.windowRect();
    var _C  = Ntalker.Config,
        _CP = Ntalker.Config.customparams;
    if(ev && ev.type == "resize"){
        if(!this._self) return;
        if(this._layout =='topcascade' ){
            x = wRt.x + this._left;
            y = wRt.y + wRt.h - this._curHeight - this._bottom;
            this.moveTo(x, y, true, this._curHeight);
        }else if( this._layout == 'dztoolbar' ) {
            var tRt = $$D.clientRect(IMToolBar.contentElement);
            var mRt = IMToolBar.get(this._destuid, this._chatType).getPost();
            if( IMToolBar.currentToolbarMode == 2 ){
            	var x = mRt.rx - this._windowWidth - tRt.left;
            }else{
            	var x = Math.min(mRt.x, tRt.w - this._width - _C['IMWidth'] - 10);
        	}
            var y = 0 - this._height;
        }else if( this._layout == 'pwtoolbar' ) {
        	return;
        }
    }
    else if(this._self){
        if( !( $$B.ie6 && this._layout == 'topcascade') ){
        	return;
        }
        var wRt = $$D.windowRect();
        var x = wRt.x + this._left;
        var y = wRt.y + this._top;
        this._self.style.top  = y + "px";
        if(this._flash){
            this._flash.style.left = ($$B.StrictMode ? 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 = $$D.windowRect();
            this.moveTo(wRt.x + offsetLeft, wRt.y + (offsetTop-this._height) );
        }
    }
};
_p.minimize = function(){
    var visiblestyle,displaystyle;
    var _V = Ntalker.variable;
    var _C = Ntalker.Config;
    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.style.height = this._titleHeight + "px";
        if( this._layout=='topcascade'){
            this._curHeight = this._titleHeight;
            this._minBtn.style.background = "url(" + _C['imagesDIR'] + "im_btbig.gif)";
        }else{
            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();
        if( this._layout=="topcascade" ){
            this._curHeight = this._height;
            this._minBtn.style.background = "url(" + _C['imagesDIR'] + "im_btmin.gif)";
            this.resize_NoTitle(this._width, this._height);
        }else{
            this.resize(this._width, this._height);
        }
        break;
    default:
        visiblestyle = "visible";
        this._curWindMode = "default";
        break;
    }
};
_p.MinMax = function(){
    var visiblestyle, displaystyle;
    var _C = Ntalker.Config,
        _CP= Ntalker.Config.customparams;
    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.style.height = this._titleHeight + "px";
        if(IMToolBar){
            var minWin = IMToolBar.get(this._destuid, this._chatType);
        if(minWin) minWin.onBlur();
        }
        if( this._layout=="topcascade" ){
            this._curWindMode = "min";
            this._curHeight = this._titleHeight;
        }else{
            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 _r   = NtUtil.scrollWidth();
        var wRt = $$D.windowRect();
        var x = this._left,y = this._top;
        if( _CP['layout'] == "dztoolbar" ){
            var tRt = $$D.clientRect(IMToolBar.contentElement);
            var minWin = IMToolBar.get(this._destuid, this._chatType);
            var mRt = minWin.onFocus();
            if( /0|1/.test(IMToolBar.currentToolbarMode) ){
            	x = Math.min(mRt.x + IMToolBar.AreaElement.scrollLeft, tRt.w - this._width - _C['IMWidth'] - 10);
        	}else{
        		x = mRt.x + mRt.w - this._width;
        	}
            if($$B.QuirksModel){
                y = mRt.y-this._height + 5;
            }else{
                y = 0-this._height;
            }
        }else if( _CP['layout'] == 'pwtoolbar' ){
            var minWin = IMToolBar.get(this._destuid, this._chatType);
            if(minWin) minWin.onFocus();
            x = 0;
            y = 0-this._height;
        }else{
            this._curHeight = this._height;
            x  = wRt.x + wRt.w - this._width;
            y  = wRt.y + wRt.h - this._height;
        }
        this.moveTo(x, y);
        break;
    default:
        visiblestyle = "visible";
        this._curWindMode = "default";
        break;
    }
};
_p.close = function(){
    $$D.css(this._self, "display", "none");
    wdkApplication._FloatWindowManager.removeWindow(this);
    this.stopFlashTitle();
    this._flash = $$O(this._flashID);
    if(this._checkFlashTimerid){
        clearTimeout(this._checkFlashTimerid);
    }
    if(this._flash){
        if(this._flash.asIM_closeChatWindow)
           this._flash.asIM_closeChatWindow();
        NtUtil.disposeFlashObj(this._flash);
        $$D.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 != ''){
        $$C.script(this._freeChatFlashGoUrl);
    }
    if(this._presenceFlashGoUrl != null && this._presenceFlashGoUrl != ''){
       $$C.script(this._presenceFlashGoUrl);
    }
    im_chat_window_manager.removeChatWindow(this._destuid, this._chatType);
    this._self.parentNode.removeChild(this._self);
    delete this._self;
    if(IMToolBar){
        IMToolBar.remove(this._destuid, this._chatType);
    }
    var _V   = Ntalker.variable;
    if( parseInt(_V['onlineChat']) < 10 ){
    	_V['onlineChat'] += 1;
	}else{
		_V['onlineChat'] = 10;
	}
    var siteid = _V['siteid'];
    var uid    = _V['user_id'];
    var destid = /^(bbshot|group|nquan)$/.test(this._chatType) ? 0 : this._destuid;
    var groupid= /^(bbshot|group|nquan)$/.test(this._chatType) ? this._destuid : 0;
    var type, desc; 
    switch(this._chatType){
        case "group":
        case "room":
        	type=3;desc=NtLang.sd_closeGroupWindow;break;
        case "nquan":
        	type=16;
        	desc=NtLang.sd_closeNQuanWindow;
        	break;
        default:type=1;desc=NtLang.sd_closeChatWindow;break;
    };
    var from = this._befrom;
    var mode   = 0;
    var source = 0;
    var action = "";
    $$C.script(Ntalker.Config.services + "/func/statistic.php?siteid="+siteid+"&uid="+uid+"&destid="+destid+"&groupid="+groupid+"&type="+type+"&mode="+mode+"&source="+source+"&desc="+encodeURIComponent(desc)+"&from="+from+"&rnd="+new Date().getTime(), "utf-8");
};
_p.startFlashTitle = function(titleText){
    if(this._flashTitleTimerID)
        return;
    this._flashTitleText = $$S.cut(titleText, 20, true);
    this._flashTitleTimerID = setInterval("im_chat_window_manager.flashWindowTitle('"+this._destuid+"')",1000);
};
_p.changeTitle = function(titleText){
    if( this._titlespan ){
    	this._titlespan.nodeValue =  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(){
    if(!this._flashcontainer)
        return;
    var swfSrc,
        _V = Ntalker.variable, 
        _C = Ntalker.Config,
        _CP= Ntalker.Config.customparams;;
    var flashvars = {v : Ntalker.version.webchat_flash,
                       r : this._jsURLPath,   
                       su: this.m_funcURLPath,
                       k : _C['skin'],
                       t : encodeURIComponent(_V['siteid']),
                       s : encodeURIComponent(_V['user_sid']),
                       u : encodeURIComponent(_V['user_id']),
                       n : encodeURIComponent(_V['user_name']),
                       d : encodeURIComponent(this._destuid),
                       dn: encodeURIComponent(this._destnick),
                       w : _C['isPopupWindow'],
                       m : (_CP['layout']=='topcascade' ? 0 : 0),
                       localeChain: _CP['localeChain'],
                       ot: this._openType,
                       ct: this._chatType,
                       lst:_CP['lstupdated']
                    };
    switch(this._chatType){
        case "chat":
            swfSrc = this._jsURLPath+"/fs/ChatMod.swf?version=" + Ntalker.version.webchat_flash;
            flashvars.l  = _C['chatlogo'] || ""; 
            flashvars.v  = Ntalker.version.webchat_flash;
            if( this._userInfo ) flashvars.info = this._userInfo;
            break;
        case "group":
        case "room":
            swfSrc = this._jsURLPath+"/fs/GroupMod.swf?version=" + Ntalker.version.group_flash;
            flashvars.l  = _C['grouplogo'] || "";                    
            flashvars.v  = Ntalker.version.group_flash;              
            if( _CP['imversion']=='2.0' && _CP.softwaretype.toLowerCase()=='phpwind' ) flashvars.iv = 'pw2.0';
            break;
        case "nquan":
            swfSrc = this._jsURLPath+"/fs/NQuanMod.swf?version=" + Ntalker.version.nquan_flash;
            flashvars.l  = _C['nquanlogo'] || "";                     
            flashvars.v  = Ntalker.version.nquan_flash;               
            flashvars.befrom = this._befrom;
            if(_V['activityid']&&_V['activitytype']){
	            flashvars.activitytype=_V['activitytype'];
	            flashvars.activityid=_V['activityid'];
            }
            break;
    } 
    if(_V['userparam'])
        flashvars.p = encodeURIComponent(_V['userparam']);
    if(_C['chatlogo'] && _CP['siteurl'])
        flashvars.f = _CP['siteurl'].toLowerCase().replace("http://","");
    else
        flashvars.f = encodeURIComponent(window.location.host);
    if(this._chatid) 
        flashvars.chatid    = this._chatid;
    if(_CP['previewsiteid']){
	    flashvars.previewsiteid = _CP['previewsiteid'];
	}
    if(flashvars.toJSONString)
        delete flashvars.toJSONString;
    var flashmode = $$B.ie?"Opaque":"Window";
    var flashmode = "Window";
    var params = {menu:"true", "salign":"LT", "allowScriptAccess":"always", "wmode":flashmode, "allowFullScreen": true};
    var attributes = {};
    var flashWidth = this._width - this._borderWidth*2;
    var flashHeight = this._height - this._borderWidth*2;
	if( parseInt(swfobject.getFlashPlayerVersion().major) < 6 ){
    	$$D.css(this._flash, 'display', 'none');
    	$$D.css($$O(this._infoTextSpanID), 'background', 'none');
    	$$O(this._infoTextSpanID).innerHTML = '<a href="http://www.adobe.com/go/getflashplayer" target="_blank">' + NtLang['noInstallFlash'] + '</a>';
    	return;
    }else{
    	swfobject.embedSWF(swfSrc, this._flashID, flashWidth, flashHeight,  "9.0.115", _V['scriptPath']+"/fs/expressInstall.swf", flashvars, params, attributes);
    	var self = this;
    	setTimeout(function(){
    		self.LoadFailure();
    	}, self._flashLoadTime);
    }
    this._flash = $$O(this._flashID);
    if( this._layout=="topcascade" ){
        this.setFlashStyle_NoTitle();
    }else{
        this.setFlashStyle();
    }
	$$D.css($$O(this._infoTextSpanID), 'display', 'none');
};
_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 flashWidth = this._width - this._borderWidth*2;
    var flashHeight = this._height - this._borderWidth*2;
    if(this._flash){
        this._flash.style.position = "relative";
        this._flash.style.width  = flashWidth + "px";
        this._flash.style.height = flashHeight + "px";
        this._flash.style.left   = this._borderWidth + "px";
        this._flash.style.top    = "0px";
        this._flashHeight        = this._flash.style.height;
    }
};
_p.setFlashStyle_NoTitle = function(){
    this._flashcontainer.style.position = "absolute";
    this._flashcontainer.style.top      = "0px";
    this._flashcontainer.style.left     = "0px";
    this._flashcontainer.style.width    = this._width+"px";
    this._flashcontainer.style.height   = this._height+"px";
    this._flashcontainer.style.overflow = "hidden";
    var flashWidth = this._width - this._borderWidth*2;
    var flashHeight = this._height - this._borderWidth*2;
    if(this._flash){
        this._flash.style.position = "relative";
        this._flash.style.width  = flashWidth + "px";
        this._flash.style.height = flashHeight + "px";
        this._flash.style.left   = this._borderWidth + "px";
        this._flash.style.top    = "0px";
        this._flashHeight        = this._flash.style.height;
    }
};
_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;
    var _Ht = [];
    var flashWidth = this._width - 2 * this.borderWidth;
	var flashHeight = this._height - 2 * this.borderWidth;
    _Ht.push(    "<div id='" + this._infoTextSpanID + "' style='cursor:auto;width:"+flashWidth+"px;height:"+flashHeight+"px;line-height:" + flashHeight + "px;text-align:center;'></div>");
    _Ht.push(    "<div id='" + this._flashID + "' style=''></div>");
    this._flashcontainer. innerHTML = _Ht.join('');
    if(this._waitFlashAutoLoadTimeid) clearTimeout(this._waitFlashAutoLoadTimeid);
    this.createFlash();
    if( this._layout=="topcascade" ){
        this.setFlashStyle_NoTitle();
    }else{
        this.setFlashStyle();
    }
};
_p.LoadFailure = function(){
    var _V = Ntalker.variable, _C = Ntalker.Config;
    if(this._isFlashLoadSuccess){
    	return;
    }
    var self = this;
    this._restoreFlash = this._flash;
    var flashWidth = this._width - 2*this.borderWidth;
    var flashHeight = this._height - this.titleHeight;
    if(self._flash){
        $$D.css(this._flash, "display", "none");
        try{
        	this._flash.parentNode.removeChild(this._flash);
    	}catch(e){
    		this._flash.style.width = 1 + 'px';
    		this._flash.style.height = 1 + 'px';
    	}
    }
    var closeButtonId = 'CloseIMWindowButton';
    var reLoadButtonId = 'reLoadFlashButton';
    $$D.css($$O(this._infoTextSpanID), 'backgroundImage', 'none');
    $$D.css($$O(this._infoTextSpanID), 'display', 'block');
    var _Ht = [];
    _Ht.push('<div>');
    _Ht.push(    '<div name="winlogo" style="float:left;width:70px;height:20px;background:url(' + _C['logo'] + ') center center no-repeat;"></div>');
    _Ht.push(    '<div name="wintitle" style="float:left;width:280px;height:20px;background:url(' + _C['publicDIR'] + 'titleText.gif) center center no-repeat;"></div>');
	_Ht.push(    '<div id="'+closeButtonId+'" name="btnclose" style="z-index:12;float:right;margin-right:8px;width:26px;height:20px;background:url('+_C['publicDIR'] + 'closewin.gif) center top no-repeat;cursor:pointer;"></div>');
	_Ht.push('</div>');
	_Ht.push('<div style="clear:both;height:' + (flashHeight-20) + 'px;line-height:' + (flashHeight-20) + 'px;">');
	_Ht.push(    '<a id="'+reLoadButtonId+'" href="javascript:void(0)">' + NtLang['loadFlashFailure'] + '</a>');
	_Ht.push('</div>');
    $$D.insert($$O(this._infoTextSpanID), _Ht.join(''));
    var self = this;
    var __clearClick  = function(e){$$E.fixEvent(e).stopPropagation();};
    var __closeWaitWin = function(e){self.close();};
    var __reloadFlash = function(){ self.reloadFlash();};
    if(this._FlashReloadCount < 2 && !this._isFlashLoadSuccess){
        this._waitFlashAutoLoadTimeid = setTimeout( __reloadFlash, this._waitFlashAutoLoad);
    }
    if( $$O(this._infoTextSpanID) ) $$O(this._infoTextSpanID).onclick = __clearClick;
    if( $$O(closeButtonId) ) $$O(closeButtonId).onclick = __closeWaitWin;
    if( $$O(reLoadButtonId) ) $$O(reLoadButtonId).onclick = __reloadFlash;
};
_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=="topcascade"){
                   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 "mousedown":
                if(this.isLocked) return;
                break;
            case "mouseup":
                break;
            case "focus":
                this.onFocus();
                break;
            case "blur":
                this.onBlur();
                break;
            case "dblclick":
            	if(this._layout=="topcascade"){
                   if(this._curWindMode=="min"){
                       this.onFocus();
                   }else
                       im_chat_window_manager.minCurWindow();
               }else
              		this.minimize(eeName);
                break;
        }
    }
};
_p.refreshFlashPos = function(){
    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 = ($$B.StrictMode ? moveOffset : (this._borderWidth + moveOffset) )+"px";
};
_p.onFocus = function(){
	var _V = Ntalker.variable;
    this._self.style.zIndex = this._focusZIndex;
    this._flashcontainer.style.zIndex = this._focusZIndex;
    this._flash.style.zIndex = this._focusZIndex;
    try{
        this._flash.focus();
    }catch(e){}
    if( this._chatType == 'nquan' ){
        showDiv(this._chatType + '_' + this._destuid);
    }
    _V['OnFocusWinParam'] = [this._destuid, this._chatType];
    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 _V = Ntalker.variable;
    var prompStr = null;
    if(this._avStatus=="audio")
        prompStr = NtLang.endAudioSession;
    else if(this._avStatus=="vedio")
        prompStr = NtLang.endVideoSession;
    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 = NtLang['audioSession'];
    }
    else if(this._avStatus!="audio"){
        this._avStatus = "audio";
        calltype = NtLang['videoSession'];
    }
    var promptTitle = sprintf(NtLang['requestSessionTitle'], 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, NtLang['fileTransfer'], true);
};
_p.closeAV = function(isVedio){
    this._avStatus = "";
    if(this._curWindMode=="min"){
        this.stopFlashTitle();
    }
    this._titleText = sprintf(NtLang['minWindowTitle'], this._destnick);
    this.changeTitle(this._titleText);
};
_p.onReceiveMessage = function(message){
    if(this._curWindMode=="min" || this._curWindMode=="hide"){
        var titleText = sprintf(NtLang['receiveMessageTitle'], this._destnick, message);
        this.startFlashTitle(titleText);
        if(IMToolBar){
            var miniWindow = IMToolBar.get(this._destuid, this._chatType);
            miniWindow.onReceiveMiniMessage(message);
        }
        var impresenceflash = $$O('impresenceflash');
        if(impresenceflash && impresenceflash.playNotifySound){
            impresenceflash.playNotifySound();
        }
    }
};
_p.onPresenceReceiveChatMsg = function(message){
    if(this._flash && this._flash.presenceReceiveChatMsg)
        this._flash.presenceReceiveChatMsg(message);
};
WDK_IM_PACK.ChatWindowManager = function(){
    this._chatWnds = new IMHashtable();
    this._chatWndsArray = new Array();
    this._popupChatWnds = new IMHashtable();
    this._creatingFlashWnds = new Array();
    this._windowWidth  = 0;
    this._windowHeight = 0;
    this._windowTitleHeight = 20;
    this._layout = "toolbar"; 
    this._align = "right";
    this._layoutRight = 0;
    this._layoutLeft = 0;
    this._layoutBottom = 0;
    this._curLayoutTop = 0;
    this._curLayoutBottom = 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, userinfo, befrom){
    var _C = Ntalker.Config,
        _CP= Ntalker.Config.customparams,
        _V = Ntalker.variable;
    this._layout = _CP['layout']; 
    this._align = _CP["floatpos"];
    var chatRect = {left:0,top:0,right:0,bottom:0};
    switch(chatType){
        case "nquan":
        case "group":
        case "room":
            this._windowWidth  = _C['groupWidth'];
            this._windowHeight = _C['groupHeight'];
            befrom = befrom ? befrom : 'groupList';
            break;
        default:
            this._windowWidth  = _C['chatWidth'];
            this._windowHeight = _C['chatHeight'];
            befrom = befrom ? befrom : 'buddyList';
            chatType = "chat";
            break;
    }
    var chatWindow = this.getChatWindow(destuid, chatType);
    if(chatWindow){
        if(this._layout=="topcascade"){
            chatWindow.onFocus();
        }else{
            this.OnTBFocusWindow(destuid, chatType);
        }
        chatWindow.onPresenceReceiveChatMsg(message);
        return;
    }
    var chatWndsArray = im_chat_window_manager._chatWndsArray, 
		chatWndCount = chatWndsArray.length, 
		maxChatWnd = false;
	for(var i = 0; i < chatWndCount; i++ ){
		if( chatWndsArray[i]._curWindMode != 'hide' ){
			maxChatWnd = true;
		}
	}
	if( (OpenType==-1&&this._layout=="topcascade") ||
		chatWndCount>0&&maxChatWnd&&OpenType<=0 ||
		!isAutoFocus&&OpenType<=0 ){
			isAutoFocus = false;
	}else{
		isAutoFocus = true;
	}
	if(_V['OnFocusWinParam'].length>0 && !isAutoFocus){
        _V['OnBlurWinParam'] = maxChatWnd ? _V['OnFocusWinParam'] : [];
    }
    if(isAutoFocus){
    	_V['OnFocusWinParam'] = [destuid, type];
    }
    if( _C['isPopupWindow']==1 && !(OpenType===1) ){
        window.focus();
        if( _C['isPopupWindow'] && promptwindow ) promptwindow.startPrompt(NtLang['popupWindowTitle'], true);
    }
    var wRt = $$D.windowRect();
    var newChatWindow = new WDK_IM_PACK.WDKChatWindow(destuid, destnick, chatid, this._layout, chatType, roomtype, OpenType, userinfo, befrom);
    var l = this._chatWndsArray.length;
    for(var i=0; i<l; i++){
        this._chatWndsArray[i].hide();
	}
    if( this._layout == 'pwtoolbar' )
    {
        var miniWinDOM_Tab = IMToolBar.add(destuid, destnick, logoUrl, isAutoFocus, chatType, OpenType);
        chatRect.bottom = 28;
        chatRect.right  = 0;
        newChatWindow.showWindow(chatRect, miniWinDOM_Tab);
        if(!isAutoFocus && _V['OnBlurWinParam'].length>0){
            newChatWindow.MinMax();
            var _destuid = _V['OnBlurWinParam'][0];
            var _chatType= _V['OnBlurWinParam'][1];
            this.OnTBFocusWindow(_destuid, _chatType);
        }else if( !isAutoFocus ){
        	newChatWindow.MinMax();
        	this.OnTBFocusWindow(0);
        }
    }else if( this._layout == 'dztoolbar' ) {
        var minWnd = IMToolBar.add(destuid, destnick, logoUrl, isAutoFocus, chatType, OpenType);
        var mRt = minWnd.getPost();
        var tRt = $$D.clientRect(IMToolBar.contentElement);
        var y, x;
        if( IMToolBar.currentToolbarMode == 2 ){
        	x = mRt.rx - this._windowWidth - tRt.left;
        }else{
        	x = Math.min(mRt.x, tRt.w - this._windowWidth - _C['IMWidth'] - 10);
    	}
        var miniWinDOM_Tab = NtUtil.$$(".miniTAG_tab", minWnd.Element)[0];
        _r = NtUtil.scrollWidth();
        if($$B.QuirksModel){
            y = mRt.y-this._height + 5;
        }else{
            y = 0-this._height;
        }
        var chatRect = {left:x, top:0, bottom:0, right:0};
        newChatWindow.showWindow(chatRect, miniWinDOM_Tab);
        if(!isAutoFocus && _V['OnBlurWinParam'].length>0){
            newChatWindow.MinMax();
            var _destuid = _V['OnBlurWinParam'][0];
            var _chatType= _V['OnBlurWinParam'][1];
            this.OnTBFocusWindow(_destuid, _chatType);
        }else if( !isAutoFocus ){
        	newChatWindow.MinMax();
        	this.OnTBFocusWindow(0);
        }
    }else if(this._layout == "toolbar"){
        var minWnd = IMToolBar.add(destuid, destnick, logoUrl, isAutoFocus, chatType, OpenType), 
            mRt = minWnd.getPost(), 
            miniWinDOM_Tab = NtUtil.$$(".miniTAG_tab", minWnd.Element)[0],
            _r = NtUtil.scrollWidth();
        chatRect.bottom = 0;
        if($$B.QuirksModel){
            rightOffset  = wRt.x + wRt.w - mRt.x - this._windowWidth;
            if(this._align=="right"){
                chatRect.right = Math.min(rightOffset, _C['IMWidth']+_r);
            }
            chatRect.bottom = 28;
            newChatWindow.showWindow(chatRect);
        }else{
            rightOffset = wRt.x + wRt.w - mRt.x - this._windowWidth;
            if(this._align=="right"){
                chatRect.right = rightOffset<_C['IMWidth']+_r ? _C['IMWidth']+_r+10 : rightOffset;
            }else{
                if(IMToolBar._Pattern!=0){
                    chatRect.right = rightOffset>wRt.w-_C['IMWidth']-this._windowWidth ? wRt.w-_C['IMWidth']-this._windowWidth : (rightOffset<_r ? _r : rightOffset);
                }else{
                    chatRect.right = rightOffset;
                }
            }
            newChatWindow.showWindow(chatRect, miniWinDOM_Tab);
        }
        if(!isAutoFocus && _V['OnBlurWinParam'].length>0){
            newChatWindow.MinMax();
            var _destuid = _V['OnBlurWinParam'][0];
            var _chatType= _V['OnBlurWinParam'][1];
            this.OnTBFocusWindow(_destuid, _chatType);
        }else if( !isAutoFocus ){
        	newChatWindow.MinMax();
        	this.OnTBFocusWindow(0);
        }
    }else if(this._layout=="topcascade"){
        _V['OnFocusWinParam'] = [destuid, chatType];
        if(isAutoFocus && this._curWindowIndex>=0){
            this._curWindowIndex = -1;
            this.layoutWindow();
        }
        this._layoutLeft  = 20;
        this._layoutRight = wRt.w - this._windowWidth - this._layoutLeft;
        chatRect = {
            left:this._layoutLeft,
            right:this._layoutRight,
            top:wRt.h - this._windowHeight - this._curLayoutTop,
            bottom:this._curLayoutBottom
        };
        newChatWindow.showWindow(chatRect);
        this._curLayoutBottom += this._windowTitleHeight;
        if(isAutoFocus || (this._curWindowIndex==-1&&OpenType>-1) ){
            this._curWindowIndex = this._chatWndsArray.length;
            curWindowHeight = newChatWindow._height;
            this._curLayoutTop += curWindowHeight;
        }
        else{
            newChatWindow.minimize();
            curWindowHeight = this._windowTitleHeight;
            leftPos = this._layoutLeft;
            topPos  = Math.max(0, wRt.y + wRt.h - this._curLayoutTop - curWindowHeight);
            newChatWindow.moveTo(leftPos, topPos);
            if(typeof(message)!="undefined" && message){
                var titleText = sprintf(NtLang['receiveMessageTitle'], destnick, message);
                newChatWindow.startFlashTitle(titleText);
            }
            this._curLayoutTop += curWindowHeight;
        }
        if(OpenType==-1){
        	this.layoutWindow();
    	}else{
    		this.layoutWindow(destnick, chatType);
    	}
    }
    this._chatWnds.add(destuid+chatType, newChatWindow);
    this._chatWndsArray.push(newChatWindow);
    this._curChatWindow = newChatWindow;
    var siteid = _V['siteid'];
    var uid = _V['user_id'];
    var destid = /^(room|group|nquan)$/.test(chatType) ? 0 : destuid;
    var groupid= /^(room|group|nquan)$/.test(chatType) ? destuid : 0;
    var type,i,desc; 
    switch(chatType){
        case "group":
        case "room":
        	type=2;desc=NtLang.sd_GroupWindow;break;
        case "nquan":
        	type=15;
	        desc=NtLang.sd_NQuanWindow;
    	    break;
        default:type=0;desc=NtLang.sd_ChatWindow;break;
    }
    var from = befrom;
    switch(OpenType){case 1:i=0;break;case -1:i=2;break;default:i=1;}
    desc += NtLang.sd_eventType[i];
    var mode; switch(OpenType){case 1:mode=1;break;case -1:mode=3;break;default:mode=2;};
    var source = 0;
    var action = "";
    $$C.script(_C['services'] + "/func/statistic.php?siteid="+siteid+"&uid="+uid+"&destid="+destid+"&groupid="+groupid+"&type="+type+"&mode="+mode+"&source="+source+"&desc="+encodeURIComponent(desc)+"&from="+from+"&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, this._chatWndsArray[newCurWindowIndex]._chatType);
    }
    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);
    var _V = Ntalker.variable;
    if(chatWindow._curWindMode == "default")
        return;
    if(this._layout=="topcascade"){
        this.layoutWindow(destuid, chatType);
    }else{
        for(var k in this._chatWnds._hash){
            chatWindow = this._chatWnds._hash[k];
            if(chatWindow._destuid!=destuid || chatWindow._chatType != chatType){
                chatWindow.onBlur();
            }
            else{
                this._curChatWindow = chatWindow;
            }
        }
    }
};
_p.layoutWindow = function(newCurWindowUid, chatType){
    if(this._layout!="topcascade") return;
    var wRt = $$D.windowRect();
    this._curLayoutTop = this._layoutBottom;
    this._curLayoutBottom = 0;
    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 && chatWindow._chatType == chatType){
            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 = this._layoutLeft;  
        topPos  = Math.max(0, wRt.y + wRt.h - this._curLayoutTop - curWindowHeight );
        chatWindow.moveTo(leftPos, topPos, true, curWindowHeight);
        this._curLayoutTop += curWindowHeight;
        this._curLayoutBottom += this._windowTitleHeight;
    }
    if(newCurWindowUid && newCurWindowIndex>=0){
        this._curWindowIndex = newCurWindowIndex;
        try{
            this._chatWndsArray[this._curWindowIndex]._flash.focus();
        }catch(e){}
    }
};
_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 = /^(group|room|nquan)$/.test(chatType) ? chatType : 'chat';
    return this._chatWnds.items(destuid + chatType);
};
_p.getPopupWindow = function(destuid, chatType){
    chatType = /^(group|room|nquan)$/.test(chatType) ? chatType : '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){
    var l = this._chatWndsArray.length;
    for(var i=0; i < l; i++){
        if(this._chatWndsArray[i]._destuid==destuid && this._chatWndsArray[i]._chatType==chatType){
            if( 'topcascade'==this._layout ){
                this._chatWndsArray[i]._curWindMode = "min";
            }else{
                this._chatWndsArray[i]._curWindMode = "hide";
                this._chatWndsArray[i].MinMax();
            }
        }else{
            if(this._chatWndsArray[i]._curWindMode == 'default'){
                if( 'topcascade'==this._layout ){
                    this._chatWndsArray[i].minimize();
                }else{
                    this._chatWndsArray[i].MinMax();
                }
            }
        }
    }
};
_p.hideFlash= function(){
    var l = this._chatWndsArray.length;
    for(var i=0; i < l; i++){
        var tab = $$O("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_reLoadFlash(destuid, chatType){
	if( destuid &&  chatType){
		if( im_chat_window_manager ){
			im_chat_window_manager.getChatWindow(destuid,chatType).reloadFlash();
		}
	}
	else{
		if(im_myIMWindow){
			im_myIMWindow.reloadFlash();
		}
	}
	return true;
}
function fIM_CloseIMWindow(){
    try{
	    if(im_myIMWindow){
	    	im_myIMWindow.close();
	    }
	}catch(e){}
	promptwindow.handleFocus();
}
function fIM_PopupIMWindow(){
    if(IMToolBar){
    	IMToolBar.onPopupOut();
    }
}
function fIM_CloseChatWindow(destuid, chatType){
    if(im_chat_window_manager){
        var chatWin = im_chat_window_manager.getChatWindow(destuid,chatType);
        chatWin && chatWin.close();
    }
    setTimeout(function(){try{promptwindow.handleBlur();}catch(e){}}, 50);
}
function fIM_PopupChatWindow(){
    if(IMToolBar) IMToolBar.onPopupOut();
}
function fIM_MinMaxChatWindow(destuid, chatType){
    var _CP = Ntalker.Config.customparams;
    if(im_chat_window_manager){
        if( _CP['layout'] == 'topcascade'){
            var curChatWin = im_chat_window_manager.getChatWindow(destuid, chatType);
            if(curChatWin._curWindMode=="min"){
               curChatWin.onFocus();
            }else{
               im_chat_window_manager.minCurWindow();
            }
        }else{
            im_chat_window_manager.getChatWindow(destuid, chatType).MinMax();
        }
    }
}
function fIM_MaximunChatWindow(destuid, chatType,roomtype){
    var _V = Ntalker.variable;
    if(!im_chat_window_manager || !/^(group|nquan)$/.test(chatType)) return;
    var groupWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
    if(!groupWindow) return;
    var popupWindow = im_popupGroupWindow(_V['user_id'], _V['user_name'], _V['user_sid'], _V['siteid'], destuid, groupWindow._destnick, null, _V['userparam'], 0, roomtype, chatType);
    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_buddylistFlashInitialization(){
	if(im_myIMWindow){
        im_myIMWindow.onFlashLoadSuccess();
    }
}
function fIM_webchatFlashInitialization(destuid, chatType){
	var chatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
    if(chatWindow){
        chatWindow.onFlashLoadSuccess();
    }
    return true;
}
function fIM_webchatFlashReady(destuid, chatType){
    return true;
}
function fIM_buddylistFlashReady(){
    var buddylistFlash = document.getElementById("wdk_buddylist_flash"),
        _V = Ntalker.variable;
    if(buddylistFlash && buddylistFlash.setBuddylistFlashParam){
        buddylistFlash.setBuddylistFlashParam(_V['user_sid'], _V['user_id'], _V['user_name'], _V['siteid'],"buddylist");
    }
}
function fIM_setBuddylistFlashParamfunc(){
    var buddylistFlash = document.getElementById("wdk_buddylist_flash"),
        _V = Ntalker.variable;
    if(buddylistFlash && buddylistFlash.setBuddylistFlashParam){
      buddylistFlash.setBuddylistFlashParam(_V['user_sid'], _V['user_id'], _V['user_name'], _V['siteid'], "buddylist");
    }
}
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 || "";
    this._headURL    = headURL;
    this.originTitle = "";
    this.Element     = null;
    this._counter    = 0;
    this.timerID     = null;
    this.autoFocus   = isAutoFocus;
    this.minChatWidth= 115;
    this.customModel = 0;
};
_p = minWindow.prototype;
_p.init = function(customModel){
    var elem;
    this.customModel = customModel ? 1 : 0;
    var _C = Ntalker.Config;
    if(this.customModel){
        var menuNode = $$O("windows");
        if(!menuNode) return;
        elem = this.Element = $$D.create('li', {id:"miniTAG_"+this._destuid+this._chatType,className:"act group"}, menuNode );
        this.originTitle = $$S.cut(this._destnick, 5, true);
        var divNode   = $$D.create('div', {}, elem);
        var linkNode  = $$D.create('a', {}, divNode);
        linkNode.href = "javascript:void(0);";
        var textNode  = $$D.create('text', {text:this.originTitle}, linkNode);
        if(this.autoFocus) this.onFocus();
        var self   = this;
        var __clickMinWindow = function(ev){self.onClick(ev);};
        $$E.addEvent(elem, "click",     __clickMinWindow);
    }else{
        elem = this.Element = $$D.create('li', {id:"miniTAG_"+this._destuid+this._chatType,className:"win"}, $$O("windows_gp"));
        this.originTitle = $$S.cut(this._destnick, 5, true);
        switch( this._chatType.toLowerCase() ){
            case 'chat':
                imgsrc = _C['publicDIR'] + '/chat.'+($$B.ie6?'gif':'png');break;
            case 'nquan':
            	imgsrc = _C['publicDIR'] + '/nquan.'+($$B.ie6?'gif':'png');break;
            case 'group':
            	imgsrc = _C['publicDIR'] + '/group.'+($$B.ie6?'gif':'png');break;
            case 'room':
                imgsrc = _C['publicDIR'] + '/room.'+($$B.ie6?'gif':'png');break;
        }
        var icoNode   = $$D.create('div', {className:"ico"}, elem);
        var imageNode = $$D.create('img', {className:"userHead",src:imgsrc}, icoNode);
        var textSpan  = $$D.create('span',{className:""}, elem);
        var textNode  = $$D.create('text',{text:this.originTitle}, textSpan);
        var closeNode = $$D.create('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= $$D.create('div', {className:"miniTAG_tab",id:"miniTAG_"+this._destuid+this._chatType+"_tab",style:"border:0px solid #f00"}, this.Element);
        if(this.autoFocus) this.onFocus();
        var self   = this;
        var __imageError     = function(ev){imageNode.src=imgsrc;};
        var __clickMinWindow = function(ev){
        	$$E.fixEvent(ev).stopPropagation();
        	self.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 ) $$D.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 ) $$D.removeClass(current, "hover", "");
        };
        var __closeMinWindow = function(ev){
            $$E.fixEvent(ev).stopPropagation();
            var aRt = $$D.clientRect('windows_area');
            var show_areaWidth = aRt.w + ($$B.ie6 ? 3 : 0);
            var scrollLeft     = $$O('windows_area').scrollLeft;
            var preCountWind   = 1;
            if(IMToolBar){
                for(var k in IMToolBar.minWindows._hash){
                    if(IMToolBar.minWindows._hash[k]._destuid == self._destuid && IMToolBar.minWindows._hash[k]._chatType == self._chatType)
                        break;
                    else
                        preCountWind++;
                }
            }
            var cur_allWidth   = self.minChatWidth*preCountWind;
            if( show_areaWidth >= (cur_allWidth - scrollLeft))
                fIM_CloseChatWindow(self._destuid, self._chatType);
        };
        $$E.addEvent(imageNode,    "error",     __imageError);
        $$E.addEvent(elem, "click",     __clickMinWindow);
        $$E.addEvent(elem, "mouseover", __overMinWindow);
        $$E.addEvent(elem, "mouseout",  __outMinWindow);
        $$E.addEvent(closeNode,    "click",     __closeMinWindow);
    }
    return elem;
};
_p.updateUserHead = function(strheadURL, intStatus){
    if(this.customModel) return;
    var _img = NtUtil.$$(".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  = $$O('windows_area');
    var scrollLeft = AreaElemt ? AreaElemt.scrollLeft : 0;
    var mRt = $$D.clientRect(this.Element);
    var _x  = mRt.left-($$B.ie6 ? 2 : 0) - scrollLeft;
    var _rx = mRt.left+mRt.w+($$B.ie6 ? 2 : 0) - scrollLeft;
    return {x:_x, y:mRt.top, w:mRt.w, h:mRt.h,rx:_rx};
};
_p.onClick = function(e, target){
    if(!target){
        var event = $$E.fixEvent(e);
        target = searchTag(event.target, "li");
        if(!target) return;
    }
    var _C = Ntalker.Config,
        _CP= Ntalker.Config.customparams;
    if(IMToolBar && _CP['layout'] == 'custom' && !_C['isPopupWindow']){
    	IMToolBar.showMenu("ntalkerchatwinsMenu", "out");
    }
    if( chatWindowManager.getChatWindow(this._destuid, this._chatType)._curWindMode == 'default' ){
    	this.onBlur();
    	im_chat_window_manager.OnTBFocusWindow(0);
    }else{
	    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;
    $$D.addClass(this.Element, "selected");
    if(this._destuid) 
        Ntalker.variable.OnFocusWinParam = [this._destuid, this._chatType];
    return this.getPost();
};
_p.onBlur = function(){
    this._focus = false;
    $$D.removeClass(this.Element, "selected");
    return;
};
_p.onReceiveMiniMessage=function(message){
    var titleText = sprintf(NtLang['sayContent'], message);
    this.startFlashTitle(titleText);
};
_p.startFlashTitle = function(titleText){
    if(this.timerID)
        return;
    this.promptMsg = $$S.cut(titleText,5);
    this.flashWindowTitle();
};
_p.flashWindowTitle = function(){
    if(this._focus){
        $$D.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){
        $$D.removeClass(this.Element, "flash");
    }else{
        $$D.addClass(this.Element, "flash");
    }
    var _timer     = this._counter%2==0 ? 500 : 1000;
    this.timerID = setTimeout("IMToolBar.get('"+this._destuid+"', '"+this._chatType+"').flashWindowTitle()", _timer);
};
function NtMenu(debug){ 
    this._debug = debug;
    this._Hash = new IMHashtable();
    this._span = null;
    this._Button = null;
    this._over  = {};
    this._out   = {};
    this._click = {};
    this._overItem = false;
    this._className = '';
    this._overClassName = '';
}
NtMenu.prototype.init = function(span, Btn, mattr, over, out, click, visibleNoneCallFunction, visibleCallFunction, openedCallFunction){
    this._span = span;
    this._Button  = Btn;
    this._mAttr = mattr;
    this._over = over;
    this._out  = out;
    this._click= click;
    this.visibleNoneCallFunction = visibleNoneCallFunction;
    this.visibleCallFunction = visibleCallFunction;
    this.openedCallFunction = openedCallFunction;
    this._timer = null;
    this._Menu = null;
    this._MenuID = mattr['id'];
    this._MenuInited = false;
    this._MenuContentElement = null;
    var self = this;
    var __showMenu = function(e){self.show();};
    $$E.addEvent(this._Button, 'click', __showMenu);
};
NtMenu.prototype.add = function(k,obj){if(this._Hash.items(k)){return false;} this._Hash.add(k, obj);};
NtMenu.prototype.remove = function(k){this._Hash.remove(k);};
NtMenu.prototype.get = function(k){return this._Hash.items(k);};
NtMenu.prototype.length = function(){return this._Hash.count();};
NtMenu.prototype.hidden = function(){
	if( this._debug ){
		return;
	}
	try{
		clearInterval(this._timer);
		this._Menu.parentNode.removeChild(this._Menu);
		this._MenuInited = false;
	}catch(e){}
};
NtMenu.prototype.show = function(){
    var self = this;
    var _B = this._Button,_PN = this._span, _U, 
    _mAttr = this._mAttr, _O1 = this._over, _O2 = this._out, _O3 = this._click;
    if(this._Hash.count()==0 && typeof self.visibleNoneCallFunction == 'function'){
        self.visibleNoneCallFunction.call(this);
        return;
    }
    if( this._MenuInited && typeof(self.openedCallFunction) == 'function' ){
    	self.openedCallFunction.call(this);
    	return;
    }
    var __menuHidden = function(){
    	if(!self._overItem){
    		self.hidden();
    	}
    };
    var __menuOver = function(e){
        var Func = _O1.callback, event, target;
        self._overItem = true;
        event = $$E.fixEvent(e);
        target= searchTag(event.target, "li");
        $$D.replaceClass(target, _O2.className, _O1.className);
        if(typeof Func == 'function') Func.call(this, target);
    };
    var __menuOut = function(e){
        var Func = _O2.callback, event, target;
        self._overItem = false;
        event = $$E.fixEvent(e);
        target= searchTag(event.target, "li");
        $$D.replaceClass(target, _O1.className, _O2.className);
        if(typeof Func == 'function') Func.call(this, target);
    };
    var __menuClick = function(e){
        var Func = _O3.callback, Exec = _O3.exec, event, target, M = self._Menu;
        event = $$E.fixEvent(e);
        target= searchTag(event.target, "li");
        if(typeof Func == 'function'){
            Func.call(this, target);
        }
        if( Exec===false ){
            return;
        }
        try{
            self.remove(target.getAttribute('k'));
            M.parentNode.removeChild(M);
        }catch(e){}
        clearInterval(self._timer);
    };
    function createChildNode(attribute, parentNode){
    	var tagName = attribute.tagName ? attribute.tagName : 'div';
    	var className = attribute.className ? attribute.className : '';
    	var styleText = attribute.style ? attribute.style : '';
    	var childNode = attribute.childNode;
    	parentNode = $$D.create(tagName, {className:className, style:styleText}, parentNode);
    	if( childNode ){
    		return createChildNode(childNode, parentNode);
    	}else{
    		return parentNode;
    	}
    }
    if( !$$O(this._MenuID)){
        var _Ht = ['<' + (_mAttr.tagName ? _mAttr.tagName : 'span')];
        for(var attr in _mAttr){
        	if( !/^(tagName|childNode)$/.test(attr) ){
            	_Ht.push(' ' + (attr.toLowerCase()=='classname' ? 'class' : attr) + '="' + _mAttr[attr]+'"');
        	}
        }
        _Ht.push('>');
        _Ht.push('</' + (_mAttr.tagName ? _mAttr.tagName : 'span') + '>');
        this._Menu = this._MenuContentElement = $$D.insert(_PN, _Ht.join(''), 'beforeend');
        if( _mAttr.childNode ){
        	this._MenuContentElement = createChildNode(_mAttr.childNode, this._MenuContentElement);
        }
        this._overItem = true;
        self._timer = setInterval(__menuHidden, 500);
    }
    this._MenuContentElement.innerHTML = '';
    _U = $$D.insert(this._MenuContentElement, '<ul class="NtMenuMessageBox"></ul>');
    for(var k in this._Hash._hash){
        var _V1 = this._Hash._hash[k], _Ht = ['<li k="' + k + '"'], type = 'item';
        for(var ck in _V1.custom){
            if (ck.toLowerCase() == 'type' )
                type = _V1.custom[ck];
            if(ck.toLowerCase()=='classname')
                _Ht.push(' class="' + _V1.custom[ck]+' '+_O2.className + '"');
            else
                _Ht.push(' ' + ck + '="' + _V1.custom[ck] + '"');
        }
        _Ht.push('><div><a href="javascript:void(0)">' + _V1.text + '</a></div></li>');
        _L = $$D.insert(_U, _Ht.join(''), 'beforeend');
        if ( type == 'item' ){
            $$E.addEvent(_L, 'mouseover', __menuOver);
            $$E.addEvent(_L, 'mouseout', __menuOut);
            $$E.addEvent(_L, 'click', __menuClick);
        }else if(type=='close'){
             $$E.addEvent($$D.filter(($$D.filter(_L.childNodes)[0]).childNodes)[0], 'click', __menuClick);
        }
    }
    this._MenuInited = true;
    if( typeof self.visibleCallFunction == 'function'){
        self.visibleCallFunction.call(this, _U);
    }
    $$A.each([_B,this._MenuContentElement], function(elem){
        $$E.addEvent(elem, 'mouseover', function(e){self._overItem = true;});
        $$E.addEvent(elem, 'mouseout', function(e){self._overItem = false;});
    });
};
function NtBaseTbar(){ 
    this.minWindows   = new IMHashtable();
    this.minWinCount  = 0;
    this._timer       = [];
    this._flashNum    = [];
    this._stopFlash   = [];
    this._customMessageCount = 0;
    this._systemMessageMenu = null;
    this._groupMessageMenu = null;
}
_p = NtBaseTbar.prototype;
_p.type = function(chatType){
    switch(chatType){
        case "nquan":return "nquan";
        case "room":return "room";
        case "group":return "group";
        case "bbshot":return "bbshot";
        default: return "chat";
    }
};
_p.get = function(uid, type){
    return this.minWindows.items("MiniTAG"+uid + this.type(type));
};
_p.add = function(uid, name, src, isAutoFocus, type, customModel){
    var _V = Ntalker.variable;
    var hashKey= "MiniTAG" + uid + this.type(type);
    var w = this.get(uid, this.type(type));
    if(w) 
        return;
    w = new minWindow(uid, name, src, isAutoFocus, type);
    w.init(customModel);
    this.minWindows.add(hashKey, w);
    this.minWinCount = this.minWindows.count();
    return w;
};
_p.remove = function(uid, type){
    var fid = "", ft="", pi = 0, pt="", g = false;
    for(var k in this.minWindows._hash){
        var item = this.minWindows._hash[k];
        if(item._destuid == uid && item._chatType == type){
            g = true;
            if(pi){
                fid = pi;
                ft  = pt; 
                break;
            }
        }else{
            pi = item._destuid;
            pt = item._chatType;
            if(g){
                fid = pi;
                ft  = pt; 
                break;
            }
        }
    }
    var mWinId = "miniTAG_" + uid + type;
    var hashKey= "MiniTAG" + uid + type;
    var mWinElement = $$O(mWinId);
    if(!mWinElement) return;
    mWinElement.parentNode.removeChild(mWinElement);
    var minWin = this.minWindows.items(hashKey);
    if( !minWin) return;
    this.minWindows.remove(hashKey);
    this.minWinCount = this.minWindows.count();
    Ntalker.variable.OnFocusWinParam = [fid, ft];
    im_chat_window_manager.OnTBFocusWindow(fid, ft);
};
_p.enableflash = function(key, className, FclassName, auto){
    var target = $$O(key);
    if( this._timer[key] && !auto) return;
    if( (this._stopFlash[key]==true || this._flashNum[key]>=3)){
        $$D.replaceClass(target, FclassName, className);
        this._stopFlash[key] = false;
        this._flashNum[key] = null;
        return;
    }else if( $$S.isDefined(this._flashNum[key]) && !auto ){
        this._flashNum[key] = 1;
    }
    if(this._timer[key] == 500){
        this._timer[key] = 1000;
        $$D.replaceClass(target, FclassName, className);
    }else{
        this._timer[key] = 500;
        $$D.replaceClass(target, className, FclassName);
        if( !$$S.isDefined(this._flashNum[key]) )
            this._flashNum[key] = 1;
        else
            this._flashNum[key] += 1;
    }
    setTimeout(function(){IMToolBar.enableflash(key, className, FclassName, true);}, this._timer[key]);
};
_p.disableFlash = function(key){
    this._stopFlash[key]   = true;
};
_p.onPopupOut = function(){
    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 = NtLang.endAudioSession;break;
                case "vedio": prompStr = NtLang.endVideoSession;break;
            }
            if(chatWins[i]._TransferState) prompStr = NtLang.endFiletrans;
        }
        if(prompStr && !confirm(prompStr))
            return;
    }
    var _V = Ntalker.variable;
    var popupWindow = im_popupToolbar(_V['user_id'], _V['user_name'], _V['user_sid'], _V['siteid'], _V['userparam'], true, _V['scriptPath'], _C['imagesDIR']);
};
_p.onPopupIn = function(){
    window.close();
};
_p.onShowBuddylist = function(e, index){
    if( !im_myIMWindow ) return;
    index = index!=null ? index : 0;
    Ntalker.Config.IMtabIndex = index;
    im_myIMWindow.OnTBShowBuddylist(true);
    if(IMToolBar&&IMToolBar.closeMessagebox)IMToolBar.closeMessagebox();
};
_p.Mutex = function(type, _MCount){
    groupMessageCount = _MCount ? _MCount : 0;
    switch(type){
        case "system":
            if(im_myIMWindow) im_myIMWindow.close();
            break;
        case "group":
            if(groupMessageCount>0) if(im_myIMWindow) im_myIMWindow.close();
            if(IMToolBar&&IMToolBar.closeMessagebox)IMToolBar.closeMessagebox();
            break;
        default:
            break;
    }
};
function NtTopTbar(){ 
    this.element = null;
    this.contentElement = null;
    this.buddylistSpanId = "buddylistFlashSpan";
    this.chatwinID = "topchatwindow";
    this.styleElement = null;
    NtBaseTbar.prototype.constructor();
    this.cache_add    = NtBaseTbar.prototype.add;
    this.cache_remove = NtBaseTbar.prototype.remove;
}
NtTopTbar.prototype = new NtBaseTbar();
NtTopTbar.prototype.init = function(span){
    var _Ht = [], _cssText = [], 
    	_V = Ntalker.variable,
    	_C = Ntalker.Config,
    	_CP = Ntalker.Config.customparams;
    this.element = span;
    _Ht.push('<div id="nt_top_toolbar" class="nt_top_toolbar">');
    if( _V['user_sid'] != 'NtalkerGuestUserSessionID' ){
	    _Ht.push(    '<span class="fr" id="spanBuddylist">');
	    _Ht.push(        '<span id="nt_firend" class="app-r nt_firend">' + sprintf(NtLang['buddylistButtonText'][1], '0', '0') + '</span>');
	    _Ht.push(    '</span>');
	}
    if( _CP['enablegroup']||_CP['enableroom'] ){
	    _Ht.push(    '<span class="fr" id="spanGroup">');
	    _Ht.push(        '<span id="nt_group" class="app-r nt_group">(0)</span>');
	    _Ht.push(    '</span>');
	}
	    _Ht.push(    '<span class="fr" id="spanSystem">');
	    _Ht.push(        '<span id="nt_system" class="app-r nt_system">(0)</span>');
	    _Ht.push(    '</span>');
    _Ht.push('</div>');
    this.contentElement = $$D.insert(this.element, _Ht.join(''));
    var self= this;
    var __buttonOver = function(e){
    	current = e.currentTarget || window.event.srcElement;
    	if( $$D.include(current, 'app-r') ) current = current.parentNode;
        if( $$D.include(current, 'fr') ) $$D.addClass(current, "hover");
	};
	var __buttonOut = function(e){
		current = e.currentTarget || window.event.srcElement;
		if( $$D.include(current, 'app-r') ) current = current.parentNode;
    	if( $$D.include(current, 'fr') ) $$D.removeClass(current, "hover");
	};
    if( $$O('nt_firend') ){
		$$E.addEvent($$O('nt_firend'), "click", self.onShowBuddylist);
	}
    $$A.each($$D.filter($$O('nt_top_toolbar').childNodes), function(elem){
    	$$E.addEvent(elem, 'mouseover', __buttonOver);
		$$E.addEvent(elem, 'mouseout',  __buttonOut);
    });
    this.initSystemMessage();
    this.initGroupMessage();
    this.changeToolBarWidth();
};
NtTopTbar.prototype.add = function(uid, name, src, isAutoFocus, type, customModel){
    return;
};
NtTopTbar.prototype.remove = function(uid, type){
    return;
};
NtTopTbar.prototype.hiddenChatWind = function(){
    var chatWins = im_chat_window_manager._chatWndsArray, l = chatWins.length;
    for(var i=0; i<l; i++)
        chatWins[i].hide();
};
NtTopTbar.prototype.showMenu = function(menuId, type){
    var Menu = $$O(menuId);
    if(!Menu) return;
    if(im_myIMWindow) im_myIMWindow.close();
    if(type=="over" && Menu.style.display != "block"){
        this.hiddenChatWind();
        Menu.style.display = "block";
    }else
        Menu.style.display = "none";
};
NtTopTbar.prototype.updateUserNumber = function(onlineUser, totalUser){
    if($$O("nt_firend")) {
        $$O("nt_firend").innerHTML = sprintf(NtLang['buddylistButtonText'][1], String(onlineUser), String(totalUser) );
        this.changeToolBarWidth();
    }
};
NtTopTbar.prototype.initSystemMessage = function(){
    var self = this;
    var __viewSystemMessage = function(target){self.viewSystemMessage(target);};
    var __viewNoneSystemMessage = function(){
        self.addSystemMessage('0', '', sprintf(NtLang['nullMessage'][1], ''), 0, '', '', 'null');
        self._systemMessageMenu.show();
    };
    var __visibleCallFunction = function(ul){
        self.customSystemMessage(ul);
        self.Mutex('system');
    };
    this._systemMessageMenu = _systemMessage = new NtMenu(parseInt(NtUtil.getCookie("__debug") || 0));
    _systemMessage.init(
        $$O('nt_system').parentNode, 
        $$O('nt_system'),
        {tagName:'div', id:'Nt-TOP-SYSTEM-MENU',className:'startbar-menuright Nt-MENU',style:''},
        {className:'nt-message-over'},
        {className:'nt-message-out'},
        {callback:__viewSystemMessage},
        __viewNoneSystemMessage,
        __visibleCallFunction
    );
    this.updateCustomSystemMessage();
};
NtTopTbar.prototype.updateCustomSystemMessage = function(){
    var customCount = 0, _systemMessage = this._systemMessageMenu, _ExtMsg = Ntalker.variable.ExMsg, _Ht = [];
    for(var i=0; i<_ExtMsg.length; i++){
        customCount = parseInt(customCount) + (isNaN(_ExtMsg[i].msgnumber) ? 0 : parseInt(_ExtMsg[i].msgnumber) );
    }
    this._customMessageCount = customCount;
    _systemMessage._Button.innerHTML = '(' + String(customCount) + ')';
};
NtTopTbar.prototype.customSystemMessage = function(ul){
	return;
};
NtTopTbar.prototype.viewCurstomSystemMessage = function(url){
    var _ExtMsg = Ntalker.variable.ExMsg;
    for(var i=0; i<_ExtMsg.length; i++){
        if(_ExtMsg[i].url==url)    _ExtMsg[i].msgnumber=0;
    }
    Ntalker.variable.ExMsg = _ExtMsg;
    window.open(url);
};
NtTopTbar.prototype.viewSystemMessage = function(target){
    var _systemMessage = this._systemMessageMenu, allCount, userID = Ntalker.variable.user_id;
    var notifyWnd, objNotify = NotifyManager.alertQueue, k = target.getAttribute('k');
    notifyWnd = _systemMessage.get(k);
    notifyWnd.sendMsg = notifyWnd['content'];
    notifyWnd.userid  = userID;
    notifyWnd._curNotifyId  = 'Notify' + userID + "TYPE" + notifyWnd.type;
    switch(notifyWnd.type)
    {
        case "confirm":
            notifyWnd.BtnType = "confirm";
            objNotify.add(notifyWnd._curNotifyId, notifyWnd);
            break;
        case "request":
            notifyWnd.BtnType = "request";
            objNotify.add(notifyWnd._curNotifyId, notifyWnd);
            break;
        case "group":
            notifyWnd.BtnType = "group";
            im_openWebchatWindow(notifyWnd.destuid, notifyWnd.destname, null, 1, 'group', 0, 'sysMsgList');
            this.removeSystemMessage("group" + notifyWnd.destuid);
            break;
        case "null":
            return;
            break;
        default:
            notifyWnd.BtnType = "alert";
            objNotify.add(notifyWnd._curNotifyId, notifyWnd);
            break;
    }
    allCount = _systemMessage._Hash.count();
    allCount += this._customMessageCount;
    _systemMessage._Button.innerHTML = '(' + allCount + ')';
};
NtTopTbar.prototype.addSystemMessage = function(destuid, destname, message, chatid, headURL, content, type, srcuid, srcnick, chatType){
    var _systemMessage = this._systemMessageMenu, allCount;
    _systemMessage.remove('null0');
    _systemMessage.add(type+destuid, {
        text:message,
        destuid:destuid,
        destname:destname,
        message:message,
        chatid:chatid,
        headurl:headURL,
        content:content,
        type:type,
        srcuid:srcuid,
        srcnick:srcnick,
        chattype:chatType,
        custom:{
            className:type=='confirm'?'addfir':type
        }
        });
    allCount = _systemMessage._Hash.count();
    allCount = _systemMessage.get('null0') && allCount==1 ? 0 : allCount;
    allCount += this._customMessageCount;
    _systemMessage._Button.innerHTML = '(' + allCount + ')';
    if( allCount > 0 ){
        this.enableflash('nt_system', "nt_system", "flash_msg");
    }else{
        this.disableFlash('nt_system');
    }
    _systemMessage.hidden();
    this.changeToolBarWidth();
};
NtTopTbar.prototype.removeSystemMessage = function(k){
    var _systemMessage = this._systemMessageMenu, allCount;
    _systemMessage.remove(k);
    menus = _systemMessage._Menu.getElementsByTagName('UL')[0].getElementsByTagName('LI');
    for(var i = 0; i < menus.length; i++ ){
        menus[i].getAttribute('k')==k && menus[i].parentNode.removeChild(menus[i]);
    }
    allCount = _systemMessage._Hash.count();
    allCount += this._customMessageCount;
    _systemMessage._Button.innerHTML = '(' + allCount + ')';
};
NtTopTbar.prototype.getSystemMessage = function(k){
    return this._systemMessageMenu.get(k);
};
NtTopTbar.prototype.loadSystemMessage = function(){
    var _V = Ntalker.variable;
    NtUtil.loadValue(_V['user_id'], Ntalker['ctKEY']);
};
NtTopTbar.prototype.saveSystemMessage = function(){
	var _V = Ntalker.variable;
    if( !this._systemMessageMenu ){
    	return;
    }
    var cookieValue = $$J.toJSONString(this._systemMessageMenu._Hash._hash);
    NtUtil.saveValue(_V['user_id'], Ntalker['ctKEY'], cookieValue);
};
NtTopTbar.prototype.initGroupMessage = function(){
    var self = this, groupMenu;
    if( !$$O('nt_group') ){
    	return;
    }
    var __viewGroupMessage = function(target){
    	self.viewGroupMessage(target);
    };
    var __openGrouplist = function(e){
    	self.onShowBuddylist(e, 2);
    };
    var __visibleCallFunction = function(ul){
        $$D.insert(ul, '<div class="bot_line"></div>', 'afterend');
        var allCount = 0;
	    for(var k in self._groupMessageMenu._Hash._hash){
	    	allCount += self._groupMessageMenu.get(k).count;
	    }
        self.Mutex('group', allCount);
    };
    this._groupMessageMenu = groupMenu = new NtMenu(parseInt(NtUtil.getCookie("__debug") || 0));
    groupMenu.init(
        $$O('nt_group').parentNode, 
        $$O('nt_group'),
        {id:'Nt-TOP-GROUP-MENU',className:'startbar-menuright Nt-MENU',style:''},
        {className:'nt-message-over'},
        {className:'nt-message-out'},
        {callback:__viewGroupMessage},
        __openGrouplist,
        __visibleCallFunction
    );
};
NtTopTbar.prototype.viewGroupMessage = function(target){
    var groupMenu = this._groupMessageMenu, _groupObject, groupId, groupName;
    var k = target.getAttribute('k');
    _groupObject = groupMenu.get(k);
    im_openWebchatWindow(_groupObject.groupid, _groupObject.groupname, null, 1, _groupObject.chattype, 0, 'groupMsgMenu');
    this.removeGroupMessage(k);
};
NtTopTbar.prototype.addGroupMessage = function(groupId, groupName, srcuid, srcnick, msg, chattype){
    var groupMenu = this._groupMessageMenu, _CP = Ntalker.Config.customparams;
    var allCount = itemCount = 0;
    var key = chattype + groupId;
    if( !groupMenu ){
    	return;
    }
    if( groupMenu.get(key) ){
    	itemCount = groupMenu.get(key).count;
    	groupMenu.remove(key);
    }
    itemCount++;
    groupMenu.add(key, {
        text:groupName + '('+itemCount+')',
        groupid:groupId,
        groupname:groupName,
        chattype:chattype,
        count:itemCount,
       	custom:{
            className:'nt-message-out'
        }
    });
    for(var k in groupMenu._Hash._hash){
    	allCount += groupMenu.get(k).count;
    }
    if(allCount>0){
        if(_CP['disablegrouptip']){
            groupMenu._Button.style.color = '#ff0000';
            window.setTimeout(function(){groupMenu._Button.style.color = '#000000';}, 1000);
        }else{
            this.enableflash('nt_group', "nt_group", "flash_group");
        }
    }else{
        this.disableFlash('nt_group');
    }
    allCount = allCount > 99 ? '99' : allCount;
    groupMenu._Button.innerHTML = '(' + allCount + ')';
    groupMenu.hidden();
    this.changeToolBarWidth();
};
NtTopTbar.prototype.removeGroupMessage = function(k){
    var groupMenu = this._groupMessageMenu, allCount = 0;
    groupMenu.remove(k);
    for(var k in groupMenu._Hash._hash){
    	allCount += groupMenu.get(k).count;
    }
    allCount = allCount > 99 ? '99' : allCount;
    groupMenu._Button.innerHTML = '(' + allCount + ')';
};
NtTopTbar.prototype.getGroupMessage = function(k){
    this._groupMessageMenu.get(k);
};
NtTopTbar.prototype.loadGroupMessage = function(){
    var _V = Ntalker.variable;
    NtUtil.loadValue(_V['user_id'], Ntalker['gpKEY']);
};
NtTopTbar.prototype.saveGroupMessage = function(){
	var _V = Ntalker.variable;
    if( !this._groupMessageMenu ){
    	return;
    }
    var cookieValue = $$J.toJSONString(this._groupMessageMenu._Hash._hash);
    NtUtil.saveValue(_V['user_id'], Ntalker['gpKEY'], cookieValue);
};
NtTopTbar.prototype.changeToolBarWidth = function(){
    var toolbarWidth = 0;
    $$A.each($$D.filter($$O('nt_top_toolbar').childNodes), function(elem){
    	$$D.css(elem, 'width', 'auto');
    	var elemWidth = $$D.clientRect(elem).w;
    	toolbarWidth += elemWidth;
    	$$D.css(elem, 'width', elemWidth + 'px');
    	$$D.css(elem, 'overflow', ($$B.ie6 ? 'hidden' : 'visible'));
    });
    $$D.css(this.contentElement, 'width', toolbarWidth + 'px');
};
function NtPHPminWindow(destuid, chattype){ 
    this._destuid = destuid;
    this._chatType = chattype;
    this._focus = false;
    this.timerID = null;
    this.promptMsg = "";
    this.Element = null;
    this._counter = 0;
}
NtPHPminWindow.prototype.onFocus = function(){
    this._focus = true;
};
NtPHPminWindow.prototype.onBlur = function(){
    this._focus = false;
};
NtPHPminWindow.prototype.updateUserHead = function(strheadURL, intStatus){
};
NtPHPminWindow.prototype.onReceiveMiniMessage=function(message){
    var titleText = sprintf(NtLang['sayContent'], message);
    this.startFlashTitle(titleText);
};
NtPHPminWindow.prototype.startFlashTitle = function(titleText){
    if(this.timerID)
        return;
    this.promptMsg = $$S.cut(titleText,5);
    this.flashWindowTitle();
};
NtPHPminWindow.prototype.flashWindowTitle = function(){
    if(this._focus){
        $$D.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){
        $$D.removeClass(this.Element, "flash");
    }else{
        $$D.addClass(this.Element, "flash");
    }
    var _timer     = this._counter%2==0 ? 500 : 1000;
    this.timerID = setTimeout("IMToolBar.get('"+this._destuid+"', '"+this._chatType+"').flashWindowTitle()", _timer);
};
function NtPHPwindTbar(){ 
    this.element = null;
    this.HashWindow = new IMHashtable();
    NtBaseTbar.prototype.constructor();
    this.cache_add    = NtBaseTbar.prototype.add;
    this.cache_remove = NtBaseTbar.prototype.remove;
};
NtPHPwindTbar.prototype = new NtBaseTbar();
NtPHPwindTbar.prototype.init = function(parentNode){
    this.element = parentNode;
    if($$O("pwb_friend")){
        var removeNode = $$O("pwb_friend").parentNode;
        removeNode.parentNode.removeChild(removeNode);
    }
    if($$O("pwb_message")){
        var removeNode = $$O("pwb_message").parentNode;
        removeNode.parentNode.removeChild(removeNode);
    }
    this.initMiniWindowList();
    this.initSystemMessage();
    this.initGroupMessage();
    this.initFriendButton();
};
NtPHPwindTbar.prototype.initFriendButton = function(){
    var _elems, _cssText = [], _Ht = [];
    _elems = $$D.filter($$D.filter(this.element.childNodes)[0].childNodes);
    if(!$$O("nt_pwb_friend"))
    {
        _Ht.push('<span class="fr">');
        _Ht.push(  '<span class="f1" style="display:none;">');
        _Ht.push(    '<span class="app-f app-current" style="margin-right:-1px;"></span>');
        _Ht.push(  '</span>');
        _Ht.push(  '<span class="app-f fl" id="nt_pwb_friend">' + sprintf(NtLang['buddylistButtonText'][0], '0', '0') + '</span>');
        _Ht.push('</span>');
        $$D.insert(_elems[1], _Ht.join(''), 'BeforeBegin');
    }
    Ntalker.variable.buddylistTag = $$D.insert($$O("nt_pwb_friend"), '<div id="buddylistFlashSpan" class="startbar-menuright" style="display:none;width:246px"></div>', 'afterEnd');
    $$O('nt_pwb_friend').onclick = this.onShowBuddylist;
};
NtPHPwindTbar.prototype.initSystemMessage = function(){
    var _elems, _cssText = [], _Ht = [];
    _elems = $$D.filter($$D.filter(this.element.childNodes)[0].childNodes);
    if(!$$O("nt_pwd_system"))
    {
        _Ht.push('<span class="fr">');
        _Ht.push(  '<span class="f1" style="display:none;">');
        _Ht.push(    '<span class="app-f app-current" style="margin-right:-1px;"></span>');
        _Ht.push(  '</span>');
        _Ht.push(  '<span class="app-f fl" id="nt_pwd_system">' + sprintf(NtLang['systemButtonText']+"(%1)", '0') + '</span>');
        _Ht.push('</span>');
        $$D.insert(_elems[1], _Ht.join(''), 'BeforeBegin');
    }
    var self = this, _systemMessage;
    var __viewSystemMessage = function(target){self.viewSystemMessage(target);};
    var __viewNoneSystemMessage = function(){
        self.addSystemMessage('0', '', sprintf(NtLang['nullMessage'][1], ''), 0, '', '', 'null');
        self._systemMessageMenu.show();
    };
    var __visibleCallFunction = function(ul){
        self.customSystemMessage(ul);
        self.Mutex('system');
        var _Left = $$D.clientRect($$O("nt_pwd_system")).left;
        if($$B.ie6) _Left -= (parseInt($$D.css($$O("nt_pwd_system"), "paddingLeft")) - 2 );
        $$D.css($$O("Nt-SYSTEM-MENU"), "left", _Left + 'px');
    };
    this._systemMessageMenu = _systemMessage = new NtMenu(parseInt(NtUtil.getCookie("__debug") || 0));
    _systemMessage.init(
        $$O('nt_pwd_system').parentNode, 
        $$O('nt_pwd_system'),
        {id:'Nt-SYSTEM-MENU',className:'startbar-menuright',style:'left:0px;width:180px;'},
        {className:'nt-item-over'},
        {className:'nt-item-out'},
        {callback:__viewSystemMessage},
        __viewNoneSystemMessage,
        __visibleCallFunction
    );
    this.updateCustomSystemMessage();
};
NtPHPwindTbar.prototype.updateCustomSystemMessage = function(){
    var _C = 0, _systemMessage = this._systemMessageMenu, _ExtMsg = Ntalker.variable.ExMsg, _Ht = [];
    for(var i=0; i<_ExtMsg.length; i++){
        _C = parseInt(_C) + (isNaN(_ExtMsg[i].msgnumber) ? 0 : parseInt(_ExtMsg[i].msgnumber) );
    }
    this._customMessageCount = _C;
    _systemMessage._Button.innerHTML = sprintf(NtLang['systemButtonText']+"(%1)", String(_C));
};
NtPHPwindTbar.prototype.customSystemMessage = function(ul){
    var _C = 0, _systemMessage = this._systemMessageMenu, _ExtMsg = Ntalker.variable.ExMsg, _Ht = [];
    if ( _ExtMsg.length > 0 ){
        this.removeSystemMessage('null0');
    }
    for(var i=0; i<_ExtMsg.length; i++){
        _Ht.push('<LI onclick="IMToolBar.viewCurstomSystemMessage(\'' + _ExtMsg[i].url + '\');" class="act nt-item-out" url="' + _ExtMsg[i].url + '"><DIV><a href="javascript:void(0);">' + _ExtMsg[i].name + ' (' + _ExtMsg[i].msgnumber + ')</a></DIV></LI>');
        _C = parseInt(_C) + (isNaN(_ExtMsg[i].msgnumber) ? 0 : parseInt(_ExtMsg[i].msgnumber) );
    }
    this._customMessageCount = _C;
    $$D.insert(ul, _Ht.join(''), 'beforeend');
    allCount = _systemMessage._Hash.count();
    allCount = _systemMessage.get('null0') && allCount==1 ? 0 : allCount;
    allCount = parseInt(allCount) + parseInt(_C);
    _systemMessage._Button.innerHTML = sprintf(NtLang['systemButtonText']+"(%1)", String(allCount));
};
NtPHPwindTbar.prototype.viewCurstomSystemMessage = function(url){
    var _ExtMsg = Ntalker.variable.ExMsg;
    for(var i=0; i<_ExtMsg.length; i++){
        if(_ExtMsg[i].url==url)_ExtMsg[i].msgnumber = 0;
    }
    Ntalker.variable.ExMsg = _ExtMsg;
    window.open(this.getAttribute(url));
};
NtPHPwindTbar.prototype.viewSystemMessage = function(target){
    var _systemMessage = this._systemMessageMenu, allCount, userID = Ntalker.variable.user_id;
    var notifyWnd, objNotify = NotifyManager.alertQueue, k = target.getAttribute('k');
    if(k == "null0") 
        return;
    notifyWnd = _systemMessage.get(k);
    notifyWnd.sendMsg = notifyWnd['content'];
    notifyWnd.userid  = userID;
    notifyWnd._curNotifyId  = 'Notify' + userID + "TYPE" + notifyWnd.type;
    switch(notifyWnd.type)
    {
        case "confirm":
            notifyWnd.BtnType = "confirm";
            objNotify.add(notifyWnd._curNotifyId, notifyWnd);
            break;
        case "request":
            notifyWnd.BtnType = "request";
            objNotify.add(notifyWnd._curNotifyId, notifyWnd);
            break;
        case "group":
            notifyWnd.BtnType = "group";
            im_openWebchatWindow(notifyWnd.destuid, notifyWnd.destname, null, 1, 'group', 0, 'sysMsgList');
            this.removeSystemMessage("group" + notifyWnd.destuid);
            break;
        case "null":
            return;
            break;
        default:
            notifyWnd.BtnType = "alert";
               objNotify.add(notifyWnd._curNotifyId, notifyWnd);
            break;
    }
    allCount = _systemMessage._Hash.count();
    allCount += this._customMessageCount;
    _systemMessage._Button.innerHTML = sprintf(NtLang['systemButtonText']+"(%1)", String(allCount));
};
NtPHPwindTbar.prototype.addSystemMessage = function(destuid, destname, message, chatid, headURL, content, type, srcuid, srcnick, chatType){
    var _systemMessage = this._systemMessageMenu, allCount;
    _systemMessage.remove('null0');
    _systemMessage.add(type+destuid, {
        text:message,
        destuid:destuid,
        destname:destname,
        message:message,
        chatid:chatid,
        headurl:headURL,
        content:content,
        type:type,
        srcuid:srcuid,
        srcnick:srcnick,
        chattype:chatType,
        custom:{
            className:type=='confirm'?'addfir':type
        }
        });
    allCount = _systemMessage._Hash.count();
    allCount = _systemMessage.get('null0') && allCount==1 ? 0 : allCount;
    allCount += this._customMessageCount;
    _systemMessage._Button.innerHTML = sprintf(NtLang['systemButtonText']+"(%1)", String(allCount));
    if( allCount > 0 ){
        this.enableflash('nt_pwd_system', "flash-conventional", "flash-red");
    }else{
        this.disableFlash('nt_pwd_system');
    }
};
NtPHPwindTbar.prototype.removeSystemMessage = function(k){
    var _systemMessage = this._systemMessageMenu, allCount;
    _systemMessage.remove(k);
    menus = _systemMessage._Menu.getElementsByTagName('UL')[0].getElementsByTagName('LI');
    for(var i = 0; i < menus.length; i++ ){
        menus[i].getAttribute('k')==k && menus[i].parentNode.removeChild(menus[i]);
    }
    allCount = _systemMessage._Hash.count();
    allCount += this._customMessageCount;
    _systemMessage._Button.innerHTML = sprintf(NtLang['systemButtonText']+"(%1)", String(allCount));
};
NtPHPwindTbar.prototype.getSystemMessage = function(k){
    return this._systemMessageMenu.get(k);
};
NtPHPwindTbar.prototype.loadSystemMessage = function(){
    var _V = Ntalker.variable;
    NtUtil.loadValue(_V['user_id'], Ntalker['ctKEY']);
};
NtPHPwindTbar.prototype.saveSystemMessage = function(){
	var _V = Ntalker.variable;
    if( !this._systemMessageMenu ){
    	return;
    }
    var cookieValue = $$J.toJSONString(this._systemMessageMenu._Hash._hash);
    NtUtil.saveValue(_V['user_id'], Ntalker['ctKEY'], cookieValue);
};
NtPHPwindTbar.prototype.initGroupMessage = function(){
    var self = this, _elems, _Ht = [], groupMenu,
    	_CP = Ntalker.Config.customparams;
    _elems = $$D.filter($$D.filter(this.element.childNodes)[0].childNodes);
    if( !_CP['enablegroup']&&!_CP['enableroom'] ){
    	return;
	}
    if(!$$O("nt_pwb_group"))
    {
        _Ht.push('<span class="fr">');
        _Ht.push(  '<span class="f1" style="display:none;">');
        _Ht.push(    '<span class="app-f app-current" style="margin-right:-1px;"></span>');
        _Ht.push(  '</span>');
        _Ht.push(  '<span class="app-f fl" id="nt_pwb_group">' + sprintf(NtLang['groupButtonText'], '0') + '</span>');
        _Ht.push('</span>');
        $$D.insert(_elems[1], _Ht.join(''), 'BeforeBegin');
    }
    var __viewGroupMessage = function(target){self.viewGroupMessage(target);};
    var __openGrouplist = function(e){self.onShowBuddylist(e, 2);};
    var __visibleCallFunction = function(){
    	var allCount = 0;
	    for(var k in self._groupMessageMenu._Hash._hash){
	    	allCount += self._groupMessageMenu.get(k).count;
	    }
        self.Mutex('group', allCount);
    };
    this._groupMessageMenu = groupMenu = new NtMenu(parseInt(NtUtil.getCookie("__debug") || 0));
    groupMenu.init(
        $$O('nt_pwb_group').parentNode, 
        $$O('nt_pwb_group'),
        {id:'Nt-GROUP-MENU',className:'startbar-menuright',style:'width:214px;'},
        {className:'nt-item-over'},
        {className:'nt-item-out'},
        {callback:__viewGroupMessage},
        __openGrouplist,
        __visibleCallFunction
    );
};
NtPHPwindTbar.prototype.addGroupMessage = function(groupId, groupName, srcuid, srcnick, msg, chattype){
    var groupMenu = this._groupMessageMenu, _CP = Ntalker.Config.customparams;
    var allCount = itemCount = 0;
    var key = chattype + groupId;
    if( !groupMenu ){
    	return;
    }
    if( groupMenu.get(key) ){
    	itemCount = groupMenu.get(key).count;
    	groupMenu.remove(key);
    }
    itemCount++;
    groupMenu.add(key, {
        text:groupName + '('+itemCount+')',
        groupid:groupId,
        groupname:groupName,
        chattype:chattype,
        custom:{
            groupid:groupId, 
            groupname:groupName,
            className:'nt-item-out'
        },
        count:itemCount
    });
    for(var k in groupMenu._Hash._hash){
    	allCount += groupMenu.get(k).count;
    }
    if(allCount>0){
        this.enableflash('nt_pwb_group', "flash-conventional", "flash-red");
    }else{
        this.disableFlash('nt_pwb_group');
    }
    allCount = allCount>99 ? '99' : allCount;
    groupMenu._Button.innerHTML = sprintf(NtLang['groupButtonText'], allCount);
};
NtPHPwindTbar.prototype.removeGroupMessage = function(k){
    var groupMenu = this._groupMessageMenu, allCount;
    if( !groupMenu ){
    	return;
    }
    groupMenu.remove(k);
    for(var k in groupMenu._Hash._hash){
    	allCount += groupMenu.get(k).count;
    }
    allCount = allCount>99 ? '99' : allCount;
    groupMenu._Button.innerHTML = sprintf(NtLang['groupButtonText'], allCount);
};
NtPHPwindTbar.prototype.viewGroupMessage = function(target){
    var groupMenu = this._groupMessageMenu, allCount, _groupObject, groupId, groupName;
    var k = target.getAttribute('k');
    _groupObject = groupMenu.get(k);
    im_openWebchatWindow(_groupObject.groupid, _groupObject.groupname, null, 1, _groupObject.chattype, 0, 'groupMsgMenu');
    this.removeGroupMessage(k);
};
NtPHPwindTbar.prototype.loadGroupMessage = function(){
    var _V = Ntalker.variable;
    NtUtil.loadValue(_V['user_id'], Ntalker['gpKEY']);
};
NtPHPwindTbar.prototype.saveGroupMessage = function(){
	var _V = Ntalker.variable;
    if( !this._groupMessageMenu ){
    	return;
    }
    var cookieValue = $$J.toJSONString(this._groupMessageMenu._Hash._hash);
    NtUtil.saveValue(_V['user_id'], Ntalker['gpKEY'], cookieValue);
};
NtPHPwindTbar.prototype.initMiniWindowList = function(){
    var _elems, _Ht = [], self = this, _CM;
    _elems = $$D.filter($$D.filter(this.element.childNodes)[0].childNodes);
    if(!$$O("nt_pwb_chats"))
    {
        _Ht.push('<span class="fr">');
        _Ht.push(  '<span class="f1" style="display:none;">');
        _Ht.push(    '<span class="app-f app-current" style="margin-right:-1px;"></span>');
        _Ht.push(  '</span>');
        _Ht.push(  '<span class="app-f fl" id="nt_pwb_chats">Ntalker聊天(0)</span>');
        _Ht.push('</span>');
        _Ht.push('<span class="fr">');
        _Ht.push(  '<div id="Nt-CHAT-LIST" style="position:absolute;bottom:24px;right:272px;"></div>');
        _Ht.push('</span>');
        $$D.insert(_elems[1], _Ht.join(''), 'BeforeBegin');
    }
    var __openChatWindow = function(target){
        self.clickChatWindow(target);
    };
    var __viewNoneChatWindow = function(){};
    var __visibleCallFunction = function(){
        var _Left = $$D.clientRect($$O("nt_pwb_chats")).left;
        if($$B.ie6) _Left -= (parseInt($$D.css($$O("nt_pwb_chats"), "paddingLeft")) - 2 );
        $$D.css($$O("Nt-CHAT-MENU"), "left", _Left + 'px');
        im_chat_window_manager.OnTBFocusWindow();
    };
    this._chatWindowMenu = _CM = new NtMenu(parseInt(NtUtil.getCookie("__debug") || 0));
    _CM.init(
        $$O('nt_pwb_chats').parentNode, 
        $$O('nt_pwb_chats'),            
        {id:'Nt-CHAT-MENU',className:'startbar-menuright',style:'left:0px;width:180px'},
        {className:'nt-item-over'},  
        {className:'nt-item-out'},   
        {callback:__openChatWindow, exec:false}, 
        __viewNoneChatWindow,
        __visibleCallFunction
        );
};
NtPHPwindTbar.prototype.add = function(destuid, destname, src, isAutoFocus, chatType){
    var _ChatWindow = this._chatWindowMenu, allCount, chatLeft,
    _cfg = Ntalker.Config;
    _ChatWindow.add(chatType+destuid, {
        text:destname,
        destuid:destuid,
        destname:destname,
        src:src ? src : '',
        isautofocus:isAutoFocus,
        chattype:chatType,
        custom:{
            className:'act'
        }
        });
    allCount = _ChatWindow._Hash.count();
    allCount = _ChatWindow.get('null0') && allCount==1 ? 0 : allCount;
    _ChatWindow._Button.innerHTML = 'Ntalker聊天(' + allCount + ')';
    this.HashWindow.add(chatType+destuid, new NtPHPminWindow(destuid, chatType));
    switch(chatType){
        case "group":
        case "room":
        case "nquan":
        	chatLeft = 0 - _cfg.groupWidth;break;
        default: chatLeft = 0 - _cfg.chatWidth;break;
    }
    var _Wind = $$D.create('div', {className:'', id:"MiniTAG" + destuid + chatType, style:'position:absolute;bottom:0px;left:' + chatLeft + 'px;'}, $$O('Nt-CHAT-LIST'));
    if( allCount > 0 ){
        this.enableflash("nt_pwb_chats", "flash-conventional", "flash-red");
    }else{
        this.disableFlash('nt_pwb_chats');
    }
    return _Wind;
};
NtPHPwindTbar.prototype.remove = function(uid, type){
    var _ChatWindow = this._chatWindowMenu, allCount;
    var fid = "", ft="", pi = 0, pt="", g = false;
    for(var k in _ChatWindow._Hash._hash){
        var item = _ChatWindow._Hash._hash[k];
        if(item.destuid == uid && item.chattype == type){
            g = true;
            if(pi){
                fid = pi;
                ft  = pt; 
                break;
            }
        }else{
            pi = item.destuid;
            pt = item.chattype;
            if(g){
                fid = pi;
                ft  = pt; 
                break;
            }
        }
    }
    this.HashWindow.remove(type+uid);
    _ChatWindow.remove(type+uid);
    Ntalker.variable.OnFocusWinParam = [fid, ft];
    im_chat_window_manager.OnTBFocusWindow(fid, ft);
    allCount = _ChatWindow._Hash.count();
    _ChatWindow._Button.innerHTML = 'Ntalker聊天(' + allCount + ')';
};
NtPHPwindTbar.prototype.get = function(uid, type){
    return this.HashWindow.items(type+uid);
};
NtPHPwindTbar.prototype.clickChatWindow = function(target){
    var _ChatWindow = this._chatWindowMenu, k = target.getAttribute('k');
    var win = _ChatWindow.get(k);
    this._focus = true;
    im_chat_window_manager.OnTBFocusWindow(win.destuid, win.chattype);
    _ChatWindow.hidden();
};
NtPHPwindTbar.prototype.updateUserNumber = function(onlineUser, totalUser){
    var firButtn = $$O('nt_pwb_friend');
    firButtn.innerHTML = sprintf(NtLang['buddylistButtonText'][0], String(onlineUser), String(totalUser));
};
function NtDiscuzTbarTag(destuid, destname, headURL, isAutoFocus, chatType, OpenType){
    this._focus = true;
    this._destuid = destuid;
    this._destnick = destname || '';
    this._chatType = chatType || 'chat';
    this._openType = OpenType;
    this._headURL = headURL || '';
    this.autoFocus = isAutoFocus;
    this.Element = null;
    this._counter = 0;
    this.originTitle = '';
}
NtDiscuzTbarTag.prototype = {
    init: function(parent){
        var _Ht = [], imgsrc, self = this, elem,_C = Ntalker.Config;
        this.originTitle = $$S.cut(self._destnick, 5, true);
        switch( self._chatType.toLowerCase() ){
            case 'chat':
                imgsrc = _C['publicDIR'] + '/chat.'+($$B.ie6?'gif':'png');break;
            case 'nquan':
            	imgsrc = _C['publicDIR'] + '/nquan.'+($$B.ie6?'gif':'png');break;
            case 'group':
            	imgsrc = _C['publicDIR'] + '/group.'+($$B.ie6?'gif':'png');break;
            case 'room':
                imgsrc = _C['publicDIR'] + '/room.'+($$B.ie6?'gif':'png');break;
        }
        _Ht.push( '<div class="win" id="miniTAG_' + this._destuid + this._chatType + '">' );
        _Ht.push(     '<span class="ico"><img src="' + imgsrc + '" onerror="this.src=\'' + imgsrc + '\'" border="0" /></span>' );
        _Ht.push(     '<span class="title">' );
        _Ht.push(     this.originTitle);
        _Ht.push(     '</span>');
        _Ht.push(     '<span class="button"></span>' );
        _Ht.push(     '<div class="miniTAG_tab" id="miniTAG_' + this._destuid + this._chatType + '_tab"></div>' );
        _Ht.push( '</div>' );
        elem = this.Element = $$D.insert(parent, _Ht.join(''), 'BeforeEnd');
        if(this.autoFocus){
        	this.onFocus();
        }else{
        	this.onBlur();
    	}
        var __clickMinWindow = function(e){
        	if( !chatWindowManager ) {
        		return;
        	}
        	if( chatWindowManager.getChatWindow(self._destuid, self._chatType)._curWindMode == 'default' ){
		    	self.onBlur();
		    	chatWindowManager.OnTBFocusWindow(0);
		    }else{
		    	IMToolBar.Mutex('buddylist|group');
	            self.onFocus();
	            chatWindowManager.OnTBFocusWindow(self._destuid, self._chatType);
	        }
        };
        var __overMinWindow  = function(e){
            current = e.currentTarget || window.event.srcElement;
            if( current.className.indexOf("win")==-1 ) current = current.parentNode;
            if( current.className.indexOf("win")!=-1 ) $$D.addClass(current, "hover");
        };
        var __outMinWindow = function(e){
            current = e.currentTarget || window.event.srcElement;
            if( current.className.indexOf("win")==-1 ) current = current.parentNode;
            if( current.className.indexOf("win")!=-1 ) $$D.removeClass(current, "hover", "");
        };
        var __clickClose = function(e){
        	$$E.fixEvent(e).stopPropagation();
            fIM_CloseChatWindow(self._destuid, self._chatType);
        };
        var closeButton = $$D.filter(elem.childNodes)[2];
        $$E.addEvent(elem, 'click', __clickMinWindow);
        $$E.addEvent(elem, 'mouseover', __overMinWindow);
        $$E.addEvent(elem, 'mouseout',  __outMinWindow);
        $$E.addEvent(closeButton, 'click',  __clickClose);
        if( this._openType == 0 ){
        	this.onReceiveMiniMessage();
    	}
        return elem;
    },
    updateUserHead:function(src, intStatus){
        var image = NtUtil.$$(' img', this.Element)[0];
        image.src = src;
        image.onload = function(){
            if(this.width>this.height){
                _width = 20;
                _height= 20/this.width*this.height;
            }else{
                _height= 20;
                _width = 20/this.height*this.width;
            }
            this.width  = _width;
            this.height = _height;
        };
    },
    getPost: function(){
        var scrollLeft = $$O('nt_area').scrollLeft;
        var contentElementX = $$D.clientRect( IMToolBar.contentElement ).left;
        var mRt = $$D.clientRect(this.Element);
        var _x  = mRt.left-($$B.ie6 ? 2 : 0) - scrollLeft - contentElementX;
        var _rx = mRt.left+mRt.w+($$B.ie6 ? 2 : 0) - scrollLeft;
        return {x:_x, y:mRt.top, w:mRt.w, h:mRt.h,rx:_rx};
    },
    onFocus: function( ){
        var _V = Ntalker.variable;
        for(var k in IMToolBar.minWindows._hash){
            IMToolBar.minWindows._hash[k].onBlur();
        }
        this._focus = true;
        $$D.removeClass(this.Element, 'flash');
        $$D.replaceClass(this.Element, 'hover', "selected");
        if(this._destuid) {
            _V['OnFocusWinParam'] = [this._destuid, this._chatType];
        }
        IMToolBar.leftMutex && IMToolBar.leftMutex('');
        return this.getPost();
    },
    onBlur: function( ){
        this._focus = false;
        $$D.replaceClass(this.Element, "selected", '');
    },
    onReceiveMiniMessage: function(message){
        var titleText;
        titleText = message ? sprintf(NtLang['sayContent'], message) : this.originTitle;
        if ( this.timerID )
            return;
        this.promptMsg = $$S.cut( titleText, 5 );
        this.flashWindowTitle();
    },
    flashWindowTitle: function(){
        var elem = this.Element;
        if(this._focus || parseInt(this._counter) == 6){
            clearInterval(this.timerID);
            this.timerID = null;
            this._counter = 0;
            return;
        }
        if(this._counter%2==1){
            $$D.replaceClass(elem, '', "flash");
        }else{
            $$D.replaceClass(elem, "flash", '');
        }
        var self = this, Timer = this._counter%2==1 ? 1000 : 500;
        this._counter = parseInt(this._counter) + 1;
        this.timerID = setTimeout(function(){
        	var toolbarTag = IMToolBar.get(self._destuid, self._chatType);
            toolbarTag && toolbarTag.flashWindowTitle();
        }, Timer);
    }
};
function NtDiscuzTbar(){ 
	this._bindingScroll = false;
    this.element = null;
    this.textContent = [];
    this.minWidth = 700;
    this.inited = [];
    this._Hash = [];
    this._feedHeight=0;
    this._spanHeight=0;
    this._Button="";
    this._customMessageCount=0;
    this._fnum=0;
  	this._inum=0;
  	this._rfnum=0;
  	this._rinum=0;
    this.contentElement = null;
    this.AreaElement = null;
    this.resetCurTop = false;
    this.minWindows = new IMHashtable();
    this._timer = [];
    this._flashNum = [];
    this._stopFlash = [];
    this._flashClassName = [];
    this.InitExpression = false;
    this.scroltimerID = null;
    this.btnSwitchWidth = 0;
    this.initToolbarMode = 0;
    this.currentToolbarMode = 1;
    this.isSpread = false;
    this.styleElement = null;
    this.isExisitCustomButton = false;
    this.backgroundDiv = null;
    this.jsonConfiguration = {
		acceptOriginalFeed: true, 
		acceptCommentFeed: true,  
		groupSetting: false,       
		buddyLoginTip: true,      
		acceptMsgFlag: "1",       
		audioOnFlag:"0"
	};
}
NtDiscuzTbar.prototype.init = function(){
	var _CP = Ntalker.Config.customparams;
	this.initToolbarMode = NtUtil.getCookie(Ntalker.tbModelKEY);
	if(_CP["intact"] == 1){
		this.isSpread = true;
	}
	if( this.initToolbarMode == '2' ){
		this.currentToolbarMode = 2;
	}else{
		this.currentToolbarMode = _CP["intact"];
	}
    this.initSheet();
    this.initToolBar();
    this.setExpression(this.currentToolbarMode);
    this.initConfigurationMenu();
    this.initFriendButton();
    this.initGroupMessage();
    this.initMessageBox();
    if ( this.isSpread ){
	    this.initSiteApplication();
	    this.initHotFocus();
		this.initCustomApplication();
	}
    this.initShowToolBarButton();
    this.initScroll();
    this.closeMenuOrWindow();
    debug("closeMenuOrWindow>");
};
NtDiscuzTbar.prototype.hidden = function(){
    $$D.css(this.element, "visibility", "hidden");
};
NtDiscuzTbar.prototype.visible = function(){
    $$D.css(this.element, "visibility", "visible");
};
NtDiscuzTbar.prototype.closeMenuOrWindow = function(){
	var self = this;
	var __closeMenuOrWindow = function(e){
		var event = $$E.fixEvent(e);
		var targetElement = event.target;
		while(targetElement){
			if( /^(ntalkerbar-wrapper|ntalkerbar)$/.test(targetElement.id) ){
				return;
			}
			targetElement = targetElement.parentNode;
		}
		self.leftMutex('');
		self.closeMessagebox();
        self.hiddenConfigurationMenu();
	};
	var Element = $$B.ie ? document : window;
	$$E.addEvent(Element, 'click', __closeMenuOrWindow);
};
NtDiscuzTbar.prototype.add = function(destuid, destname, headURL, isAutoFocus, type, customModel){
    var Tag, k = type + destuid, 
        parentNode = $$O('nt_wins'), 
        _C = Ntalker.Config,
    	self = this;
    if ( this.get( k ) ) return;
    Tag = new NtDiscuzTbarTag(destuid, destname, headURL, isAutoFocus, type);
    Tag.init(parentNode);
    this.minWindows.add(k, Tag);
    if( this.currentToolbarMode == 0 ){
    	this.setToolBarMode(1, true);
    }
    this.onToolBarTextChanage();
	self.leftMutex('');
    if( /0|1/.test(self.currentToolbarMode) ){
    	self.initScroll();
	}else{
    	self.Mutex('');
	}
    return Tag;
};
NtDiscuzTbar.prototype.remove = function( destuid, type ){
    var self = this, _V = Ntalker.variable;
    var getUID = "", getTYPE="", _uid = '', _type = '', isGetNext = false;
    for(var k in this.minWindows._hash){
        var item = this.minWindows._hash[k];
        if(item._destuid == destuid && item._chatType == type){
            isGetNext = true;
            if(_uid){
                getUID = _uid;
                getTYPE = _type;
                break;
            }
        }else{
            _uid = item._destuid;
            _type = item._chatType;
            if(isGetNext){
                getUID = _uid;
                getTYPE = _type;
                break;
            }
        }
    }
    var elem = $$O('miniTAG_' + destuid + type);
    if ( elem ){
        elem.parentNode.removeChild(elem);
    }
    self.minWindows.remove( type + destuid );
    var tagWindowCount = IMToolBar.minWindows.count();
    if( this.currentToolbarMode == 1 && !this.isSpread && tagWindowCount==0 ){
    	this.setToolBarMode(0, true);
    }
    if( /0|1/.test(this.currentToolbarMode) ){
	    self.onLeftScroll();
	}else{
		this.onToolBarTextChanage();
	}
    _V['OnFocusWinParam'] = [getUID, getTYPE];
    im_chat_window_manager.OnTBFocusWindow(getUID, getTYPE);
};
NtDiscuzTbar.prototype.get = function( destuid, type ){
    return this.minWindows.items( type + destuid );
};
NtDiscuzTbar.prototype.setExpression = function(setToolBarModeValue, clearExpression){
	var _R5, self = this, toolBarSpan = self.element;
	var _h2 = document.body.currentStyle,_a = "fixed";
	var _O = document.documentElement, _F1 = "url(about:blank)", _a3 = _O.runtimeStyle;
    var __onscroll = function(e){self.onScroll(e);};
    if( $$B.ie6 || $$B.QuirksModel ){
    	if( setToolBarModeValue == 2 ){
	    	debug('clearExpression, _bindingScroll='+self._bindingScroll);
	    	if (_O.currentStyle.backgroundImage == _F1){
	    		_a3.backgroundImage = "none";
	            _a3.backgroundAttachment = "scroll";
	    	}
			toolBarSpan.style.setExpression("top", "");
    	}
    	if( setToolBarModeValue == 2 && !self._bindingScroll ){
    		debug("addEvent scroll");
    		$$E.addEvent(window, 'scroll', __onscroll);
	        self._bindingScroll = true;
	        return;
    	}else{
    		$$E.removeEvent(window, 'scroll', __onscroll);
    		debug("removeEvent scroll");
		    debug("<i>setExpression</i>");
			if( !self.InitExpression ){
		        if (_O.currentStyle.backgroundImage == "none"){
		            if ($$B.StrictMode) {
		                if (_h2.backgroundImage == "none" || _h2.margin == "0px") {
		                	debug("setExpression set background before");
		                    _a3.backgroundColor = _h2.backgroundColor.indexOf("#")==-1 ? _O.currentStyle.backgroundColor : _h2.backgroundColor;
		                    _a3.backgroundPositionX = _h2.backgroundPositionX;
		                    _a3.backgroundPositionY = _h2.backgroundPositionY;
		                    _a3.backgroundRepeat = _h2.backgroundRepeat;
		                    _a3.backgroundImage = _F1;
		                    _a3.backgroundAttachment = _a;
		                    debug("setExpression set background complete");
		                }
		            } else {
		                _a3.backgroundImage = _F1;
		                _a3.backgroundAttachment = _a;
		            }
		        }
		        self.InitExpression = true;
		    }
		    if( $$B.StrictMode ){
		        _R5 = "document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight";
		        if (toolBarSpan.offsetParent == document.body) {
		            _R5 += "-this.offsetParent.offsetTop-this.offsetParent.clientTop";
		        }
		    }
		    else{
		        _R5 = "document.body.scrollTop+document.body.clientHeight-this.offsetHeight";
		    }
		   	toolBarSpan.style.setExpression("top", _R5);
	    }
    }
};
NtDiscuzTbar.prototype.initShowToolBarButton = function(){
	if( !$$O("btnSwitch") ){
		return;
	}
    var _CP = Ntalker.Config.customparams;
    var toolbarElems = $$D.filter($$O('spanSwitch').parentNode.childNodes);
    var tagWindowCount = IMToolBar.minWindows.count();
    var __controlToolBarMode = function(e){
    	var tagWindowCount = IMToolBar.minWindows.count();
    	if( IMToolBar.currentToolbarMode == 2 && tagWindowCount == 0 ){
    		if( IMToolBar.isSpread ){
    			IMToolBar.setToolBarMode(1);
    		}else{
    			IMToolBar.setToolBarMode(0);
    		}
    	}else if( IMToolBar.currentToolbarMode == 2 && tagWindowCount > 0 ){
    		IMToolBar.setToolBarMode(1);
    	}else{
    		IMToolBar.setToolBarMode(2);
    	}
    };
    var __buttonOver = function(e){
        $$D.addClass($$O('spanSwitch'), "hover");
    };
    var __buttonOut = function(e){
        $$D.removeClass($$O('spanSwitch'), "hover");
    };
    $$E.addEvent($$O("btnSwitch"), 'click', __controlToolBarMode);
    $$E.addEvent($$O("btnSwitch"), 'mouseover', __buttonOver);
	$$E.addEvent($$O("btnSwitch"), 'mouseout',  __buttonOut);
};
NtDiscuzTbar.prototype.setToolBarMode = function(toolBarModeValue, noAnimation){
    var btnSwitch = $$O("btnSwitch"), 
    	toolBarSpan = this.element, 
    	toolBar = $$O("ntalkerbar"), 
    	self = this, 
    	_C = Ntalker.Config;
    debug('setToolBarMode( '+toolBarModeValue+' )');
    var toolbarElems = $$D.filter($$O('spanSwitch').parentNode.childNodes, 'span');
    toolBarModeValue = toolBarModeValue!='undefined' ? toolBarModeValue : this.currentToolbarMode;
    if( toolBarModeValue == 2 ){
    	this.setExpression(toolBarModeValue, true);
    	this.Mutex('');
    	this.leftMutex('');
    	if(chatWindowManager) {
    		chatWindowManager.OnTBFocusWindow(0);
    	}
    	if( noAnimation ){
    		toMinimizeToolbar();
    	}else{
            $$D.animate(toolBar, {top:28}, 'fast', 'easeInOutQuint', function(){
	            toMinimizeToolbar();
                $$D.animate(toolBar, {top:0}, 'fast', 'easeInOutQuint', function(){});
	        });
    	}
	}else if( toolBarModeValue == 0 ){
		if( noAnimation ){
			toSimplifyToolbar(toolBarModeValue);
			self.setExpression(toolBarModeValue);
		}else{
    		this.Mutex('');
            $$D.animate(toolBar, {top:28}, 'fast', 'easeInOutQuint', function(){
				toSimplifyToolbar();
				self.setExpression(toolBarModeValue);
				self.onToolBarTextChanage();
                $$D.animate(toolBar, {top:0}, 'fast', 'easeInOutQuint', function(){});
			});
		}
	}else if( toolBarModeValue == 1 ){
    	if(chatWindowManager) {
    		chatWindowManager.OnTBFocusWindow(0);
    	}
    	if( noAnimation ){
    		toMaximumToolbar();
    		self.setExpression(toolBarModeValue);
    	}else{
    		this.Mutex('');
            $$D.animate(toolBar, {top:28}, 'fast', 'easeInOutQuint', function(){
	    		toMaximumToolbar();
	    		self.setExpression(toolBarModeValue);
	    		self.onToolBarTextChanage();
                $$D.animate(toolBar, {top:0}, 'fast', 'easeInOutQuint', function(){});
	        });
	    }
	}
    this.initScroll();
	function toMinimizeToolbar(){
		self.currentToolbarMode = toolBarModeValue;
        NtUtil.setCookie(Ntalker.tbModelKEY, toolBarModeValue, 1000*3600*24*7);
        $$D.replaceClass(btnSwitch, 'ntalkerbar-close', 'ntalkerbar-open');
        if( self.isExisitCustomButton ){
        	$$D.css($$O('nt_system'), 'borderLeft', '1px dotted '+_C['bColor']);
    	}else{
    		$$D.css($$O('nt_system'), 'borderLeft', 'none');
    	}
        var marginWidth = toolbarWidth = parseInt($$D.css($$O('ntalkerbar'), "marginLeft")) + parseInt($$D.css($$O('ntalkerbar'), "marginRight")) + parseInt($$D.css($$O('nt_content'), "borderLeftWidth")) + parseInt($$D.css($$O('nt_content'), "borderRightWidth"));
        $$A.each(toolbarElems, function(elem){
        	if( /^(spanSwitch|spanSystem)$/.test(elem.id) ){
        		$$D.css(elem, 'display', 'block');
       			self.btnSwitchWidth = $$D.clientRect(elem).w;
       			toolbarWidth += self.btnSwitchWidth;
        	}else{
        		$$D.css(elem, 'display', 'none');
        	}
        });
        var tagWindowCount = IMToolBar.minWindows.count();
        var AreaWidth = parseInt(tagWindowCount * 130);
        $$D.css(self.AreaElement, 'width', (AreaWidth+1) + 'px');
        if( $$B.ie6 ){
        	AreaWidth += 7;
        }else if( $$B.chrome || $$B.ie8 || $$B.ie7 ){
        	AreaWidth += 2;
        }
        toolbarWidth += AreaWidth;
        if( toolbarWidth > ($$D.windowRect().w - marginWidth) ){
        	self.setToolBarMode(1);
        	return;
        }
        if( $$D.css(self.AreaElement, 'display') == 'none' ){
        	$$D.css(self.AreaElement, 'display', 'block');
        }
        $$D.css(toolBarSpan, 'width', toolbarWidth + 'px');
        self.AreaElement.scrollLeft = 0;
	}
	function toMaximumToolbar(){
		$$D.css(toolBarSpan, 'width', '100%');
        self.currentToolbarMode = toolBarModeValue;
        NtUtil.setCookie(Ntalker.tbModelKEY, toolBarModeValue, 1000*3600*24*7);
        $$D.replaceClass(btnSwitch, 'ntalkerbar-open', 'ntalkerbar-close');
        $$D.css($$O('nt_system'),'borderLeft', '1px dotted '+_C['bColor']);
		var toolBarAreaWidth = $$D.windowRect()._w - parseInt($$D.css($$O('ntalkerbar'), "marginLeft")) - parseInt($$D.css($$O('ntalkerbar'), "marginRight")) + parseInt($$D.css($$O('nt_content'), "borderLeftWidth")) - parseInt($$D.css($$O('nt_content'), "borderRightWidth"));
        $$A.each(toolbarElems, function(elem){
        	$$D.css(elem, 'display', 'block');
           	toolBarAreaWidth -= parseInt($$D.clientRect(elem).w);
           	toolBarAreaWidth -= 1;
        });
        if( $$B.ie6 ){
         	toolBarAreaWidth -= 6; 
	    }
	    $$D.css(self.AreaElement, 'width',  toolBarAreaWidth + 'px');
	    $$D.css(self.AreaElement, 'visibility', 'visible');
	    if( $$D.css(self.AreaElement, 'display') == 'none' ){
        	$$D.css(self.AreaElement, 'display', 'block');
        }
	}
	function toSimplifyToolbar(){
		var tagWindowCount = IMToolBar.minWindows.count();
		if( tagWindowCount > 0 ){
			self.setToolBarMode(1);
			return;
		}
		self.currentToolbarMode = toolBarModeValue;
		NtUtil.setCookie(Ntalker.tbModelKEY, toolBarModeValue, 1000*3600*24*7);
        $$D.replaceClass(btnSwitch, 'ntalkerbar-open', 'ntalkerbar-close');
        if( self.isExisitCustomButton || $$B.ie6 ){
        	$$D.css($$O('nt_system'), 'borderLeft', 'none');
        }else{
        	$$D.css($$O('nt_system'), 'borderLeft', '1px dotted '+_C['bColor']);
    	}
		var toolbarWidth = parseInt($$D.css($$O('ntalkerbar'), "marginLeft")) + parseInt($$D.css($$O('ntalkerbar'), "marginRight")) + parseInt($$D.css($$O('nt_content'), "borderLeftWidth")) + parseInt($$D.css($$O('nt_content'), "borderRightWidth"));
		$$A.each(toolbarElems, function(elem){
        	if( /^(spanSwitch|ntConfiguration|spanSystem|spanGroup|spanBuddylist)$/.test(elem.id) || elem.className.indexOf('customlink') > -1 || elem.className.indexOf('applicationItem') > -1 ){
        		$$D.css(elem, 'display', 'block');
        		toolbarWidth += $$D.clientRect(elem).w;
        	}else {
        		$$D.css(elem, 'display', 'none');
        	}
        });
        var AreaWidth = 0;
        if( $$B.ie6 ){
        	$$D.css(self.AreaElement, 'display', 'none');
        	AreaWidth += 7;
        }
        $$D.css(self.AreaElement, 'width', '1px');
        toolbarWidth += AreaWidth;
        $$D.css(toolBarSpan, 'width', toolbarWidth+'px');
	}
};
NtDiscuzTbar.prototype.initFriendButton = function(){ 
	var firendButton = $$O("nt_firend");
	var _V = Ntalker.variable;
	if( _V['user_sid'] == 'NtalkerGuestUserSessionID' ){
		return;
	}
	var __buttonOver = function(e){
        $$D.addClass($$O('spanBuddylist'), "hover");
    };
    var __buttonOut = function(e){
        $$D.removeClass($$O('spanBuddylist'), "hover");
    };
    $$E.addEvent(firendButton, "click", this.onShowBuddylist);
	$$E.addEvent(firendButton, 'mouseover', __buttonOver);
	$$E.addEvent(firendButton, 'mouseout',  __buttonOut);
};
NtDiscuzTbar.prototype.initGroupMessage = function(){ 
	var self = this, groupMenu;
    var _CP = Ntalker.Config.customparams;
    if( (!_CP['enablegroup']&&!_CP['enableroom']) || !$$O("nt_group") ){
    	return;
    }
    var __viewGroupMessage = function(target){self.viewGroupMessage(target);};
    var __openGrouplist = function(e){self.onShowBuddylist(e, 2);};
    var __visibleCallFunction = function(){
    	self.disableFlash('spanGroup');
    	var allCount = 0;
	    for(var k in self._groupMessageMenu._Hash._hash){
	    	allCount += self._groupMessageMenu.get(k).count;
	    }
        self.Mutex('group', allCount);
        var contentRect = $$D.clientRect($$O('ntalkerbar-wrapper'));
        var _Right = Math.max(parseInt(contentRect.left + contentRect.w - $$D.clientRect($$O("spanGroup")).left - $$D.clientRect($$O("Nt-GROUP-MENU")).w), 20);
        $$D.css($$O("Nt-GROUP-MENU"), "right", _Right + 'px');
    };
    this._groupMessageMenu = groupMenu = new NtMenu(parseInt(NtUtil.getCookie("__debug") || 0));
    groupMenu.init(
        $$O('nt_group').parentNode, 
        $$O('nt_group'),
        {id:'Nt-GROUP-MENU',className:'ntalkerbar-menuright  messageMenu',style:''},
        {className:'nt-message-over icotype'},
        {className:'nt-message-out icotype'},
        {callback:__viewGroupMessage},
        __openGrouplist,
        __visibleCallFunction
    );
    var __buttonOver = function(e){
        $$D.addClass($$O('spanGroup'), "hover");
    };
    var __buttonOut = function(e){
        $$D.removeClass($$O('spanGroup'), "hover");
    };
	$$E.addEvent($$O("nt_group"), 'mouseover', __buttonOver);
	$$E.addEvent($$O("nt_group"), 'mouseout',  __buttonOut);
};
NtDiscuzTbar.prototype.addGroupMessage = function(groupId, groupName, srcuid, srcnick, msg, chattype){
    var groupMenu = this._groupMessageMenu, _CP = Ntalker.Config.customparams;
    var allCount = itemCount = 0;
    var key = chattype + groupId;
    if( !groupMenu ){
    	return;
    }
    if( groupMenu.get(key) ){
    	itemCount = groupMenu.get(key).count;
    	groupMenu.remove(key);
    }
    itemCount++;
    groupMenu.add(key, {
        text:$$S.cut(groupName,8) + '('+itemCount+')',
        groupid:groupId,
        groupname:groupName,
        srcuid:srcuid,
        srcnick:srcnick,
        msg:msg,
        chattype:chattype,
        custom:{
            groupid:groupId, 
            groupname:groupName,
            className:'nt-message-out icotype'
        },
        count:itemCount
    });
    for(var k in groupMenu._Hash._hash){
    	allCount += groupMenu.get(k).count;
    }
    if(allCount>0){
        this.enableflash('spanGroup', '', 'flash');
    }else{
        this.disableFlash('spanGroup');
    }
    allCount = allCount>99 ? '99' : allCount;
    groupMenu._Button.innerHTML = sprintf(NtLang['groupButtonText'], String(allCount) );
};
NtDiscuzTbar.prototype.removeGroupMessage = function(k){
    var groupMenu = this._groupMessageMenu, allCount = 0;
    if( !groupMenu ){
    	return;
    }
    groupMenu.remove(k);
    for(var k in groupMenu._Hash._hash){
    	allCount += groupMenu.get(k).count;
    }
    allCount = allCount>99 ? '99' : allCount;
    groupMenu._Button.innerHTML = sprintf(NtLang['groupButtonText'] , String(allCount) );
};
NtDiscuzTbar.prototype.viewGroupMessage = function(target){
    var groupMenu = this._groupMessageMenu, allCount, _groupObject, groupId, groupName;
    var k = target.getAttribute('k');
    if( !groupMenu ){
    	return;
    }
    _groupObject = groupMenu.get(k);
    im_openWebchatWindow(_groupObject.groupid, _groupObject.groupname, null, 1, _groupObject.chattype, 0, 'groupMsgMenu');
    this.removeGroupMessage(k);
};
NtDiscuzTbar.prototype.loadGroupMessage = function(){
    var _V = Ntalker.variable;
    NtUtil.loadValue(_V['user_id'], Ntalker['gpKEY']);
};
NtDiscuzTbar.prototype.saveGroupMessage = function(){
    var _V = Ntalker.variable;
    if( !this._groupMessageMenu ){
    	return;
    }
    var cookieValue = $$J.toJSONString(this._groupMessageMenu._Hash._hash);
    NtUtil.saveValue(_V['user_id'], Ntalker['gpKEY'], cookieValue);
};
NtDiscuzTbar.prototype.updateCustomSystemMessage = function(){
    var customCount = 0, _systemMessage = this._systemMessageMenu, _ExtMsg = Ntalker.variable.ExMsg;
    for(var i=0; i<_ExtMsg.length; i++){
        customCount = parseInt(customCount) + (isNaN(_ExtMsg[i].msgnumber) ? 0 : parseInt(_ExtMsg[i].msgnumber) );
    }
    this._customMessageCount = customCount;
    _systemMessage._Button.innerHTML = sprintf(NtLang['systemButtonText']+'(%1)', String(customCount) );
};
NtDiscuzTbar.prototype.updateSystemtMessageCount = function(){
	return;
};
NtDiscuzTbar.prototype.customSystemMessage = function(ul){
    var customCount = 0, _systemMessage = this._systemMessageMenu, _ExtMsg = Ntalker.variable.ExMsg, _Ht = [];
    if ( _ExtMsg.length > 0 ){
        this.removeSystemMessage('null0');
    }
    for(var i=0; i<_ExtMsg.length; i++){
        _Ht.push('<LI onclick="IMToolBar.viewCurstomSystemMessage(this, \'' + _ExtMsg[i].url + '\');" class="act nt-message-out" url="' + _ExtMsg[i].url + '"><DIV><a href="javascript:void(0);">' + $$S.cut(_ExtMsg[i].name, 6) + ' (' + _ExtMsg[i].msgnumber + ')</a></DIV></LI>');
        customCount = parseInt(customCount) + (isNaN(_ExtMsg[i].msgnumber) ? 0 : parseInt(_ExtMsg[i].msgnumber) );
    }
    this._customMessageCount = customCount;
    $$D.insert(ul, _Ht.join(''), 'beforeend');
    allCount = _systemMessage._Hash.count();
    allCount = _systemMessage.get('null0') && allCount==1 ? 0 : allCount;
    allCount = parseInt(allCount) + parseInt(customCount);
    _systemMessage._Button.innerHTML = sprintf(NtLang['systemButtonText']+'(%1)', String(allCount) );
};
NtDiscuzTbar.prototype.viewCurstomSystemMessage = function(url,e){
    var _ExtMsg = Ntalker.variable.ExMsg;
    e = $$E.fixEvent(e);
    e.stopPropagation();
	target= searchTag(e.target, "li");
	if(target.parentNode.childNodes.length<=1){
	setTimeout(function(){
			target.innerHTML="<div class='nt_box_null'>"+sprintf(NtLang['nullMessage'][0], NtLang['systemMessageBoxText'][1])+"</div>";
		},100);
	}else{
		target.parentNode.removeChild(target);
	}
    for(var i=0; i<_ExtMsg.length; i++){
        if(_ExtMsg[i].url==url)_ExtMsg[i].msgnumber = 0;
    }
    Ntalker.variable.ExMsg = _ExtMsg;
    this.countMessageBox("im",false,true);
    window.open(url);
};
NtDiscuzTbar.prototype.initSheet = function(){
    var _cssText = [], 
    	_V = Ntalker.variable,
    	_C = Ntalker.Config;
};
NtDiscuzTbar.prototype.initToolBar = function(){
    var _Ht = [], elem, first = true, initSimplifyToolbarWidth = 0, initMinimizeToolbarWidth = 0;
    var _CP = Ntalker.Config.customparams,
    	_C = Ntalker.Config,
    	_V = Ntalker.variable,
		_A = Ntalker.Config.application,
		_B = Ntalker.Config.customtoolbarButtons;
   	var toolbarElemStyle = _CP['showmode']=='hidden' ? 'visibility:hidden;' : 'visibility:visible;';
   	var myAppButtonStyle = /1/.test(this.currentToolbarMode) ? 'display:block;' : 'display:none;';
   	var hotFocusButtonStyle = /1/.test(this.currentToolbarMode) ? 'display:block;' : 'display:none;';
   	var applicationButtonStyle = /1|0/.test(this.currentToolbarMode) ? 'display:block;' : 'display:none;';
    var customHyperlinkStyle = /0|1/.test(this.currentToolbarMode) ? 'display:block' : 'display:none';
    var scrollButtonStyle = /1/.test(this.currentToolbarMode) ? 'display:block' : 'display:none';
    var areaElementStyle = /1|2/.test(this.currentToolbarMode) ? 'visibility:visible;' : 'visibility:hidden;';
    var systemButtonStyle = /0|1|2/.test(this.currentToolbarMode) ? 'display:block' : 'display:none';
    var groupButtonStyle = /0|1/.test(this.currentToolbarMode) ? 'display:block' : 'display:none';
    var buddylistButtonStyle = /0|1/.test(this.currentToolbarMode) ? 'display:block' : 'display:none';
    var settingButtonStyle = /0|1/.test(this.currentToolbarMode) ? 'display:block' : 'display:none';
    var switchButtonClassName = /0|1/.test(this.currentToolbarMode) ? 'ntalkerbar-close' : 'ntalkerbar-open';
    var switchButtonText = /0|1/.test(this.currentToolbarMode) ? '' : '(0)';
    for(var k in Ntalker.Config.customtoolbarButtons){
    	if( k ) this.isExisitCustomButton = true;
    }
    if( this.currentToolbarMode==1 )
    	var systemSpanBorder = 'border-left:1px dotted '+_C['bColor'];
    else
    	var systemSpanBorder = '';
    _Ht.push('<div id="ntalkerbar" class="ntalkerbar">');
    _Ht.push(    '<div class="ntalkerbar-ui cc" id="nt_content">');
    if ( this.isSpread ){
	    _Ht.push('<span class="fl" id="siteApplication" style="'+myAppButtonStyle+'">');
	    _Ht.push(    '<span id="nt_app" class="app-l nt_app">' + NtLang['myAppButtonText'] + '</span>');
	    _Ht.push('</span>');
	    _Ht.push(        '<span class="fl" id="siteHotFocus" style="'+hotFocusButtonStyle+'">');
	    _Ht.push(            '<span id="nt_hot" class="app-l nt_hot">' + NtLang['hotFocusButtonText'][0] + '</span>');
	    _Ht.push(        '</span>');
		for(var k in _A ){
			if( typeof(_A[k]) == 'object' ){
				_Ht.push('<span k="'+k+'" id="' + _A[k]['id'] + '_button" class="applicationItem fl" style="'+applicationButtonStyle+'">');
	        	_Ht.push(    '<span class="app_item">');
	        	_Ht.push(        '<span class="app_itemImg" style="background:url(' + _C['publicDIR'] + _A[k]['ico'] + ') no-repeat center center;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=noscale, src=' + _C['customDIR'] + _A[k]['ico'] + ');"></span>');
	        	_Ht.push(        '<span class="app_itemText">' + _A[k]['name'] + '</span>');
	        	_Ht.push(    '</span>');
	        	_Ht.push('</span>');
			}
		}
	}
	for(var k in _B){
        if( typeof(_B[k])=="object" && _B[k]["float"]=="left" ){
       		var firstHyperlinkBorder = "";
        	_Ht.push('<span class="customlink fl" style="'+customHyperlinkStyle+'">');
        	_Ht.push(    '<span class="customhyperlink" style="'+firstHyperlinkBorder+'">');
        	_Ht.push(        '<a href="' + _B[k]['url'] + '" title="' + _B[k]['tip'] + '" target="_blank" style="' + _B[k]['style'] + '"></a>');
        	_Ht.push(    '</span>');
        	_Ht.push('</span>');
        	first = false;
        	initSimplifyToolbarWidth += 29;
        }
    }
    _Ht.push(        '<span class="fl" style="'+scrollButtonStyle+'">');
    _Ht.push(            '<span id="nt_forward" class="scroll_pre" title="' + NtLang['scrollButtonText'][0] + '"></span>');
    _Ht.push(        '</span>');
    _Ht.push(        '<span class="fr" id="spanSwitch">');
    _Ht.push(            '<span id="btnSwitch" class="'+switchButtonClassName+'"><span></span></span>');
    _Ht.push(        '</span>');
    initSimplifyToolbarWidth += 29;
    initMinimizeToolbarWidth += 29;
    if( _V['user_sid'] != 'NtalkerGuestUserSessionID' ){
		_Ht.push('<span class="fr" id="ntConfiguration" style="' + settingButtonStyle + '">');
	    _Ht.push(    '<span id="nt_setting" class="app-l"></span>');
	    _Ht.push('</span>');
	    initSimplifyToolbarWidth += 33;
	}
    if( _V['user_sid'] != 'NtalkerGuestUserSessionID' ){
	    _Ht.push(        '<span class="fr" id="spanBuddylist" style="'+buddylistButtonStyle+'">');
	    _Ht.push(            '<span id="nt_firend" class="app-r nt_firend">' + sprintf(NtLang['buddylistButtonText'][0], '0', '0') + '</span>');
	    _Ht.push(        '</span>');
	    initSimplifyToolbarWidth += 111;
	}
    if( _CP['enablegroup']||_CP['enableroom'] ){
	    _Ht.push(        '<span class="fr" id="spanGroup" style="'+groupButtonStyle+'">');
	    _Ht.push(            '<span id="nt_group" class="app-r nt_group">' + sprintf(NtLang['groupButtonText'], '0') + '</span>');
	    _Ht.push(        '</span>');
	    initSimplifyToolbarWidth += 83;
	}
    _Ht.push(        '<span class="fr" id="spanSystem" style="'+systemButtonStyle+'">');
    _Ht.push(            '<span id="nt_system" class="app-r nt_system" style="'+systemSpanBorder+'">' + sprintf(NtLang['systemButtonText']+"(%1)", '0') + '</span>');
    _Ht.push(        '</span>');
    initSimplifyToolbarWidth += 83;
    initMinimizeToolbarWidth += 83;
    _Ht.push(        '<span class="fr" style="'+scrollButtonStyle+'">');
    _Ht.push(            '<span id="nt_back" class="scroll_next" title="' + NtLang['scrollButtonText'][1] + '"></span>');
    _Ht.push(        '</span>');
    _Ht.push(        '<div class="nt_area" id="nt_area" style="'+areaElementStyle+'">');
    _Ht.push(            '<div class="nt_wins" id="nt_wins">');
    _Ht.push(            '</div>');
    _Ht.push(        '</div>');
    _Ht.push(    '</div>');
    _Ht.push(    '<div id="buddylistFlashSpan" class="ntalkerbar-menuright" style="border:none;width:' + _C['IMWidth'] + 'px;right:20px;' + ($$B.ie6 ? 'right:0px;' : '') + 'display:none;"></div>');
    _Ht.push('</div>');
    if( this.currentToolbarMode==0 ){
    	toolbarElemStyle += 'width:'+(initSimplifyToolbarWidth + 42 + ($$B.ie6 ? 7 : ($$B.ie7 ? 2 :0)))+'px;';
    }else if( this.currentToolbarMode==2 ){
		toolbarElemStyle += 'width:'+(initMinimizeToolbarWidth + 42 + ($$B.ie6 ? 7 : ($$B.ie7 ? 2 :0)))+'px;';
    }else{
    	var scrollWidth = NtUtil.scrollWidth();
    	var winRt = $$D.windowRect();
		if( winRt.w - scrollWidth < this.minWidth ){
			$$D.css($$O("ntalkerbar-wrapper"), 'width', this.minWidth + 'px');
			debug('init set toolbar width = '+ this.minWidth);
		}
    }
   	toolbarElemStyle += 'height:32px;right:0;overflow:visible;z-index:1000;' + ($$B.ie6 ? 'position:absolute;bottom:0px;' : 'position:fixed;bottom:0px;');
    debug('initToolBar insert html before');
    var toolbarHtml = '<div id="ntalkerbar-wrapper" class="ntalkerbar-wrapper fixed" style="'+toolbarElemStyle+'">'+_Ht.join('')+'</div>';
    this.element = $$D.insert(document.body.firstChild, toolbarHtml, 'beforeBegin');
    debug('initToolBar insert html complete');
    if( this.currentToolbarMode==2 ){
    	this.onScroll();
    }
    this.contentElement = $$O('nt_content');
    Ntalker.variable.buddylistTag = $$O('buddylistFlashSpan');
    this.AreaElement = $$O('nt_area');
    $$D.css($$O('nt_area'), 'width', '1px');
    $$D.css($$O('nt_wins'), 'width', '2000px');
    var self = this;
    var _onLeft  = function(e){self.onLeftScroll(e);};
    var _onRight = function(e){self.onRightScroll(e);};
    $$O('nt_forward') && $$E.addEvent($$O('nt_forward'), 'click', _onLeft);
    $$O('nt_back') && $$E.addEvent($$O('nt_back'), 'click',   _onRight);
    var __onresize = function(e){self.onResize(e);};
    $$E.addEvent(window, "resize", __onresize);
};
NtDiscuzTbar.prototype.onScroll = function(e){
    var openButton = $$O("ntalkerbar"), toolbarTop, toolBarSpan = IMToolBar.element;
    if( $$B.chrome && toolBarSpan ){
    	var setNewZIndex = $$D.css(toolBarSpan, 'z-index') == '9999' ? '9998' : '9999';
    	$$D.css(toolBarSpan, 'z-index', setNewZIndex);
    }
    if( (!$$B.ie6 || IMToolBar.currentToolbarMode != 2) ){
        return;
    }
    clearTimeout(IMToolBar.scroltimerID);
    $$D.css(openButton, "display", "none");
    IMToolBar.scroltimerID = setTimeout(function(){
    	if( $$B.StrictMode ){
        	toolbarTop = document.documentElement.scrollTop + document.documentElement.clientHeight - toolBarSpan.offsetHeight;
	        if (toolBarSpan.offsetParent == document.body) {
	            toolbarTop = toolbarTop - toolBarSpan.offsetParent.offsetTop - toolBarSpan.offsetParent.clientTop;
	        }
	    }
	    else{
	        toolbarTop = document.body.scrollTop + document.body.clientHeight - toolBarSpan.offsetHeight;
	    }
	    $$D.css(toolBarSpan, "top", toolbarTop+'px');
	    debug('<i>onScroll display block</i>');
        $$D.css(openButton, "display", "block");
        $$D.animate(openButton, {opacity:100}, 'slow', 'easeInOutQuint',function(){
            openButton.style.filter="";
        });
    }, 400);
};
NtDiscuzTbar.prototype.onResize = function(e){
    this.onToolBarTextChanage();
    this.initScroll();
    this.onScroll();
};
NtDiscuzTbar.prototype.onToolBarTextChanage = function(){
	var _C = Ntalker.Config;
	var toolbarWidth, AreaWidth;
	var friendButton=$$O("nt_firend");
	if( this.currentToolbarMode == 1 ){
		if(friendButton){
			$$D.css(friendButton,"width","auto");
			var tempWidth=parseInt($$D.clientRect(friendButton).w)-parseInt($$D.css(friendButton, "paddingLeft"))-parseInt($$D.css(friendButton, "paddingRight"));
			$$D.css(friendButton,"width",tempWidth+"px");
		}
		var scrollWidth = NtUtil.scrollWidth();
		var winRt = $$D.windowRect();
		var width = $$D.clientRect($$O("ntalkerbar-wrapper")).w;
		if( width < this.minWidth ){
			$$D.css($$O("ntalkerbar-wrapper"), 'width', this.minWidth + 'px');
			width = this.minWidth;
		}else if( width < winRt.w - scrollWidth ){
			$$D.css($$O("ntalkerbar-wrapper"), 'width', 'auto');
			width = winRt.w - scrollWidth;
		}
		toolbarWidth = width - parseInt($$D.css($$O('ntalkerbar'), "marginLeft")) - parseInt($$D.css($$O('ntalkerbar'), "marginRight")) + parseInt($$D.css($$O('nt_content'), "borderLeftWidth")) - parseInt($$D.css($$O('nt_content'), "borderRightWidth"));
	    $$A.each($$D.filter(this.contentElement.childNodes, 'span'), function(elem){
	        if( $$D.css(elem, 'display') != 'none' ){
	            toolbarWidth -= parseInt( $$D.clientRect(elem).w );
	            toolbarWidth -= 1;
	        }
	    });
	    AreaWidth = toolbarWidth - ($$B.ie6 ? 9 : 0);
	    if( !isNaN(AreaWidth) && AreaWidth > 0 ){
	        $$D.css(this.AreaElement, 'width', AreaWidth + 'px');
	    }
	}else if( this.currentToolbarMode == 0 ){
		if(friendButton){
			$$D.css(friendButton,"width","auto");
			var tempWidth=parseInt($$D.clientRect(friendButton).w)-parseInt($$D.css(friendButton, "paddingLeft"))-parseInt($$D.css(friendButton, "paddingRight"));
			$$D.css(friendButton,"width",tempWidth+"px");
		}
		toolbarWidth = parseInt($$D.css($$O('ntalkerbar'), "marginLeft")) + parseInt($$D.css($$O('ntalkerbar'), "marginRight")) + parseInt($$D.css($$O('nt_content'), "borderLeftWidth")) + parseInt($$D.css($$O('nt_content'), "borderRightWidth"));
	    $$A.each($$D.filter(this.contentElement.childNodes, 'span'), function(elem){
	       if( /^(spanSwitch|ntConfiguration|spanSystem|spanGroup|spanBuddylist)$/.test(elem.id) || elem.className.indexOf('customlink') > -1 || elem.className.indexOf('applicationItem') > -1 ){
        		$$D.css(elem, 'display', 'block');
        		toolbarWidth += $$D.clientRect(elem).w;
        	}
	    });
	    if( $$B.ie6 ){
	    	$$D.css(this.AreaElement, 'width', '1px');
	    	toolbarWidth += 2;
	    }
	    toolbarWidth = toolbarWidth + ($$B.ie6 ? 5 : 0);
        !isNaN(toolbarWidth) && $$D.css(this.element, 'width', toolbarWidth + 'px');
	}else if( this.currentToolbarMode == 2 ){
		if($$D.css($$O('ntalkerbar'), "display")=="none") return;
		toolbarWidth = parseInt($$D.css($$O('ntalkerbar'), "marginLeft")) + parseInt($$D.css($$O('ntalkerbar'), "marginRight")) + parseInt($$D.css($$O('nt_content'), "borderLeftWidth")) + parseInt($$D.css($$O('nt_content'), "borderRightWidth"));
	    $$A.each($$D.filter(this.contentElement.childNodes, 'span'), function(elem){
	       if( /^(spanSwitch|spanSystem)$/.test(elem.id) ){
        		toolbarWidth += $$D.clientRect(elem).w;
        	}
	    });
	    var tagWindowCount = IMToolBar.minWindows.count();
        AreaWidth = tagWindowCount * 130;
        $$D.css(this.AreaElement, 'width', (AreaWidth + 1) + 'px');
        if( $$B.ie6 ){
	    	AreaWidth += 6;
	    }else if( $$B.chrome || $$B.ie8 || $$B.ie7 ){
	    	AreaWidth += 2;
	    }
	    toolbarWidth += AreaWidth;
        $$D.css(this.element, 'width', (isNaN(toolbarWidth) ? 160 : toolbarWidth) + 'px');
	}
};
NtDiscuzTbar.prototype.initScroll = function(){
    var _V = Ntalker.variable, _C = Ntalker.Config,
    	ForwardElemt = $$O('nt_forward'), 
        BackElemt = $$O('nt_back'),
        AreaElement = this.AreaElement,
        WinsElemt = $$O('nt_wins'), WinsWidth = 0,
	    AreaWidth = $$D.clientRect(AreaElement).w;
    if( AreaWidth==0 ){
    	return;
    }
    $$A.each($$D.filter(WinsElemt.childNodes ), function(win){
        WinsWidth += parseInt( $$D.css(win, 'width') );
    });
    if( WinsWidth <= AreaWidth ){
        $$D.replaceClass(ForwardElemt, 'scroll_pre', 'scroll_pre_disable');
        $$D.replaceClass(BackElemt, 'scroll_next', 'scroll_next_disable');
    }
    else{
        if( AreaElement.scrollLeft > 0 ){
            $$D.replaceClass(ForwardElemt, 'scroll_pre_disable', 'scroll_pre');
        }
        else{
            $$D.replaceClass(ForwardElemt, 'scroll_pre', 'scroll_pre_disable');
        }
        if( WinsWidth - AreaElement.scrollLeft > AreaWidth ){
            $$D.replaceClass(BackElemt, 'scroll_next_disable', 'scroll_next');
        }
        else{
            $$D.replaceClass(BackElemt, 'scroll_next', 'scroll_next_disable');
        }
    }
};
NtDiscuzTbar.prototype.onLeftScroll = function(e){
    var self = this;
    $$D.animate(self.AreaElement, {scrollLeft:"-130"}, 'slow', 'easeInOutQuint', function(){ 
        self.initScroll();
    });
};
NtDiscuzTbar.prototype.onRightScroll = function(e){
    var self = this;
    var _C = Ntalker.Config,
    	ForwardElemt = $$O('nt_forward'), 
        BackElemt = $$O('nt_back'),
        AreaElement = this.AreaElement,
        WinsElemt = $$O('nt_wins'), WinsWidth = 0,
	    AreaWidth = $$D.clientRect(AreaElement).w;
    if( AreaWidth==0 ){
    	return;
    }
    $$A.each($$D.filter(WinsElemt.childNodes ), function(win){
        WinsWidth += parseInt( $$D.css(win, 'width') );
    });
    if( WinsWidth - AreaElement.scrollLeft <= AreaWidth ){
    	return;
    }
    $$D.animate(self.AreaElement, {scrollLeft:"+130"}, 'slow', 'easeInOutQuint', function(){ 
        self.initScroll();
    });
};
NtDiscuzTbar.prototype.onShowBuddylist = function(e, index){
    if( !im_myIMWindow ) return;
    index = index!=null ? index : 0;
    Ntalker.Config.IMtabIndex = index;
    im_myIMWindow.OnTBShowBuddylist(true);
    	IMToolBar.closeMessagebox();
    IMToolBar.hiddenConfigurationMenu();
    IMToolBar.leftMutex('');
};
NtDiscuzTbar.prototype.Mutex = function(type, _MCount){
    var groupMessageCount = _MCount ? _MCount : 0;
    type = type == 'undefined' ? '' : type;
    if( type.indexOf('buddylist') == -1 ){
        if(im_myIMWindow) {
        	im_myIMWindow.close();
        }
    }
	if( type.indexOf('group') == -1 ){
        if(groupMessageCount>0 && im_myIMWindow) {
        	im_myIMWindow.close();
		}
	}
    if( type.indexOf('system') == -1 ){
    	this.closeMessagebox();
	}
	if( type.indexOf('setting') == -1 ){
        this.hiddenConfigurationMenu();
	}
};
NtDiscuzTbar.prototype.leftMutex = function(type){
		if( type != 'siteApplication' ){
			this.closeSiteApplication();
		}
		if( type != 'siteHotFocus' ){
			this.closeHotFocus();
		}
		if( type != 'applicationItem' ){
			this.closeApplicationWindow();
		}
};
NtDiscuzTbar.prototype.enableflash = function(key, className, FclassName, auto){
    var target = $$O(key), self = this;
	this._flashClassName[key] = [className, FclassName];
    if( this._timer[key] && !auto) return;
    if( (this._stopFlash[key]==true || this._flashNum[key] == 6)){
        this._stopFlash[key] = false;
        this._flashNum[key] = 0;
        return;
    }
    if(this._timer[key] == 500){
        this._timer[key] = 1000;
        $$D.replaceClass(target, className, FclassName);
    }else{
        this._timer[key] = 500;
        $$D.replaceClass(target, FclassName, className);
    }
    this._flashNum[key] = !$$S.isDefined(this._flashNum[key]) ? 1 : parseInt(this._flashNum[key]) + 1;
    setTimeout(function(){
        self.enableflash(key, className, FclassName, true);
    },  self._timer[key]);
};
NtDiscuzTbar.prototype.disableFlash = function(key){
	try{
		var className = this._flashClassName[key][1] || '';
		var FclassName = this._flashClassName[key][0] || '';
	}catch(e){}
	$$D.replaceClass($$O(key), className, FclassName);
    this._stopFlash[key] = true;
    this._flashNum[key] = 0;
};
NtDiscuzTbar.prototype.initSiteApplication = function(){
    var self = this, _C = Ntalker.Config;
    if( !$$O('nt_app') ){
    	return;
    }
    var __buttonOver = function(e){
        $$D.addClass($$O('siteApplication'), "hover");
    };
    var __buttonOut = function(e){
        $$D.removeClass($$O('siteApplication'), "hover");
    };
    $$E.addEvent($$O('nt_app'), 'mouseover', __buttonOver);
    $$E.addEvent($$O('nt_app'), 'mouseout',  __buttonOut);
    this.t_menu = new NtMenu(true);
    var __viewNoneMyAppMenu = function(e){
    	self.loadSiteApplication();
    	self.t_menu.show();
    	self.inited['myapp'] = true;
    };
    var __visibleCallFunction = function(e){
    	$$D.addClass($$O('siteApplication'), 'selected');
    	self.leftMutex("siteApplication");
    	var menuElem = self.t_menu._Menu;
    	var menuRect = $$D.clientRect(menuElem);
    	$$D.css(menuElem, 'height', '1px');
    	$$D.animate(menuElem, {height:(menuRect.h - 2)}, 'fast', 'easeInOutQuint', function(){});
    };
    var __openMyAppItem = function(o){
        if(o.attributes['k'].value=='app_close'){
            self.closeSiteApplication();
        }else{
            window.open(o.attributes["url"].nodeValue);
        }
    };
    var __openedCallFunction = function(){
    	self.closeSiteApplication();
	};
    this.t_menu.init(
        $$O('ntalkerbar'), 
        $$O('nt_app'), 
        {
        	id: 'siteApplicationMenu',
        	className:'ntalkerbar-menuleft',
        	style:'left:0px;width:120px;', 
	        childNode:{
	        		tagName:'div', 
	        		className:'TopGradient', 
	        		childNode:{tagName:'div', className:'BottomGradient'}
	        }
	    },
        {className: 'nt-item-over'},
        {className: 'nt-item-out'},
        {callback:__openMyAppItem, exec: false},
        __viewNoneMyAppMenu,
        __visibleCallFunction,
        __openedCallFunction
    );
};
NtDiscuzTbar.prototype.closeSiteApplication = function(){
	var self = this;
	var menuElem = $$O('siteApplicationMenu');
	if( !menuElem ){
		return;
	}
	var menuRect = $$D.clientRect(menuElem);
	$$D.animate(menuElem, {height:1}, 'fast', 'easeInOutQuint', function(){
		menuElem.parentNode.removeChild(menuElem);
		self.t_menu._MenuInited = false;
		$$D.removeClass($$O('siteApplication'), 'selected');
	});
    this.inited['myapp'] = false;
};
NtDiscuzTbar.prototype.loadSiteApplication=function(){
    var _C  = Ntalker.Config;
    var t_menu = this.t_menu, self=this;
    var count=0;padding='';
    var array = Ntalker.variable.myApp;
    t_menu.add('app_close',{text:'&nbsp;&nbsp;',custom:{type:'close', className:"siteApplicationClose",style:''}});
    for(k in array){
    	if( array[k].menuitems.length > 0){
	    	t_menu.add('app_line_' + k, {text:'',custom:{style:'border-top:1px #cccccc dotted;magin:1 1 0 0;font-size:0px;height:1px;line-height:1px;',type:'line',className:'nt-item-out'}});
	        }
        for(v in array[k].menuitems){ 
            padding='6px';
            if(count>10) break;
            var icon = array[k].menuitems[v].icon ? array[k].menuitems[v].icon : _C['publicDIR'] + 'app_ico.gif';
                t_menu.add('app_' +k+ v, {
             	 	text : array[k].menuitems[v].title,
	                custom:{
                    style:'background-image:url(' + icon + ');background-repeat:no-repeat;overflow:hidden;background-position: 5px 50%;padding-left:'+padding+';',
	                    url : array[k].menuitems[v].url,
	                    className:'nt-item-out',
	                    type:'item'
	                    }
	                }
	            );
            if(array[k].groupname==NtLang['CONST_siteApplication'])count++;
        }
    }
};
NtDiscuzTbar.prototype.initHotFocus = function(){
    var self = this, _C = Ntalker.Config;
    if( !$$O('nt_hot') ){
    	return;
    }
    var __visibleActivity = function(e){
    	$$E.fixEvent(e).stopPropagation();
        self.showHotFocus(e);
    };
    var __buttonOver = function(e){
        $$D.addClass($$O('siteHotFocus'), "hover");
    };
    var __buttonOut = function(e){
        $$D.removeClass($$O('siteHotFocus'), "hover");
    };
    $$E.addEvent($$O('nt_hot'), 'click', __visibleActivity);
    $$E.addEvent($$O('nt_hot'), 'mouseover', __buttonOver);
    $$E.addEvent($$O('nt_hot'), 'mouseout',  __buttonOut);
};
NtDiscuzTbar.prototype.showHotFocus = function(e){
	this.leftMutex('siteHotFocus');
	if( this.inited['activity'] ){
		this.closeHotFocus();
        return;
    }
    var url, HotButton = $$O('nt_hot'), 
    	self = this, _Ht = [],
        _C = Ntalker.Config,
        _V = Ntalker.variable;
    var left = $$D.clientRect(HotButton).left - $$D.clientRect(HotButton.parentNode.parentNode).left - 1;
    im_chat_window_manager && im_chat_window_manager.OnTBFocusWindow(0);
    _Ht.push('<span id="hotFocusMenu" class="ntalkerbar-menuleft" style="">');
    _Ht.push(    '<div class="TopGradient">');
    _Ht.push(        '<div class="BottomGradient">');
    _Ht.push(            '<div style="height:30px;">');
    _Ht.push(                '<span id="newactivity_tag" class="newactivity_tag newactivity_tag_select">' + NtLang['hotFocusButtonText'][1] + '</span>');
    _Ht.push(                '<span id="hotactivity_tag" class="hotactivity_tag">' + NtLang['hotFocusButtonText'][2] + '</span>');
    _Ht.push(        '<span id="activity_close" class="ntclose"></span>');
    _Ht.push(        '<br class="clearfloat" />');
    _Ht.push(    '</div>');
    _Ht.push(            '<div id="newactivity" class="nt-tagcontent" style="display:block;"><div style="padding:5px;">' + NtLang['hotFocusButtonText'][1] + NtLang['LoadingText'] + '...</div></div>');
    _Ht.push(            '<div id="hotactivity" class="nt-tagcontent" style="display:none;"><div style="padding:5px;">' + NtLang['hotFocusButtonText'][2] + NtLang['LoadingText'] + '...</div></div>');
    _Ht.push(        '</div>');
    _Ht.push(    '</div>');
    _Ht.push('</span>');
    var menuElem = $$D.insert($$O('ntalkerbar'), _Ht.join(''), 'beforeEnd');
    $$D.addClass($$O('siteHotFocus'), "selected");
    function __getHotFocusData(){
    	url = _C['IMXMLURL'] + '?query=siteactivity&uid=' + _V['user_id'] + '&sid=' + _V['user_sid'] + '&maxnum=7&cachemode=true' ;
	    $$C.script(url, null, false, __setHotFocusData);
    };
    function __setHotFocusData(){
        imHotFocusJsonp = typeof(imHotFocusJsonp)!='undefined' ? imHotFocusJsonp : typeof(jsonp)!='undefined' ? jsonp : null;
        if( !imHotFocusJsonp ){
        	return;
        }
        var _cHt = ['<ul style="border-top:1px solid '+_C['bColor']+';">'];
        if( imHotFocusJsonp.newactivity.length==0 ) _cHt.push('<li><a href="#">' + sprintf(NtLang['nullMessage'][1], '') + '</a></li>');
        for(var i=0; i < imHotFocusJsonp.newactivity.length; i++ ){
            var item = imHotFocusJsonp.newactivity[i];
            _cHt.push('<li><a href="' + item.url + '" target="_blank" title="' + item.title + '">' + $$S.cut(item.title, 18, true) + '</a></li>');
        }
        _cHt.push('</ul>');
        $$O('newactivity').innerHTML = _cHt.join('');
        _cHt = ['<ul style="border-top:1px solid '+_C['bColor']+';">'];
        if( imHotFocusJsonp.hotactivity.length==0 ) _cHt.push('<li><a href="#">' + sprintf(NtLang['nullMessage'][1], '') + '</a></li>');
        for(var i=0; i < imHotFocusJsonp.hotactivity.length; i++ ){
            var item = imHotFocusJsonp.hotactivity[i];
            _cHt.push('<li><a href="' + item.url + '" title="' + item.title + '">' + $$S.cut(item.title, 18, true) + '</a></li>');
        }
        _cHt.push('</ul>');
        $$O('hotactivity').innerHTML = _cHt.join('');
    };
    if( !_C['IMXMLURL'] ){
    	_C['services'] && $$C.script( _C['services'] + '/func/getflashserver.php?resulttype=5&siteid=' + _V['siteid'], 'utf-8', null, __getHotFocusData);
    }
    else{
    	__getHotFocusData();
    }
    $$O('newactivity_tag').onclick = function(){
    	$$E.fixEvent(e).stopPropagation();
        $$D.replaceClass($$O('newactivity_tag'), '', 'newactivity_tag_select');
        $$D.css($$O('newactivity'), 'display', 'block');
        $$D.replaceClass($$O('hotactivity_tag'), 'hotactivity_tag_select', '');
        $$D.css($$O('hotactivity'), 'display', 'none');
    };
    $$O('hotactivity_tag').onclick = function(){
    	$$E.fixEvent(e).stopPropagation();
        $$D.replaceClass($$O('newactivity_tag'), 'newactivity_tag_select', '');
        $$D.css($$O('newactivity'), 'display', 'none');
        $$D.replaceClass($$O('hotactivity_tag'), '', 'hotactivity_tag_select');
        $$D.css($$O('hotactivity'), 'display', 'block');
    };
    var __closeHotFocus = function(){
    	self.closeHotFocus();
    };
    $$E.addEvent($$O('activity_close'), 'click', __closeHotFocus);
    this.inited['activity'] = true;
    $$D.css(menuElem, 'display', 'block');
    var menuHeight = $$D.clientRect(menuElem).h - 2;
    $$D.css(menuElem, 'height', '1px');
    $$D.animate(menuElem, {height:menuHeight}, 'fast', 'easeInOutQuint', function(){});
};
NtDiscuzTbar.prototype.closeHotFocus = function(){
	var menuElem = $$O('hotFocusMenu');
	if( !menuElem ){
		return;
	}
	$$D.animate(menuElem, {height:1}, 'fast', 'easeInOutQuint', function(){ 
		menuElem.parentNode.removeChild(menuElem);
		$$D.removeClass($$O('siteHotFocus'), "selected");
	});
    this.inited['activity'] = false;
};
NtDiscuzTbar.prototype.initCustomApplication = function(){
	var self = this, _A = Ntalker.Config.application;
	var __buttonClick = function(e){
		var event = $$E.fixEvent(e);
		var targetElement = event.target;
		while(targetElement){
			if( /applicationItem/.test(targetElement.className) ){break;}
			targetElement = targetElement.parentNode;
		}
		var k = targetElement.getAttribute('k');
		self.openApplicationWindow(k);
	};
	var __buttonOver = function(e){
		var event = $$E.fixEvent(e);
		var targetElement = event.target;
		while(targetElement){
			if( /applicationItem/.test(targetElement.className) ){break;}
			targetElement = targetElement.parentNode;
		}
        $$D.addClass(targetElement, "hover");
    };
    var __buttonOut = function(e){
    	var event = $$E.fixEvent(e);
    	var targetElement = event.target;
		while(targetElement){
			if( /applicationItem/.test(targetElement.className) ){break;}
			targetElement = targetElement.parentNode;
		}
        $$D.removeClass(targetElement, "hover");
    };
    for(var k in _A ){
	    if( $$O(_A[k]['id'] + '_button') ){
	    	$$E.addEvent($$O(_A[k]['id'] + '_button'), 'click', __buttonClick);
	    	$$E.addEvent($$O(_A[k]['id'] + '_button'), 'mouseover', __buttonOver);
	    	$$E.addEvent($$O(_A[k]['id'] + '_button'), 'mouseout',  __buttonOut);
	    }
	}
};
NtDiscuzTbar.prototype.openApplicationWindow = function(k){
	if( !k ){
		return;
	}
	var appWidth,appHeight,iframeWidth,iframeHeight;
	var _A = Ntalker.Config.application,
		_V = Ntalker.variable, 
		_C = Ntalker.Config, self = this,
		_Ht = [],
		winRt = $$D.windowRect();
	var applicationWindow = $$O(_A[k]['id']);
	var applicationLoadingId = _A[k]['id'] + '_loading';
	var applicationiFrameId = _A[k]['id'] + '_iframe';
	var applicationButtonId = _A[k]['id'] + '_button';
	var applicationClose = _A[k]['id'] + '_close';
	var applicationURL = _A[k]['url'] + '?siteid=' + _V['siteid'];
	if( !applicationWindow ){
		_V['applicationOpened'] = true;
    	this.Mutex('');
    	this.leftMutex('');
    	if(chatWindowManager) {
    		chatWindowManager.OnTBFocusWindow(0);
    	}
		var winHeight = Math.max(document.body.scrollHeight || document.documentElement.scrollHeight, document.documentElement.clientHeight);
		this.backgroundDiv = $$O('ntApplicationBackground') ? $$O('ntApplicationBackground') : $$D.create('div', {id:"ntApplicationBackground", style:"position:absolute;left:0px;top:0px;background:#000000;opacity:0;filter:alpha(opacity:0);width:100%;height:"+winHeight+"px;"});
		appHeight = _A[k]['height']=='auto' ? parseInt(winRt.h*0.8) : _A[k]['height'];
		appWidth = _A[k]['width']=='auto' ? parseInt(appHeight/3*4) : _A[k]['width'];
		iframeHeight = appHeight - 24 - 11;
		iframeWidth = appWidth;
		applicationURL += (_A[k]['Parameters'] ? '&'+_A[k]['Parameters'] : '');
		applicationURL += '&height=' + iframeHeight;
		var winLeft = Math.round((winRt.w-appWidth)/2);
		var winBottom = _A[k]['align'] == 'bottom' ? 28 : (winRt.h - appHeight)/2;
		var ico = _C['publicDIR'] + _A[k]['ico'];
		_Ht.push('<div class="app_win" style="position:fixed !important; _position:absolute;width:'+appWidth+'px;height:'+appHeight+'px;left:'+winLeft+'px;bottom:'+winBottom+'px;" id="' + _A[k]['id'] + '">');
		_Ht.push(    '<div class="app_win_header">');
		_Ht.push(        '<span class="app_itemImg"><img src="' + ico + '" border="0" /></span>');
		_Ht.push(        '<span class="app_itemText">' + _A[k]['name'] + '</span>');
		_Ht.push(        '<span id="'+applicationClose+'" class="app_itemClose"></span>');
		_Ht.push(    '</div>');
		_Ht.push(    '<div class="app_win_body">');
		_Ht.push(        '<div id="' + applicationLoadingId + '" style="background:url(' + _C['publicDIR'] + '/loading.gif) no-repeat ' + (iframeWidth - 32)/2 + 'px ' + (iframeHeight - 32)/2 + 'px; width:' + iframeWidth + 'px;height:' + iframeHeight + 'px;"></div>');
		_Ht.push(        '<iframe id="' + applicationiFrameId + '" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + applicationURL + '" frameborder="0" style="overflow: hidden;display:none;" allowtransparency="true" scrolling="No"></iframe>');
		_Ht.push(    '</div>');
		_Ht.push(    '<div class="app_win_footer">');
		_Ht.push(     'Powered by Ntalker');
		_Ht.push(    '</div>');
		_Ht.push('</div>');
		$$D.insert($$O('ntalkerbar'), _Ht.join(''), 'beforeEnd');
		applicationWindow = $$O(_A[k]['id']);
		$$C.ready( $$O(applicationiFrameId), function(){
			$$D.css($$O(applicationLoadingId), 'display', 'none');
			$$D.css($$O(applicationiFrameId), 'display', 'block');
		});
		var __closeApplicationWindow = function(){
			self.closeApplicationWindow(k);
		};
		var __overApplicationCloseButton = function(){
			$$D.replaceClass($$O(applicationClose), 'app_itemClose', 'app_itemClose_over');
		};
		var __outApplicationCloseButton = function(){
			$$D.replaceClass($$O(applicationClose), 'app_itemClose_over', 'app_itemClose');
		};
		$$E.addEvent($$O(applicationClose), 'click', __closeApplicationWindow);
		$$E.addEvent($$O(applicationClose), 'mouseover', __overApplicationCloseButton);
		$$E.addEvent($$O(applicationClose), 'mouseout', __outApplicationCloseButton);
	}else{
		this.closeApplicationWindow(k);
		return;
	}
	$$D.addClass($$O(applicationButtonId), 'selected');
	$$D.animate(this.backgroundDiv, {opacity:75}, 400, "swing", function(){});
	$$D.animate(applicationWindow, {opacity:100}, 'fast', "easeOutQuint", function(){});
};
NtDiscuzTbar.prototype.closeApplicationWindow = function(k){
	var _A = Ntalker.Config.application;
	if( !k ){
		for(var k in _A ){
			this.closeApplicationWindow(k);
		}
		return;
	}
	var _A = Ntalker.Config.application,
		applicationButtonId = _A[k]['id'] + '_button',
		winElem = $$O(_A[k]['id']),
		applicationButton = $$O(applicationButtonId),
	    applicationiFrameId = _A[k]['id'] + '_iframe';
	if( winElem ){
		$$D.removeClass($$O(applicationButtonId), 'selected');
	$$D.animate([winElem, $$O('ntApplicationBackground')], {opacity:1}, 'fast', "easeOutQuint", function(elem){
			try{
				if( $$B.ie8 ) $$O(applicationiFrameId).src = '';
				elem.parentNode.removeChild(elem);
				Ntalker.variable.applicationOpened = false;
			}catch(e){
				winElem && winElem.parentNode.removeChild(winElem);
				$$O('ntApplicationBackground') && $$O('ntApplicationBackground').parentNode.removeChild($$O('ntApplicationBackground'));
			}
		});
	}
};
NtDiscuzTbar.prototype.updateUserNumber = function(onlineUser, totalUser){
    if( $$O('nt_firend') ){
    	$$O('nt_firend').innerHTML = sprintf(NtLang['buddylistButtonText'][0], String(onlineUser), String(totalUser));
    }
    var strOnline = String(onlineUser) + '' + String(totalUser);
    if( strOnline.length>2 ){
		this.onToolBarTextChanage();
	}
};
NtDiscuzTbar.prototype.initMessageBox=function(){
	var self = this, _C = Ntalker.Config;
	if( !$$O('nt_system') ){
		return;
	}
	var currentTag='divFeedContent',current_feed_Page=1,current_im_page=1;
	var __visibleActivity=function(currentTag,current_feed_Page,current_im_page){
		self.Mutex('system');
		self.leftMutex('');
		self.showMessageBox(currentTag,current_feed_Page,current_im_page);
	};
	var __hiddenActivity=function(e){
		if(IMToolBar&&IMToolBar.closeMessagebox){
			IMToolBar.closeMessagebox();
		}
	};
	var __buttonClick = function(){
		self.disableFlash('spanSystem');
		if(!$$O('feed_ul')&&!$$O('im_ul')){
			__visibleActivity.call(this);
			$$D.addClass($$O('spanSystem'), 'selected');
			$$D.css($$O('messageboxmenu'), 'height', '1px');
			var menuHeight = self._feedHeight <= 80 ? 119 : (self._feedHeight +38);
			menuHeight=(self._spanHeight||menuHeight);
    		$$D.animate($$O('messageboxmenu'), {height:menuHeight}, 'fast', 'easeInOutQuint', function(){});
		}else{
			__hiddenActivity.call(this);
		}
	};
	var __buttonOver = function(e){
        $$D.addClass($$O('spanSystem'), "hover");
    };
    var __buttonOut = function(e){
        $$D.removeClass($$O('spanSystem'), "hover");
    };
	$$E.addEvent($$O('nt_system'), 'click', __buttonClick);
	$$E.addEvent($$O('nt_system'), 'mouseover', __buttonOver);
	$$E.addEvent($$O('nt_system'), 'mouseout',  __buttonOut);
	this.countMessageBox("im",false,true);
};
NtDiscuzTbar.prototype.closeMessagebox = function(height){
	var self = this;
	var height=height;
	if( !$$O('messageboxmenu') ){
		return;
	}
	$$D.removeClass($$O('spanSystem'), 'selected');
	$$D.animate($$O('messageboxmenu'), {height:1}, 'fast', 'easeInOutQuint', function(){
		$$O('messageboxmenu').parentNode.removeChild($$O('messageboxmenu'));
        if(height){
        	self._feedHeight=height;
        }else{
        	self._feedHeight=0;
        }
	});
	this._Button="";
	this.countMessageBox('im',null,true);
};
NtDiscuzTbar.prototype.contentMessageBox=function(currentTag,current_feed_Page,current_im_page,e){
	if(e){
		$$E.fixEvent(e).stopPropagation();
	}
	var _C = Ntalker.Config, _V = Ntalker.variable;
	var MessageBox=$$O('nt_system');
	this.countMessageBox();
	var self=this;
	var perPage=5;
	var _fnum=this._fnum;
	var _inum=this._inum;
	var _anum=this._fnum*1+this._inum*1+this._customMessageCount*1;
	var _feedPage=Math.ceil((_fnum*1)/(perPage*1));
	var _sysPage=Math.ceil((_inum*1)/(perPage*1));
	var _hash=this._Hash;
	var _feedHT=['<ul id="feed_ul">'],_sysHT=['<ul id="im_ul">'];
	var im_show,feed_show;
	var current_feed_Page=typeof(current_feed_Page)=="number"?current_feed_Page:1;
	var current_im_page=typeof(current_im_page)=="number"?current_im_page:1;
	this._current_feed_Page=current_feed_Page;
	this._current_im_page=current_im_page;
	this._currentTag=currentTag;
	var feed_page_content,im_page_content;
	var feed_nex_page,feed_pre_page,im_nex_page,im_pre_page;
	if(current_feed_Page>_feedPage)current_feed_Page=_feedPage;
	if(current_im_page>_sysPage)current_im_page=_sysPage;
	if(current_feed_Page<_feedPage)feed_nex_page=current_feed_Page*1+1;else feed_nex_page=current_feed_Page;
	if(current_feed_Page>1)feed_pre_page=current_feed_Page*1-1;else feed_pre_page=current_feed_Page;
	if(current_im_page<_sysPage)im_nex_page=current_im_page*1+1;else im_nex_page=current_im_page;
	if(current_im_page>1)im_pre_page=current_im_page*1-1;else im_pre_page=current_im_page;
	if(feed_nex_page==current_feed_Page){
		feed_page_content='<span class="nt_box_page"><span class="nt_box_pre" onClick="IMToolBar.contentMessageBox(\'ntFeedTag\','+feed_pre_page+','+current_im_page+',event)" >&nbsp;</span><span style="margin-left:4px;" class="nt_box_nexnone" >&nbsp;</span></span>';
	}else if(feed_pre_page==current_feed_Page){
		feed_page_content='<span class="nt_box_page"><span class="nt_box_prenone" >&nbsp;</span><span class="nt_box_nex" style="margin-left:4px;" onClick="IMToolBar.contentMessageBox(\'ntFeedTag\','+feed_nex_page+','+current_im_page+',event)">&nbsp;</span></span>';
	}else{
		feed_page_content='<span class="nt_box_page"><span class="nt_box_pre" onClick="IMToolBar.contentMessageBox(\'ntFeedTag\','+feed_pre_page+','+current_im_page+',event)">&nbsp;</span><span style="margin-left:4px;" class="nt_box_nex" onClick="IMToolBar.contentMessageBox(\'ntFeedTag\','+feed_nex_page+','+current_im_page+',event)">&nbsp;</span></span>';
	}
	if(im_nex_page==current_im_page){
		im_page_content='<span class="nt_box_page"><span class="nt_box_pre" onClick="IMToolBar.contentMessageBox(\'ntIMTag\','+current_feed_Page+','+im_pre_page+',event)">&nbsp;</span><span style="margin-left:4px;" class="nt_box_nexnone" >&nbsp;</span></span>';
	}else if(im_pre_page==current_im_page){
		im_page_content='<span class="nt_box_page"><span class="nt_box_prenone">&nbsp;</span><span style="margin-left:4px;" class="nt_box_nex" onClick="IMToolBar.contentMessageBox(\'ntIMTag\','+current_feed_Page+','+im_nex_page+',event)">&nbsp;</span></span>';
	}else{
		im_page_content='<span class="nt_box_page"><span class="nt_box_pre" onClick="IMToolBar.contentMessageBox(\'ntIMTag\','+current_feed_Page+','+im_pre_page+',event)">&nbsp;</span><span style="margin-left:4px;" class="nt_box_nex" onClick="IMToolBar.contentMessageBox(\'ntIMTag\','+current_feed_Page+','+im_nex_page+',event)">&nbsp;</span></span>';
	}
	var feed_flag=0,im_flag=0,lineClass="nt_box_line",have_feed=false;
	for(var k=0;k<_hash.length;k++){
		var _V1 = _hash[k];
		var unread="";
		if(_V1.msgtype=='feed'){
			if(feed_flag>=(current_feed_Page-1)*perPage&&feed_flag<(current_feed_Page*1-1)*perPage+perPage*1){
				if(currentTag=="ntFeedTag"){
					if(!_V1.isRead){
						this._rfnum++;unread='style=\"font-weight: bold;\"';
						var _V = Ntalker.variable;
						var desc="feedmsg";
						var siteurl=Ntalker.Config['services'] + "/func/statistic.php?siteid="+_V['siteid']+"&uid="+_V['user_id']+"&destid=0&groupid=0&type=18&mode=2&source=0&desc="+encodeURIComponent(desc)+"&from=sysMsgList&rnd="+new Date().getTime();
						$$C.script(siteurl,"utf-8");
					}
					_V1.isRead=true;
				}
				_feedHT.push('<li style="cursor:pointer;" k="' + _V1.key + '" class="' + lineClass + ' nt_box_out" onClick=\'fIM_navigateToModuleView("'+_V1.id+'", "'+_V1.name+'","'+_V1.opentype+'" ,"'+_V1.activitytype+'", "'+_V1.activityid+'", "'+_V1.key+'", "feed_ul", "feedMsgList","'+_V1.chatid+'","'+_V1.msgtype+'",event)\'>');
				_feedHT.push(    '<div class="nt_box_ico"><img onerror=\'this.src="'+_C['imagesDIR'] + '/notify_userhead.png"\'  src="' + (_V1.iconurl ? _V1.iconurl : _C['imagesDIR'] + '/notify_userhead.png') + '" width=38 height=38 border=0 /></div>');
				_feedHT.push(    '<div class="nt_box_content_big" '+unread+'>');
				_feedHT.push(    _V1.content);
				_feedHT.push(    '</div>');
				_feedHT.push(    '<div class="nt_item_box_close" onClick="IMToolBar.removeMessageBox(\''+_V1.key+'\', \'feed_ul\', false, event)"></div>');
				_feedHT.push(    '<span class="clearfloat"></span>');
				_feedHT.push('<div class="nt_box_button" style="width:100%"></div>');
				_feedHT.push('</li>');
				feed_flag++;
			}else{
				feed_flag++;
			}
		}
		else{
			if(!_V1.msgtype) {return;}
			if(im_flag>=(current_im_page-1)*perPage&&im_flag<(current_im_page*1-1)*perPage+perPage*1){
				if(currentTag=="ntIMTag"){
					if(!_V1.isRead){
						this._rinum++;unread='style=\"font-weight: bold;\"';
						if(_V1.msgtype=="notify"){
							var _V = Ntalker.variable;
							var desc="msgid_is_"+_V1.msgid;
							var siteurl=Ntalker.Config['services'] + "/func/statistic.php?siteid="+_V['siteid']+"&uid="+_V['user_id']+"&destid=0&groupid=0&type=17&mode=2&source=0&desc="+encodeURIComponent(desc)+"&from=sysMsgList&rnd="+new Date().getTime();
							$$C.script(siteurl,"utf-8");
						}
					}
					 _V1.isRead=true;
				}
				if(_V1.id&&_V1.name&&_V1.opentype!="img"){
					_sysHT.push('<li style="cursor:pointer;" k="' + _V1.key + '" class="' + lineClass + ' nt_box_out" onClick=\'fIM_navigateToModuleView("'+_V1.id+'", "'+_V1.name+'","'+_V1.opentype+'","'+_V1.activitytype+'","'+_V1.activityid+'", "'+_V1.key+'", "im_ul", "sysMsgList","'+_V1.chatid+'","'+_V1.msgtype+'",event,"'+_V1.msgid+'")\'>');
				}else if(_V1.opentype=="img"){
					_sysHT.push('<li style="cursor:pointer;" k=\'' + _V1.key + '\' class=\'' + lineClass + ' nt_box_out\' onClick=\'javascript:window.open("'+(_V1.profileurl?_V1.profileurl:"")+'");IMToolBar.removeMessageBox("'+_V1.key+'","im_ul",false,event);\'>');
				}else{
					_sysHT.push('<li k="' + _V1.key + '" class="' + lineClass + ' nt_box_out" >');
				}
				_sysHT.push(    '<div class="nt_box_ico"><img 	onerror=\'this.src="'+_C['imagesDIR'] + '/notify_userhead.png"\'  src="' + (_V1.iconurl ? _V1.iconurl : _C['imagesDIR'] + '/notify_userhead.png') + '" width=38 height=38 border=0 /></div>');
				_sysHT.push(    '<div class="nt_box_content_big" ' +unread+'>');
				_sysHT.push(    _V1.content);
				_sysHT.push(    '</div>');
				_sysHT.push(    '<div class="nt_item_box_close" onClick="IMToolBar.removeMessageBox(\''+_V1.key+'\', \'im_ul\', false, event)"></div>');
				_sysHT.push(    '<span class="clearfloat"></span>');
					switch(_V1.msgtype){
					case 'notify':
						_sysHT.push('<div class="nt_box_button"></div>');
						break;
					case 'confirm':
						_sysHT.push('<div class="nt_box_button"><input type="button" class="nt_box_ignore" onclick="IMToolBar.removeMessageBox(\''+_V1.key+'\',\'im_ul\',false,event)"><input type="button" class="nt_box_approve" onclick="im_boxConfrim(\''+_V1.id+'\',1,\''+_V1.key+'\',\'im_ul\');fIM_navigateToModuleView(\''+_V1.id+'\',\''+_V1.name+'\',\''+_V1.opentype+'\' ,\''+_V1.activitytype+'\', \''+_V1.activityid+'\', \''+_V1.key+'\', \'feed_ul\', \'feedMsgList\',\''+_V1.chatid+'\',\''+_V1.msgtype+'\',event);"></div>');
							break;
					case 'request':
						_sysHT.push('<div class="nt_box_button"><input type="button" class="nt_box_ignore" onclick="IMToolBar.removeMessageBox(\''+_V1.key+'\',\'im_ul\',false,event)"><input type="button" class="nt_box_approve" onclick="fIM_navigateToModuleView(\''+_V1.id+'\',\''+_V1.name+'\',\''+_V1.opentype+'\' ,\''+_V1.activitytype+'\', \''+_V1.activityid+'\', \''+_V1.key+'\', \'feed_ul\', \'feedMsgList\',\''+_V1.chatid+'\',\''+_V1.msgtype+'\',event);IMToolBar.removeMessageBox(\''+_V1.key+'\',\'im_ul\',false,event);"></div>');
						break;
					}
				_sysHT.push('</li>');
				im_flag++;
			}else{
				im_flag++;
			}
		}
	}
	for(var i=0;i<Ntalker.variable.ExMsg.length;i++){
		var _ExtMsg=Ntalker.variable.ExMsg[i];
		if(_ExtMsg.msgnumber>0){
			_sysHT.push('<LI class="nt_box_single nt_box_out" onclick="IMToolBar.viewCurstomSystemMessage(\'' + _ExtMsg.url + '\',event);" class="act nt-item-out" url="' + _ExtMsg.url + '"><DIV><a href="javascript:void(0);">' + _ExtMsg.name + ' (' + _ExtMsg.msgnumber + ')</a></DIV></LI>');	
		}
	}
	if(_fnum==0){
		_feedHT.push('<li class="nt_box_single nt_box_out"><div class="nt_box_null">' + sprintf(NtLang['nullMessage'][0], NtLang['systemMessageBoxText'][0]) + '</div></li>');
	}else{
		if(_feedPage>1)
		_feedHT.push(feed_page_content);
	}
	if( _anum - _fnum == 0){
		_sysHT.push('<li class="nt_box_single nt_box_out"><div class="nt_box_null">' + sprintf(NtLang['nullMessage'][0], NtLang['systemMessageBoxText'][1]) + '</div></li>');
	}else{
		if(_sysPage>1)
		_sysHT.push(im_page_content);
	}
	_feedHT.push('</ul>');
	_sysHT.push('</ul>');
	$$O('divFeedContent').innerHTML=_feedHT.join('');
	$$O('divIMContent').innerHTML=_sysHT.join('');
		if($$O('divFeedContent').scrollHeight!=0&&$$O('divFeedContent').scrollHeight>this._feedHeight) {
			this._feedHeight=$$O('divFeedContent').scrollHeight;
		}
		var feedHeight = ($$O('divFeedContent').scrollHeight>this._feedHeight)?($$O('divFeedContent').scrollHeight):(this._feedHeight);
		var imHeight   = $$O('divIMContent').scrollHeight ? ($$O('divIMContent').scrollHeight):(_inum>perPage?perPage*50+25*1:_inum*50+25*1);
		if( feedHeight > imHeight ){
	        var paddingHeight = parseInt($$D.css($$O('divFeedContent'), 'paddingTop')) + parseInt($$D.css($$O('divFeedContent'), 'paddingBottom'));
	        if(this._feedHeight<feedHeight){
	        	this._feedHeight=feedHeight;
	        }
	        var menuContentHeight = Math.max(80, feedHeight - paddingHeight);
	        var spanHeight=(feedHeight-paddingHeight)>80 ? menuContentHeight+48 : menuContentHeight+39;
	        this._spanHeight=spanHeight;
			if(currentTag=="ntFeedTag"){
				$$D.css($$O('divFeedContent'), 'height', menuContentHeight + 'px' );
			}else{
				$$D.css($$O('divIMContent'), 'height', menuContentHeight + 'px' );
			}
			if(!this._Button){
				this._Button=($$O("messageboxmenu")||"");
			}
			$$D.css(this._Button, 'height', spanHeight + 'px' );
	    }else{
	        var paddingHeight = parseInt($$D.css($$O('divIMContent'), 'paddingTop')) + parseInt($$D.css($$O('divIMContent'), 'paddingBottom'));
	        if(this._feedHeight<imHeight){
	        	this._feedHeight=imHeight;
	        }
	        var menuContentHeight = (imHeight-paddingHeight)>80 ? (imHeight-paddingHeight) : 80;
	       	var spanHeight=(imHeight-paddingHeight)>80 ? menuContentHeight+48 : menuContentHeight+39;
	       	this._spanHeight=spanHeight;
			if(currentTag=="ntFeedTag"){
				$$D.css($$O('divFeedContent'), 'height', menuContentHeight + 'px' );
			}else{
				$$D.css($$O('divIMContent'), 'height', menuContentHeight + 'px' );
			}
			if(!this._Button){
				this._Button=($$O("messageboxmenu")||"");
			}
			$$D.css(this._Button, 'height', spanHeight + 'px' );
	    }
	var __mouseOver = function(e){
		e = $$E.fixEvent(e);
		target= searchTag(e.target, "li");
		$$D.replaceClass(target, 'nt_box_out', 'nt_box_over');
		for(var k in target.childNodes ){
			var itemCloseButton = target.childNodes[k];
			if( itemCloseButton && itemCloseButton.className == 'nt_item_box_close' ){
				$$D.css(itemCloseButton, 'background', 'url('+_C['imagesDIR']+'/nt_box_bj.gif) -20px -140px');
			}
		}
	};
	var __mouseOut = function(e){
		e = $$E.fixEvent(e);
		target= searchTag(e.target, "li");
		$$D.replaceClass(target,'nt_box_over','nt_box_out');
		for(var k in target.childNodes ){
			var itemCloseButton = target.childNodes[k];
			if( itemCloseButton && itemCloseButton.className == 'nt_item_box_close' ){
				$$D.css(itemCloseButton, 'background', 'none');
			}
		}
	};
	var __onClick=function(e){
		e = $$E.fixEvent(e);
		target= searchTag(e.target, "li");
		for(var k in target.childNodes ){
			var itemCloseButton = target.childNodes[k];
			if( itemCloseButton && itemCloseButton.className == 'nt_box_content_big' ){
				$$D.css(itemCloseButton, 'font-weight', 'normal');
			}
		}
	};
	for(k in $$O('feed_ul').childNodes){
		var elem = $$O('feed_ul').childNodes[k];
		if( elem.nodeName && elem.nodeName.toUpperCase()== "LI"){
			$$E.addEvent(elem, 'mouseover', __mouseOver);
			$$E.addEvent(elem, 'mouseout', __mouseOut);
			$$E.addEvent(elem, 'click', __onClick);
		}
	}
	for(k in $$O('im_ul').childNodes){
		var elem = $$O('im_ul').childNodes[k];
		if( elem.nodeName &&elem.nodeName.toUpperCase() == "LI"){
			$$E.addEvent(elem, 'mouseover', __mouseOver);
			$$E.addEvent(elem, 'mouseout', __mouseOut);
			$$E.addEvent(elem, 'click', __onClick);
		}
	}
	this.countMessageBox('im',null,true);
};
NtDiscuzTbar.prototype.showMessageBox = function(currentTag,current_feed_Page,current_im_page){
	var _C = Ntalker.Config;
	var _CP = Ntalker.Config.customparams;
	var MessageBox=$$O('nt_system');
	var self=this;
	var _inum=this._inum;
	var _fnum=this._fnum;
	var _rfnum=this._rfnum;
	var _rinum=this._rinum;
	var _anum=this._fnum*1+this._inum*1+this._customMessageCount*1;
	var _Ht=[];
	var isShowFeed="";
	if(chatWindowManager) {
		chatWindowManager.OnTBFocusWindow(0);
	}
	if(!currentTag){
		var _urfnum=this._fnum-this._rfnum;
		var _urinum=this._inum-this._rinum;
		if(_urfnum>0&&_urinum==0){
			currentTag="ntFeedTag";
		}else{
			currentTag="ntIMTag";
		}
	}else{
		currentTag=currentTag;
	}
	if(_CP['quanflag']==0){
		currentTag="ntIMTag";
		isShowFeed="style=\"display:none\"";
	}
	if(currentTag=='ntIMTag'){im_show="block";feed_show="none";im_current="nt_box_currenttag";feed_current="nt_box_tag";}else{im_show="none";feed_show="block";feed_current="nt_box_currenttag";im_current="nt_box_tag";}
	var feed_str=(_fnum-_rfnum>0)?'<span style="color:red" id="feed_num" ><span style="color:black">(</span>'+(_fnum-_rfnum)+'<span style="color:black">)</span></span>':"";
	var im_str=((_inum-_rinum)*1+this._customMessageCount*1>0)?'<span style="color:red" id="im_num" ><span style="color:black">(</span>'+((_inum-_rinum)*1+this._customMessageCount*1)+'<span style="color:black">)</span></span>':"";
	var temp=$$D.clientRect("nt_content").left+$$D.clientRect("nt_content").w-$$D.clientRect("nt_system").left;
	if(temp>300){
		temp=temp-301;
	}else{
		temp=0;
	}
	_Ht.push('<span id="messageboxmenu" class="nt_box_menu" style="right:'+temp+'px;" >');
	_Ht.push('<div class="nt_box_top">');
	_Ht.push('<div class="nt_box_bottom">');
	_Ht.push('	<span id="ntFeedTag" '+isShowFeed+' class=" nt_box_feed '+feed_current+'">' + NtLang['systemMessageBoxText'][0] + feed_str + '</span>');
	_Ht.push('	<span id="ntIMTag" class=" nt_box_im '+im_current+'">' + NtLang['systemMessageBoxText'][1] + im_str + '</span>');
	_Ht.push('	<span class="nt_box_close" onClick="IMToolBar.closeMessagebox();">&nbsp;</span>');
	_Ht.push('<br class="clearfloat" />');
	_Ht.push('<div id="divFeedContent" style="overflow:hidden;display:'+feed_show+';" class="nt_box_feed_content">' + NtLang['systemMessageBoxText'][0] + NtLang['LoadingText'] + '</div>');
	_Ht.push('<div id="divIMContent" style="overflow:hidden;display:'+im_show+';" class="nt_box_im_content">' + NtLang['systemMessageBoxText'][1] + NtLang['LoadingText'] + '</div>');
	_Ht.push('</div></div>');
	_Ht.push('</span>');
	this._Button=($$D.insert($$O("ntalkerbar"), _Ht.join(''), 'beforeEnd')||$$O("messageboxmenu"));
	var _V = Ntalker.variable;
	var desc="messagebox";
	var siteurl=Ntalker.Config['services'] + "/func/statistic.php?siteid="+_V['siteid']+"&uid="+_V['user_id']+"&destid=0&groupid=0&type=19&mode=2&source=0&desc="+encodeURIComponent(desc)+"&from=sysMsgList&rnd="+new Date().getTime();
	$$C.script(siteurl,"utf-8");
	this.contentMessageBox(currentTag,current_feed_Page,current_im_page);
	function changetag(type){
		if(type=="feed"){
			$$D.replaceClass($$O('ntFeedTag'),'nt_box_tag','nt_box_currenttag');
			$$D.css($$O('divFeedContent'),'display','block');
			$$D.replaceClass($$O('ntIMTag'),'nt_box_currenttag','nt_box_tag');
			$$D.css($$O('divIMContent'),'display','none');
		}else{
			$$D.replaceClass($$O('ntFeedTag'),'nt_box_currenttag','nt_box_tag');
			$$D.css($$O('divFeedContent'),'display','none');
			$$D.replaceClass($$O('ntIMTag'),'nt_box_tag','nt_box_currenttag');
			$$D.css($$O('divIMContent'),'display','block');
		}
	}
	$$O('ntFeedTag').onclick = function(e){
		e = window.event || e;
		if(e){
			$$E.fixEvent(e).stopPropagation();
		}
		self._currentTag = "ntFeedTag";
		changetag('feed');
		self.contentMessageBox(self._currentTag,self._current_feed_Page,self._current_im_page);
	};
	$$O('ntIMTag').onclick = function(e){
		e = window.event || e;
		if(e){
			$$E.fixEvent(e).stopPropagation();
		}
		self._currentTag="ntIMTag";
		changetag('im');
		self.contentMessageBox(self._currentTag,self._current_feed_Page,self._current_im_page);
	};
};
NtDiscuzTbar.prototype.countMessageBox=function(type,isread,isnew){
	var _hash=this._Hash;
	var imMsgCount=0;
	var _inum=this._inum;
	var _fnum=this._fnum;
	this._customMessageCount=0;
	for(var i=0;i<Ntalker.variable.ExMsg.length;i++){
		var _ExtMsg=Ntalker.variable.ExMsg[i];
		if(_ExtMsg.msgnumber>0){
			this._customMessageCount=_ExtMsg.msgnumber*1+this._customMessageCount*1;
		}
	}
	if($$O('nt_system')&&isnew==true){
		var unum=(this._fnum-this._rfnum)*1+(this._inum-this._rinum)*1+this._customMessageCount*1;
		var _uinum=this._inum-this._rinum;
		if(_uinum>0){
			$$O('nt_system').innerHTML=NtLang['systemButtonText']+'<span class="nt_box_tip2">('+unum+')</span>';
				var allCount = this._Hash.length;
				if(allCount>0){
			        this.enableflash('spanSystem', '', 'flash');
			    }else{
			        this.disableFlash('spanSystem');
			    }
		}else if(unum>=0){
			$$O('nt_system').innerHTML=NtLang['systemButtonText']+'<span class="nt_box_tip2">('+unum+')</span>';
		}
	}
	if($$O('feed_num')&&_fnum-this._rfnum>0){
		$$O('feed_num').innerHTML="<span style='color:black'>(</span>"+(_fnum-this._rfnum)+'<span style="color:black">)</span>';
	}else if($$O('feed_num')){
		$$O('feed_num').innerHTML="";
	}
	if($$O('im_num')&&(_inum-this._rinum)*1+this._customMessageCount*1>0) {
		$$O('im_num').innerHTML="<span style='color:black'>(</span>"+((_inum-this._rinum)*1+this._customMessageCount*1)+'<span style="color:black">)</span>';
	}else if($$O('im_num')){
		$$O('im_num').innerHTML="";
	}
    if(type=="all") return this._customMessageCount*1+_hash.length*1;
};
NtDiscuzTbar.prototype.addMessageBox=function(id,name,content,opentype,iconurl,msgtype,activitytype,activityid,activityname,activityicon,profileurl,chatid,isread,msgid,srcuid,msgtime){
	var _hash=this._Hash;
	var _CP = Ntalker.Config.customparams;
	var rand=1, isupdate = false;
	var temp=0;
	var _fnum=this._fnum;
	var _inum=this._inum;
	var _tipTime=1800;
	if(_CP['quanflag']==0){
		if(msgtype=="feed"){
			return;
		}
	}
	function contains(_hash,msgtype,rand){
		for(var i=0;i<_hash.length;i++){if (_hash[i]&&_hash[i].key==msgtype+rand){ temp++; return true;}}
	}
	while(contains(_hash,msgtype,rand)){
		rand=Math.floor(Math.random()*99);
		if(temp>=99) break;
		if(msgtype=="feed"){
			if(_fnum>=50) break;
		}else{
			if(_inum>=50) break;
		}
	}
	for(var i=0;i<_hash.length;i++){
		var tmp=_hash[i];
		if(tmp&&tmp.id==id&&msgtype==tmp.msgtype){
			if(msgtype=="confirm"||msgtype=="request"){
				if(_hash[i].isRead){this._rinum--;isread=true;}
				this._inum--;
				_hash.splice(i,1);
				break;
			}else if(msgtype=="feed"){
				if((srcuid&&tmp.srcuid==srcuid)||tmp.activityid==activityid){
					if(_hash[i].isRead){
						this._rfnum--;
					}
					this._fnum--;
					if((Date.parse(new Date()))/1000-tmp.msgtime>_tipTime){
						isread=false;
						msgtime=Date.parse(new Date())/1000;
					}else{
						isread=tmp.isRead;
						msgtime=tmp.msgtime;
					}
					_hash.splice(i,1);
					break;
				}
			}
		}
	}
	if(_fnum>=50||_inum>=50){
		for(var i=_hash.length-1;i>=0;i--){
			var tmp=_hash[i];
			if(msgtype=="feed"&&_fnum>=50){
				if(tmp&&tmp.msgtype==msgtype){
					this._fnum--;
					if(tmp.isRead) this._rfnum--;
					_hash.splice(i,1);
					break;
				}
			}else{
				if(tmp&&tmp.msgtype==msgtype&&_inum>=50){
					this._inum--;
					if(tmp.isRead) this._rinum--;
					_hash.splice(i,1);
					break;
				}
			}
		}
	}
	if(!isupdate){
		_hash.unshift({
				key:msgtype+rand,
				id:id,
				name:name,
				content:content,
				opentype:opentype,
				iconurl:iconurl,
				msgtype:msgtype,
				activitytype:activitytype,
				activityid:activityid,
				activityname:activityname,
				activityicon:activityicon,
				profileurl:profileurl,
				chatid:chatid,
				isRead:isread,
				msgid:msgid,
				srcuid:srcuid,
				msgtime:msgtime
			}
		);
		if(msgtype=="feed"){ 
			this._fnum++;
			if(isread) this._rfnum++;
		}
		else{
			if(isread) this._rinum++;
		 	this._inum++;
		}
	}
	if(!this._Button){
		this.countMessageBox('im',null,true);
	}
};
NtDiscuzTbar.prototype.removeMessageBox=function(k,ulid,keepHt,e){
	if(e)
	$$E.fixEvent(e).stopPropagation();
	var _hash=this._Hash;
	for(var i=0;i<_hash.length;i++){
		if(_hash[i].key==k){
			if(_hash[i].msgtype=="feed"){ 
				if(_hash[i].isRead) this._rfnum--;
				this._fnum--;
			}
			else{ 
				if(_hash[i].isRead) this._rinum--;
				this._inum--; 
			}	
		_hash.splice(i,1);
		}
	}
	if(keepHt!=true){
	var span=$$O(ulid);
	for(i in span.childNodes){
		var child=span.childNodes[i];
			if(child&&child.nodeName=="LI"&&child.attributes['k']&&child.attributes['k'].nodeValue==k){
			span.removeChild(child);
			break;
		}
	}
	}
	this.countMessageBox('im',null,true);
	if(this._Button)
		this.contentMessageBox(this._currentTag,this._current_feed_Page,this._current_im_page);
};
NtDiscuzTbar.prototype.saveMessageBox=function(){
	var _V = Ntalker.variable;
    if( !this._Hash ){
    	return;
    }
    var _hash=this._Hash,feed=0,im=0,flag=[];
    for(var i=0; i<_hash.length;i++){
    	var _V1=_hash[i];
    	if(_V1.msgtype=="feed"){
	    	if( feed<20 ){
	    		flag.push(_V1);feed++;
			}
			}else {
			if( im<20 ){flag.push(_V1); im++;
			}
		}
	}
	if( flag.length == 0 ){
    	cookieValue = null;
    }else{
    	cookieValue = $$J.toJSONString(flag);
    }
    NtUtil.saveValue(_V['user_id'], Ntalker['ctKEY'], cookieValue);
};
NtDiscuzTbar.prototype.loadMessageBox=function(){
	var _V = Ntalker.variable;
	NtUtil.loadValue(_V['user_id'], Ntalker['ctKEY']);
};
NtDiscuzTbar.prototype.initConfigurationMenu = function(){
	var _V = Ntalker.variable;
	if( _V['user_sid'] == 'NtalkerGuestUserSessionID' || !$$O('nt_setting') ){
		return;
	}
    var self = this;
    var __buttonOver = function(e){
        $$D.addClass($$O('ntConfiguration'), "hover");
    };
    var __buttonOut = function(e){
        $$D.removeClass($$O('ntConfiguration'), "hover");
    };
    var __visibleConfigurationMenu = function(){
    	self.visibleConfigurationMenu();
	};
    $$E.addEvent($$O('nt_setting'), 'mouseover', __buttonOver);
    $$E.addEvent($$O('nt_setting'), 'mouseout',  __buttonOut);
    $$E.addEvent($$O('nt_setting'), 'click',  __visibleConfigurationMenu);
};
NtDiscuzTbar.prototype.visibleConfigurationMenu = function(){
	var _Ht = [], _CP = Ntalker.Config.customparams;
	if( $$O('configurationMenu') ){
		this.hiddenConfigurationMenu();
		return;
	}
	IMToolBar.Mutex('');
	_Ht.push('<span id="configurationMenu" class="ntalkerbar-menuright" style="">');
    _Ht.push(    '<div class="TopGradient">');
    _Ht.push(        '<div class="BottomGradient">');
    _Ht.push(            '<div class="ntMenuTitle">');
    _Ht.push(                '<span class="ntConfigMenuText"></span>');
    _Ht.push(                '<span class="ntConfigMenuClose" id="ntConfigMenuClose"></span>');
    _Ht.push(            '</div>');
    _Ht.push(            '<div class="ntMenuLine"></div>');
    _Ht.push(            '<div class="ntMenuContent" id="ntConfigMenuList">');
    if( _CP['quanflag'] ){
	    _Ht.push(                '<div class="ntMenuItemtTitle">' + NtLang['configurationMenuDynamicMessages'][0] + '</div>');
	    _Ht.push(                '<div cusname="acceptOriginalFeed" cusgroupname="dynamicMessages" class="ntMenuItemtText dynamicMessages" custype="Checkbox">' + NtLang['configurationMenuDynamicMessages'][1] + '</div>');
	    _Ht.push(                '<div cusname="acceptCommentFeed" cusgroupname="dynamicMessages" class="ntMenuItemtText dynamicMessages" custype="Checkbox">' + NtLang['configurationMenuDynamicMessages'][2] + '</div>');
	    _Ht.push(                '<div class="ntMenuLine"></div>');
	}
    _Ht.push(                '<div class="ntMenuItemtTitle">' + NtLang['configurationMenuGroupSetting'][0] + '</div>');
    _Ht.push(                '<div cusgroupname="groupSetting" class="ntMenuItemtText groupSetting" custype="Radio" cusvalue="0">' + NtLang['configurationMenuGroupSetting'][1] + '</div>');
    _Ht.push(                '<div cusgroupname="groupSetting" class="ntMenuItemtText groupSetting" custype="Radio" cusvalue="1">' + NtLang['configurationMenuGroupSetting'][2] + '</div>');
    _Ht.push(                '<div class="ntMenuLine"></div>');
    _Ht.push(                '<div class="ntMenuItemtTitle">' + NtLang['configurationMenuOtherSettings'][0] + '</div>');
    _Ht.push(                '<div cusname="buddyLoginTip" cusgroupname="otherSettings" class="ntMenuItemtText otherSettings" custype="Checkbox">' + NtLang['configurationMenuOtherSettings'][1] + '</div>');
    _Ht.push(                '<div cusname="acceptMsgFlag" cusgroupname="otherSettings" class="ntMenuItemtText otherSettings" custype="Checkbox">' + NtLang['configurationMenuOtherSettings'][2] + '</div>');
    if( _CP['playsound'] ){
    	_Ht.push(            '<div cusname="audioOnFlag" cusgroupname="otherSettings" class="ntMenuItemtText otherSettings" custype="Checkbox">' + NtLang['configurationMenuOtherSettings'][3] + '</div>');
	}
    _Ht.push(            '</div>');
    _Ht.push(        '</div>');
    _Ht.push(    '</div>');
    _Ht.push('</span>');
    var menuElem = $$D.insert($$O('ntalkerbar'), _Ht.join(''), 'beforeEnd');
    $$D.addClass($$O('ntConfiguration'), "selected");
    $$D.css(menuElem, 'display', 'block');
    var menuHeight = $$D.clientRect(menuElem).h - 2;
    $$D.css(menuElem, 'height', '1px');
    $$D.animate(menuElem, {height:menuHeight}, 'fast', 'easeInOutQuint', function(){});
	    var impresenceflash = $$O('impresenceflash');
		if( impresenceflash && impresenceflash.getSetting ){
			impresenceflash.getSetting( );
		}
    var self = this;
    var __menuItemOver = function(e){
    	current = e.currentTarget || window.event.srcElement;
        if( current.className.indexOf("ntMenuItemtText")==-1 ) current = current.parentNode;
        $$D.addClass(current, "hover");
    };
    var __menuItemOut = function(e){
    	current = e.currentTarget || window.event.srcElement;
        if( current.className.indexOf("ntMenuItemtText")==-1 ) current = current.parentNode;
        $$D.removeClass(current, "hover");
    };
    var __menuItemClick = function(e){
    	current = e.currentTarget || window.event.srcElement;
        if( current.className.indexOf("ntMenuItemtText")==-1 ) current = current.parentNode;
        self.setConfiguration(current);
    };
    var __hiddenConfigurationMenu = function(e){
        self.hiddenConfigurationMenu();
    };
    $$E.addEvent($$O('ntConfigMenuClose'), 'click', __hiddenConfigurationMenu);
    var menuItems = $$D.filter($$O('ntConfigMenuList').childNodes);
    $$A.each(menuItems, function(elem){
    	if( elem.className.indexOf("ntMenuItemtText") > -1 ){
    		$$E.addEvent(elem, 'mouseover', __menuItemOver);
    		$$E.addEvent(elem, 'mouseout',  __menuItemOut);
    		$$E.addEvent(elem, 'click',  __menuItemClick);
    	}
    });
};
NtDiscuzTbar.prototype.hiddenConfigurationMenu = function(){
	$$D.removeClass($$O('ntConfiguration'), "selected");
	if( !$$O('configurationMenu') ){
		return;
	}
	$$D.animate($$O('configurationMenu'), {height:1}, 'fast', 'easeInOutQuint', function(){
		$$O('configurationMenu').parentNode.removeChild($$O('configurationMenu'));
	});
};
NtDiscuzTbar.prototype.setConfiguration = function(clickElement){
	var custype, cusGroupName,groupItems, modifyIndex = 0;
	if( !clickElement ){
		return;
	}
	custype = clickElement.getAttribute('custype');
	cusGroupName = clickElement.getAttribute('cusgroupname');
	if( cusGroupName == 'dynamicMessages' ){
		modifyIndex = 0;
	}else if( cusGroupName == 'groupSetting' ){
		modifyIndex = 1;
	}else{
		modifyIndex = 2;
	}
	if( custype.toLowerCase() == 'radio' ){
		groupItems = $$D.filter($$O('ntConfigMenuList').childNodes, '.'+cusGroupName);
		$$A.each(groupItems, function(elem){
			if( clickElement == elem ){
				$$D.addClass(elem, 'selected_radio');
			}else{
				$$D.removeClass(elem, 'selected_radio');
			}
		});
	}else if( custype.toLowerCase() == 'checkbox' ){
		if( !$$D.include(clickElement, 'selected_checkbox') ){
			$$D.addClass(clickElement, 'selected_checkbox');
		}else{
			$$D.removeClass(clickElement, 'selected_checkbox');
		}
	}else if( custype.toLowerCase() == 'checkbox' ){
		return;
	}
	this.saveConfiguration(modifyIndex);
};
NtDiscuzTbar.prototype.loadConfiguration = function(strJson){
	var jsonConfiguration = {};
	jsonConfiguration = this.jsonConfiguration = $$J.parseJSON(strJson);
	if( !$$O('ntConfigMenuList') ){
		return;
	}
	var Items = $$D.filter($$O('ntConfigMenuList').childNodes, '.ntMenuItemtText');
	$$A.each(Items, function(elem){
		var custype = elem.getAttribute('custype');
		if( custype.toLowerCase() == 'radio' ){
			if( elem.getAttribute('cusvalue') == jsonConfiguration.groupSetting ){
				$$D.addClass(elem, 'selected_radio');
			}else{
				$$D.removeClass(elem, 'selected_radio');
			}
		}else if( custype.toLowerCase() == 'checkbox' ){
			if( jsonConfiguration[elem.getAttribute('cusname')] === true || jsonConfiguration[elem.getAttribute('cusname')] === elem.getAttribute('cusvalue') ){
				$$D.addClass(elem, 'selected_checkbox');
			}else{
				$$D.removeClass(elem, 'selected_checkbox');
			}
		}
	});
};
NtDiscuzTbar.prototype.saveConfiguration = function(modifyIndex){
	var jsonConfiguration = {modifyIndex:modifyIndex};
	var Items = $$D.filter($$O('ntConfigMenuList').childNodes, '.ntMenuItemtText');
	$$A.each(Items, function(elem){
		var custype = elem.getAttribute('custype');
		if( custype.toLowerCase() == 'radio' && $$D.include(elem, 'selected_radio') ){
			jsonConfiguration[elem.getAttribute('cusgroupname')] = elem.getAttribute('cusvalue');
		}else if( custype.toLowerCase() == 'checkbox' ){
			jsonConfiguration[elem.getAttribute('cusname')] = $$D.include(elem, 'selected_checkbox');
		}
	});
	if( typeof(jsonConfiguration.acceptOriginalFeed)=='undefined' ) jsonConfiguration.acceptOriginalFeed = true;
	if( typeof(jsonConfiguration.acceptCommentFeed)=='undefined' )  jsonConfiguration.acceptCommentFeed = true;
	this.jsonConfiguration = jsonConfiguration;
	var strJson = $$J.toJSONString(jsonConfiguration);
	var impresenceflash = $$O('impresenceflash');
	if( impresenceflash && impresenceflash.setSetting ){
		impresenceflash.setSetting( strJson );
	}
};
function fIM_setConfiguration(strJson){
	if( IMToolBar ){
		IMToolBar.loadConfiguration(strJson);
	}
}
function im_boxConfrim(id, confirmStr, key, ulid,e){
	if(e)
	$$E.fixEvent(e).stopPropagation();
	var impresence = $$O('impresenceflash');
    if(impresence && impresence.addFriendConfirmResult){
       impresence.addFriendConfirmResult(id, confirmStr);
    }
    if(IMToolBar&&IMToolBar.removeMessageBox){
    	IMToolBar.removeMessageBox(key,ulid,false);
    }
}
function fIM_navigateToModuleView(id, name,opentype, activitytype,activityid, key, ulid, befrom,chatid,msgtype,e,msgid){
	if(e)
		$$E.fixEvent(e).stopPropagation();
	if(im_chat_window_manager){
		var quan=im_chat_window_manager.getChatWindow(id, opentype);
		if(quan&&quan._isFlashLoadSuccess){
				im_chat_window_manager.OnTBFocusWindow(id,opentype);
				quan._flash.navigateToModuleView(activityid,activitytype);
		}else{
			Ntalker.variable.activityid=activityid;
			Ntalker.variable.activitytype=activitytype;
			im_openWebchatWindow(id, name, chatid, 1, opentype, 0, befrom);
			Ntalker.variable.activityid=Ntalker.variable.activitytype="";
		}
	}
	if(msgid){
		var _V = Ntalker.variable;
		var desc="msgid_is_"+msgid;
		var siteurl=Ntalker.Config['services'] + "/func/statistic.php?siteid="+_V['siteid']+"&uid="+_V['user_id']+"&destid=0&groupid=0&type=20&mode=1&source=0&desc="+desc+"&from=sysMsgList&rnd="+new Date().getTime();
		$$C.script(siteurl,"utf-8");
	}
    if(IMToolBar&&IMToolBar.currentToolbarMode==2){
    	IMToolBar.closeMessagebox();
    }
}
function fIM_onPresenceReceiveSysMessage(msgtype,strMsg){
    var _M = strMsg, _Index = _M.indexOf('ntalker://'), _JSON;
    var _V = Ntalker.variable;
    if( _Index == -1 ){
    }else{
        try{
            _Message = _M.substring(0, _Index);
            if(_M.substr(_Index+10).length>0){
            	_JSON = $$J.parseJSON(_M.substr(_Index+10));
            }else{
            	var str='{"id":"","name":"","iconurl":"","opentype":"","activitytype":"","activityid":"","activityname":"","activityicon":"","profileurl":"","chatid":"","srcuid":"","msgtime":""}';
            	_JSON = $$J.parseJSON(str);
            }
            _Message = _Message ? _Message : _JSON.name;
            if(typeof(msgtype)!="string")msgtype=_JSON.msgtype;
            switch(msgtype)
            {
                case "nquan":
                    IMToolBar.addSystemMessage(_JSON.id, _JSON.name, _Message, 0, _JSON.iconurl, '', 'alert', '','','nquan');
                    break;
                case "group":
                    break;
                case "notify":
                case "confirm":
                case "feed":
                case "request":
				    if(_JSON.opentype=="nquan"&&msgtype!="feed"){
				    	var desc="msgid_is_"+_JSON.msgid;
						var siteurl=Ntalker.Config['services'] + "/func/statistic.php?siteid="+_V['siteid']+"&uid="+_V['user_id']+"&destid=0&groupid="+(_JSON.id?_JSON.id:"")+"&type=13&mode=2&source=0&desc="+desc+"&from=sysMsgList&rnd="+new Date().getTime();
						$$C.script(siteurl,"utf-8");
					}
                	IMToolBar.addMessageBox(_JSON.id?_JSON.id:"",_JSON.name?_JSON.name:"",_Message?_Message:"",_JSON.opentype?_JSON.opentype:"", _JSON.iconurl?_JSON.iconurl:"",msgtype?msgtype:"",_JSON.activitytype?_JSON.activitytype:"",_JSON.activityid?_JSON.activityid:"",_JSON.activityname?_JSON.activityname:"",_JSON.activityicon?_JSON.activityicon:"",_JSON.profileurl?_JSON.profileurl:"",_JSON.chatid?_JSON.chatid:"",_JSON.isRead?_JSON.isRead:false,_JSON.msgid?_JSON.msgid:'',_JSON.srcuid?_JSON.srcuid:"",_JSON.msgtime?_JSON.msgtime:(Date.parse(new Date())/1000) );
                	break;
            }
        }catch(e){}
    }
}
function fIM_updateUserHead(uid, src, intStatus, chatType){
    setTimeout(function(){
        var miniWin = IMToolBar.get(uid, chatType || 'chat');
        if(miniWin) miniWin.updateUserHead(src, intStatus);
    }, 50);
}
function fIM_updateUserStatus(statusValue, message){
    setTimeout(function(){
        if(statusValue>0 && statusValue<=4){
            im_openHistoryChatWindow();
        }
    }, 50);
}
function fIM_updateUserNumber(onlineUser, totalUser){
    setTimeout(function(){
        if(IMToolBar && IMToolBar.updateUserNumber){
            IMToolBar.updateUserNumber(onlineUser, totalUser);
        }
        if( (Ntalker.Config['isPopupWindow']==1 || Ntalker.variable['siteid'] == 'ntalkerpreview') && Ntalker.temp['OpenBuddyListWindow'] != true){
            Ntalker.temp['OpenBuddyListWindow'] = true;
            setTimeout(function(){
            	im_openBuddyListWindow(true);
        	}, 800);
        }
    }, 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]);
        }
        $$O("impresenceflash").runJSFunction("fIM_openPopupChatWindow", im_sendOpenChatWindowList, -1);
    }
    fIM_CloseIMWindow();
    im_chat_window_manager.closeAll();
    if(IMToolBar && IMToolBar.hidden) IMToolBar.hidden();
}
function fIM_visibleToolBar(){ 
    if(IMToolBar && IMToolBar.visible){
    	IMToolBar.visible();
    }
}
function fIM_openPopupChatWindow(arrWin, OpenType){ 
    if(Ntalker.Config.isPopupWindow==0) return;
    setTimeout(function(){
        var l = arrWin.length;
        for(var i=0; i<l; i++){
            im_openWebchatInPage(arrWin[i][0], arrWin[i][1], arrWin[i][2], OpenType, arrWin[i][3]);
        }
    }, 50);
}
function fIM_disconnects(){
    var impresenceflash = $$O('impresenceflash');
    if(impresenceflash && impresenceflash.runJSFunction){
        impresenceflash.runJSFunction("fIM_disconnect");
    }
}
function fIM_disconnect(){
    var impresenceflash = $$O('impresenceflash');
    if(impresenceflash && impresenceflash.disconnect){
        impresenceflash.disconnect();
    }
}
function im_onGetFlashServer(servers, resulttype){
	if( resulttype==5 ){
		Ntalker.Config.IMXMLURL = 'http://' + servers;
	}
}
function im_openHistoryChatWindow(){
    var _V = Ntalker.variable;
    if(_V['openHistoryWindow']) return;
    	_V['openHistoryWindow'] = true;
    if(IMToolBar){
        if(IMToolBar.loadMessageBox){
        	IMToolBar.loadMessageBox();
        }else if( IMToolBar.loadSystemMessage ){
        	IMToolBar.loadSystemMessage();
        }
    }
    var k = Ntalker['unKey'] + _V['user_id'];
    var cookieValue = NtUtil.getCookie(k);
    NtUtil.delCookie(k);
    if(!cookieValue) return;
    var curid = 0,curtype = "chat";
    cookieValue = cookieValue.replace(/{/g, "").split("}");
    for(var k in cookieValue){
        if(!cookieValue[k]) continue; 
        if(IMToolBar && IMToolBar.onMaximize && IMToolBar._Pattern==1){
            IMToolBar.onMaximize();
        }
        chatWindow = $$S.toArray(cookieValue[k]);
        if(typeof(chatWindow)=='undefined'|| !chatWindow) continue; 
        im_openWebchatWindow(chatWindow["uid"], chatWindow["nick"], null, -1, chatWindow["type"]);
        _V['onlineChat'] -= 1;
        if(chatWindow["current"]=="default"){
            curid = chatWindow["uid"];
            curtype = chatWindow["type"];
        }
    }
    if(im_chat_window_manager && Ntalker.Config.layout!='cascade'){
    	if( Ntalker.variable['siteid'] == 'ntalkerpreview' ){
        	im_chat_window_manager.OnTBFocusWindow(curid, curtype);
        }else{
        	im_chat_window_manager.OnTBFocusWindow(0);
    	}
    }
}
function im_onUnload(){
    var _V = Ntalker.variable;
    var _presenceFlashGoUrl = Ntalker.temp.presenceFlashGoUrl;
    var chatWins = im_chat_window_manager._chatWndsArray;
    var cookieValue = "";
    if(_V['user_id'] && im_chat_window_manager && chatWins.length>0 && Ntalker.Config.isPopupWindow==0 ){
        for(var i=0; i<chatWins.length; i++){
            if(/^(group|chat|room|nquan)$/.test(chatWins[i]._chatType) && chatWins[i]._isFlashLoadSuccess){
                cookieValue += "{uid:" + chatWins[i]._destuid+";nick:"+chatWins[i]._destnick+";type:"+chatWins[i]._chatType+";current:"+chatWins[i]._curWindMode+";}";
            }
        }
        if(cookieValue){
            NtUtil.setCookie(Ntalker['unKey']+_V['user_id'], cookieValue, 1000*3600*1);
        }
    }
    if(IMToolBar){
        if( IMToolBar.saveMessageBox ){
        	IMToolBar.saveMessageBox();
        }else if( IMToolBar.saveSystemMessage ){
        	IMToolBar.saveSystemMessage();
        }
    }
    if(_presenceFlashGoUrl) $$C.script(_presenceFlashGoUrl);
    if(im_chat_window_manager) im_chat_window_manager.closeAll();
    if(im_myIMWindow) im_myIMWindow.close();
    var flashobj = $$O('impresenceflash');
    if(flashobj){
        if(flashobj.closePresence) flashobj.closePresence();
        NtUtil.disposeFlashObj(flashobj);
        flashobj.parentNode.removeChild(flashobj);
    }
}
function startGetMyIMStatus(imStatusUrl){
    var _V = Ntalker.variable;
	if(imStatusUrl && _V['user_id'])
    	$$C.script(imStatusUrl+"?query=onlinenum&sitid="+_V['siteid']+"&uid="+_V['user_id']+"&imsid="+_V['imsid']);
}
function im_runPresenceStart() {
    $$E.addEvent(window, "unload", im_onUnload);
    wdkApplication = new WDK_IM_PACK.Application();
    wdkApplication.init();
    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 = NtUtil.$$(" div", $$O("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.countMessageBox){
    	IMToolBar.countMessageBox("im",null,true);
    }
}
function im_myMenu(array){
	Ntalker.variable.myApp = array;
	return;
}
function im_openBuddyWindow(type){
	index = 0;
	switch(type){
		case "buddylist":index=0;break;
		case "onlinelist":index=1;break;
		case "grouplist":index=2;break;
		default:index=0;break;
	}	
    Ntalker.Config.IMtabIndex = index;
	if(im_myIMWindow&&IMToolBar&&IMToolBar.onShowBuddylist){
		IMToolBar.onShowBuddylist(null,index);
	}else{
			setTimeout(function(){im_openBuddyWindow(type);},3000);
	}
} 
function im_conncetChatRoom(roomid, roomname)
{
    if( !roomid || !roomname || Ntalker.room.exec) return;
    var presenceFlash = $$O("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 = $$O("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]);
        }
    }
}
function fIM_onWebchatReceiveChatMsg(destuid, destnick, message, chatType, chatid){
    chatType = /^(group|room|nquan)$/.test(chatType) ? chatType : 'chat';
    if(promptwindow){
        promptwindow.startPrompt(destnick, message, true);
        if(typeof(im_chat_window_manager) != "undefined"){
            var chatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
            if(chatWindow) chatWindow.onReceiveMessage(message);
        }
    }
}
function fIM_onWebchatReceiveEvent(destuid, destnick, eventname, eventcontent){
    if(promptwindow) promptwindow.startPrompt(destnick, eventcontent, true);
    var chatType = "chat";
    if(eventname=="DestOpenWindow" && IMToolBar){
        var miniWindow = IMToolBar.getMiniWindow(destuid, chatType);
        miniWindow.onReceiveMiniMessage(eventcontent);
    }
}
function fIM_OnFlashFocus(){
    if(promptwindow) promptwindow.handleFocus();
}
function fIM_OnFlashBlur(){
    if(promptwindow) promptwindow.handleBlur();
}
var PromptWindow = function(){
    this.isfocus = false;
    this.isprompting = false;
    this.timerID = null;
    this.promptMsg = null;
    this.promptMsg2 = null;
    this.originTitle = document.title;
    this.counter = 0;
    this.autostop = true; 
};
PromptWindow.prototype.init = function(){
    var self = this;
    function _handleFocus(e){
        self.handleFocus(e);
    }
    function _handleBlur(e){
        self.handleBlur(e);
    }
    if($$B.ie){
        document.attachEvent("onfocusin", _handleFocus);
        document.attachEvent("onfocusout", _handleBlur);
    }
    $$E.addEvent(window, 'focus', _handleFocus);
    $$E.addEvent(window, 'blur', _handleBlur);
};
PromptWindow.prototype.dispose = function(){
};
PromptWindow.prototype.handleFocus = function(e){
    this.isfocus = true;
    var presenceFlash = $$O("impresenceflash");
    if(presenceFlash && presenceFlash.setPageFocus){
        try{
        	presenceFlash.setPageFocus(true);
        }catch(e){}
    }
    if(this.autostop)
        this.stopPrompt();
};
PromptWindow.prototype.handleBlur = function(e){
    var newvar = 1;
    this.isfocus = false;
    var presenceFlash = $$O("impresenceflash");
    if(presenceFlash && presenceFlash.setPageFocus){
        try{
            presenceFlash.setPageFocus(false);
        }catch(e){}
    }
};
PromptWindow.prototype.startPrompt = function(destnick, proMsg, autostop){
    if(this.isprompting || this.isfocus)
        return;
    if(proMsg && proMsg.length>0){
        this.promptMsg = sprintf(NtLang['promptTitle'], $$S.cut(destnick, 5, true), proMsg, this.originTitle);
        this.promptMsg2 = "";
        var l = $$S.len(destnick)>=10 ? 5 : Math.ceil($$S.len(destnick)/2);
        for(var i=0; i<l; i++){
          this.promptMsg2+=NtLang.zhBlank;
        }
        this.promptMsg2 = sprintf(NtLang['promptTitle'], this.promptMsg2, proMsg, this.originTitle);
    }
    var impresenceflash = document.getElementById('impresenceflash');
    if(impresenceflash && impresenceflash.playNotifySound){
        impresenceflash.playNotifySound();
    }
    if(autostop!=null)
        this.autostop = autostop;
    var self = this;
    var _changeWindowTitle = function(){ self.changeWindowTitle(); };
    this.timerID = setInterval(_changeWindowTitle, 800);
    this.isprompting = true;
};
PromptWindow.prototype.changeWindowTitle = function(){
    this.counter++;
    if(this.counter%2==0)
       document.title = this.promptMsg2;
    else
       document.title = this.promptMsg;
    try{
        if(top!=self){
            if(this.counter%2==0)
                top.document.title = this.promptMsg2;
            else
                top.document.title = this.promptMsg;
        }
    }catch(e){}
};
PromptWindow.prototype.stopPrompt = function(){
    if(!this.isprompting)
        return;
    window.clearInterval(this.timerID);
    this.timerID = null;
    this.counter = 0;
    document.title = this.originTitle;
    this.isprompting = false;
    try{
        if(top!=self) top.document.title = this.originTitle;
    }catch(e){}
};
if(typeof(promptwindow)=="undefined" || !promptwindow){
    promptwindow = new PromptWindow();
    promptwindow.init();
}
function im_openWebchat(myuid, myname, mysid, siteid, destuid, destname, chatid, userparam, isPopup, imScriptPath, sourcePath, userinfo){
    if(!myuid || myuid.length<=0 ){
	        alert("\u60A8\u5C1A\u672A\u767B\u5F55\uFF0C\u8BF7\u767B\u5F55\u540E\u518D\u4F7F\u7528\u5728\u7EBF\u804A\u5929\u529F\u80FD\uFF01");
	        return null;
	    }
        if(typeof(chatid)=="undefined")
	        var chatid = null;
	    var chatWidth  = 514;
	    var chatHeight = 534;
	    var cus        = Ntalker.Config.customparams;
	    if(typeof(userparam)=="undefined")
	        var userparam = null;
	    var popupwindowURL = imScriptPath + "/chatwindow.html";
	    var _popupwinURL = "";
	    if(typeof(popupwindowURL)!="undefined" && popupwindowURL){
	        _popupwinURL = popupwindowURL;
	        if(myuid)     _popupwinURL += "?u="+encodeURIComponent(myuid);
	        if(myname)    _popupwinURL += "&n="+encodeURIComponent(myname);
	        if(mysid)     _popupwinURL += "&s="+encodeURIComponent(mysid);
	        if(siteid)    _popupwinURL += "&t="+encodeURIComponent(siteid);
	        if(destuid)   _popupwinURL += "&d="+encodeURIComponent(destuid);
	        if(destname)  _popupwinURL += "&dn="+encodeURIComponent(destname);
	        if(chatid)    _popupwinURL += "&c="+encodeURIComponent(chatid);
	        if(userparam) _popupwinURL += "&p="+encodeURIComponent(userparam);
	        _popupwinURL += "&r="+Ntalker.variable.scriptPath;
	        _popupwinURL += "&su="+Ntalker.Config.services;
	        _popupwinURL += "&sp="+(cus.simple||0);
	        _popupwinURL += "&av="+(cus.avroom||0);
	        _popupwinURL += "&w=1&m=1";
	        _popupwinURL += "&k="+(Ntalker.variable.skin ? encodeURIComponent(Ntalker.variable.skin) : encodeURIComponent("hue=0"));
	        _popupwinURL += "&f="+encodeURIComponent(window.location.host);
	        _popupwinURL += "&l="+(Ntalker.Config.chatlogo ? Ntalker.Config.chatlogo : "");
	        _popupwinURL += "&ad="+(cus.ad || 1);
	        _popupwinURL += "&info="+userinfo;
	    }
	    popupWindow = window.open( _popupwinURL, "imwebchat_"+destuid, "width="+chatWidth+",height="+chatHeight+",toolbar=no,directories=no,menubar=no,status=no,location=no,scrollbars=no,resizable=no" );
	    return popupWindow;
}
function im_openBuddyList(myuid, myname, mysid, siteid, userparam, isPopup, imScriptPath, sourcePath){
    if (typeof(im_openwindow_inbuddylist)=='undefined'){
        if(!Ntalker.variable.user_id || Ntalker.variable.user_id.length<=0){
            alert("\u60A8\u5C1A\u672A\u767B\u5F55\uFF0C\u8BF7\u767B\u5F55\u540E\u518D\u4F7F\u7528\u5728\u7EBF\u804A\u5929\u529F\u80FD\uFF01");
            return null;
        }
    }
    var IMWidth  = 304;
    var IMHeight = 534;
    if(typeof(userparam)=="undefined")
        var userparam = null;
    var _popupwinURL = "";
    var cust = Ntalker.Config.customparams;
    var popupwindowURL = imScriptPath + "/buddylistwindow.html";
    if(typeof(popupwindowURL)!="undefined" && popupwindowURL){
        _popupwinURL = popupwindowURL;
        if(myuid)     _popupwinURL += "?u="+encodeURIComponent(myuid);
        if(myname)    _popupwinURL += "&n="+encodeURIComponent(myname);
        if(mysid)     _popupwinURL += "&s="+encodeURIComponent(mysid);
        if(siteid)    _popupwinURL += "&t="+encodeURIComponent(siteid);
        if(userparam) _popupwinURL += "&p="+encodeURIComponent(userparam);
        _popupwinURL += "&r="+Ntalker.variable.scriptPath;
        _popupwinURL += "&su="+Ntalker.Config.services;
        _popupwinURL += "&g="+((cust.enablegroup ? "1" : "0")+(cust.enableroom?"1":"0"));
        _popupwinURL += "&b="+cust.introbuddy;
        _popupwinURL += "&o="+cust.onlinelist;
        _popupwinURL += "&h="+cust.head;
        _popupwinURL += "&se="+cust.search;
        _popupwinURL += "&il="+cust.imagelist;
        _popupwinURL += "&w=1&m=1&i=0";
        _popupwinURL += "&k="+(Ntalker.variable.skin ? encodeURIComponent(Ntalker.variable.skin) : encodeURIComponent("hue=0"));
        _popupwinURL += "&f="+encodeURIComponent(window.location.host);
        _popupwinURL += "&l="+(Ntalker.Config.buddylistlogo ? Ntalker.Config.buddylistlogo : "");
        _popupwinURL += "&ad="+(cust.ad || 1);
    }
    var popupWindow = window.open( _popupwinURL, "imbuddylist_"+myuid, "width="+IMWidth+",height="+IMHeight+",toolbar=no,directories=no,menubar=no,status=no,location=no,scrollbars=no,resizable=no" );
    return popupWindow;
}
function fIM_OpenPostThreadWindow(str){
	var url="http://www.ntalker.com/postthread/?"+str;
	var width  = window.screen.width  - 5;
    var height = window.screen.height - 50;
	var _Ht = [];
	_Ht.push('<html>');
	_Ht.push(    '<head>');
	_Ht.push(        '<title>\u53d1\u5e16</title>');
	_Ht.push(    '</head>');
	_Ht.push(    '<body style="margin:0;padding:0;">');
	_Ht.push(        '<iframe src="'+url+'" style="border:0;height:'+height+';width:'+width+'">');
	_Ht.push(		'</iframe>');
	_Ht.push(    '</body>');
	_Ht.push('</html>');
	if(str.indexOf("bbs_tiexue")!=-1){
		window.open(url, "", "left=0, top=0, width="+width+",height="+height+",toolbar=no,directories=no,menubar=no,status=no,location=no,scrollbars=yes,resizable=no" );
		return;
	}
    var photoWallWindow = window.open('about:blank', "", "left=0, top=0, width="+width+",height="+height+",toolbar=no,directories=no,menubar=no,status=no,location=no,scrollbars=no,resizable=no" );
    try{
    	var windowContent = photoWallWindow.document || photoWallWindow.contentWindow.document;
	}catch(e){}
	function writeHtml(){
	    windowContent.charset = "utf-8";
	    windowContent.write(_Ht.join(''));
	    windowContent.close();
	    photoWallWindow.focus();
	}
	if( $$B.mozilla ){
		writeHtml();
	}else{
		setTimeout(writeHtml(), 100);
	}
}
function im_popupToolbar(myuid, myname, mysid, siteid, userparam, isPopup, imScriptPath, sourcePath){
    if(!Ntalker.variable.user_id || Ntalker.variable.user_id.length<=0){
        alert("\u60A8\u5C1A\u672A\u767B\u5F55\uFF0C\u8BF7\u767B\u5F55\u540E\u518D\u4F7F\u7528\u5728\u7EBF\u804A\u5929\u529F\u80FD\uFF01");
        return null;
    }
    if(typeof(userparam)=="undefined"){
        var userparam = null;
    }
    var _popupwinURL = "";
    var popupwindowURL = typeof(im_popupwindowURL)!='undefined' ? im_popupwindowURL : Ntalker.variable.scriptPath + "/popupwindow.html";
    if(typeof(popupwindowURL)!="undefined" && popupwindowURL){
        _popupwinURL = popupwindowURL;
        if(myuid)     _popupwinURL += "?myuid="+encodeURIComponent(myuid);
        if(myname)    _popupwinURL += "&myname="+encodeURIComponent(myname);
        if(mysid)     _popupwinURL += "&mysid="+encodeURIComponent(mysid);
        if(siteid)    _popupwinURL += "&siteid="+encodeURIComponent(siteid);
        if(userparam) _popupwinURL += "&userparam="+encodeURIComponent(userparam);
        _popupwinURL += "&skin="+(Ntalker.variable.skin ? encodeURIComponent(Ntalker.variable.skin) : encodeURIComponent("hue=0"));
    }
    var popupWindow = Ntalker.variable.popupWindow;
    if(!popupWindow){
        try{
            var width  = window.screen.width  - 5;
            var height = window.screen.height - 50;
            var popupWindow = window.open( _popupwinURL, "imbuddylist_"+myuid, "left=0, top=0, width="+width+",height="+height+",toolbar=no,directories=no,menubar=no,status=no,location=no,scrollbars=no,resizable=no" );
        }catch(e){
            popupWindow = null;
            return null;
        }
    }
    popupWindow.focus();
    return popupWindow;
}
function im_popupGroupWindow(myuid, myname, mysid, siteid, groupid, groupname, chatid, userparam, isPopup, roomtype, chattype){
    if(!myuid || myuid.length<=0){
         alert("\u60A8\u5C1A\u672A\u767B\u5F55\uFF0C\u8BF7\u767B\u5F55\u540E\u518D\u4F7F\u7528\u5728\u7EBF\u804A\u5929\u529F\u80FD\uFF01");
         return null;
    }
	chattype = /^(group|room|nquan)$/.test(chattype) ? chattype : 'group';
    if(typeof(chatid)=="undefined")
        var chatid = null;
    if(typeof(userparam)=="undefined")
        var userparam = null;
    var _popupGroupURL = "";
    var cus = Ntalker.Config.customparams;
    var im_popupGroupURL = typeof(im_popupGroupURL)!='undefined' ? im_popupGroupURL : Ntalker.variable.scriptPath + "/chatwindow.html";
    if(typeof(im_popupGroupURL)!="undefined" && im_popupGroupURL){
        _popupGroupURL = im_popupGroupURL;
        var custom     = Ntalker.Config.customparams;
        if(myuid)     _popupGroupURL += "?u="+encodeURIComponent(myuid);
        if(myname)    _popupGroupURL += "&n="+encodeURIComponent(myname);
        if(mysid)     _popupGroupURL += "&s="+encodeURIComponent(mysid);
        if(siteid)    _popupGroupURL += "&t="+encodeURIComponent(siteid);
        if(groupid)   _popupGroupURL += "&groupid="+encodeURIComponent(groupid);
        if(groupname) _popupGroupURL += "&groupname="+encodeURIComponent(groupname);
        if(userparam) _popupGroupURL += "&p="+encodeURIComponent(userparam);
        if(chatid)    _popupGroupURL += "&c="+encodeURIComponent(chatid);
        _popupGroupURL += "&r="+Ntalker.variable.scriptPath;
        _popupGroupURL += "&su="+Ntalker.Config.services;
        _popupGroupURL += "&sp="+(cus.simple||0);
        _popupGroupURL += "&av="+(cus.avroom||0);
        _popupGroupURL += "&w=1&m=1";
        _popupGroupURL += "&k="+(Ntalker.variable.skin ? encodeURIComponent(Ntalker.variable.skin) : encodeURIComponent("hue=0"));
        _popupGroupURL += "&f="+encodeURIComponent(window.location.host);
        _popupGroupURL += "&l="+(Ntalker.Config.chatlogo ? Ntalker.Config.chatlogo : "");
        _popupGroupURL += "&rt="+(roomtype?1:0);
        _popupGroupURL += "&ad="+(cus.ad || 1);
        _popupGroupURL += "&tp="+chattype;
    }
    var popupWindow = Ntalker.variable.popupWindow;
    if(!popupWindow){
        try{
            var width  = window.screen.width  - 5;
            var height = window.screen.height - 50;
            var popupWindow = window.open( _popupGroupURL, "", "left=0, top=0, width="+width+",height="+height+",toolbar=no,directories=no,menubar=no,status=no,location=no,scrollbars=no,resizable=no" );
        }catch(e){
            popupWindow = null;
            return null;
        }
    }
    popupWindow.focus();
    return popupWindow;
}
function fIM_OpenChatWindow(destuid, destname, myuid, myname, mysid, siteid, userparam, userinfo, type){
    if(typeof(im_openWebchatInPage)!="undefined"){
    	var chatType = /^(group|room|nquan|chat)$/.test(type) ? type : 'chat';
        im_openWebchatInPage(destuid, destname, null, 1, chatType, 0, userinfo);
        return true;
    }
    else{
        var imScriptPath = Ntalker.variable.scriptPath;
        im_openWebchat(myuid, myname, mysid, siteid, destuid, destname, null, userparam, true, imScriptPath, "", userinfo);
    }
}
function fIM_OpenIMWindow(source){
    if( window.location.pathname.indexOf("chatwindow")!=-1 ){
        var imScriptPath = Ntalker.variable.scriptPath;
        im_openBuddyList(Ntalker.variable.user_id, Ntalker.variable.user_name, Ntalker.variable.user_sid, Ntalker.variable.siteid, Ntalker.variable.userparam, 0, imScriptPath);
    }else if(im_myIMWindow){
    	im_myIMWindow.showWindow(Ntalker.Config.isPopupMode);
    }
    return;
}
function fIM_OnGroupOpenChatWindow(destuid, destname, myuid, myname, mysid, siteid, userparam, chattype){
    if( window.location.pathname.indexOf("chatwindow")!=-1 ){
    	if( destuid.indexOf("guest")!=-1 || myuid.indexOf("guest")!=-1 ){
    		alert("\u8bf7\u767b\u5f55\u540e\u518d\u4f7f\u7528\u4e00\u5bf9\u4e00\u804a\u5929!");
    		return;
    	}
        var imScriptPath = Ntalker.variable.scriptPath;
        im_openWebchat(myuid, myname, mysid, siteid, destuid, destname, null, userparam, 0, imScriptPath);
    }else
        im_openWebchatInPage(destuid, destname, null, 1, 'chat');
}
function fIM_OnGroupListOpenGroupWindow(groupid, groupname, myuid, myname, mysid, siteid, userparam, chattype, befrom){
    chattype = /^(nquan|room|group)$/.test(chattype) ? chattype : 'group';
    im_openWebchatWindow(groupid, groupname, null, 1, chattype);
}
function fIM_openPhotoWallWindow(fileServer, siteId, roomId, selectFileName, viewSource){
	var flashvars, selectURL, swfUrl;
	var width, height, _Ht = [];;
	if( !fileServer ){
		return;
	}
	if( viewSource == 'nquan' && selectFileName ){
		siteId = selectFileName.split("_")[0] || siteId;
	}
	flashvars = 'feed=' + fileServer + '/imageupload.php%3Faction=rss%26siteid='+siteId+'%26roomid='+roomId;
	flashvars += '&style=light&numRows=3&showItemEmbed=false&showReflections=false&showNavArrows=true&showSearch=false&showDescription=false&showEmbed=false&backgroundColor=#000000';
	selectURL = fileServer + '/imageupload.php?action=index&siteid='+siteId+'&roomid='+roomId+'&indexfile=' + selectFileName;
	swfUrl = Ntalker.variable.scriptPath;
	swfUrl += '/fs/cooliris.swf';
	width  = window.screen.width  - 5;
        height = window.screen.height - 50;
	_Ht.push('<html>');
	_Ht.push(    '<head>');
	_Ht.push(        '<title>' + NtLang['viewPhotoTitle'] + '</title>');
	_Ht.push(    '</head>');
	_Ht.push(    '<body style="margin:0;padding:0;">');
	_Ht.push(        '<object id="photoWall" width="100%" height="100%" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">');
    _Ht.push(        '<param name="movie" value="'+swfUrl+'" />');
    _Ht.push(        '<param name="allowFullScreen" value="true" />');
    _Ht.push(        '<param name="allowScriptAccess" value="always" />');
    _Ht.push(        '<param name="flashvars" value="'+flashvars+'" />');
    _Ht.push(        '<embed id="photoWall" src="'+swfUrl+'" flashvars="'+flashvars+'" width="100%" height="100%" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always"></embed>');
	_Ht.push(        '</object>');
	_Ht.push(        '<script type="text/javascript">');
	_Ht.push(            'setTimeout(function(){document.getElementById("photoWall").style.display = "block";}, 100);');
	_Ht.push(        '</script>');
	if( selectFileName ){
		_Ht.push(    '<script type="text/javascript" src="' + selectURL + '"></script>');
	}
	_Ht.push(    '</body>');
	_Ht.push('</html>');
    var photoWallWindow = window.open('about:blank', "", "left=0, top=0, width="+width+",height="+height+",toolbar=no,directories=no,menubar=no,status=no,location=no,scrollbars=no,resizable=no" );
    try{
    	var windowContent = photoWallWindow.document || photoWallWindow.contentWindow.document;
	}catch(e){}
	function writeHtml(){
	    windowContent.charset = "utf-8";
	    windowContent.write(_Ht.join(''));
	    windowContent.close();
	    photoWallWindow.focus();
	}
	if( $$B.mozilla ){
		writeHtml();
	}else{
		setTimeout(writeHtml(), 100);
	}
}
var __debug__scrolltimerID = null;
function debug(info){
	var _debug = parseInt(NtUtil.getCookie("__debug") || 0);
	if( !_debug ){
		return;
	}
	var execCommandTimer = Math.floor(new Date().getTime()) - parseInt(NtExecCommandTimer);
	if( !$$O('debugSpan') ){
		var _Ht = [];
		_Ht.push('<div id="debugDiv" style="background:#000000;position:absolute;left:0px;top:0px;height:320px;width:420px;z-index:99999">');
		_Ht.push('<div id="debug_head" style="text-align:right;color:#fff;height:20px;background:#ccc;" >');
		_Ht.push('<span style="cursor:pointer;display:block;background:#eee;float:right;height:20px;width:20px;margin-left:10px;text-align:center;" id="btnClose">x</span>');
		_Ht.push('<span style="cursor:pointer;display:block;background:#eee;float:right;height:20px;width:40px;margin-left:10px;text-align:center;" id="btnClear">clear</span>');
		_Ht.push('<span style="cursor:pointer;display:block;background:#eee;float:right;height:20px;width:20px;margin-left:10px;text-align:center;" id="btnRight">&gt;</span>');
		_Ht.push('<span style="cursor:pointer;display:block;background:#eee;float:right;height:20px;width:20px;margin-left:10px;text-align:center;" id="btnLeft">&lt;</span>');
		_Ht.push('</div>');
		_Ht.push('<div id="debugSpan" style="color:#00FF00;height:300px;width:420px;overflow-y:scroll;text-align:left;opacity:0.7;filter:alpha(opacity=70);"></div>');
		_Ht.push('</div>');
		$$D.insert(document.body, _Ht.join("\n"));
		function __debugScroll(){
			clearTimeout(__debug__scrolltimerID);
    		__debug__scrolltimerID = setTimeout(function(){
				var debugDivTop = document.documentElement.scrollTop;
			    if ($$O('debugDiv').offsetParent == document.body && $$B.StrictMode) {
		            debugDivTop = debugDivTop - $$O('debugDiv').offsetParent.offsetTop - $$O('debugDiv').offsetParent.clientTop;
		        }
			    $$D.animate($$O('debugDiv'), {top:debugDivTop}, 'fast', 'easeInOutQuint');
			},400);
		}
		$$E.addEvent(window, 'scroll', __debugScroll);
		$$E.addEvent($$O('btnLeft'), 'click', function(e){
			$$D.css($$O('debugDiv'), "right", 'auto');
			$$D.css($$O('debugDiv'), "left", '0px');
		});
		$$E.addEvent($$O('btnRight'), 'click', function(e){
			$$D.css($$O('debugDiv'), "left", 'auto');
			$$D.css($$O('debugDiv'), "right", '0px');
		});
		$$E.addEvent($$O('btnClear'), 'click', function(e){
			$$O('debugSpan').innerHTML = '';
		});
		$$E.addEvent($$O('btnClose'), 'click', function(e){
			$$E.removeEvent(window, 'scroll', __debugScroll);
			NtUtil.setCookie("__debug", 0);
			$$O('debugDiv').parentNode.removeChild($$O('debugDiv'));
		});
	}
	$$O('debugSpan').innerHTML += info + ' - ' + execCommandTimer + "<br />";
	$$O('debugSpan').scrollTop = $$O('debugSpan').scrollHeight;
	NtExecCommandTimer =  Math.floor(new Date().getTime());
}
var IFrame_applicationId = [];
function createIFrame(frameID, webChatID)
{
    IFrame_applicationId[frameID] = frameID;
    var parentID = $$O(webChatID) || document.getElementsByTagName("body")[0];
    if( $$O(frameID) )
        return false;
    var newDiv = document.createElement("DIV");
    newDiv.id = frameID;
    newDiv.style.position = 'absolute';
    newDiv.style.backgroundColor = '#FFFFFF';
    newDiv.style.border = '0px';
    newDiv.style.overflow = 'auto';
    newDiv.style.display = 'none';
    if(parentID) parentID.appendChild(newDiv);
    window.onerror = function(){return true;};
    return true;
}
function moveIFrame(frameID, iframeID, x, y, w, h, objectID)
{
    try{
        var frameRef = document.getElementById(frameID); 
        var swfObject = document.getElementById(objectID); 
        frameRef.style.left = x + swfObject.offsetLeft + 'px';  
        frameRef.style.top = y + swfObject.offsetTop + 'px'; 
        frameRef.style.width = w + 'px'; 
        frameRef.style.height = h + 'px'; 
        var iFrameRef = document.getElementById(iframeID); 
        iFrameRef.width = w;
        iFrameRef.height = h;
        var loadRef = document.getElementById(iframeID + "Loading");
        if( loadRef ){
        	loadRef.style.width = w + 'px';
        	loadRef.style.height = h + 'px';
        	loadRef.style.backgroundPosition = (w-32)/2 + 'px ' + (h-32)/2 + 'px';
    	}
    }catch(e){}
}
function hideIFrame(frameID, iframeID)
{
    var iframeRef = document.getElementById(iframeID);
    var iframeDoc;
    if (iframeRef.contentWindow) {
        iframeDoc = iframeRef.contentWindow.document;
    } else if (iframeRef.contentDocument) {
        iframeDoc = iframeRef.contentDocument;
    } else if (iframeRef.document) {
        iframeDoc = iframeRef.document;
    }
    if (iframeDoc) {
        iframeDoc.body.style.display = 'none';
    }
    if ($$O(frameID)) {
        $$O(frameID).style.display = 'none';
    }
}
function showIFrame(frameID, iframeID)
{
    var iframeRef = document.getElementById(iframeID);
    if ($$O(frameID)) {
        $$O(frameID).style.display='block';
    }
    var iframeDoc;
    if (iframeRef.contentWindow) {
        iframeDoc = iframeRef.contentWindow.document;
    } else if (iframeRef.contentDocument) {
        iframeDoc = iframeRef.contentDocument;
    } else if (iframeRef.document) {
        iframeDoc = iframeRef.document;
    }
    if (iframeDoc) {
        iframeDoc.body.style.display='block';
    }
}
function hideDiv(frameID)
{
    if ($$O(frameID)) {
        $$O(frameID).style.display='none';
    }
}
function showDiv(frameID)
{
    if ($$O(frameID)) {
        $$O(frameID).style.display = 'block';
    }
}
function loadIFrame(frameID, iframeID, url, embedID, frameType){
    var frame= $$O(frameID);
    var _C = Ntalker.Config;
	var loadId = iframeID + "Loading";
    if ( !frame ) 
        return;
	var math = /\w+\.(swf|aspx|asp|jsp|php|htm|html|shtml)/ig.exec(url);
	var src, _Ht = [], iframe;
	if( $$B.ie6&&frameType=='video' ){
		src = 'about:blank';
		_Ht.push("<iframe id='" + iframeID + "' src='"+src+"' name='"+iframeID+"' onLoad='"+embedID+"."+frameID+"_load();' frameborder='0' scrolling='no'></iframe>");
    	iframe = $$D.insert(frame, _Ht.join(''));
    	var iFrameContent = iframe.contentWindow.document;
        iFrameContent.designMode = 'On';
        iFrameContent.contentEditable = true;
        iFrameContent.open();
        var _ht = [];
        _ht.push('<html>');
        _ht.push(    '<head>');
        _ht.push(    '</head>');
        _ht.push(    '<body marginwidth="0" marginheight="0">');
       	_ht.push(        '<embed height="100%" width="100%" name="plugin" src="' + url + '" type="application/x-shockwave-flash">');
        _ht.push(    '</body>');
        _ht.push('</html>');
        iFrameContent.write(_ht.join(''));
        iFrameContent.close();
        iFrameContent.designMode = 'Off';
        iFrameContent.contentEditable = false;
	}else if( frameType=='video' ){
		src = url;
		_Ht.push("<iframe id='" + iframeID + "' src='"+src+"' name='"+iframeID+"' onLoad='"+embedID+"."+frameID+"_load();' frameborder='0' scrolling='no'></iframe>");
    	iframe = $$D.insert(frame, _Ht.join(''));
	}else{
		src = url;
		_Ht.push('<div id="' + loadId + '" style="display:none;background:url(' + _C['publicDIR'] + '/loading.gif) no-repeat center #FAFAFA;"></div>');
    	_Ht.push("<iframe id='" + iframeID + "' style='display:block;' src='"+src+"' name='"+iframeID+"' onLoad='"+embedID+"."+frameID+"_load();' frameborder='0' scrolling='no'></iframe>");
    	iframe = $$D.insert(frame, _Ht.join(''));
	}
}
function reloadIFrame(frameID, iframeID, url, embedID){
	var frame= $$O(frameID);
	var loadId = iframeID + "Loading";
    if ( !frame ) 
        return;
    var math = /\w+\.(swf|aspx|asp|jsp|php|htm|html|shtml)/ig.exec(url);
    if( $$B.ie6&&math&&math[1]=='swf' ){
    	return;
    }
    $$O(iframeID).src = url;
    $$D.css($$O(iframeID), 'display', 'none');
    $$D.css($$O(loadId),   'display', 'block');
    $$C.ready($$O(iframeID), function(){
		$$D.css($$O(loadId),   'display', 'none');
		$$D.css($$O(iframeID), 'display', 'block');
	});
}
function loadDivContent(frameID, iframeID, content)
{
    if ($$O(frameID)) {
        $$O(frameID).innerHTML = "<div id='"+iframeID+"' frameborder='0'>"+content+"</div>";
    }
}
function callIFrameFunction(iframeID, functionName, args)
{
    var iframeRef=document.getElementById(iframeID);
    var iframeDoc;
    if (iframeRef.contentDocument) {
        iframeDoc = iframeRef.contentDocument;
    } else if (iframeRef.contentWindow) {
        iframeDoc = iframeRef.contentWindow.document;
    } else if (iframeRef.document) {
        iframeDoc = iframeRef.document;
    }
    if (iframeDoc.wrappedJSObject != undefined) {
        iframeDoc = iframeDoc.wrappedJSObject;
    }
    return iframeDoc[functionName](args);
}
function removeIFrame(frameID)
{
    var iFrameDiv = document.getElementById(frameID);
    if ( $$B.ie6 ){
        iframe = $$O('iframe_' + frameID);
        var iFrameContent = iframe.contentWindow.document;
        iFrameContent.designMode = 'On';
        iFrameContent.contentEditable = true;
        iFrameContent.open();
        iFrameContent.write('');
        iFrameContent.close();
        iFrameContent.designMode = 'Off';
        iFrameContent.contentEditable = false;
        iFrameDiv.parentNode.removeChild(iFrameDiv);
    }
    else{
        iFrameDiv.parentNode.removeChild(iFrameDiv);
    }
}
function bringIFrameToFront(frameID)
{
    var frameRef=document.getElementById(frameID);
    if (oldFrame!=frameRef) {
        if (oldFrame) {
            oldFrame.style.zIndex="99";
        }
        frameRef.style.zIndex="100";
        oldFrame = frameRef;
    }
}
function askForEmbedObjectId(randomString)
{
    var embeds = document.getElementsByTagName('embed');
    for (var i = 0; i < embeds.length; i++) {
        try {
            var isTheGoodOne = embeds[i].checkObjectId(embeds[i].getAttribute('id'),randomString);
            if(isTheGoodOne) {
                return embeds[i].getAttribute('id');
            }
        }catch(e){}
    }
    var objects = document.getElementsByTagName('object');
    for(i = 0; i < objects.length; i++) {
        try{
            var isTheGoodOne = objects[i].checkObjectId(objects[i].getAttribute('id'),randomString);
            if(isTheGoodOne) {
                return objects[i].getAttribute('id');
            }
        } catch(e) {}
    }
    return null;
}
function getBrowserMeasuredWidth(objectID)
{
    return document.getElementById(objectID).offsetWidth;
}
function setupResizeEventListener(frameId)
{
    if(!frameId) return;
    var resizeTimeout = []; 
    $$E.addEvent(window, "resize", function(e, frameId){
        window.clearTimeout(resizeTimeout[frameId]);
        resizeTimeout[frameId] = window.setTimeout(function(){
             eval("document.getElementById('" + IFrame_applicationId[frameId] + "')." + frameId + "_resize();");
         }, 10);
    });
}
function printIFrame(iframeID)
{
    try
    {
        if (navigator.appName.indexOf('Microsoft') != -1)
        {
            document[iframeID].focus();
            document[iframeID].print();
        }
        else
        {
            for (var i=0; i < window.frames.length; i++)
            {
                if (window.frames[i].name == iframeID)
                {
                    window.frames[i].focus();
                    window.frames[i].print();
                }
            }
        }
    }
    catch(e){}
}
function historyBack(iframeID)
{
    frames[iframeID].history.go(-1);
}
function historyForward(iframeID)
{
    frames[iframeID].history.go(1);
}
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}}X.removeChild(aa);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;
