﻿var st = new Date().getTime();
var execTimer = [];
var Ntalker = {
	execIMOnlineStatus:false,
    execRunPresence:false,
    loadedConfig:false,
    unKey:"imNt_uLoad_ctWind",
    ctKEY:"imNt_uRdsys_",
    gpKEY:"imNt_uRdgroup_",
    tipKEY:"imNt_stip", 
    openHotKEY:"imNt_hot",
    guestUserNoKEY:"imNt_guestNo",
    tbModelKEY:"imNt_Session_tbMode",
    tbClosedKEY:"imNt_Session_tbClosed"
};
Ntalker.version = {
    imxml_version  : "",
    software_name  : "",
    presence_flash : "2.9.6",
    buddylist_flash: "2.9.7",
    webchat_flash  : "2.9.7",
    group_flash    : "2.9.91",
    nquan_flash    : "2.9.95",
    hot_flash      : "2.9.6"
};
Ntalker.variable = {
    openHistoryWindow: false,
    presenceConnet : false,
    ExMsg : [],
    onlineChat     : 10,
    OnFocusWinParam : [],
    OnBlurWinParam  : [],
    autoFocus      : true,
    offlineChatList: [],
    siteid         : null,
    user_id        : null,
    user_name      : null,
    user_sid       : null,
    userparam      : null,
    popupWindow    : null,
    webchatURL     : "",
    scriptPath     : "",
    serverPath     : "",
    buddylistTag   : null
};
Ntalker.temp = {
    versionValue:false,
    statusValue :false,
    menuTimer            : -1,
    flashServers         : null,
    userStatusServer     : null,
    presenceFlashGoUrl   : null,
    buddylistFlashGoUrl  : null,
    notify_id            : 0,
    userSpanArray        : null,
    resetwintop          : new Array(),
    imSid                : null
};
Ntalker.Config = {
	services             :"http://" + "config.ntalker.com/res",    logo                 :"",
    toolbarlogo          :"",
    buddylistlogo        :"",
    chatlogo             :"",
    nquanlogo            :"",
    grouplogo            :"",
    chatroomlogo         :"",
    startlogo            :"",
    groupstartlogo       :"",
    copyrighturl         :"",
    copyrighttip         :"",
    chatWidth            :384,
    chatHeight           :414,
    groupWidth           :460,
    groupHeight          :532,
    hotWidth             :510,
    hotHeight            :520,
    IMWidth              :248,
    IMHeight             :532,
    IMtabIndex           : 0,
    isPopupWindow        : 0,
    isPopupMode          : false,
    customtoolbarButtons : [],     
    customparams         : [],
    layout               : 'toolbar'
};
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 wdkApplication = null;
var im_myIMWindow = null;
var IMToolBar = null;
var im_flashGoUrl = null;
var Ntalker_DOMContentLoaded = false;
var $$O, $$B, $$A, $$F, $$D, $$E, $$S, $$C;
(function(){
var O, B, A, F, D, E, S, C;
O = function(id){return document.getElementById(id)||null;};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)
	};
	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;
			}
		}
	};
	function each( object, callback ) {
		if ( object.length == undefined ){
			for ( var name in object )
				if ( callback( object[name], name, object ) === false )
					break;
		} else {
			for ( var i = 0, len = object.length; i < len; i++ ) {
				if (i in object) { 
					if ( callback( object[i], i, object ) === false )
						break; 
				}
			}
		}
	};
	each({
			forEach: function( object, callback, thisp ){
				each.call( thisp, object, function(){ callback.apply(thisp, arguments); } );
			},
			map: function( object, callback, thisp ){
				var ret = [];
				each.call( thisp, object, function(){ ret.push(callback.apply(thisp, arguments)); });
				return ret;
			},
			filter: function( object, callback, thisp ){
				var ret = [];
				each.call( thisp, object, function(item){
						callback.apply(thisp, arguments) && ret.push(item);
					});
				return ret;
			},
			every: function( object, callback, thisp ){
				var ret = true;
				each.call( thisp, object, function(){
						if ( !callback.apply(thisp, arguments) ){ ret = false; return false; };
					});
				return ret;
			},
			some: function( object, callback, thisp ){
				var ret = false;
				each.call( thisp, object, function(){
						if ( callback.apply(thisp, arguments) ){ ret = true; return false; };
					});
				return ret;
			}
		}, function(method, name){
			ret[name] = function( object, callback, thisp ){
				if (object[name]) {
					return object[name]( callback, thisp );
				} else {
					return method( object, callback, thisp );
				}
			}
		});
	return ret;
}();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=[], el;
		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' )
	            el = doc.createTextNode(arrt.text);
	        else{
		        el = doc.createElement(tagName);
		        for(var k in arrt){
		            switch(k){
		                case "className": el.className = arrt[k];break;
		                case "style": el.style.cssText = arrt[k];break;
		                default : el.setAttribute(k, arrt[k]);
		            }
		        }
	        }
	        par.appendChild(el);
	        return el;
	    }
	},
	insert: function(el, h, where) {
	    where = where ? where.toLowerCase() : 'afterbegin';
	    if (el.insertAdjacentHTML) {
	        switch (where) {
	            case "beforebegin":el.insertAdjacentHTML('BeforeBegin', h);return el.previousSibling;
	            case "afterbegin": el.insertAdjacentHTML('AfterBegin', h);return el.firstChild;	            case "afterend":el.insertAdjacentHTML('AfterEnd', h); return el.nextSibling;
	            default :el.insertAdjacentHTML('BeforeEnd', h);return el.lastChild;
	        }
	        throw 'Illegal insertion point -> "' + where + '"';
	    }
	    var range = el.ownerDocument.createRange();
	    var frag;
	    switch (where) {
	    case "beforebegin":range.setStartBefore(el);frag = range.createContextualFragment(h);el.parentNode.insertBefore(frag, el);return el.previousSibling;
	    case "afterbegin":
	        if (el.firstChild) {
	            range.setStartBefore(el.firstChild);frag = range.createContextualFragment(h);el.insertBefore(frag, el.firstChild);return el.firstChild;
	        } else {
	            el.innerHTML = h;return el.firstChild;
	        }
	    case "beforeend":
	        if (el.lastChild) {
	            range.setStartAfter(el.lastChild);frag = range.createContextualFragment(h);el.appendChild(frag);return el.lastChild;
	        } else {
	            el.innerHTML = h;return el.lastChild;
	        }
	    case "afterend":range.setStartAfter(el);frag = range.createContextualFragment(h);el.parentNode.insertBefore(frag, el.nextSibling);return el.nextSibling;
	    }
	    throw 'Illegal insertion point -> "' + where + '"';
	},
	getScrollTop: function(node){
		var doc = node ? node.ownerDocument : document;
		return doc.documentElement.scrollTop || doc.body.scrollTop;
	},
	getScrollLeft: function(node){
		var doc = node ? node.ownerDocument : document;
		return doc.documentElement.scrollLeft || doc.body.scrollLeft || 0;
	},
	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(node){
		var d  = {x:0,y:0,w:0,h:0,left:0,top:0};
		var doc = document.body || document.documentElement;
		d.w = node.offsetWidth  || (node.style && node.style.pixelWidth) || 0;
	    d.h = node.offsetHeight || (node.style && node.style.pixelHeight) || 0;
		if ( !node.getBoundingClientRect || B.ie8 ) {
			var n = node;
			while (n) { d.left += n.offsetLeft; d.top += n.offsetTop; n = n.offsetParent; };        	d.left += parseInt(D.css(D.Doc,"borderLeftWidth")) || 0;
        	d.top  += parseInt(D.css(D.Doc,"borderTopWidth")) || 0;
			d.right = d.left + node.offsetWidth; d.bottom = d.top + node.offsetHeight;
		} else {
			var rect = node.getBoundingClientRect();
			d.left = d.right = this.getScrollLeft(node); d.top = d.bottom = this.getScrollTop(node);
			d.left += rect.left; d.right += rect.right;
			d.top += rect.top; d.bottom += rect.bottom;
		};
		return d;
	},
	clientRect: function(node){
		node = typeof node=='string' ? O(node) : node;
		var rect = this.rect(node), sLeft = this.getScrollLeft(node), sTop = this.getScrollTop(node);
		rect.left -= sLeft; rect.right -= sLeft;
		rect.top -= sTop; rect.bottom -= sTop;
		rect.x = rect.left; rect.y = rect.top;
		return rect;
	},
	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];
				if (name == "opacity" && B.ie) {
					elem.style.filter = (elem.currentStyle.filter || "").replace( /alpha\([^)]*\)/, "" ) + "alpha(opacity=" + value * 100 + ")";
				} else if (name == "float") {
					elem.style[ B.ie ? "styleFloat" : "cssFloat" ] = value;
				} else {
					elem.style[ S.camelize( name ) ] = value;
				}
			};
		}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) ) {
						var opacity = parseFloat(RegExp.$1);
						return opacity ? opacity / 100 : 0;
					}
					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( el, className ){
        if( !this.include(el, className) ){
            el.className = el.className.split(/\s+/).join(" ") + " " + className;
        }
    },
    removeClass: function( el, className ){
        if(el && el.className.length>0 ){
            var reg = new RegExp( "\\b" + className + "\\b", "gi" );
            el.className = el.className.replace( reg, "" );
        }
    },
    replaceClass:function( el, oldclassName, className){
        this.addClass(el, className);
        this.removeClass(el, oldclassName);
    },
    include: function( el, className ){
        if(!el || !el.className ){
            return false;
        }else{
            var reg = new RegExp( "\\b" + className + "\\b", "gi" );
            return reg.test(el.className);
        }
    },
    windowRect: function(obj){
    	var d = {x: 0,y: 0,w: 0,h: 0};
        d.x = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
        d.y = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
        d.w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0;
        d.h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0;
        return d;
    },
    filter: function(Nodes){		var _N = [], i=0;
		for(i=0; i<Nodes.length; i++)
			Nodes[i].tagName && _N.push(Nodes[i]);
		return _N;
    }
};
D.Doc = document.documentElement || document.body;E = (function(){
	var addEvent, removeEvent, guid = 1;
	if ( window.addEventListener ) {
		addEvent = function( element, type, handler ){
			element.addEventListener(type, handler, false);
		};
		removeEvent = function( element, type, handler ){
			element.removeEventListener(type, handler, false);
		};
	} else {
		addEvent = function( element, type, handler ){
			element.attachEvent( "on"+type, handler);
		};
		removeEvent = function( element, type, handler ){
			element.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.forEach(targets, function(target){
			var attr = target.getAttribute(arrt);
			if( attr && attr.indexOf(src) > -1 ) return true;
		});
		return false;
	},
	script: function(src, charset, c){
	    if( (c && this.include(src)) || typeof(src)=='undefined' ) return;
	    var script  = window.document.createElement("script");
	    script.type     = "text/javascript";
	    script.language = "javascript";
	    script.src      = src;
	    if(charset) script.charset  = charset;
	    document.getElementsByTagName("HEAD")[0].appendChild(script);
	    return script;
	},
	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){    
        	try{
            	styleElement.styleSheet.cssText += cssCode;
            }catch(e){
            	styleElement.appendChild(doc.createTextNode(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;
    }
};if (B.ie6) {
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(e) {}
};
$$O = O; $$B = B; $$A = A; $$F = F; $$D = D; $$E = E; $$S = S; $$C = C;
})();var IMAnimate = {
    animate:function(el, attr, par, func, curValue, JsAttribute){
        par.start = $$S.isDefined(par.start) ? par.start : 100;
        par.end   = $$S.isDefined(par.end) ? par.end : 0;
        par.step  = $$S.isDefined(par.step) ? par.step : 10;
        par.attach= $$S.isDefined(par.attach) ? par.attach : 0;
        par.buffer= par.buffer ? true  : false;
        curValue = $$S.isDefined(curValue)&&curValue!=null ? curValue : par.start;       
        if(par.buffer){
            var max = par.start>par.end ? par.start : par.end; par.step  = Math.ceil((max-curValue)/5.9999999999999);
        }
        if(attr=="opacity") IMAnimate._alpha(el, curValue);
        else if(JsAttribute){eval("document.getElementById('"+el.id+"')." + attr + "=" + curValue + "");}
        else $$D.css(el, attr, curValue+par.attach );
        curValue += par.step;
        if( (par.start>par.end && curValue<par.end) || (par.start<par.end && curValue>par.end) || par.step==0 ){if(func!=undefined)func();return true;}
        return IMAnimate.timer(function(){IMAnimate.animate(el, attr, par, func, curValue, JsAttribute);}, 50);
    },
    _alpha:function(el, curOpa){
        try{
        	el.style.display    = 'block';
            el.style.MozOpacity = ''+curOpa/100;
            el.style.opacity    = ''+curOpa/100;
            el.style.filter     = "alpha(opacity:"+curOpa+")";
        }catch(e){}
    },
    timer:function(func,timer){return window.setTimeout(func, timer);}
};NtUtil = {};
NtUtil.cookie = {};
NtUtil.cookie.save = function(a, f, d, c) {
    if (typeof d != "number" && !(d instanceof Date)) {
        d = (365 * 24 * 60 * 60 * 1000)
    }
    var b;
    if (d instanceof Date) {
        b = d
    } else {
        if (d >= 0) {
            b = new Date();
            b.setTime(b.getTime() + d)
        }
    }
    var e = b ? "expires=" + b.toGMTString() + "; ": "";
    var k = a + "=" + encodeURIComponent(f) + "; ";
    var g = /([^\.]+(\.com(\.cn)?|\.net(\.cn)?|\.org(\.cn)?|\.cn))$/i.exec(document.domain);
	g = c || (g ? g[0] : document.domain);
    var c = "domain=" + g + "; ";
    var h = "path=/; ";
    document.cookie = k + e + c + h
};
NtUtil.cookie.erase = function(b, a) {
    NtUtil.cookie.save(b, "", new Date(0), a)
};
NtUtil.cookie.load = 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.$ = function(El){
    if(typeof(El)=='object' || !El) return El;
    return(document.getElementById ? document.getElementById(El)
            : document.all ? document.all[El]
            : null);
};
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(el, childNodetagName){
    if(!el) return;
    var Nodes = childNodetagName ? el.getElementsByTagName(childNodetagName) : el.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("el."+id+"=null");
                else{el.removeAttribute(id);}
            }
        }
        this.removeChildNodes(Nodes[i], childNodetagName);
        el.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)
        return;
    for(var id in flashObj){
        if(typeof(flashObj[id]) == "function"){
            if($$B.ie)                eval("flashObj."+id+"=null");
            else
                flashObj.removeAttribute(id);
        }
    }
};
NtUtil.onlyOne = function(key, dtyp, timer){
    if(NtUtil.cookie.load(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.cookie.save(key, "1"); return;
        }
        var t = d.getTime() - od.getTime();
        NtUtil.cookie.save(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;
}
NtUtil.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();
        })();
    }
};
function NtLoadScript(src, charset, check, callback) {
    if(check && $$C.include(src))
        return;
    var script = document.createElement("script");
    if(script.addEventListener){
        script.addEventListener("load", callback, false);
        script.addEventListener("error", callback,false);
    }else if(script.attachEvent)
        script.attachEvent("onreadystatechange",  function(){
        	var target = window.event.srcElement;  
		    if(target.readyState == "loaded")  
		    	callback.call(target); 
        });
    script.src      = src;
    script.type     = "text/javascript";
    script.language = "javascript";
    if(charset) script.charset  = charset;
    document.getElementsByTagName("head")[0].appendChild(script);  
}  (function(){
	var scripts = window.document.getElementsByTagName("script");
    var script  = scripts[scripts.length - 1];
    var src  = script.getAttribute("src");
	var mts  = /(.*?)\/imfunction(_utf8)?\.js/gi.exec(src);
	var path = (mts && mts[1]) || 'http://download.ntalker.com/res';
	Ntalker.variable.scriptPath = path;
    if(!Ntalker.variable.image_dir){
        Ntalker.variable.image_dir = path+"/images/";
        Ntalker.variable.style_dir = path+"/images/";
    }
    $$C.link(path + "/images/public.css");
    $$C.script(path + "/openimwindow_v2.js", "utf-8", true);
    $$D.create('div', {id:"im_popMenuid", style:"left:-100px;top:-100px;"}, null, 'afterbegin');
    execTimer.push('InitializationTimer:' + parseInt(new Date().getTime() - st) );
})();
function sprintf() {
    if (!arguments || arguments.length < 1 || !RegExp || !arguments[0]) {
        return
    }
    var b = arguments[0], l = arguments.length;
    for (var a = 1;a < l;a++) {
        b = b.replace(new RegExp("%" + a, "g"), arguments[a] || "")
    }
    return b
}
function 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 im_getIMOnlineStatus(siteid, webchaturl){
	if(!Ntalker.sTimer){
		Ntalker.sTimer = true;
		st = new Date().getTime();
	}
	var _cfg       = Ntalker.Config;
    var _var       = Ntalker.variable;
    createGestFlashConnet(siteid, _cfg.isPopupMode);
    if(Ntalker.loadedConfig==false && !$$C.include(_cfg.services + "/configjs/config_"+siteid+".js") ){
        NtLoadScript(_cfg.services + "/configjs/config_"+siteid+".js", "utf-8", true, function(){
            if(typeof(Ntalker_Config) == 'undefined'){
                im_getIMOnlineStatus(_var.siteid);
            }
        });
        Ntalker.loadedConfig = true;
        return;
    }
    Ntalker.execIMOnlineStatus = true;
    if(typeof(Ntalker_Config) != 'undefined'){
        if(Ntalker_Config["style_dir"]) _var.style_dir += Ntalker_Config["style_dir"]; else _var.style_dir += siteid+"/";
        if(Ntalker_Config["image_dir"]) _var.image_dir += Ntalker_Config["image_dir"]; else _var.image_dir += siteid+"/";        switch(Ntalker_Config["skin"])
        {
        	case "ntalker_skin1":_var.skin = "hue=0";break;
        	case "ntalker_skin2":_var.skin = "hue=92.92";break;
        	case "ntalker_skin3":_var.skin = "hue=2.31,saturation=0.61,hue=101.19,saturation=0.75";break;
        	case "ntalker_skin4":_var.skin = "hue=-155.31";break;
        	case "ntalker_skin5":_var.skin = "hue=-79.78,light=9.26";break;
        	case "ntalker_skin6":_var.skin = "hue=149.96";break;
        	case "ntalker_skin7":_var.skin = "saturation=0";break;
        	case "ntalker_skin8":_var.skin = "hue=-22.5,light=10.61";break;
        	case "ntalker_skin9":_var.skin = "hue=67.5";break;
        	case "ntalker_skin10":_var.skin = "hue=-114.81";break;
        	case "ntalker_skin11":_var.skin = "hue=0";break;
        	case "ntalker_skin12":_var.skin = "hue=180";break;
        	case "ntalker_skin13":_var.skin = "saturation=0";break;
        	default:_var.skin = Ntalker_Config["skin"];break;
        }
        if(Ntalker_Config["Chat"]){
            _cfg.chatWidth        = Ntalker_Config["Chat"].width;
            _cfg.chatHeight       = Ntalker_Config["Chat"].height;
        }
        if(Ntalker_Config["groupChat"]){
            _cfg.groupWidth       = Ntalker_Config["groupChat"].width;
            _cfg.groupHeight      = Ntalker_Config["groupChat"].height;
        }
        if(Ntalker_Config["hotChat"]){
            _cfg.hotWidth         = Ntalker_Config["hotChat"].width;
            _cfg.hotHeight        = Ntalker_Config["hotChat"].height;
        }
        if(Ntalker_Config["IM"]){
            _cfg.IMWidth          = Ntalker_Config["IM"].width;
            if(Ntalker_Config["IM"].height != "auto")
            	_cfg.IMHeight     = Ntalker_Config["IM"].height;
        }
        _cfg.logo          = Ntalker_Config['logo'].publiclogo   ? _var.scriptPath + "/images/" + Ntalker_Config['logo'].publiclogo : _var.image_dir + "logo.gif";        _cfg.buddylistlogo = Ntalker_Config['logo'].buddylistlogo? siteid+"/logo_big.png"   : Ntalker_Config["image_dir"] + "logo_big.png";
        _cfg.chatlogo      = Ntalker_Config['logo'].chatlogo     ? siteid+"/logo_small.png" : Ntalker_Config["image_dir"] + "logo_big.png";
        _cfg.nquanlogo     = Ntalker_Config['logo'].nquanlogo    ? siteid+"/nquanlogo.png"  : "/nquanlogo.png";
        _cfg.grouplogo     = Ntalker_Config['logo'].grouplogo    ? siteid+"/nquanlogo.png"  : "/nquanlogo.png";
        _cfg.chatroomlogo  = Ntalker_Config['logo'].chatroomlogo ? siteid+"/nquanlogo.png"  : "/nquanlogo.png";        _cfg.startlogo     = Ntalker_Config['logo'].startlogo    ? _cfg.services + "/images/" + siteid+"/":_var.image_dir;
        _cfg.groupstartlogo= _var.scriptPath + "/images/group.png";
        if( Ntalker_Config['config'] )
            _cfg.customparams     = Ntalker_Config['config'];
        if( Ntalker_Config['customButtons'] ){
            _cfg.customtoolbarButtons = Ntalker_Config['customButtons'];
        }        var _Btns = _cfg.customtoolbarButtons;
        for(var k in _Btns){
            if(typeof(k)=="string" && _Btns[k] && _Btns[k].style){
                _Btns[k].style = sprintf(_Btns[k].style, _cfg.services + "/images/");
            }
            if(typeof(k)=="string" && _Btns[k] && _Btns[k].url){
                _Btns[k].url = _Btns[k].url.replace("{$destid}",   _var.user_id);
                _Btns[k].url = _Btns[k].url.replace("{$username}", _var.user_name);                _Btns[k].url = sprintf(_Btns[k].url, _var.user_id, _var.user_name);
            }
        }
    }
    else{
        _var.skin       = "hue=0";
        _var.style_dir += "ntalker_skin1/";
        _var.image_dir += "ntalker_skin1/";
        _cfg.buddylistlogo= "ntalker_skin1/logo_big.png";
        _cfg.chatlogo     = "ntalker_skin1/logo_small.png";
        _cfg.startlogo    = _var.image_dir;
        _cfg.logo         = _var.image_dir + "logo.gif";
        _cfg.grouplogo    = _var.scriptPath + "/images/nquanlogo.png";
        _cfg.chatroomlogo = _var.scriptPath + "/images/nquanlogo.png";
        _cfg.nquanlogo    = _var.scriptPath + "/images/nquanlogo.png";
        _cfg.customparams = {enblebuddyentry: 1,floatpos:"right",intact:0,show_popmenu:1,show_tooltip:1,hiddenmode:0,createblank:0,enablegroup:1,enableroom:1,enablehot:1,sys_enableguest:1,introbuddy:1,onlinelist:1,chataddbuddy:1,enablepopup:1,disablegrouptip:1,head:1,ad:0,search:1,imagelist:1,simple:0,avroom:0,roomtype:0,entrytype:"toolbar",enabletitle:1,enabletextad:1,playsound:1,enablepicturewall:1,enabletoolsbar:1,simpleinput:0};
    }
    execTimer.push('toLoadConfigTimer:' + parseInt(new Date().getTime() - st) );
    if(Ntalker.Config.customparams["hiddenmode"]) return;
    if(!Ntalker.execRunPresence){
        im_runPresence(_var.userparam, _var.siteid, _var.user_id, _var.user_name, _var.user_sid, '', '', Ntalker.Config.customparams)
    }
    StartGetGroupEntry();
}
function im_runPresence(userparam, siteid, userid, username, sessionid, flashserver, webchatpageurl, customParams) {
    var _cfg   = Ntalker.Config;
    var _var   = Ntalker.variable;
	if(!username || username=='')
		username = "name";
	var _CP = Ntalker.Config.customparams;
    _var.userparam = userparam;
    _var.siteid    = siteid;
    _var.user_id   = userid;
    _var.user_name = username;
    _var.user_sid  = sessionid;
    if(customParams && typeof customParams =="object"){
        for(var k in customParams){
            if(typeof(_CP[k]) != "undefined")
                _CP[k] = customParams[k];
        }
    }else if(customParams && typeof customParams == "string"){
        var aParam = customParams.split(";")
        for(var i in aParam){
            if(aParam[i] && aParam[i].indexOf(":")){
                var a = aParam[i].split(":");
                k = a[0];v = a[1];
                if(typeof(_CP[k]) != "undefined")
                    _CP[k] = v=="false" ? false : v=="true"  ? true : v;
            }
        }
    }
    _CP.show_tooltip = NtUtil.onlyOne(Ntalker.tipKEY, "d", 1)&&_CP.show_tooltip ? true : false;
    if(typeof(userparam)=='undefined' || !userparam || userparam.length==0){
        userparam = username;
    }	if(!Ntalker.execIMOnlineStatus) return;
	Ntalker.execRunPresence = true;
	if( (userid=='0' || userid==0 || userid=='' || sessionid=='') ){
    	if( Ntalker.Config.customparams.sys_enableguest != 1 ){    		return;
    	}else{
	    	var userNO = NtUtil.cookie.load(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     = gLang.t_userIDHead   + userNO;
				username   = gLang.t_userNameHead + userNO;
			}else{
				userid     = gLang.t_userIDHead   + userNO;
				username   = gLang.t_userNameHead + userNO;
			}
			sessionid      = gLang.t_sessionID;			NtUtil.cookie.save(Ntalker.guestUserNoKEY, userNO, 1000*3600*24*7);
			_var.user_id   = userid;
		    _var.user_name = username;
		    _var.user_sid  = sessionid;
		}
	}
	im_changeFlashConnet();
    im_runPresenceStart();
    if(_var.user_sid && _var.user_name && _var.user_id){
    	$$C.link(_var['image_dir'] + "toolbar_"+Ntalker.Config.customparams['floatpos']+".css");
    	var tst = new Date().getTime();
    	var span = NtUtil.$('ntalker');
    	if (span && _CP.entrytype=='cascade'){
    		_cfg.layout = 'cascade';
    		_CP.entrytype='cascade';
    		IMToolBar = new NtTopTbar();
    		IMToolBar.init(span);
    	}else{
    		_cfg.layout = 'toolbar';
    		_CP.entrytype='toolbar';
    		IMToolBar = new NtBottomTbar();
    		IMToolBar.init();
    		setTimeout(function(){
    			if(Ntalker.variable.scriptPath.indexOf('download.wdknet.com') == -1 ){
    				return;
    			}else{					var groupdisplay = $$D.css($$O("ico_group"), "display");
				    groupspan = groupdisplay=="none"||!$$O("ico_group") ? "ico_zoom" : "ico_group";
				    IMTipManager.addIMTip(groupspan, [{user:'系统管理员',msg:'6月10日后老版本接口将停用.'}], {step:5, wait:0, nextwait:3000},{roomid:'', roomname:'',usercount:''});
			    }
    		}, 2000)
    	}
    	execTimer.push('CreateToolBarTimer:' + parseInt(new Date().getTime() - tst) );
    }
}function im_connectIM(siteid, userid, username, sessionid, userparam, customParams, param1, param2){
    im_getIMOnlineStatus(siteid);
    im_runPresence(userparam, siteid, userid, username, sessionid, "", "", customParams);    
}
var connetSt;
function createGestFlashConnet(siteid, popup){
    if(Ntalker.temp.createFlash)
        return;
    connetSt = new Date().getTime();
    Ntalker.temp.createFlash = true;
    Ntalker.variable.siteid = siteid;
    var flashvars = "siteid=" + siteid + "&ispopup=" + (popup ? "1" : "0") + "&rurl=" + Ntalker.variable.scriptPath + '&surl=' + Ntalker.Config.services;
    var flashurl  = Ntalker.variable.scriptPath+"/fs/impresence.swf?version="+Ntalker.variable.presence_flash;
    if(window.location.pathname.indexOf("window.html")>0 ) flashurl += "?rnd="+new Date().getTime();
    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+'" /> ');
        flashnode.push('</object>');
        flashnode.push('</div>');
        var flashnodehtml = flashnode.join('');
        if(window.location.pathname.indexOf("window.html")>0 || Ntalker_DOMContentLoaded )
            document.body.insertAdjacentHTML('BeforeEnd', flashnodehtml);
        else
            document.write(flashnodehtml);
    }
    else{
        if(window.location.pathname.indexOf("window.html")>0 || Ntalker_DOMContentLoaded ){
            $$D.create('div', {id:"wdk_mini_state",style:"display:none;"});
            var divDOM = $$D.create('div', {id:"im_presence_div", style:"position:absolute;z-index:9996; top: -200px;"});
            var flashDOM = document.createElement("embed");
            flashDOM.src               = flashurl;
            flashDOM.id                = "impresenceflash";
            flashDOM.width             = 1;
            flashDOM.height            = 1;
            flashDOM.setAttribute("type",              "application/x-shockwave-flash");
            flashDOM.setAttribute("pluginspage",       "http://www.macromedia.com/go/getflashplayer");
            flashDOM.setAttribute("flashvars",         flashvars);
            flashDOM.setAttribute("allowscriptaccess", "always");
            divDOM.appendChild(flashDOM);
        }else{
        	var 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);
            flashnode.push('" id="impresenceflash" width="1" height="1" flashvars="'+flashvars+'" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> ');
            flashnode.push('   </embed>');
            flashnode.push('</div>');
            var flashnodehtml = flashnode.join('');
            document.write(flashnodehtml);
        }
    }
}
function fIM_presenceFlashReady(){
	execTimer.push('PresenceCreateToConnet:' + parseInt(new Date().getTime() - connetSt) );
    IMAnimate.timer(function(){
        im_changeFlashConnet();
        StartGetUsersStatus();
        if(Ntalker.Config.isPopupWindow == 1){
            IM_initPopuWindowScript();
        }
        if(NtUtil.$("impresenceflash") && NtUtil.$("impresenceflash").setPageFocus){
            NtUtil.$("impresenceflash").setPageFocus(true);
        }
    }, 50);
    return true;
}function fIM_setPackageVersion(packageVersion, bbsType, hotserver){	return;
    Ntalker.version.imxml_version = packageVersion;
    Ntalker.version.software_name = bbsType;
    if(!hotserver) return;
    Ntalker.temp.hotserver = hotserver + "?query=havasitehot&siteid="+Ntalker.variable.siteid+"&uid="+Ntalker.variable.user_id+"&sid="+Ntalker.variable.user_sid;
    if(Ntalker.Config.customparams['enablehot'] && !NtUtil.lt(packageVersion,"2.0.0")){
        Ntalker.temp.versionValue = true;
        var serverkey = Ntalker.openHotKEY+Ntalker.variable.user_id+"_ck";
        var checkKey  = NtUtil.cookie.load(serverkey);
        if((checkKey=="" || checkKey==null || typeof(checkKey)=="undefined") && Ntalker.temp.statusValue){
            NtUtil.cookie.save(serverkey, "1", 1000*3600*2);
            $$C.script(Ntalker.temp.hotserver);
        }else if(checkKey=="1"){
            sIM_checkCreateHot("1", "N");
        }
    }
}
function fIM_hotStatSet(){
	return;
}
function sIM_checkCreateHot(createHot, isService){
    isService = isService=="N" ? false : true;
    if( IMToolBar && IMToolBar.createHotButton && createHot=="1" ) {
        IMToolBar.createHotButton();
    }
    if(Ntalker.temp.versionValue && Ntalker.temp.statusValue && createHot=="1" ){
        if(IMToolBar.onShowHost && NtUtil.onlyOne(Ntalker.openHotKEY+Ntalker.variable.user_id, "d", 1)){
            IMToolBar.onShowHost();
        }
    }
}
function fIM_checkPopupWin(){
    if(Ntalker.Config.isPopupMode){
        NtUtil.$("impresenceflash").runJSFunction("fIM_setPopupMode", true);
    }
    return true;
}
function fIM_setPopupMode(isPopupMode){
    IMAnimate.timer(function(){
        Ntalker.Config.isPopupMode = isPopupMode ? true : false;
        if(Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==0)
            fIM_hiddenToolBar();
        else
            fIM_visibleToolBar();
    },200);
    return true;
}
function im__mouseover(e){
	var event = $$E.fixEvent(e);
	var target= searchTag(event.target, "li");
    $$D.addClass(target, 'hover');
}
function im__mouseout(e){
    var event = $$E.fixEvent(e);
	var target= searchTag(event.target, "li");
    $$D.removeClass(target, 'hover');
}
function im_popMenu(obj, destuid, destnick){
    var _var = Ntalker.variable;
    if(Ntalker.temp.menuTimer>=0){
        clearTimeout(Ntalker.temp.menuTimer);
        Ntalker.temp.menuTimer = -1;
        return;
    }
    var menudiv = NtUtil.$('im_popMenuid');
    if(!menudiv || !obj) return;
    var _Rect   = $$D.clientRect(obj);
    var _winRect= $$D.windowRect();
    menux = _Rect.x + _Rect.w + _winRect.x;
    menuy = _Rect.y + _winRect.y;
    menuStr = '<ul class="popMenuUL">';
    for(i=0; i<gLang.popMenus.length; i++){
		menuStr += '<li>'+gLang.popMenus[i]+'</li>';
	}
	menuStr += '</ul>';
    menudiv.innerHTML   = menuStr;
    var _Items = NtUtil.$$(" li", menudiv), l = _Items.length;
    for(var i = 0; i < l; i++){
        $$E.addEvent(_Items[i], "mouseover", im__mouseover);
        $$E.addEvent(_Items[i], "mouseout", im__mouseout);
    }
    $$E.addEvent(_Items[0], "click", function(){
        var menudiv = NtUtil.$('im_popMenuid');
        menudiv.style.display = 'none';
        Ntalker.temp.menuTimer = -1;
        im_openWebchatWindow(destuid, destnick, null, 1);
    });
    $$E.addEvent(_Items[1], "click", function(){
        var menudiv = NtUtil.$('im_popMenuid');
        menudiv.style.display = 'none';
        Ntalker.temp.menuTimer = -1;
        im_openBuddyListWindow(true);
    });
    menudiv.style.display = 'block';
    menudiv.style.left  = menux+"px";
    menudiv.style.top   = menuy+"px";
    menudiv.onmouseover = im_popMenu;
    menudiv.onmouseout  = im_beginCloseMenu;
}
function im_beginCloseMenu(obj){
    Ntalker.temp.menuTimer = setTimeout(function(){
        var menudiv = NtUtil.$('im_popMenuid');
        menudiv.style.display = 'none';
        Ntalker.temp.menuTimer = -1;
    }, 100);
}
function StartGetUsersStatus(){
	var sst = new Date().getTime();
    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++){
        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 = NtUtil.$("impresenceflash");
    Ntalker.temp.userSpanArray = _arrSpan;
    if( Ntalker.Config.customparams["enblebuddyentry"]){
        if(_presenceFlash && _presenceFlash.requestUserStatus){
            _presenceFlash.requestUserStatus(strUserIDList, _arrSpan.length);
        }
    }
    execTimer.push('SearchUserStatusSpanTimer:' + parseInt(new Date().getTime() - sst) );
}
function StartGetGroupEntry() {
	var enablegroup = Ntalker.Config.customparams['enablegroup'];
    var statusSpans = document.getElementsByTagName("SPAN");
    var imgsrc = Ntalker.Config.groupstartlogo;
    var spanindex = 0, l = statusSpans.length;
    for (i = 0; i < l; i++) {
        statusSpan = statusSpans[i];
        if (statusSpan.className == "wdk_group_chat_span" && statusSpan.id) {
        	var cursorGroupType = statusSpan.getAttribute("ischatroom");
            pos = statusSpan.id.indexOf("wdk_group_");
            if (pos >= 0 && cursorGroupType=="true" ) {
            	var newGroupObj = new Object();
                newGroupObj.groupid   = statusSpan.id.substring(pos + "wdk_group_".length, statusSpan.id.length);
                newGroupObj.groupnick = NtUtil.EncodeSpecialChar(statusSpan.title);
                newGroupObj.roomtype  = 1;
              	im_conncetChatRoom(newGroupObj.groupid, newGroupObj.groupnick);
                var tiptext = sprintf(gLang.m_pgroupTip[0], newGroupObj.groupnick);
                chatLinkStr = "<a  href=\"#\" target=\"_blank\" style=\"display:inline;padding-left:7px; overflow:hidden;\" alt=\"" + tiptext + "\" onClick=\"javascript: im_openWebchatWindow('" + newGroupObj.groupid + "', '" + newGroupObj.groupnick + "', null, 1, 'group', "+newGroupObj.roomtype+"); return false;\">";
                chatLinkStr += "<img name=\"wdk_presence_image\" tip=\"" + tiptext + "\" style=\"left:0px;top:0px;\" id=\"wdk_presence_" + newGroupObj.groupid + "\" border=\"0\" style=\"display:inline;";
                chatLinkStr += "\" src=\"" + imgsrc + "\" title=\"" + tiptext + "\"/></a>";
                statusSpan.innerHTML = chatLinkStr;
            }else if(pos >= 0){
                var newGroupObj = new Object();
                newGroupObj.groupid   = statusSpan.id.substring(pos + "wdk_group_".length, statusSpan.id.length);
                newGroupObj.groupnick = NtUtil.EncodeSpecialChar(statusSpan.title);
                var tiptext = sprintf(gLang.m_pgroupTip[1], newGroupObj.groupnick);
                chatLinkStr = "<a  href=\"#\" target=\"_blank\" style=\"display:inline;padding-left:7px; overflow:hidden;\" alt=\"" + tiptext + "\" onClick=\"javascript: im_openWebchatWindow('" + newGroupObj.groupid + "', '" + newGroupObj.groupnick + "', null, 1, 'group'); return false;\">";
                chatLinkStr += "<img name=\"wdk_presence_image\"";
                if (spanindex == 0) {
                    chatLinkStr += " tip=\"" + tiptext + "\" style=\"left:0px;top:0px;\"";
                    if (Ntalker.Config.customparams["show_tooltip"] ) { chatLinkStr += " onload=\"IMTipManager.addIMTip('wdk_presence_" + newGroupObj.groupid + "', '"+tiptext+"')\" ";}
                }
                chatLinkStr += " id=\"wdk_presence_" + newGroupObj.groupid + "\" border=\"0\" style=\"display:inline;";
                chatLinkStr += "\" src=\"" + imgsrc + "\" title=\"" + tiptext + "\"/></a>";
                statusSpan.innerHTML = chatLinkStr;
                spanindex++;
            }
        }
    }
}
function im_changeFlashConnet(){
    var impresenceflash = NtUtil.$("impresenceflash");
    var _var       = Ntalker.variable;
    if(impresenceflash && !Ntalker.variable.presenceConnet){
        if( impresenceflash.changeFlashConnet){        	try{
            	impresenceflash.changeFlashConnet(_var.siteid, _var.user_id, _var.user_name, _var.user_sid, _var.userparam);
            }catch(e){}
            Ntalker.variable.presenceConnet = true;
        }
    }
}function fIM_onGetUserStatus(responseText){
    var _cfg = Ntalker.Config;
    var _temp= Ntalker.temp;
    if(responseText=="-1" || responseText=="-2" || _cfg.customparams["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 = _cfg.startlogo+"/offline."+($$B.ie6?"gif":"png");
            errsrc = Ntalker.variable.scriptPath + "/images/ntalker_skin1/offline."+($$B.ie6?"gif":"png");
            break;
        case "1":
            imgsrc = _cfg.startlogo+"/online."+($$B.ie6?"gif":"png");
            errsrc = Ntalker.variable.scriptPath + "/images/ntalker_skin1/online."+($$B.ie6?"gif":"png");
            break;
        }
        chatLinkStr =  ' <a  href="javascript:void(0);" style="display:inline;padding:0px;overflow:visible;" alt="' + gLang.m_pageAlt + '"';
		chatLinkStr += 'onClick="javascript: im_openWebchatWindow(\''+_temp.userSpanArray[i].destuid+'\', \''+_temp.userSpanArray[i].destnick+'\', null, 1); return false;" ';
        if(_cfg.customparams["show_popmenu"] && !_cfg.customparams["hiddenmode"])
            chatLinkStr += ' onmouseover="im_popMenu(this,\''+_temp.userSpanArray[i].destuid+'\',\''+_temp.userSpanArray[i].destnick+'\');" onmouseout="im_beginCloseMenu(this);"';
        chatLinkStr += '><img name="wdk_presence_image" style="display:inline;left:0px;top:0px;"';
        if(i==0 && false){
            chatLinkStr += ' tip="' + gLang.buddyentry_tip + '"';
            if(_cfg.customparams["show_tooltip"] && !_cfg.customparams["hiddenmode"])
                chatLinkStr += ' onload="IMTipManager.addIMTip(\'wdk_presence_'+_temp.userSpanArray[i].destuid+'\', \'' + gLang.buddyentry_tip + '\')"';
        }
        chatLinkStr += " id=\"wdk_presence_"+_temp.userSpanArray[i].destuid+"\" border=\"0\" src=\""+imgsrc+"\" onerror=\"this.src='"+errsrc+"';\" />";
        chatLinkStr += "</a>";
        _temp.userSpanArray[i].spanElement.style.border = '';
        _temp.userSpanArray[i].spanElement.innerHTML = chatLinkStr;
    }
}
function im_openWebchatWindow(destuid, destname, chatid, OpenType, chatType, roomtype){
	var cst = new Date().getTime();
	var otype = OpenType===true||OpenType===1 ? 1 : (OpenType===-1 ? -1 : 0);
    chatType = /group|bbshot|nquan/.test(chatType) ? chatType : 'chat';
    if( !Ntalker.variable.user_sid || !Ntalker.variable.user_name ){
    	if( chatType=="group" && roomtype==1 && Ntalker.Config.customparams["sys_enableguest"]){
	    	im_popupGroupWindow(null, null, null, Ntalker.variable.siteid, destuid, destname, null, '', 0, 1);
	    	return;
	    }else{
        	alert(gLang.notLogin);
        	return;
        }
    }
    if( IMToolBar && IMToolBar._disable && chatType!="bbshot"){
        alert(gLang.connectErr);return;
    }
    if(Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==0){
        NtUtil.$("impresenceflash").runJSFunction("fIM_openPopupChatWindow", [[destuid, destname, chatid, chatType, roomtype]], OpenType);
    }else if(IMToolBar && IMToolBar.tbClosed){    	var _var       = Ntalker.variable;
    	im_popupGroupWindow(_var.user_id, _var.user_name, _var.user_sid, _var.siteid, destuid, destname, null, _var.userparam, 0, roomtype);
    }else{
        im_openWebchatInPage(destuid, destname, chatid, otype, chatType, roomtype);
    }
    execTimer.push('OpenChatWindowTimer:' + parseInt(new Date().getTime() - cst) );
}
function im_openWebchatInPage(destuid, destname, chatid, OpenType, chatType, roomtype){
    if(Ntalker.variable.popupWindow){
        if(Ntalker.Config.isPopupWindow==0) return;
    }
    if(destuid==Ntalker.variable.user_id && chatType!="group") return;
    return im_chat_window_manager.addChatWindow(destuid, destname, chatid, true, null, null, OpenType, chatType, roomtype);
}function im_openBuddyListWindow(OpenType, program){
	var c = Ntalker.Config;
    if(!c.isPopupMode || (c.isPopupMode && c.isPopupWindow==1)){
        IMAnimate.timer(function(){
            if(im_myIMWindow){
                im_myIMWindow.showWindow(c.isPopupMode);
                if(c.isPopupWindow && promptwindow && !OpenType)
                    promptwindow.startPrompt(gLang.buddylist_title, gLang.zhBlank, true);
            }else{
                alert(gLang.buddylist_open);
            }
        }, 100);
    }else{
        if(c.isPopupWindow==0 && OpenType){
        	if(program) return;
            NtUtil.$("impresenceflash").runJSFunction("im_openBuddyListWindow", OpenType, true);
        }
    }
    return true;
}
function IMHashtable(){
    this._hash = new Object();  
    this.add = function(key,value){
        if(typeof(key)!="undefined"){
            if(this.contains(key)==false){
                this._hash[key]=typeof(value)=="undefined"?null:value;
                return true;
            }else {
                return false;
            }
        }else {
            return false;
        }
    }
    this.remove = function(key){delete this._hash[key];}
    this.count = function(){var i=0;for(var k in this._hash){i++;} return i;}
    this.items = function(key){return this._hash[key];}
    this.contains  = function(key){ return typeof(this._hash[key])!= "undefined";}
    this.clear = function(){for(var k in this._hash){delete this._hash[k];}}
}var IMTipManager = {
    _arrTips: new IMHashtable(),
    _curTip : null,
    getIMTip: function(key){
        return this._arrTips.items(key);
    },
    addIMTip: function(key, msg, param, room){
    	if(Ntalker.Config.customparams['disablegrouptip']) return;
    	if(!$$A.isArray(msg) || msg.length==0){
    		msg = [{msg:gLang.m_groupTip,user:gLang.m_groupUser}];
    	}
    	var menuDisplay = $$D.css(NtUtil.$$(".ntalkermenu", NtUtil.$("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], gLang.m_expression);    	if(msg[0].msg.indexOf(gLang.m_picture)!=-1)
    		msg[0].msg = gLang.m_picture;
    	if(msg[0].msg.replace(/(^\s*)|(\s*$)/g, "").length==0 || menuDisplay=="block")return;
    	var _curTip = this.getIMTip(key);
        if(_curTip){			if(_curTip.message.length>=3) return;
        	_curTip.add(msg, room);
        	_curTip.show();
        }else{
	        this._curTip = new IMtoolTip(key, param);
	        this._curTip.init(msg, room);
	        this._arrTips.add(key, this._curTip);
        }
    },
    addIMTips:function(els, msg, param){
        var _keys = NtUtil.$$(els);
        for(k in _keys){
            if(!_keys[k].id) _keys[k].id = "imNt_tooltip_" + Math.round(Math.random()*10000);
            this.addIMTip(_keys[k].id, msg, param);
        }
    },
    removeIMTip: function(key){
        this._arrTips.remove(key);
    },
    closeIMTip: function(key){
        var _curTip = this.getIMTip(key);
        if(_curTip)_curTip.Element.parentNode.removeChild(_curTip.Element);
        IMTipManager.removeIMTip(key);
    }
}
var IMtoolTip = function(key, param){
    this.key = key;
    this.id  = "imNt_tooltip_"+key;
    this.message = [];
    this.param = !param ? {step:5, wait:5000, nextwait:5000} : param;
    this.curNum = 0;
    this.Element = null;
    this.parentNode = null;
    this.isshow  = false;
}
_p = IMtoolTip.prototype;
_p.init = function(msg, room){
	if(NtUtil.$(this.id)) return;
	this.add(msg, room);
	var _param = this.param, _key = this.key, _this = this;
	if(_param.wait>0){
		this.parentNode = null;
    	this.Element = $$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");
    	this.Element.innerHTML  = this.getTip();
    }else{
    	if(_key.indexOf("wdk_group_")>-1 )
    		this.parentNode = null;
    	else
    		this.parentNode = NtUtil.$(_key);
    	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("+Ntalker.variable.image_dir+"/imNt_tips_r.gif) no-repeat;"}, this.parentNode, "beforeend");
    	this.Element.innerHTML  = this.toolbarTip(0);
    	if( _key.indexOf("wdk_group_")>-1 ){
    		var usercount = 0;
    		if(this.message.length>0 && this.message[0].usercount)
    		   usercount = parseInt(this.message[0].usercount);
    		if(NtUtil.$(_key)) $$D.insert(NtUtil.$(_key), "<span style=\"font-size:12px;\">("+usercount+")</span>");
    	}
    }
    var _winRect = $$D.windowRect();
    var _icoRect = $$D.clientRect(_key);
    var _tipRect = $$D.clientRect(this.Element);
    if(_param.wait>0 || _key.indexOf("wdk_group_")>-1){
		var _x = _icoRect.x + _icoRect.w/2 - 12;
		var _y = _icoRect.y - _tipRect.h  + _winRect.y;
	    if( _x+_tipRect.w + 10 > _winRect.x+_winRect.w ){
	        var bA = NtUtil.$('bALlOOnT'+_key);
	        if(bA){bA.style.left=""; bA.style.right="4px";}
	        _x = _icoRect.x + _icoRect.w/2 - _tipRect.w + 12;
	        _y = _icoRect.y - _tipRect.h + _winRect.y;
	    }
	    if( _param.wait<=0 ){
	    	this.Element.style.backgroundImage = "url("+Ntalker.variable.image_dir+"/imNt_tips_l.gif)";
	    	_x += 0;
	    	_y -= 10;
	    }
	}else{
		var _y = 0 - _tipRect.h;
		if('cascade'==Ntalker.Config.customparams.entrytype){
			var _x = _icoRect.w/2 - 12;
			this.Element.style.backgroundImage = "url("+Ntalker.variable.image_dir+"/imNt_tips_l.gif)";
		}
		else if( Ntalker.Config.customparams["floatpos"]=="right" ){
			var _x = _icoRect.w/2 + 12 + _icoRect.x;
			if(_x+_tipRect.w>_winRect.x+_winRect.w){
				var _x = 0 - _tipRect.w + _icoRect.w/2 + 8;
				this.Element.style.backgroundImage = "url("+Ntalker.variable.image_dir+"/imNt_tips_r.gif)";
			}else{
				this.Element.style.backgroundImage = "url("+Ntalker.variable.image_dir+"/imNt_tips_l.gif)";
			}
		}else{
			var _x = _icoRect.w/2 - 12;
			this.Element.style.backgroundImage = "url("+Ntalker.variable.image_dir+"/imNt_tips_l.gif)";
		}
	}
    this.Element.style.top  = _y + "px";
    this.Element.style.left = _x + "px";
	IMAnimate.animate(IMTipManager._curTip.Element,"opacity", {start:0,end:100,step:_param.step}, function(){
		_this.isshow = true;
        if(_param.wait>0)
        	IMAnimate.timer(function(){IMTipManager.getIMTip(_key).close();}, _param.wait);
        else
        	IMAnimate.timer(function(){
        	var _curTip = IMTipManager.getIMTip(_key);if(_curTip)_curTip.next(_key, _param.nextwait);}, _param.nextwait);
    });
};
_p.show = function(){
	if(this.isshow) return;
	var _param    = this.param, _key   = this.key, _this = this;
	IMAnimate.animate(IMTipManager._curTip.Element,"opacity", {start:0,end:100,step:_param.step}, function(){
        if(_param.wait>0)
        	IMAnimate.timer(function(){IMTipManager.getIMTip(_key).close();}, _param.wait);
        else
        	IMAnimate.timer(function(){
	        	var _curTip = IMTipManager.getIMTip(_key);
	        	if(_curTip)
	        		_curTip.next(_key, _param.nextwait);
        	}, _param.nextwait);
    });
};
_p.add = function(msg, room){
	var 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;
		this.message.push({msg:m[0].msg,user:m[0].user,roomid:room.roomid,roomname:room.roomname,roomtype:room.roomtype,usercount:room.usercount});
	}catch(e){}
}
_p.close = function(){
	var _param = this.param, _key   = this.key;
	var _curTip = IMTipManager.getIMTip(_key);
	if(!_curTip) return;
	this.curNum = 0;
	this.isshow = false;
    IMAnimate.animate(_curTip.Element,"opacity", {start:100,end:0,step:(0-_param.step)}, function(){    	if(_curTip){    		_curTip.Element.style.display = "none";
    	}
    });
}
_p.next = function(key, wait){
	if(!this.Element) return;
	this.curNum++;
	if( this.curNum >= this.message.length ){
		this.curNum = 0;
		IMTipManager.getIMTip(key).close();
		return;
	}
	this.Element.innerHTML = this.toolbarTip(this.curNum);
	IMAnimate.timer(function(){var _curTip = IMTipManager.getIMTip(key);if(_curTip)_curTip.next(key, wait);}, wait);
}
_p.getTip = function(){
    var url = Ntalker.variable.scriptPath;
    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('+url+'/images/tipleft.png) 0 0 no-repeat;width:6px;"></td>'+
        '        <td style="margin-left:6px;_margin-left:0px;background:url('+url+'/images/tipmid.png) 0 0 repeat-x;height:32px;color:#333;font-size:14px;text-align:center;">' + m + '</td>'+
        '        <td style="background:url('+url+'/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('+url+'/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 = '';
	if( this.message[k].roomname=='' ){
		tipTitle = $$S.cut(this.message[k].user, 12, false)
	}else{
		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), 13, true);
	var _TipHTML   = '<span style="display:block;margin:8px 0 0 25px;color:#016722;">'+tipTitle+'</span>'
				   + '<div id="imNt_tooltip_con" style="display:block;margin:0 0 0 25px;">' + tipContent + '</div>';
    var _msg = this.message[k];
    var _key = this.key;
    this.Element.onclick = function(ev){
    	$$E.fixEvent(ev).stopPropagation();
    	IMTipManager.getIMTip(_key).close();
    	if( !roomid || roomname=='' ){
    		return;
    	}
    	if(IMToolBar && IMToolBar.viewGroupMessage)
    		IMToolBar.viewGroupMessage(null, null, _msg.roomid, _msg.roomname, _msg.roomtype);
    	else{
    		im_openWebchatWindow(_msg.roomid, _msg.roomname, null, 1, 'group', _msg.roomtype);
    	}
    };
    return(_TipHTML ? _TipHTML : null);
}
var NotifyManager = {
    _notifyWnds   : new IMHashtable(),
    _NotifySPAN   : $$D.create('div', {id:"OnlineNotifyGroup"}, null, "afterbegin"),
    _maxNotify    : 3,
    _width        : 215,
    _height       : 130,
    _bottom       : 30,
    init:function(){
    	var _V = Ntalker.variable;
        var __NotifyRepos = function(){
            var list = NotifyManager.showQueue._showList;
            var _winRect = $$D.windowRect();
            for(var k in list._hash){
                if(k && list._hash[k]._curNotifyId){
                  var _notifyWnd = NtUtil.$(list._hash[k]._curNotifyId);
                  if(typeof(_notifyWnd)=="undefined"||!_notifyWnd)
                    continue;
                  var _top   = $$D.css(_notifyWnd, "top");
                  _notifyWnd.style.right  = "10px";
              }
            }
        };
        $$E.addEvent(window, "resize", __NotifyRepos);
        $$E.addEvent(window, "scroll", __NotifyRepos);        var _cssText = [];
        _cssText.push('.nt_notify{color:#fff;z-index:10000;');
        _cssText.push('background: url(' + _V['image_dir'] + '/notifybg.png) no-repeat !important; ');		_cssText.push('_background:url(' + _V['image_dir'] + '/notifybg.gif) no-repeat;');
		_cssText.push('margin:0;padding:0;position:absolute;text-align:left;}');
		_cssText.push('.nt_notify_nquan{color:#fff;z-index:10000;');
        _cssText.push('background: url(' + _V['image_dir'] + '/nquan_notifybg.png) no-repeat !important; ');		_cssText.push('_background:url(' + _V['image_dir'] + '/nquan_notifybg.gif) no-repeat;');
		_cssText.push('margin:0;padding:0;position:absolute;text-align:left;}');
		_cssText.push('.nt_close{line-height:0px;font-size:0px;width:9px;height:9px;background:url(' + _V['image_dir'] + '/icon-close.png) no-repeat; _display:inline-table;display:block;_margin-right:8px;float:right;}');
		$$C.addSheet(_cssText.join(''));
    },
    checkonline:function(destuid, destname, type){
        var _Wnd, type = type? type:"online";;
        for(var k in this.showQueue._showList._hash){
            _Wnd = this.showQueue._showList.items(k);
            if(_Wnd.type=="online" && _Wnd.destuid==destuid && _Wnd.destname==destname) return true;
        }
        for(var k in this._notifyWnds._hash){
            _Wnd = this.get(k);
            if(_Wnd.type=="online" && _Wnd.destuid==destuid && _Wnd.destname==destname) return true;
        }
        return false;
    },
    clearonline:function(type){
        type = type ? type : "online";        for(var k in this._notifyWnds._hash){
            if(this.get(k).type==type) this.remove(k);
        }
    },
    add: function(destuid, destname, message, chatid, headURL, type, BtnType, sendMsg){
        if(this.checkonline(destuid, destname, type)) return;
        Ntalker.temp.notify_id++;
        var notifyWnd     = new Object();
        notifyWnd.destuid = destuid;
        notifyWnd.destname= destname;
        notifyWnd.message = message;
        notifyWnd.chatid  = chatid;
        notifyWnd.logoUrl = headURL;
        notifyWnd.type    = type? type:"online";
        notifyWnd.BtnType = BtnType;
        notifyWnd.sendMsg = sendMsg;
        notifyWnd.userid  = Ntalker.variable.user_id;
        if (!notifyWnd.userid)
            return;
        notifyWnd._curNotifyId  = 'Notify' + Ntalker.temp.notify_id + "TYPE" + notifyWnd.type;
        this._notifyWnds.add(notifyWnd._curNotifyId, notifyWnd);
        this.push();
    },
    remove: function(k){
        this._notifyWnds.remove(k);
    },
    get: function(k){
        return this._notifyWnds.items(k);
    },
    push:function(){
        var _sPush = false;var _aPush = false;
        for(var k in this._notifyWnds._hash){
            var sLen = this.showQueue._showList.count();
            var aLen = this.alertQueue._showList.count();
            var _Wnd = this.get(k);
            if(sLen<this._maxNotify && !this.showQueue._showing && _Wnd.type=="online"){
                _sPush = true;
                this.showQueue.add(k, this.get(k));this.remove(k);
            }
            if(aLen<1 && !this.alertQueue._showing && _Wnd.type=="alert"){
                _aPush = true;
                this.alertQueue.add(k, this.get(k));this.remove(k);
            }
            if(_sPush && _aPush){break;}
        }
    },
    alertQueue:{
        _showList   : new IMHashtable(),
        _showing    : false,
        add: function(key, notifyWnd){
            var alertNotifys = 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['entrytype'] == 'toolbar' ){
               	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:_V['image_dir']+"notify_userhead.png",
            	_errimg = _V['image_dir']+"notify_userhead.png";
            var _openChatWindow = function(){
            	im_openWebchatWindow(notifyWnd.destuid, notifyWnd.destname, notifyWnd.chatid, 1, notifyWnd.chattype);
            	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 1px;margin:10px 10px 0 10px;height:20px;padding-top:5px;_padding-top:0px;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 + '" onerror="this.src=\'' + _errimg + '\'" 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(gLang.tb_minWindow_Session, $$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(' + _V['image_dir'] + '/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(' + _V['image_dir'] + '/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(' + _V['image_dir'] + '/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(el, autoclose){
            this._showing = true;                  NotifyManager.alertQueue._showing = false;
                if(autoclose){
                    IMAnimate.timer(function(){
                        IMAnimate.animate(el,"opacity", {start:100,end:0,step:-10}, function(){
                            if(el.parentNode)el.parentNode.removeChild(el);
                            NotifyManager.alertQueue._showList.remove(el.id);
                            IMAnimate.timer(function(){NotifyManager.push();}, 500);
                        });
                    }, 6000);
                }        },
        close:function(el, btntype,type){
            el = NtUtil.$(el);                if(el.parentNode) el.parentNode.removeChild(el);
                NotifyManager.alertQueue._showList.remove(el.id);
                if(/confirm|request/.test(btntype) || type == 'alert'){
                    Ntalker.Config.customparams.entrytype=='toolbar' && im_chat_window_manager.OnTBFocusWindow(Ntalker.variable.OnFocusWinParam[0], Ntalker.variable.OnFocusWinParam[1]);
                }        }
    },    showQueue:{
        _showList   : new IMHashtable(),
        _showing    : false,
        add: function(key, notifyWnd){
            var _winRect = $$D.windowRect();
            var _top     = _winRect.y + _winRect.h - NotifyManager._bottom;
            var _headURL = notifyWnd.logoUrl?notifyWnd.logoUrl:Ntalker.variable.image_dir+"notify_userhead.png";
            var _errimg  = Ntalker.variable.image_dir+"notify_userhead.png";
            this._showList.add(key, notifyWnd);
            _curElement = $$D.create('div', {id:key,className:"ntalker_notify"}, NotifyManager._NotifySPAN);
            _curElement.style.cssText = "z-index:99999;top:"+_top+"px;right:10px;height:0px;width:"+NotifyManager._width+"px;background:transparent url("+Ntalker.variable.image_dir+"notifybg."+($$B.ie?"gif":"png")+") no-repeat left top;";            var htmls = ["<div style=\"background: url("+Ntalker.Config.logo+") no-repeat 1px 1px; margin:10px 10px 0 10px;height:20px;text-align:right;\"><a href=\"javascript:NotifyManager.showQueue.close('"+key+"');\" class=\"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 src=\""+_headURL+"\" onerror=\"this.src='"+_errimg+"'\" style=\"width:61px;_width:60px;height:61px;_height:60px;border:1px solid #ccc;margin:1px;\" /></div>",
                        "  <div style=\"padding: 10px 5px 0px 0px; float: right; width: 105px; color: #000000; font-size: 14px;font-family:宋体;\">",
                        "    <B>" + $$S.cut(notifyWnd.destname, 5, true) + "</B><br />" + notifyWnd.message + "",
                        "  </div>",
                        "</div>"].join('');
            _curElement.innerHTML = htmls;
            if(NtUtil.$('impresenceflash') && NtUtil.$('impresenceflash').playNotifySound)
                NtUtil.$('impresenceflash').playNotifySound();
            this.animate(_curElement);
        },
        animate:function(el){
        	if(im_myIMWindow){        		if(im_myIMWindow.isShow) return;
        	}
            this._showing = true;
            var _preNodes = [];var _curEl = el;
            while(_curEl.previousSibling){_preNodes.push(_curEl.previousSibling);_curEl = _curEl.previousSibling;}
            for(var k in _preNodes){
                var _top    = $$D.css(_preNodes[k], "top");
                var _newTop = _top - NotifyManager._height;
                IMAnimate.animate(_preNodes[k], "top", {start:_top,end:_newTop,step:-13});
            }
            _top = $$D.css(el, "top");
            IMAnimate.animate(el, "top",{start:_top,end:(_top - NotifyManager._height), step:-13});
            IMAnimate.animate(el, "height",{start:0,end:NotifyManager._height,step:13}, function(){
                NotifyManager.showQueue._showing = false;
                IMAnimate.timer(function(){NotifyManager.push();},500);
                IMAnimate.timer(function(){
                    IMAnimate.animate(el,"opacity", {start:100,end:0,step:-10}, function(){
                        if(el.parentNode)el.parentNode.removeChild(el);
                        NotifyManager.showQueue._showList.remove(el.id);
                        NotifyManager.push();
                    });
                }, 15000);
            });
        },
        close:function(el){
            el = NtUtil.$(el);
            IMAnimate.animate(el,"opacity", {start:100,end:0,step:-10}, function(){
                var _curEl = el;var _preNodes = [];
                while(_curEl.previousSibling){_preNodes.push(_curEl.previousSibling);_curEl = _curEl.previousSibling;}
                if(el.parentNode) el.parentNode.removeChild(el);
                NotifyManager.showQueue._showList.remove(el.id);
                for(var k in _preNodes){
                    var _top    = $$D.css(_preNodes[k], "top");
                    var _newTop = _top + NotifyManager._height;
                    IMAnimate.animate(_preNodes[k], "top", {start:_top,end:_newTop,step:13}, function(){
                        NotifyManager.push();
                    });
                }
            });
        }
    }
};
function im_Confirm(destuid, key, alertType, strConfirm, destname, typ){
    if(alertType=="request"){
        if(strConfirm==1){
            im_openWebchatInPage(destuid, destname, null, true);
        }
    }else{
        var impresence = NtUtil.$('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 _cfg = Ntalker.Config;
    var _var = Ntalker.variable;    if(isMyFriend!=2 && _cfg.customparams["ignoreChatInvite"])
    	return;
    if(Ntalker.Config.isPopupMode && Ntalker.Config.isPopupWindow==0)
        return;
    if(isNotify && IMToolBar && IMToolBar.addSystemMessage){
        IMToolBar.addSystemMessage(destuid, destnick, gLang.nt_requestSession, chatid, logoUrl, message, "request", '','','chat');
    }else{
    	try{
    		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;
        		}
        	}
        	var _autoFocus = chatWndCount>0&&maxChatWnd ? false : true;
    	}catch(e){}
        if(isOnlineMsg){
            if(_var.onlineChat>=0){                im_chat_window_manager.addChatWindow(destuid, destnick, chatid, _autoFocus, message, logoUrl, 0);
                _var.onlineChat -= 1;
            }else if(IMToolBar && IMToolBar.addSystemMessage){
                IMToolBar.addSystemMessage(destuid, destnick, gLang.nt_requestSession, chatid, logoUrl, message, "request", '','','chat');
            }
        }else{
            if(_var.offlineChatList.length<6){
                im_chat_window_manager.addChatWindow(destuid, destnick, chatid, _autoFocus, message, logoUrl, 0);
                var openOfflineChatWindow = true;
                for(var k in _var.offlineChatList){
                    if(_var.offlineChatList[k][0]==destuid && _var.offlineChatList[k][1]==destnick){
                        openOfflineChatWindow = false; break;
                    }
                }
                if(openOfflineChatWindow) {
                    _var.offlineChatList.push([destuid, destnick]);
                }
            }else{
                var openOfflineChatWindow = false;
                for(var k in _var.offlineChatList){
                    if(_var.offlineChatList[k][0]==destuid && _var.offlineChatList[k][1]==destnick){
                        openOfflineChatWindow = true; break;
                    }
                }
                if(!openOfflineChatWindow && IMToolBar && IMToolBar.addSystemMessage){
                    IMToolBar.addSystemMessage(destuid, destnick, gLang.nt_requestSession, chatid, logoUrl, message, "request", '','','chat');
                }
            }
        }
    }
    if(promptwindow){
        promptwindow.startPrompt(destnick, gLang.nt_requestSession_title, true);
    }
    return true;
}function fIM_OnPresenceReceiveGroupMsg( groupId, groupName, groupIcon, srcuid, srcnick, msg, isNotify, chattype){
    var _CP = Ntalker.Config.customparams;
    if(!_CP["enablegroup"] && !_CP["enableroom"]) return;
    if(!groupId || groupId=="") return;
    chattype = /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(Ntalker.Config.isPopupMode && !Ntalker.Config.isPopupWindow)
        return;
    if(bconfirm){
        if(IMToolBar && IMToolBar.addSystemMessage) IMToolBar.addSystemMessage(destuid, destnick, gLang.nt_requestAddFriends, 0, logoUrl, "", "confirm", '','','chat');
        if(promptwindow){promptwindow.startPrompt(destnick, gLang.nt_requestAddFriends_title, true);}
    }else
        if(IMToolBar && IMToolBar.addSystemMessage) IMToolBar.addSystemMessage(destuid, destnick, gLang.nt_AddFriends, 0, logoUrl, "","alert", '','','chat');
        if(promptwindow){promptwindow.startPrompt(destnick, gLang.nt_AddFriends_title, true);}
    return;
}
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, gLang.nt_online, 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;
};
_p.createFlash = function(parent, id, src, title, w, h, mode){
    mode = mode ? mode:"Opaque";
    var obj;
    if($$B.ie){
        obj = this._doc.createElement("OBJECT");
        obj.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
        obj.setAttribute("codeBase", "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab");
        obj.setAttribute("movie", src);
    }else{
        obj = this._doc.createElement("EMBED");
        obj.setAttribute("src", src);
        obj.setAttribute("type", "application/x-shockwave-flash");
        obj.setAttribute("pluginspage","http://www.adobe.com/go/getflashplayer");
        obj.setAttribute("quality", "high");
    }
    obj.setAttribute("id", id);
    obj.setAttribute("name", id);
    obj.setAttribute("title", title);
    obj.setAttribute("width", w);
    obj.setAttribute("height", h);
    obj.style.width = w + "px";
    obj.style.height = h + "px";
    obj.setAttribute("allowScriptAccess", "always");
    obj.setAttribute("wmode", mode);
    if(obj){
        obj.style.display = "block";
        if(parent) parent.appendChild(obj);
    }else{
        var textNode = this._doc.createTextNode(gLang.a_createFlashFailure);
        if(parent) parent.appendChild(textNode);
    }
    try{
        return obj;
    }finally{
        obj = null;
    }
};
WDK_IM_PACK.FloatWindow = function(){
    this._top = 0;
    this._right = 0;
    this._bottom = 0;
    this._left = 0;
    this._width = 0;
    this._height = 0;
};
_p = WDK_IM_PACK.FloatWindow.prototype;
_p.FloatWindowManager = function(inFloatPos, inOffsetX, inOffsetY){
};
_p.moveTo = function(x, y){
};
_p.resize = function(w, h){
};
_p.fooRepos = function(){
};
WDK_IM_PACK.FloatWindowManager = function(){
    this._window = window;
    this._doc = this._window.document;
    this._activeWindow = null;
    this._windows = [];
    this.dragWin = null;
    this.clientArea = null;
    this._panel = null;
    this.dragSx;
    this.dragSy;
    this.isDrag = 0;
    this.isCascadeMode = false;
    this.resizeWin = null;
    this.dir = "";
    this.resizeX;
    this.resizeY;
    this.isresize = 0;
    this._inHead = true;
};
_p = WDK_IM_PACK.FloatWindowManager.prototype;
_p.init = function(){
    if(!this._doc.body){
        this._doc.write("<body></body>");
        this._inHead = true;
    }else{
        this._inHead = false;
    }
    this._body = this._doc.documentElement.clientHeight == 0 ? this._doc.body : this._doc.documentElement;
    var _this = this;
    function __repos(ev){
        ev = ev || _this._window.event
        var l = _this._windows.length;
        for(var i = 0; i < l; i++){
            _this._windows[i].fooRepos(ev);
            if(ev.type=='scroll' && _this._windows[i]._flash && !$$B.msie){
                if(Ntalker.temp.resetwintop[i] != true){
                    window.setTimeout("wdkApplication._FloatWindowManager.updateWindowPos("+i+", 1)", 500);
                    Ntalker.temp.resetwintop[i] = true;
                }
            }
        }
        return;
    }
    $$E.addEvent(this._window, "resize", __repos);
    $$E.addEvent(this._window, "scroll", __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 _this = this;
    function __mousemove(ev){_this.onmousemove(ev || _this._window.event);}
    function __mouseup(ev){_this.onmouseup(ev || _this._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.entrytype=="toolbar" && type.indexOf("w") == -1){
        this.resizeX = win._self.offsetLeft;
        this.resizeY = win._self.offsetTop;
    }else{
        this.resizeX = ev.clientX - win._self.offsetLeft;
        this.resizeY = ev.clientY - win._self.offsetTop;
    }
    window.resizeSx = ev.clientX;
    window.resizeSy = ev.clientY;
    this.isresize = 1;
    if($$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 rect = $$D.windowRect();
        obj.style.width = rect.w + "px";
        obj.style.height = rect.h + "px";
        this._panel = obj;
    }
    return this._panel;
};
_p.showPanel = function(bShow){
    if(!this._panel)
        this.getPanel();
    var rect = $$D.windowRect();
    this._panel.style.display = bShow ? "block" : "none";
    this._panel.style.left = rect.x + "px";
    this._panel.style.top  = rect.y + "px";
    this._panel.style.width = (rect.w-20>0?(rect.w-20):0) + "px";
    this._panel.style.height = (rect.h-20>0?(rect.h-20):0) + "px";
};
_p.onmouseup = function(ev){
    this.showPanel(false);
    if(this.dragWin != null){
        if($$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 rect = $$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.entrytype=="toolbar"){
            var _r = NtUtil.scrollWidth();
            if(!$$B.QuirksModel){
                var _absX = x + this.dragWin._baseLeft;
                if(_absX+this.dragWin._self.offsetWidth+_r > rect.x+rect.w){
                    x = rect.x+rect.w - this.dragWin._baseLeft - this.dragWin._self.offsetWidth - _r;
                }else if(_absX > rect.x){
                    x = x;
                }else{
                    x = 0-this.dragWin._baseLeft;
                }
            }else{
                x = Math.max(Math.min(x, this._body.scrollLeft + this._doc.documentElement.offsetWidth - this.dragWin._self.offsetWidth), this._body.scrollLeft);
                x = (x+this.dragWin._self.offsetWidth)>this._body.clientWidth ? (this._body.clientWidth-this.dragWin._self.offsetWidth) : x;
            }
            y = (y+this.dragWin._self.offsetHeight)>max_height ? (max_height-this.dragWin._self.offsetHeight) : y;
            this.dragWin.moveTo(x, y, true);
        }
        else{
            x = Math.max(Math.min(x, this._body.scrollLeft + this._doc.documentElement.offsetWidth - this.dragWin._self.offsetWidth), this._body.scrollLeft);
            x = (x+this.dragWin._self.offsetWidth)>this._body.clientWidth ? (this._body.clientWidth-this.dragWin._self.offsetWidth) : x;
            y = (y+this.dragWin._self.offsetHeight)>max_height ? (max_height-this.dragWin._self.offsetHeight) : y;
            this.dragWin.moveTo(x, y, true);
        }
    }
    if(this.resizeWin != null){
        window.obj = {
            x: this.resizeWin._self.offsetLeft,
            y: this.resizeWin._self.offsetTop,
            w: this.resizeWin._self.offsetWidth,
            h: this.resizeWin._self.offsetHeight
        };
        this.resizing(ev, this.resizeWin);    }
};
_p.resizing = function(ev, win){
    var minWidth  = win._minWidth;
    var minHeight = win._minHeight;
    var flag = this.dir;
    var obj = window.obj;
    var x = obj.x;
    var y = obj.y;
    var w = obj.w;
    var h = obj.h;
    var _CP = Ntalker.Config.customparams;
    var entrytype = _CP.entrytype=="toolbar" && flag.indexOf("w") == -1;
    var _parentRect = $$D.clientRect(this.resizeWin._self.parentNode);
    var ev_clientX = ev.clientX - (entrytype ? _parentRect.x : 0);
    var ev_clientY = ev.clientY - (entrytype ? _parentRect.y : 0);
    if(flag.indexOf("w") != -1){  
        w = obj.x + obj.w - ev_clientX + this.resizeX;
        if(w < minWidth) w = minWidth;
        x = obj.x + obj.w - w;
    }
    if(flag.indexOf("e") != -1){  
        w = ev_clientX - obj.x;
        if(w < minWidth) w = minWidth;
    }
    if(flag.indexOf("s") != -1){  
        h = ev_clientY - obj.y;
        if(h < minHeight) h = minHeight;
    }
    if(flag.indexOf("n") != -1){  
        h = obj.y + obj.h - ev_clientY + this.resizeY;
        if(h < minHeight) h = minHeight;
        y = obj.y + obj.h - h;
    }
    win.moveTo(x, y, true);
    win.resize(w, h);
    if($$B.ie)
        win._self.setCapture();
    ev.cancelBubble = true;  
    return false;
};
_p.updateWindowPos = function(winID, times){
	if(Ntalker.Config.layout=='cascade'){
		return;
    }
    if(typeof(this._windows[winID].refreshFlashPos)!="undefined"){
        this._windows[winID].refreshFlashPos();
        if(times<2)
            window.setTimeout("wdkApplication._FloatWindowManager.updateWindowPos("+winID+", "+(times+1)+")", 300);
        else
            Ntalker.temp.resetwintop[winID] = null;
    }
};
WDK_IM_PACK.IMWindow = function(){
    WDK_IM_PACK.FloatWindow.prototype.constructor();
    this._window = window;
    this._doc  = this._window.document;
    this._self = null;
    this.bxMini0;
    this.isLoad;
    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;
    this.m_rlLong;
    this.m_miniImgBottom;
    this.m_tataType;
    this.m_wid;
    this.m_isButtonFloat = "float";
    this.m_miniIMgSrc;
    this.m_startShow;
    this.m_miniImgEvent;
    this.m_miniImgID;
    this.m_jsSrc;
    this.m_nick;
    this.m_title;
    this.m_enableEditNick;
    this._flashID;
    this.m_flashContainerID;
    this._flashcontainer;
    this.m_miniImgDivID = "wdk_mini_state";
    this._titleid = "wdk_buddylist_title";
    this.timerID;
    this.isLocked = false;
    this.dockPos = "";  
    this._leftright = 0;
    this._isPopup = false;
    this._popupWindow = null;
    this._flash;
    this.isInited = false;
    this.imEntrySpan = null;
    this.isMiniFloat = true;
    this._isFlashLoadSuccess = false;
    this._flashLoadTime = 30000; 
    this._waitFlashAutoLoad = 5000; 
    this._FlashReloadCount = 0;
    this._checkFlashTimerid = null;
    this._waitFlashAutoLoadTimeid = null;
    this.isShow = false;
    this.created = false;
    this._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 _this = this;
    _this.startWork();
};
_p.moveTo = function(x, y){
    var rect = $$D.windowRect();
    this._left = x - rect.x;
    this._top = y - rect.y;
    this._right =  rect.x+rect.w-x;
    this._bottom = rect.y+rect.h-y;
    var _CP = Ntalker.Config.customparams;
    if($$B.ie){
        this._self.style.pixelLeft = x;
        if($$B.ie6 || _CP.entrytype=='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 _CP = Ntalker.Config.customparams;
    var rect = $$D.windowRect();
    var _r = NtUtil.scrollWidth();
    if( (!$$B.QuirksModel && _CP.entrytype=="toolbar") ){
        return;
    }
    if(ev&&ev.type == "resize"){
        if(!this._self) return;
        if(_CP.entrytype=='toolbar'){
            var _tabRect = $$D.clientRect(Ntalker.variable.buddylistTag);
            if(this.m_align=="left"){
                this._left = rect.x + rect.w - this._width - _tabRect.x - _r;
            }else{
                this._left = rect.x + rect.w - this._width - _tabRect.x - _r;
            }
            var left = this._left;
            var top  = this._top;
        }else{            var left = rect.x+rect.w-this._width-this.m_rlLong;
            var top  = rect.y+rect.h-this._height;
        }
        if($$B.ie){
            this._self.style.pixelLeft = left;
            if(_CP.entrytype=='toolbar' || $$B.ie6 )
	            this._self.style.pixelTop = top;
        }else{
            this._self.style.left = left + "px";
            if(_CP.entrytype=='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( 'cascade' == Ntalker.Config.layout ){
	        	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 _cfg = Ntalker.Config;
    var _CP = Ntalker.Config.customparams;
	if(this.isLoad == 1) return;
	this.isLoad = 1;    if(_CP['layout'] == 'topcascade' || $$B.chrome){
		this.fooRepos();
        this.isMiniFloat = true;
        wdkApplication._FloatWindowManager.addWindow(this);  
	}
	return;
};
_p.createWin = function(tagIndex){
    var _cfg = Ntalker.Config;
    var _var = Ntalker.variable;
    var wRt  = $$D.windowRect();
    var _CP = Ntalker.Config.customparams;
    var _r = NtUtil.scrollWidth();
    this.created = true;
    var cacheDom = document.createDocumentFragment();
    if( _CP.entrytype=='cascade' ) {
		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', {}, cacheDom, "AfterBegin");
        if($$B.ie6){
        	_pos = 'absolute';
        	this._self.style.top = y + 'px';
        }else{
        	_pos = 'fixed';
        	this._self.style.bottom = '0px';
        }
        with(this._self.style){
	        position = _pos;
			left   = x + "px";
        }
    }else{
        $$D.css(_var.buddylistTag, "display", "block");
        var _TabRect   = $$D.clientRect(_var.buddylistTag);
        this._self     = $$D.create('div', { id:"buddylist_tag_con"}, cacheDom);
        if(this.m_align=="left"){
            this._right = _TabRect.x;
            this._bottom = 0;
            this._left   = 0 - _TabRect.x;
            this._top    = 0;
        }else{
            if(_TabRect.x+this._width+_r > wRt.x+wRt.w){
                this._left  = wRt.x + wRt.w - this._width - _TabRect.x - _r;
                this._right = 0 - this._left;
            }
			this._top    = 0 - this._height + ($$B.QuirksModel ? 4 : 0);
            this._bottom = 0;
        }
        with(this._self.style){
        	position = "absolute";
        	left   = this._left+'px';
        	bottom = this._bottom+'px';
        }
    }
	this._self.style.zIndex = 10000;
    this.m_flashContainerID = "container_" + this._flashID;
    var bg = wdkApplication._debug ? "background-color:#000333;" : "background-image:url(" + Ntalker.variable.image_dir + "blank.gif);";
    var flashWidth = this._width - 2*this.borderWidth;
    var ww = this.borderWidth;
    var ch = this._height - this.titleHeight - 2*this.borderWidth;
    var sb = [];
    sb.push("<div type='dlgHead' style='position:absolute;left:0px;top:" + ww + "px;width:" + this._width + "px;height:" + this.titleHeight + "px;z-index:8;cursor:move;'>");
    sb.push("  <div type='dlgHead' style='position:absolute;left:0px;width:9px;top:0px;height:20px;z-index:4;'></div>");
    sb.push("  <div type='dlgHead' style='position:absolute;left:6px;width:96%;top:0px;height:20px;z-index:3;'><div style='-moz-user-select: none;-khtml-user-select: none;user-select: none;font-size:"+_cfg.fSize+";height:20px;padding:"+($$B.QuirksModel ? 4 : 0)+"px 0px 0px 10px;text-align:left;overflow:hidden'></div></div>");
    sb.push("  <div type='dlgHead' style='position:absolute;right:0px;width:60px;top:0px;height:20px;z-index:5;'></div>");
    sb.push("</div>");
    sb.push("<div id='" + this.m_flashContainerID + "'><div id='" + this._flashID + "'><div style='width:"+flashWidth+"px;height:"+ch+"px; background: #CBECC1 url("+Ntalker.variable.image_dir+"/installbg.gif) repeat-x; font-size:12px;line-height:"+ch+"px; text-align:center;'><a href='http://www.adobe.com/go/getflashplayer' target='_blank'>" + gLang.f_noInstallFlash + "</a></div></div></div>");
    if($$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;
    var body = _var.buddylistTag ? _var.buddylistTag : document.body;
    body.appendChild(cacheDom);
    this._self.style.display = "block";
    this._minBtn = this._self.childNodes[1];    this._flashcontainer = this._doc.getElementById(this.m_flashContainerID);
    var _this = this;
    this.createFlash(tagIndex);
    function __doEvent(e){_this.eventHandle(e || window.event);}
    this._self.onmouseover = __doEvent
    this._self.onmouseout  = __doEvent
    this._self.onmousedown = __doEvent
    this._self.onmouseup   = __doEvent;
    this.resize(this._width, this._height);
    if(!this.isMiniFloat){
        wdkApplication._FloatWindowManager.addWindow(this);  
    }
};
_p.createFlash = function(tagIndex){
    if(!this._flashcontainer)
        return;
    var swfSrc,
    	v = Ntalker.variable,
    	c = Ntalker.Config,
    	_CP = Ntalker.Config.customparams;
    swfSrc = this.m_jsURLPath+"/fs/ContactMod.swf?version=" + Ntalker.version.buddylist_flash;
    var flashvars = {v : Ntalker.version.buddylist_flash,
    				 r : this.m_jsURLPath,
    				 su: this.m_funcURLPath,
    				 k : Ntalker.variable.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,
                     g : (_CP.enablegroup ? "1" : "0")+(_CP.enableroom?"1":"0"),
                     w : Ntalker.Config.isPopupWindow,
                     b : !_CP.introbuddy ? 0 : 1,
                     o : !_CP.onlinelist ? 0 : 1,
                     h : !_CP.head ? 0 : 1,
                     ad: !_CP.ad ? 0 : 1,
                     se: !_CP.search ? 0 : 1,
                     il: !_CP.imagelist ? 0 : 1,
                     ep: !_CP.entrytype ? 1 : 0,
                     et: _CP.enabletitle===0 ? 0 : 1,
                     ea: _CP.enabletextad===0 ? 0 : 1,
                     od: _CP['order'],
                     ps: 6
                     };
    if(v.userparam)
        flashvars.p = encodeURIComponent(v.userparam);
    if(c.buddylistlogo && _CP.copyrighturl)
        flashvars.f = _CP.copyrighturl.toLowerCase().replace("http://","");
    else
        flashvars.f = encodeURIComponent(window.location.host);    if(flashvars.toJSONString)
        delete flashvars.toJSONString;
    var flashWidth = this._width - 2*this.borderWidth;
    var flashmode = "Window";
    var params = {menu:"true", "salign":"LT", "allowScriptAccess":"always", "wmode":flashmode, "allowFullScreen": true};
    var attributes = {};
    swfobject.embedSWF(swfSrc, this._flashID, flashWidth, this._height, "9.1.115", v.scriptPath+"/fs/expressInstall.swf", flashvars, params, attributes);
    this._flash = NtUtil.$(this._flashID);
    this.setFlashStyle();
    var _this = this;
    if(this._flash && !im_installFlashActionX){
        var __checkFlashLoad =function(){ _this.checkFlashLoad();};
        this._checkFlashTimerid = window.setTimeout(__checkFlashLoad, this._flashLoadTime);
        this._flashLoadTime = this._flashLoadTime*2; 
    }
};
_p.setFlashStyle = function(){  
    var fw = Math.max(this._width - 2 * this.borderWidth, 0);
    var fh = Math.max(this._height - 2 * this.borderWidth - this.titleHeight, 0);
    if(this._flash){
        this._flash.style.position = "absolute";
        this._flash.style.top    = (this.borderWidth + this.titleHeight) + "px";
        this._flash.style.left   = this.borderWidth + "px";
        this._flash.style.width  = fw + "px";
        this._flash.style.height = fh + "px";
        this._flashHeight        = this._flash.style.height;
    }
  }
_p.checkFlashLoad = function(){
    if(!this._isFlashLoadSuccess){
        var _this = this;
        this._restoreFlash = this._flash;
        var imgsrc   = Ntalker.variable.image_dir;
        var waitwinid = "winwdk_buddylist_wait";
        var closewinid = "btnwdk_buddylist_close";
        var reloadwinid = "btnwdk_buddylist_reload";
        var fw = this._width - 2*this.borderWidth;
        var fh = this._height - this.titleHeight - this.borderWidth*2;
        var html = ['<div id="'+waitwinid+'" style="z-index:10;position: absolute;top:'+this.titleHeight+'px;background:#F6F6F6 none;height:' + fh + 'px;width:' + fw + 'px;font-size:12px;font-weight: 100;border:1px solid #8C8C8C; text-align:center;cursor:auto;">',
                    '<div name="winlogo" style="float:left;width:70px;height:22px;background:url(' + Ntalker.Config.logo + ') bottom right no-repeat;"></div>',
                    '<div name="wintitle" style="float:left;margin-left:25px;width:132px;height:19px;background:url(' + imgsrc + '/titleText.gif) bottom  no-repeat;"></div>',
                    '<div id="'+closewinid+'" name="btnclose" style="z-index:12;float:right;margin-right:8px;width:26px;height:20px;background:url('+imgsrc+'/icon.gif) no-repeat;cursor:pointer;"></div>',
                    '<div style="clear:both;height:' + (fh-20) + 'px;line-height:' + (fh-20) + 'px;"><a id="'+reloadwinid+'" href="javascript:void(0)">' + gLang.f_loadFlashFailure + '</a></div>',
                    '</div>'].join('');
        $$D.insert(this._flashcontainer, html);
        this._flash.style.width = "1px";
        this._flash.style.height = "1px";
        this._flash = this._flashFailedDiv = NtUtil.$(waitwinid);
        var _this = this;
        var __clearClick  = function(e){$$E.fixEvent(e).stopPropagation();}
        var __closeWaitWin = function(e){_this.close();if(IMToolBar) IMToolBar.BuddylistVisible = false;}
        var __reloadFlash =function(){ _this.reloadFlash();}		if(this._FlashReloadCount>=2){
	        this._waitFlashAutoLoadTimeid = window.setTimeout( __reloadFlash , this._waitFlashAutoLoad);
	        this._waitFlashAutoLoad = this._waitFlashAutoLoad;
	    }
        NtUtil.$(waitwinid).onclick   = __clearClick;
        NtUtil.$(closewinid).onclick  = __closeWaitWin
        NtUtil.$(reloadwinid).onclick = __reloadFlash;
    }
};
_p.reloadFlash = function(){
    if(this._restoreFlash){
        delete this._restoreFlash;
    }
    this._flash = null;
    if(this._flashFailedDiv){
        this._flashcontainer.removeChild(this._flashFailedDiv);
        delete this._flashFailedDiv;
    }
    this._flashcontainer.innerHTML = "<div id='" + this._flashID + "'></div>";
    if(this._waitFlashAutoLoadTimeid) clearTimeout(this._waitFlashAutoLoadTimeid);
    this.createFlash();
}
_p.onFlashLoadSuccess = function(){
    this._isFlashLoadSuccess = true;
}
_p.eventHandle = function(ev){
	var event = ev||window.event;
    var ee = event.srcElement||event.target;
    if(ee.tagName == "IFRAME"){
        return;
    }
    if(ee.getAttribute("type") == "button"){
        switch(ev.type){
        case "mouseover":
            ee.style.backgroundPosition = "0 -" + ee.offsetHeight + "px";
            break;
        case "mouseout":
            ee.style.backgroundPosition = "0 0";
            break;
        case "mousedown":
            ee.style.backgroundPosition = "0 -" + (ee.offsetHeight * 2) + "px";
            break;
        case "mouseup":
            ee.style.backgroundPosition = "0 -" + ee.offsetHeight + "px";
            var eeName = ee.getAttribute("name");
            switch(eeName){
            case "btmin"   :
            case "btclose" :              this.close(true);
              break;
            case "btpopup" :
              this.popup();
              break;
            }
        }
    }
    var type = ee.getAttribute("type");
    if(type == "nw" || type == "n" || type == "ne" || type == "s" || type == "se" || type == "w" || type == "e"){
        switch(ev.type){
	        case "mousedown":
	            wdkApplication._FloatWindowManager.startResize(ev, this, type);
	            break;
	        case "mouseup":
	            wdkApplication._FloatWindowManager.showPanel(false);
	            break;
        }
    }
};
_p.updateMinButton = function(bMin){
    if(this._minBtn){    }
};
_p.minimize = function(){
    if(this.minDiv)    this.minDiv.style.visibility = "visible";
    if(this._self)    this._self.style.visibility = "hidden";
    if(this._flash) this._flash.style.visibility = "hidden";
};
_p.close = function(isShowMini){
    if(!this._self)
        return;
    if(this._flash){
        if(this._flash.asIM_closeIMBuddyList)
            this._flash.asIM_closeIMBuddyList();        NtUtil.disposeFlashObj(this._flash);
        if(!!this._flash.parentNode){
            $$D.css(this._flash, "display", "none");
            this._flash.parentNode.removeChild(this._flash);
        }
    }
    this._self.onmouseover = null;
    this._self.onmouseout  = null;
    this._self.onmousedown = null;
    this._self.onmouseup   = null;
    this._self.onfocus   = null;
    this._self.onblur   = null;
    if(Ntalker.temp.buddylistFlashGoUrl){
        $$C.script(Ntalker.temp.buddylistFlashGoUrl);
        Ntalker.temp.buddylistFlashGoUrl = null;
    }
    this._self.parentNode.removeChild(this._self);
    delete this._self;
    if(isShowMini && this.minDiv)
        this.minDiv.style.visibility = "visible";
    if(!this.isMiniFloat)
        wdkApplication._FloatWindowManager.removeWindow(this);
    if(Ntalker.variable.buddylistTag)
        Ntalker.variable.buddylistTag.style.display = "none";
    this.isShow = false;
    var siteid = Ntalker.variable.siteid;
    var uid    = Ntalker.variable.user_id;
    var destid = 0;
    var groupid= 0;
    var type   = 7;
    var desc   = gLang.sd_eventClose + gLang.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 _CP = Ntalker.Config.customparams;
    var _var = Ntalker.variable;
    if(_var.user_id==0 || !_var.user_id){
        alert(gLang.notLogin);return;
    }
    if(IMToolBar._disable || this.isShow){
        return;
    }
    if(IMToolBar._Pattern==0 && IMToolBar.onNatural){    	IMToolBar.onNatural();
    }
    if(this._self == null){
    	var cst = new Date().getTime();
        this.createWin(Ntalker.Config.IMtabIndex);
        execTimer.push('createBuddylistTimer:' + parseInt(new Date().getTime() - cst) );    }
    else{
        this._self.style.visibility = "visible";
        if(this._flash) this._flash.style.visibility = "visible";
        IM_BuddyListDOM = NtUtil.$("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 = Ntalker.variable.siteid;
    var uid    = Ntalker.variable.user_id;
    var destid = 0;
    var groupid= 0;
    var type   = 6;
    var desc   = gLang.sd_evOpen + gLang.sd_Buddylist;
    var mode   = 1;
    var source = 1;
    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.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 = NtUtil.$("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){
    WDK_IM_PACK.FloatWindow.prototype.constructor();
    this._destuid = destuid;
    this._destnick = destnick;
    this._chatType   = chatType==""?"chat":chatType;
    this._roomType   = roomtype ? 1 : 0;
    this._window = window;
    this._layout = layoutmode; 
    this._doc = this._window.document;
    this._self = null;
    this._selfid = "webchat_window"+destuid+this._chatType;
    this._titleid = "webchat_title"+destuid+this._chatType;
    this._headerid = "webchat_header"+destuid+this._chatType;
    this._width  = (/group|nquan/.test(this._chatType) ? Ntalker.Config.groupWidth : (this._chatType=="chat"?Ntalker.Config.chatWidth:Ntalker.Config.hotWidth));
    this._height = (/group|nquan/.test(this._chatType) ? Ntalker.Config.groupHeight : (this._chatType=="chat"?Ntalker.Config.chatHeight:Ntalker.Config.hotHeight));
    this._avwidth = 340; 
    this._avheight = 0;  
    this._savewidth = null;
    this._saveheight = null;
    this._curHeight = this._height;
    this._titleHeight = layoutmode=='cascade' ? 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._miniImgBottom;
    this._title;
    this._isFlashTitle = false;
    this._flashID = "webchat_flash"+destuid+this._chatType;
    this._flash = null;
    this._flashContainerID = "webchat_container"+destuid+this._chatType;
    this._flashcontainer;
    this._jsURLPath = Ntalker.variable.scriptPath;
    this.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;
    this._entrytype = Ntalker.Config.customparams.entrytype;
};
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();
    if(miniWinTabDOM && this._entrytype=="toolbar"){
        this._self = $$D.create('div', {}, 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._self = $$D.create('div', {}, 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._entrytype=='cascade'){
		if(this._chatType != 'chat' )
			this._titleText = this._destnick;
		else
			this._titleText = sprintf(gLang.tb_minWindow_title, this._destnick);
		titleWidth    = Ntalker.Config.chatWidth;
		minBtnLeft    = titleWidth - 39;
		closeBtnLeft  = titleWidth - 21;
	}else{
		this._titleText = sprintf(gLang.tb_minWindow_title, this._destnick);
		titleWidth    = this._width;
		minBtnLeft    = titleWidth - 39;
		closeBtnLeft  = titleWidth - 21;
	}
    var bg = "background-image:url(" + Ntalker.variable.image_dir + "blank.gif);";
    var ww = this._borderWidth;    var fw = Math.max(this._width - this._borderWidth*2, 0);
    var fh = this._height - this._borderWidth;
    this._iframeid = this._destuid+"_iframe";
    var sb = [];
    sb.push("<div type='dlgHead'  style='position:absolute;left:0px;top:" + ww + "px;width:" + titleWidth + "px;height:" + this._titleHeight + "px;cursor:auto;background:url(" + Ntalker.variable.image_dir + "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:"+Ntalker.Config.fSize+";background:url("+Ntalker.variable.scriptPath + '/images/' + Ntalker.Config.chatlogo+") no-repeat 4px 3px;height:auto;text-align:left;padding-left:30px;line-height:20px;'>" + 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;background:url(" + Ntalker.variable.image_dir + "im_btmin.gif);'></div>");
    sb.push("<div name='btclose' type='button' style='position:absolute;left:" + closeBtnLeft + "px;top:4px;font-size:0;width:14px;height:14px;background:url(" + Ntalker.variable.image_dir + "im_btclose.gif);'></div>");
    sb.push("<div id='" + this._flashContainerID + "'><div id='" + this._flashID + "'><div style='background:#CBECC1 url("+Ntalker.variable.image_dir+"/installbg.gif) repeat-x;height:"+fh+"px;width:"+fw+"px;font-weight: 100;font-size:12px;line-height:"+fh+"px; text-align:center;'><a href='http://www.adobe.com/go/getflashplayer' target='_blank'>" + gLang.f_noInstallFlash + "</a></div></div></div>");
    this._self.innerHTML = sb.join("");
    delete sb;
    var body = miniWinTabDOM ? miniWinTabDOM : document.body;
    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 _this = this;
    function __doEvent(e){_this.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=="cascade" ){
    	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(isSavePos){
        if(this._entrytype=="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()
    if(ev && ev.type == "resize"){
        if(!this._self) return;
        if(this._entrytype=='cascade'){
        	x = _wRt.x + this._left;
        	y = _wRt.y + _wRt.h - this._curHeight - this._bottom;
        	this.moveTo(x, y, true, this._curHeight);
        }else{
	        var _mRt = IMToolBar.get(this._destuid, this._chatType).getPost();
	        var x = _mRt.x;
	        var y = _wRt.y + _wRt.h-this._height-this._bottom;
            if(this._curWindMode!='hide'){
            	var _r = NtUtil.scrollWidth();
                y = $$B.QuirksModel ? y : this._top;
                y = _wRt.h-28+y<0 ? 0-_wRt.h+28 : y;
                if(IMToolBar._Pattern>0){
	                if(this._align=="left"){
	                    x = x<_wRt.x+Ntalker.Config.IMWidth+10 ? _wRt.x+Ntalker.Config.IMWidth+10 : (x+this._width>_wRt.x+_wRt.w-_r ? _wRt.x+_wRt.w-this._width-_r : x);
	                }else{
	                    x = x<_wRt.x ? _wRt.x+10 : (x+this._width > _wRt.x+_wRt.w-Ntalker.Config.IMWidth-_r-10 ? _wRt.x+_wRt.w-Ntalker.Config.IMWidth-_r-10-this._width : x );
	                }
	            }else{
	            	if(this._align=="left"){
	            		x = _mRt.rx-_mRt.w;
	            	}else{
	            		x = _mRt.rx-this._width;
	            		var _aRt = $$D.clientRect('windows_area');
			        	x = x+_aRt.x<_wRt.x ? _wRt.x-_aRt.x : x;
		        	}
	            }
            }else{
                x = -2000;
            }
            this.moveTo(x, y);
	    }
    }
    else if(this._self){
    	if(this._entrytype=='toolbar' || !$$B.ie6)
        	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;
    var displaystyle;
    switch(this._curWindMode){
    case "default":
        visiblestyle = "hidden";
        displaystyle = "none";
        this._curWindMode = "min";
        this._flashcontainer.style.width = "1px";
        this._flashcontainer.style.height = "1px";
        this._flash.style.width = "1px";
        this._flash.style.height = "1px";
        if(this._avStatus=="vedio" && this._savewidth){
            this._self.style.width = this._savewidth + "px";        }
        this._self.style.height = this._titleHeight + "px";
        if( this._layout=="toolbar" ){
        	this._curWindMode = "hide";
            this.moveTo(-2000, 0);
        }else{
        	this._curHeight = this._titleHeight;
        	this._minBtn.style.background = "url(" + Ntalker.variable.image_dir + "im_btbig.gif)";
        }
        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=="cascade" ){
        	this._curHeight = this._height;
        	this._minBtn.style.background = "url(" + Ntalker.variable.image_dir + "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;
    var displaystyle;
    switch(this._curWindMode){
    case "default":
        visiblestyle = "hidden";
        displaystyle = "none";
        this._curWindMode = "hide";
        this._flashcontainer.style.width = "1px";
        this._flashcontainer.style.height = "1px";
        this._flash.style.width = "1px";
        this._flash.style.height = "1px";
        if(this._avStatus=="vedio" && this._savewidth){
            this._self.style.width = this._savewidth + "px";        }
        this._self.style.height = this._titleHeight + "px";
        if(IMToolBar){
        	var minWin = IMToolBar.get(this._destuid, this._chatType)
        	if(minWin) minWin.onBlur();
        }
        if( this._layout=="cascade" ){
        	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(Ntalker.Config.customparams.entrytype=="toolbar"){
            var _mRt = IMToolBar.get(this._destuid, this._chatType).onFocus();
            x = _mRt.x;
            if($$B.QuirksModel){
            	y = _mRt.y-this._height + 5;
            }else{
            	y = 0-this._height;
            }
            if(IMToolBar._Pattern>0){
	            if(this._align=="left"){
		            x = x<_wRt.x+Ntalker.Config.IMWidth+5 ? _wRt.x+Ntalker.Config.IMWidth+5 : (x+this._width>_wRt.x+_wRt.w-_r ? _wRt.x+_wRt.w-this._width-_r : x);
		        }else{
		            x = x<_wRt.x ? _wRt.x+10 : (x+this._width > _wRt.x+_wRt.w-Ntalker.Config.IMWidth-_r-10 ? _wRt.x+_wRt.w-Ntalker.Config.IMWidth-_r-10-this._width : x);
		        }
            }else{
            	var _aRt = $$D.clientRect("windows_area");
	            if(this._align=="left"){
		            x = _mRt.x>_wRt.x+_wRt.w-this._width-_r ? _wRt.x+_wRt.w-this._width-_r : _mRt.x;
		        }else{
		        	x = 0 - this._width + _mRt.rx;
		        	x = x+_aRt.x<_wRt.x ? _wRt.x-_aRt.x : x;
		        }
		        x = x - _aRt.x;
            }
        }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 = NtUtil.$(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 _var   = Ntalker.variable;
    var siteid = _var.siteid;
    var uid    = _var.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 "bbshot":type=5;desc=gLang.sd_closeHotWindow;break;
    	case "group":type=3;desc=gLang.sd_closeGroupWindow;break;
    	case "nquan":type=9;desc=gLang.sd_closeNQuanWindow;break;
    	default:type=1;desc=gLang.sd_closeChatWindow;break;
    };
    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.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){
	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 = c.customparams;;
    var flashvars = {v : Ntalker.version.webchat_flash,
                  	 r : this._jsURLPath,   
                  	 su: this.m_funcURLPath,
                  	 k : Ntalker.variable.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),
                  	 sp: !_CP.simple ? 0 : 1,
                  	 w : c.isPopupWindow,
                  	 m : (_CP.entrytype=='cascade' ? 0 : 0),
                  	 av: !_CP.avroom ? 0 : 1,
                  	 rt: this._roomType ? 1 : 0, 
                  	 ep: !_CP.entrytype ? 1 : 0,
                  	 et: _CP.enabletitle===0 ? 0 : 1,
                     ea: _CP.enabletextad===0 ? 0 : 1,
                  	 ad: !_CP.ad ? 0 : 1
				    };
	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;        
			flashvars.od = _CP['order'];
			break;
		case "bbshot":
			swfSrc = this._jsURLPath+"/fs/NtalkerHotActivity.swf?version=" + Ntalker.version.hot_flash;
			flashvars.l  = c.chatlogo || "";                     
			flashvars.v  = Ntalker.version.hot_flash;            
			break;
		case "group":
			swfSrc = this._jsURLPath+"/fs/GroupMod.swf?version=" + Ntalker.version.group_flash;
			flashvars.l  = c.grouplogo || "";                    
			flashvars.v  = Ntalker.version.group_flash;          
			flashvars.epw= _CP.enablepicturewall==0 ? 0 : 1;     
			flashvars.etb= _CP.enabletoolsbar==0 ? 0 : 1;        
			flashvars.si = _CP.simpleinput ? 1 : 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;           
			break;
	}
    if(v.userparam)
        flashvars.p = encodeURIComponent(v.userparam);
    if(c.chatlogo && _CP.copyrighturl)
        flashvars.f = _CP.copyrighturl.toLowerCase().replace("http://","");
    else
        flashvars.f = encodeURIComponent(window.location.host);
    if(this._chatid) 
        flashvars.chatid    = this._chatid;    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 = false;
    var fw = Math.max(this._width - this._borderWidth*2, 0);
    var fh = this._height - this._borderWidth;
    swfobject.embedSWF(swfSrc, this._flashID, fw, fh,  "9.0.115", v.scriptPath+"/fs/expressInstall.swf", flashvars, params, attributes);
    this._flash = NtUtil.$(this._flashID);
    if( this._layout=="cascade" ){
	    this.setFlashStyle_NoTitle();
	}else{
		this.setFlashStyle();
	}
    if(this._flash && this._flash.tagName.toLowerCase()=="object"){
        var _this = this;
        var __checkFlashLoad =function(){ _this.checkFlashLoad();};
        this._checkFlashTimerid = window.setTimeout(__checkFlashLoad, this._flashLoadTime);
        this._flashLoadTime = this._flashLoadTime;
    }
}
_p.setFlashStyle = function(){
	this._flashcontainer.style.position = "absolute";
    this._flashcontainer.style.top      = this._titleHeight+"px";
    this._flashcontainer.style.left     = "0px";
    this._flashcontainer.style.width    = this._width+"px";
    this._flashcontainer.style.height   = (this._height-this._titleHeight - this._borderWidth)+"px";
    this._flashcontainer.style.overflow = "hidden";
    var fw = this._width - this._borderWidth*2;
    var fh = this._height-this._titleHeight - this._borderWidth*2;
    if(this._flash){
        this._flash.style.position = "relative";
        this._flash.style.width  = fw + "px";
        this._flash.style.height = fh + "px";
        this._flash.style.left   = this._borderWidth + "px";
        this._flash.style.top    = "0px";
        this._flashHeight        = this._flash.style.height;
    }
}_p.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 fw = this._width - this._borderWidth*2;
    var fh = this._height - this._borderWidth*2;
    if(this._flash){
        this._flash.style.position = "relative";
        this._flash.style.width  = fw + "px";
        this._flash.style.height = fh + "px";
        this._flash.style.left   = this._borderWidth + "px";
        this._flash.style.top    = "0px";
        this._flashHeight        = this._flash.style.height;
    }
}
_p.checkFlashLoad = function(){
    if(!this._isFlashLoadSuccess){
        var _this = this;
        this._restoreFlash = this._flash;
        var waitwinid = "win"+this._chatType+"reload"+this._destuid;
        var closewinid = "btn"+this._chatType+"close"+this._destuid;
        var reloadwinid = "btn"+this._chatType+"reload"+this._destuid;
        var fw = Math.max(this._width - this._borderWidth*2, 0) - 2;
        var fh = this._height - this._borderWidth*2;
        var html = ['<div id="'+waitwinid+'" style="background:#F6F6F6 none;height:' + fh + 'px;width:' + fw + 'px;font-size:12px;font-weight: 100;border:1px solid #8C8C8C; text-align:center;cursor:auto;">',
                   '<div name="winlogo" style="float:left;width:70px;height:22px;background:url(' + Ntalker.Config.logo + ') bottom right no-repeat;"></div>',
                   '<div name="wintitle" style="float:left;margin-left:60px;width:132px;height:19px;background:url(' + Ntalker.variable.image_dir + '/titleText.gif) bottom  no-repeat;"></div>',
                   '<div id="'+closewinid+'" name="btnclose" style="float:right;margin-right:8px;width:26px;height:20px;background:url('+Ntalker.variable.image_dir+'/icon.gif) no-repeat;cursor:pointer;"></div>',
                   '<div style="clear:both;height:' + (fh-20) + 'px;line-height:' + (fh-20) + 'px;"><a id="'+reloadwinid+'" href="javascript:void(0)">' + gLang.f_loadFlashFailure + '</a></div>',
                   '</div>'].join('');
        $$D.insert(this._flashcontainer, html);
        this._flash.style.width = "1px";
        this._flash.style.height = "1px";
        this._flash = NtUtil.$(waitwinid);
		this._FlashReloadCount++;
        var _this = this;
        var __clearClick  = function(e){$$E.fixEvent(e).stopPropagation();}
        var __closeWaitWin = function(e){_this.close();}
        var __reloadFlash = function(){ _this.reloadFlash();}		if(this._FlashReloadCount>=2){
	        this._waitFlashAutoLoadTimeid = window.setTimeout( __reloadFlash , this._waitFlashAutoLoad);
	        this._waitFlashAutoLoad = this._waitFlashAutoLoad * 2; 
	    }
        NtUtil.$(waitwinid).onclick = __clearClick;
        NtUtil.$(closewinid).onclick = __closeWaitWin
        NtUtil.$(reloadwinid).onclick = __reloadFlash;
    }
}
_p.restoreFlash = function(){
    if(this._flashFailedDiv){
       this._flashcontainer.removeChild(this._flashFailedDiv);
       delete this._flashFailedDiv;
    }
    this._flash = this._restoreFlash;
    this.resize(this._width, this._height);
    this._flash.focus();
}
_p.reloadFlash = function(){
    if(this._restoreFlash){
        delete this._restoreFlash;
    }
    this._flash = null;
    if(this._flashFailedDiv){
        this._flashcontainer.removeChild(this._flashFailedDiv);
        delete this._flashFailedDiv;
    }
    this._flashcontainer.innerHTML = "<div id='" + this._flashID + "'></div>";
    if(this._waitFlashAutoLoadTimeid) clearTimeout(this._waitFlashAutoLoadTimeid);
    this.createFlash();
    if( this._layout=="cascade" ){
	    this.setFlashStyle_NoTitle();
	}else{
		this.setFlashStyle();
	}
}
_p.onFlashLoadSuccess = function(){
    this._isFlashLoadSuccess = true;
}
_p.eventHandle = function(ev){
	var event = ev||window.event;
    var ee = event.srcElement||event.target;
    if(typeof(ee.getAttribute)=="undefined")
        return;
    if(ee.getAttribute("type") == "button"){
        switch(ev.type){
        case "mouseover":
            ee.style.backgroundPosition = "0 -" + ee.offsetHeight + "px";
            break;
        case "mouseout":
            ee.style.backgroundPosition = "0 0";
            break;
        case "mousedown":
            ee.style.backgroundPosition = "0 -" + (ee.offsetHeight * 2) + "px";
            break;
        case "mouseup":
            ee.style.backgroundPosition = "0 -" + ee.offsetHeight + "px";
            var eeName = ee.getAttribute("name");
            switch(eeName){
            case "btmin":
               if(this._layout=="cascade"){
                   if(this._curWindMode=="min")
                       this.onFocus();
                   else
                       im_chat_window_manager.minCurWindow();
               }else if( this._layout=="toolbar" ){
                   this.MinMax();
               }else{
                   this.minimize();
               }
               break;
            case "btclose" :
               this.close();
               break;
            case "btpopup" :
               this.popup();
               break;
            };
        }
    }    if(ev.type=="mousedown" && ee.getAttribute("type")!="button")
        this.onFocus();
    if(ee.getAttribute("type") == "dlgHead" || (typeof(ee.parentNode.getAttribute)!="undefined" && ee.parentNode.getAttribute("type") == "dlgHead")){
        switch(ev.type){
            case "mousedown":
                if(this.isLocked) return;                break;
            case "mouseup":                break;
            case "focus":
                this.onFocus();
                break;
            case "blur":
                this.onBlur();
                break;
            case "dblclick":
                if(this._layout=="cascade"){
                    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(){
    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);
    }    im_chat_window_manager.focusWindow(this._destuid, this._chatType);
};_p.onBlur = function(){
    this._self.style.zIndex = this._defaultZIndex;
    this._flashcontainer.style.zIndex = this._defaultZIndex;
    this._flash.style.zIndex = this._defaultZIndex;    this._flash.style.visibility = "hidden";
    this._flash.style.visibility = "visible";
};
_p.popup = function(){
    var _var = Ntalker.variable;
    var prompStr = null;
    if(this._avStatus=="audio")
        prompStr = gLang.a_endAudioSession;
    else if(this._avStatus=="vedio")
        prompStr = gLang.a_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 = gLang.w_AudioSession;
    }
    else if(this._avStatus!="audio"){
        this._avStatus = "audio";
        calltype = gLang.w_VideoSession;
    }
    var promptTitle = sprintf(gLang.w_requestSession_title, 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, gLang.w_Imagetrans_title, true);
}
_p.closeAV = function(isVedio){
    this._avStatus = "";
    if(this._curWindMode=="min"){
        this.stopFlashTitle();
    }
    this._titleText = sprintf(gLang.tb_minWindow_title, this._destnick);
    this.changeTitle(this._titleText);
}
_p.onReceiveMessage = function(message){
    if(this._curWindMode=="min" || this._curWindMode=="hide"){
        var titleText = sprintf(gLang.w_ReceiveMessage_title, this._destnick, message)
        this.startFlashTitle(titleText);
        if(IMToolBar){
            var miniWindow = IMToolBar.get(this._destuid, this._chatType);            miniWindow.onReceiveMiniMessage(message);
        }
        var impresenceflash = NtUtil.$('impresenceflash');
        if(impresenceflash && impresenceflash.playNotifySound){
            impresenceflash.playNotifySound();
        }
    }
}_p.onPresenceReceiveChatMsg = function(message){
    if(this._flash && this._flash.presenceReceiveChatMsg)
        this._flash.presenceReceiveChatMsg(message);
};
WDK_IM_PACK.ChatWindowManager = function(){
    this._chatWnds = new IMHashtable();
    this._chatWndsArray = new Array();
    this._popupChatWnds = new IMHashtable();
    this._creatingFlashWnds = new Array();
    this._windowWidth  = Ntalker.Config.chatWidth;
    this._windowHeight = Ntalker.Config.chatHeight;
    this._windowTitleHeight = 20;
    this._layout = Ntalker.Config.layout; 
    this._align = Ntalker.Config.customparams["floatpos"];
    this._entrytype = Ntalker.Config.customparams.entrytype;
    this._layoutRight = 0;
    this._layoutLeft = 0;
    this._layoutBottom = 0;
    this._curLayoutTop = 0;
    this._curChatWindow = null;
    this._curWindowIndex = -1;
}
_p = WDK_IM_PACK.ChatWindowManager.prototype;_p.addChatWindow = function(destuid, destnick, chatid, isAutoFocus, message, logoUrl, OpenType, chatType, roomtype){
    var cfg = Ntalker.Config;
    var chatRect = {left:0,top:0,right:0,bottom:0}
    switch(chatType){
    	case "nquan":
    	case "group":
    		this._windowWidth  = cfg.groupWidth;
    		this._windowHeight = cfg.groupHeight;
    		break;
    	case "bbshot":
    		this._windowWidth  = cfg.hotWidth;
    		this._windowHeight = cfg.hotHeight;
    		break;
    	default:
    		this._windowWidth  = cfg.chatWidth;
    		this._windowHeight = cfg.chatHeight;
    		chatType = "chat";
    		break;
    }
    var chatWindow = this.getChatWindow(destuid, chatType);
    if(chatWindow){
    	if(this._layout=="cascade"){
    		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(Ntalker.variable['OnFocusWinParam'].length>0 && !isAutoFocus){
        Ntalker.variable['OnBlurWinParam'] = maxChatWnd ? Ntalker.variable['OnFocusWinParam'] : [];
    }
    if(isAutoFocus){
    	Ntalker.variable['OnFocusWinParam'] = [destuid, type];
    }
    if(Ntalker.Config.isPopupWindow==1 && !(OpenType===1) ){
        window.focus();
        if(Ntalker.Config.isPopupWindow && promptwindow) promptwindow.startPrompt(gLang.w_popupWindow_title, true);
    }
    var wRt = $$D.windowRect();
    var newChatWindow = new WDK_IM_PACK.WDKChatWindow(destuid, destnick, chatid, this._layout, chatType, roomtype);    var l = this._chatWndsArray.length;
    for(var i=0; i<l; i++)
        this._chatWndsArray[i].hide();
	var cst = new Date().getTime(),curMo;
    if(this._entrytype=="toolbar"){
    	var MiniWnd   = IMToolBar.add(destuid, destnick, logoUrl, isAutoFocus, chatType);
        var _mRt 	  = MiniWnd.getPost();
        var _r = NtUtil.scrollWidth();
        var miniWinDOM_Tab = NtUtil.$$(".miniTAG_tab", MiniWnd.Element)[0];
        chatRect.bottom = 0;
        if($$B.QuirksModel){
            rightOffset  = wRt.x + wRt.w - _mRt.x - this._windowWidth;
            if(this._align=="right"){
                chatRect.right = rightOffset<Ntalker.Config.IMWidth+_r+10 ? Ntalker.Config.IMWidth+_r : rightOffset;
            }
            chatRect.bottom = 28;
            newChatWindow.showWindow(chatRect);
        }else{
        	rightOffset = wRt.x + wRt.w - _mRt.x - this._windowWidth;
            if(this._align=="right"){
                chatRect.right = rightOffset<Ntalker.Config.IMWidth+_r ? Ntalker.Config.IMWidth+_r+10 : rightOffset;
            }else{
            	if(IMToolBar._Pattern!=0){
                	chatRect.right = rightOffset>wRt.w-Ntalker.Config.IMWidth-this._windowWidth ? wRt.w-Ntalker.Config.IMWidth-this._windowWidth : (rightOffset<_r ? _r : rightOffset);
                }else{
                	chatRect.right = rightOffset;
                }
            }
            newChatWindow.showWindow(chatRect, miniWinDOM_Tab);
        }
        if(!isAutoFocus && Ntalker.variable.OnBlurWinParam.length>0){
            newChatWindow.MinMax();
            var _destuid = Ntalker.variable.OnBlurWinParam[0];
            var _chatType= Ntalker.variable.OnBlurWinParam[1];
            this.OnTBFocusWindow(_destuid, _chatType);
        }
    }else if(this._layout=="cascade"){
    	Ntalker.variable.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._curLayoutTop
        };
        newChatWindow.showWindow(chatRect);
        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(gLang.w_ReceiveMessage_title, destnick, message);
                newChatWindow.startFlashTitle(titleText);
            }
            this._curLayoutTop += curWindowHeight;
        }
    }
    this._chatWnds.add(destuid+chatType, newChatWindow);
    this._chatWndsArray.push(newChatWindow);
    this._curChatWindow = newChatWindow;    if(this._layout=="cascade" && OpenType==-1)
    	this.layoutWindow();
    execTimer.push('createChatTimer:' + parseInt(new Date().getTime() - cst) );
    var siteid = Ntalker.variable.siteid;
    var uid    = Ntalker.variable.user_id;
    var destid = /bbshot|group/.test(chatType) ? 0 : destuid;
    var groupid= /bbshot|group/.test(chatType) ? destuid : 0;
    var type,i,desc; 
    switch(chatType){
    	case "bbshot":type=4;desc=gLang.sd_HotWindow;break;
    	case "group":type=2;desc=gLang.sd_GroupWindow;break;
    	case "nquan":type=9;desc=gLang.sd_NQuanWindow;break;
    	default:type=0;desc=gLang.sd_ChatWindow;break;
    }
    switch(OpenType){case 1:i=0;break;case -1:i=2;break;default:i=1;}
    desc += gLang.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(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.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);
    if(chatWindow._curWindMode == "default")
        return;
    if(this._layout=="cascade"){
        this.layoutWindow(destuid, chatType);
        Ntalker.variable.OnFocusWinParam = [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!="cascade") return;	var wRt = $$D.windowRect()
	this._curLayoutTop = this._layoutBottom;
	var newCurWindowIndex = -1;
	var chatWindow = null;
	var curWindowHeight = 0;
	for(var i = 0; i < this._chatWndsArray.length; i++){
	    var chatWindow = this._chatWndsArray[i];
	    if(i==this._curWindowIndex){
	    	if(newCurWindowUid){
	        	curWindowHeight = this._windowTitleHeight;
	          	if(chatWindow._curWindMode=="default")
	            	chatWindow.minimize();
	      	}
	      	else
	        	curWindowHeight = chatWindow._height;
		}
	    else if(chatWindow._destuid == newCurWindowUid && 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;
	}
	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|bbshot|nquan/.test(chatType) ? chatType : 'chat';
    return this._chatWnds.items(destuid + chatType);
}
_p.getPopupWindow = function(destuid, chatType){
    chatType = /group|bbshot|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( 'cascade'==this._entrytype ){
            	this._chatWndsArray[i]._curWindMode = "min";            }else{
            	this._chatWndsArray[i]._curWindMode = "hide";
            	this._chatWndsArray[i].MinMax();
            }
            this._chatWndsArray[i].onFocus();
        }else{
            if(this._chatWndsArray[i]._curWindMode == 'default'){
            	if( 'cascade'==this._entrytype ){
            		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 = NtUtil.$("miniTAG_"+this._chatWndsArray[i]._destuid+"_tab");
        if(arguments[0]){
            tab.style.left = (tab.style.pixelLeft - 1000) + "px";
            if(this._chatWndsArray[i]._curWindMode == 'default'){
                this._chatWndsArray[i]._flash.style.visibility = "hidden";
                for(var j=3;j<8;j++){
                    this._chatWndsArray[i]._self.childNodes[j].style.visibility = "hidden";
                    this._chatWndsArray[i]._self.childNodes[j].style.display = "none";
                }
            }
        }else{
            tab.style.left = (tab.style.pixelLeft + 1000) + "px";
             if(this._chatWndsArray[i]._curWindMode == 'default'){
                this._chatWndsArray[i]._flash.style.visibility = "visible";
                for(var j=3;j<8;j++){
                    this._chatWndsArray[i]._self.childNodes[j].style.visibility = "visible";
                    this._chatWndsArray[i]._self.childNodes[j].style.display = "block";
                }
            }
        }
    }
}
function fIM_CloseIMWindow(){
    if(IMToolBar) IMToolBar.BuddylistVisible = false;
    if(im_myIMWindow) im_myIMWindow.close();
}
function fIM_PopupIMWindow(){
    if(IMToolBar) IMToolBar.onPopupOut();
}
function fIM_CloseChatWindow(destuid, chatType){
    if(im_chat_window_manager)
        im_chat_window_manager.getChatWindow(destuid,chatType).close();
}
function fIM_PopupChatWindow(){
    if(IMToolBar) IMToolBar.onPopupOut();
}
function fIM_MinMaxChatWindow(destuid, chatType){
    if(im_chat_window_manager){
    	if(Ntalker.Config.customparams.entrytype=='cascade'){
    		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 _var = 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(_var.user_id, _var.user_name, _var.user_sid, _var.siteid, destuid, groupWindow._destnick, null, _var.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_webchatFlashReady(destuid, chatType)
{
    var chatWindow = im_chat_window_manager.getChatWindow(destuid, chatType);
    if(chatWindow){
        chatWindow.onFlashLoadSuccess();
    }
    return true;
}
function fIM_buddylistFlashReady(){
    var buddylistFlash = document.getElementById("wdk_buddylist_flash");
    if(buddylistFlash && buddylistFlash.setBuddylistFlashParam){
        buddylistFlash.setBuddylistFlashParam(Ntalker.variable.user_sid, Ntalker.variable.user_id, Ntalker.variable.user_name, Ntalker.variable.siteid,"buddylist");
    }
    if(im_myIMWindow)
        im_myIMWindow.onFlashLoadSuccess();
}
function fIM_setBuddylistFlashParamfunc(){
  var buddylistFlash = document.getElementById("wdk_buddylist_flash");
    if(buddylistFlash && buddylistFlash.setBuddylistFlashParam){
      buddylistFlash.setBuddylistFlashParam(Ntalker.variable.user_sid, Ntalker.variable.user_id, Ntalker.variable.user_name, Ntalker.variable.siteid, "buddylist");
    }
}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){
	this.customModel = customModel ? 1 : 0;
	var u = Ntalker.variable.scriptPath;
	if(this.customModel){
		var menuNode = NtUtil.$("windows");
		if(!menuNode) return;
		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', {}, this.Element);
		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 _this   = this;
		var __clickMinWindow = function(ev){_this.onClick(ev);};
		$$E.addEvent(this.Element, "click",     __clickMinWindow);
	}else{
	    this.Element = $$D.create('li', {id:"miniTAG_"+this._destuid+this._chatType,className:"win"}, NtUtil.$("windows_gp"));
	    this.originTitle = $$S.cut(this._destnick, 5, true);
	    switch(this._chatType)
	    {
	    	case "chat":
	    		var imgsrc = u+"/images/chat.png";
	    		break;
	    	case "nquan":
	    	case "group":
	    		var imgsrc = u+"/images/group.png";
	    		break;
	    	case "bbshot":
	    		var imgsrc = u+"/images/hot."+($$B.ie6?"gif":"png");
	    		break;
	    }
	    var icoNode   = $$D.create('div', {className:"ico"}, this.Element);
	    var imageNode = $$D.create('img', {className:"userHead",src:imgsrc}, icoNode);
	    var textSpan  = $$D.create('span',{className:""}, this.Element);
	    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 _this   = this;
	    var __imageError     = function(ev){imageNode.src=imgsrc;}
	    var __clickMinWindow = function(ev){_this.onClick(ev);};
	    var __overMinWindow  = function(ev){
	    	current = ev.currentTarget || window.event.srcElement;
	    	if( current.className.indexOf("win")==-1 ) current = current.parentNode;
	    	if( current.className.indexOf("win")!=-1 ) $$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     = NtUtil.$('windows_area').scrollLeft;
	    	var preCountWind   = 1;
	    	if(IMToolBar){
		    	for(var k in IMToolBar.minWindows._hash){
			        if(IMToolBar.minWindows._hash[k]._destuid == _this._destuid && IMToolBar.minWindows._hash[k]._chatType == _this._chatType)
			            break;
			        else
			        	preCountWind++;
			    }
		    }
	    	var cur_allWidth   = _this.minChatWidth*preCountWind;
	    	if( show_areaWidth >= (cur_allWidth - scrollLeft))
	    		fIM_CloseChatWindow(_this._destuid, _this._chatType);
	    };
	    $$E.addEvent(imageNode,    "error",     __imageError);
	    $$E.addEvent(this.Element, "click",     __clickMinWindow);
	   	$$E.addEvent(this.Element, "mouseover", __overMinWindow);
	   	$$E.addEvent(this.Element, "mouseout",  __outMinWindow);
	    $$E.addEvent(closeNode,    "click",     __closeMinWindow);
    }
    return this.Element;
}
_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  = NtUtil.$('windows_area');
	var scrollLeft = AreaElemt ? AreaElemt.scrollLeft : 0;
	var mRt = $$D.clientRect(this.Element);
    var _x  = mRt.x-($$B.ie6 ? 2 : 0) - scrollLeft;
    var _rx = mRt.x+mRt.w+($$B.ie6 ? 2 : 0) - scrollLeft;
    return {x:_x, y:mRt.y, 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;
    if(IMToolBar && c.customparams.entrytype=="custom" && !c.isPopupWindow) IMToolBar.showMenu("ntalkerchatwinsMenu", "out")
    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(gLang.tb_minWindow_Session, message);
    this.startFlashTitle(titleText);
}  
_p.startFlashTitle = function(titleText){
    if(this.timerID)
        return;
    this.promptMsg = $$S.cut(titleText,5);
    this.flashWindowTitle();
};
_p.flashWindowTitle = function(){    if( IMToolBar._Pattern == 2){    }
    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 = IMAnimate.timer("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 = '';
}
_p = NtMenu.prototype;_p.init = function(span, Btn, mattr, over, out, click, func, visibleCallFunction){
	this._span = span;
	this._Button  = Btn;
	this._mAttr = mattr;
	this._over = over;
	this._out  = out;
	this._click= click;
	this._Func = func;
	this.visibleCallFunction = visibleCallFunction;
	this._Menu = null;
	this._MenuID = mattr['id'];
	var _this = this;
	var __showMenu = function(e){_this.show();};
	$$E.addEvent(this._Button, 'click', __showMenu);
}_p.add = function(k,obj){if(this._Hash.items(k)){return false;} this._Hash.add(k, obj);};
_p.remove = function(k){this._Hash.remove(k);};
_p.get = function(k){return this._Hash.items(k);};
_p.length = function(){return this._Hash.count();};
_p.hidden = function(){try{this._Menu.parentNode.removeChild(this._Menu);}catch(e){}};
_p.show = function(hidden){
	var _this = this;
	var _timer,_B = this._Button,_PN = this._span,_M1, _U, 
	_mAttr = this._mAttr, _O1 = this._over, _O2 = this._out, _O3 = this._click;
	if(this._Hash.count()==0 && typeof _this._Func == 'function'){
		_this._Func.call(this);
		return;
	}
	var __menuHidden = function(){if(!_this._overItem){clearInterval(_timer);_this.show(true);}};
	var __menuOver = function(e){
		var Func = _O1.callback, event, target;
		_this._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;
		_this._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 = _this._Menu;
		event = $$E.fixEvent(e);
		target= searchTag(event.target, "li");
		if(typeof Func == 'function'){
			Func.call(this, target);
		}
		if( Exec===false ){
			return;
		}
		try{
			_this.remove(target.getAttribute('k'));
			M.parentNode.removeChild(M);
		}catch(e){}        clearInterval(_timer);
	};
	if( !$$O(this._MenuID) && !hidden){
		tagName = _mAttr['tagName'] ? _mAttr['tagName'] : 'span';
		var _Ht = ['<' + tagName];
		for(var k in _mAttr){
			_Ht.push(' ' + (k.toLowerCase()=='classname' ? 'class' : k) + '="' + _mAttr[k]+'"');
		}
		_Ht.push('></' + tagName + '>');
		_M1 = $$D.insert(_PN, _Ht.join(''), 'beforeend');
		this._overItem = true;
		_timer = window.setInterval(__menuHidden, 500);
	}else{
		M = _this._Menu;
		try{
			if(!this._debug && M && M.parentNode){
				M.parentNode.removeChild(M);
				delete _this._Menu
			}
			clearInterval(_timer);
		}catch(e){}
		return;
	}
	_U = $$D.insert(_M1, '<ul class="emssagebox"></ul>');
	for(var k in this._Hash._hash){
		var _V1 = this._Hash._hash[k], _Ht = ['<li k="' + k + '"'];
		for(var ck in _V1.custom){
			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');
		$$E.addEvent(_L, 'mouseover', __menuOver);
		$$E.addEvent(_L, 'mouseout', __menuOut);
		$$E.addEvent(_L, 'click', __menuClick);
	}	if( typeof _this.visibleCallFunction == 'function'){
		_this.visibleCallFunction.call(this, _U);
	}
	$$A.forEach([_B,_M1], function(el){
		$$E.addEvent(el, 'mouseover', function(e){_this._overItem = true;});
		$$E.addEvent(el, 'mouseout', function(e){_this._overItem = false;});
	});
	this._Menu = _M1;
}function NtBaseTbar(){
	this.minWindows   = new IMHashtable();
	this.minWinCount  = 0;
	this._timer       = [];
	this._flashNum    = [];
	this._stopFlash   = [];
    this._waitTimeOut  = [];
    this._customMessageCount = 0;
    this._systemMessageMenu = null;
    this._groupMessageMenu = null;
}
_p = NtBaseTbar.prototype;
_p.type = function(chatType){
	switch(chatType){
		case "nquan":return "nquan";
		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 = NtUtil.$(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 = NtUtil.$(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;
    }
    IMAnimate.timer(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 = gLang.a_endAudioSession;break;
                case "vedio": prompStr = gLang.a_endVideoSession;break;
            }
            if(chatWins[i]._TransferState) prompStr = gLang.a_endFiletrans;
        }
        if(prompStr && !confirm(prompStr))
            return;
    }
    var _var = Ntalker.variable;
    var popupWindow = im_popupToolbar(_var.user_id, _var.user_name, _var.user_sid, _var.siteid, _var.userparam, true, _var.scriptPath, Ntalker.variable.image_dir);
};
_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);
};
_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();
			break;
		default:
			break;
	}
}function NtBottomTbar(){
	this.inited        = false;
	this.tbClosed      = false;
    this.Element       = null;
    this._tbWidth      = [];
    this._Pattern      = 2;
    this._align        = "right";
    this._statusValue  = 0;
    this._viewRect     = null;
    this.overMenu      = false;
    this.showMenu      = false;
    this.minChatWidth  = 115;
    this.customButtonNum = 0;
    NtBaseTbar.prototype.constructor();
    this.cache_add    = NtBaseTbar.prototype.add;
    this.cache_remove = NtBaseTbar.prototype.remove;
    this.resetCurTop = false;
}
NtBottomTbar.prototype = new NtBaseTbar();
_p = NtBottomTbar.prototype;
_p.init = function(parentNode){
	var _CP = Ntalker.Config.customparams;
	var b    = Ntalker.Config.customtoolbarButtons;
	if(NtUtil.cookie.load(Ntalker.tbModelKEY)==null){
    	var _initMode = _CP["intact"] ? 2 : 1;
    }else{
    	var _initMode = NtUtil.cookie.load(Ntalker.tbModelKEY);
    }
	this.inited = true;
    this._align = _CP["floatpos"];
    if( ($$B.ie6 || $$B.QuirksModel) && _CP['softwaretype'] != 'phpwind' ) {
    	this.resetCurTop = true;
	    var _h2 = document.body.currentStyle,_a = "fixed";
    	var _O = document.documentElement, _F1 = "url(about:blank)", _a3 = _O.runtimeStyle;
    	if (_O.currentStyle.backgroundImage == "none"){
	    	if ($$B.StrictMode) {
		        if (_h2.backgroundImage == "none" || _h2.margin == "0px") {
		            _a3.backgroundColor = _h2.backgroundColor;
		            _a3.backgroundPositionX = _h2.backgroundPositionX;
		            _a3.backgroundPositionY = _h2.backgroundPositionY;
		            _a3.backgroundRepeat = _h2.backgroundRepeat;
		            _a3.backgroundImage = _F1;
		            _a3.backgroundAttachment = _a;
		        }
		    } else {
		        _a3.backgroundImage = _F1;
		        _a3.backgroundAttachment = _a;
		    }
	    }
    }    _CP["createblank"] && $$D.create('div', {style:"height:30px;"});
    this.Element = $$D.create('div', {id:"NtalkerToolbar"}, null, "afterbegin");
    this.Element.innerHTML = this.toolbarHtml();
    if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
    	this._tbWidth = [[30,55], ($$B.ie6 ? 62 : 60), 0];
    	Ntalker.variable.buddylistTag = NtUtil.$("group_tab");
    }else{
		this._tbWidth = [[30,55], ($$B.ie6 ? 202 : 200), 0];
		Ntalker.variable.buddylistTag = NtUtil.$("buddylist_tab");
	}
    for(var k in b){
        if( typeof(b[k])=="object" && b[k]["float"]=="left" ){this.customButtonNum++;this._addCustomLeftButton(b[k]);}
    }
    this._tbWidth[1] += (_CP['enablegroup']||_CP['enableroom'] ? 62 : 0);
    var t = gLang.tip;
    for(var k in t){
    	var btnLI = NtUtil.$(k);
        if( !$$S.isDefined(t[k]) || (!_CP['enablegroup'] && !_CP['enableroom'] && k=="ico_group") || !btnLI ) continue;
        var btnDIV = NtUtil.$$(" div", btnLI)[0];
        if(!btnDIV) btnDIV = NtUtil.$(k);
        if(btnDIV){
        	$$E.addEvent(btnDIV, "mouseover", this.onOverEvent);
        	$$E.addEvent(btnDIV, "mouseout",  this.onOverEvent);
        }
        if(/ico_group|ico_msg/.test(k)){
        }else if( k == 'ico_buddylist'){
            $$E.addEvent(btnDIV, "click", this.onShowBuddylist);
    	}else if( k == 'ico_zoom'){
            $$E.addEvent(btnDIV, "click", this.onMinimize);
        }else if( k == 'ico_pre'){
            $$E.addEvent(btnDIV, "click", this.onLeft);
        }else if( k == 'ico_next'){
            $$E.addEvent(btnDIV, "click", this.onRight);
        }else if( k == 'ico_close'){
            $$E.addEvent(btnDIV, "click", this.close);
        }
    }
    this._viewRect = $$D.clientRect('windows_area');
    $$E.addEvent(window, "resize", this.onResize);
    $$E.addEvent(window, "scroll", this.onScroll);
    if( (NtUtil.cookie.load(Ntalker.tbClosedKEY)=="1" || (!_CP['enablegroup'] && !_CP['enableroom'] && !_CP['enablehot'])) && Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
    	this.close();
    }    var _ckEl = NtUtil.$('upPanel');
    if(_ckEl && $$D.css(_ckEl,"overflowY")=="scroll") {
        $$D.css(this.Element, "right", 17+'px');
    }
    if(this.resetCurTop){
		if($$B.StrictMode){
			_R5 = "document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight+2";
		    if (this.Element.offsetParent == document.body) { 
		    	_R5 += "-this.offsetParent.offsetTop-this.offsetParent.clientTop";
		    }
		}
		else{
			_R5 = "document.body.scrollTop+document.body.clientHeight-this.offsetHeight+2";
		}
		this.Element.style.setExpression("top",   _R5);
	}	this.initSystemMessage();	this.initGroupMessage();
    switch( parseInt(_initMode) ){
    	case 0:
    		this.onMinimize();
    		break;
    	case 1:
    		this.onNatural();
    		break;
    }
    if( /discuz61gbkdzy|wdknetbbs/.test(Ntalker.variable.siteid) && false ){    	this.createCustomButton();
    }
};
_p.close = function(){
	$$D.css(this.Element, "visibility", "hidden");
	NtUtil.cookie.save(Ntalker.tbClosedKEY, "1");
	var _presenceFlash = NtUtil.$('impresenceflash');
	NtUtil.disposeFlashObj(_presenceFlash);
	_presenceFlash.parentNode.removeChild(_presenceFlash);
	if(im_chat_window_manager) im_chat_window_manager.closeAll();
	this.tbClosed = true;
};
_p.hidden = function(){
    $$D.css(this.Element, "visibility", "hidden");
};
_p.visible = function(){
    $$D.css(this.Element, "visibility", "visible");
};
_p._addCustomLeftButton = function(btnCfg){
    if(!this.Element) return;
    var Element   = NtUtil.$("ico_pre");
    var _Attrib   = this._align=="left" ? "BeforeEnd" : "AfterBegin";
    var btnElement= $$D.create('div', {id:btnCfg.id, className:"user_custom", style:btnCfg.style+"width:28px;"}, null, _Attrib);
    $$D.create('a', {href:btnCfg.url,target:"_blank", style:"display:block;height:28px;"}, $$D.create('div', {className:"ico_button"}, btnElement));
    Element.parentNode.insertBefore(btnElement, Element);
    $$D.css(NtUtil.$(btnCfg.id), "float", (this._align=="left" ? "right" : "left"));
    gLang.tip[btnCfg.id] = btnCfg.tip;
    this._tbWidth[1] += 30;
};
_p.add = function(destuid, destname, src, isAutoFocus, chatType){
	var mWin = this.cache_add(destuid, destname, src, isAutoFocus, chatType);
	var wRt = $$D.windowRect();
    var minToolbarWidth = this.minChatWidth * this.minWinCount + 30;
    if(this._Pattern!=0 || (this._Pattern==0 && minToolbarWidth>wRt.w) )
    	this.onMaximize();
    else{
    	this._tbWidth[0][0] += this.minChatWidth;
    	this._tbWidth[0][1] += this.minChatWidth;
    	this.updateToolbar();
    }    this.initScroll();
    return mWin;
}
_p.remove = function(destuid, chatType){
	this.cache_remove(destuid, chatType);
	this.onRight();
	this._tbWidth[0][0] -= this.minChatWidth;
    this._tbWidth[0][1] -= this.minChatWidth;
    if( this._Pattern!=0 && this.minWinCount == 0 )
    	this.onNatural();
    else
    	this.updateToolbar();
}
_p.onMinimize = function(ev){
	var tbcloseWidth = 0;
	var _wRt = $$D.windowRect();
	if(Ntalker.Config.isPopupWindow==1){
		IMToolBar.onMaximize();
		return;
	}
	if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
		tbcloseWidth = 30;
	}
	if(IMToolBar._Pattern == 0 || (IMToolBar.minWinCount*IMToolBar.minChatWidth+55+tbcloseWidth) > _wRt.w ) return;
	if(im_chat_window_manager){
		im_chat_window_manager.OnTBFocusWindow(0);
	}
    gLang.tip["ico_zoom"]      = gLang.tip["cache"][1];
    var TipSpanClass = IMToolBar._align=="right" ? ".TipRight" : ".TipLeft";
    if(NtUtil.$('TOOLBARTIPico_zoom')) {NtUtil.$$(TipSpanClass, NtUtil.$('TOOLBARTIPico_zoom'))[0].innerHTML = "<span>" + gLang.tip["cache"][1] + "</span>";}
    $$D.css(NtUtil.$("ico_pre"),        "display", "none");
    $$D.css(NtUtil.$("ico_next"),       "display", "none");
    IMToolBar._Pattern = 0;
    IMToolBar._tbWidth[0][0] = IMToolBar.minWinCount*IMToolBar.minChatWidth + 30;
    IMToolBar._tbWidth[0][1] = IMToolBar.minWinCount*IMToolBar.minChatWidth + 55;
    IMToolBar.updateToolbar();
    var target  = NtUtil.$('ico_zoom');
    var btnZoom = NtUtil.$$(".ico_button", target)[0];
    if(btnZoom){
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onMinimize);
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onNatural);
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onMaximize);
    	$$E.addEvent(btnZoom,    "click", IMToolBar.onNatural);
    }
    if(im_chat_window_manager){
    	var focusID   = Ntalker.variable.OnFocusWinParam[0];
    	var focusType = Ntalker.variable.OnFocusWinParam[1];
		im_chat_window_manager.OnTBFocusWindow(focusID, focusType);
	}
};
_p.onNatural = function(ev){
	if(Ntalker.Config.isPopupWindow==1 || IMToolBar.minWinCount>0){
		IMToolBar.onMaximize();
		return;
	}
	if(IMToolBar._Pattern == 1) return;
    IMToolBar._Pattern = 1;
   	IMToolBar.updateToolbar();
	gLang.tip["ico_zoom"]      = gLang.tip["cache"][0];
	var TipSpanClass = IMToolBar._align=="right" ? ".TipRight" : ".TipLeft";
	if(NtUtil.$('TOOLBARTIPico_zoom')) { NtUtil.$$(TipSpanClass, NtUtil.$('TOOLBARTIPico_zoom'))[0].innerHTML = "<span>" + gLang.tip["cache"][0] +  "</span>";}
	$$D.css(NtUtil.$("ico_pre"),        "display", "none");
    $$D.css(NtUtil.$("ico_next"),       "display", "none");
    var target = NtUtil.$('ico_zoom');
    var btnZoom = NtUtil.$$(".ico_button", target)[0];
    if(btnZoom){
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onMinimize);
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onNatural);
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onMaximize);
    	$$E.addEvent(btnZoom,    "click", IMToolBar.onMinimize);
    }
};
_p.onMaximize = function(ev){
    var wRt = $$D.windowRect();
    gLang.tip["ico_zoom"]      = gLang.tip["cache"][0];
    var TipSpanClass = IMToolBar._align=="right" ? ".TipRight" : ".TipLeft";
    if(NtUtil.$('TOOLBARTIPico_zoom')) { NtUtil.$$(TipSpanClass, NtUtil.$('TOOLBARTIPico_zoom'))[0].innerHTML = "<span>" + gLang.tip["cache"][0] + "</span>";}
    $$D.css(NtUtil.$("ico_pre"),        "display", "block");
    $$D.css(NtUtil.$("ico_next"),       "display", "block");
    if(im_chat_window_manager){
    	im_chat_window_manager.OnTBFocusWindow(0);
    }
  	IMToolBar._Pattern = 2;
   	IMToolBar.updateToolbar();
    var target = NtUtil.$('ico_zoom');
    var btnZoom = NtUtil.$$(".ico_button",target)[0];
    if(btnZoom){
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onMinimize);
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onNatural);
    	$$E.removeEvent(btnZoom, "click", IMToolBar.onMaximize);
    	$$E.addEvent(btnZoom,    "click", IMToolBar.onMinimize);
    }
    if(im_chat_window_manager){
    	var focusID   = Ntalker.variable.OnFocusWinParam[0];
    	var focusType = Ntalker.variable.OnFocusWinParam[1];
		im_chat_window_manager.OnTBFocusWindow(focusID, focusType);
	}
    IMToolBar._viewRect = $$D.clientRect('windows_area');
};
_p.updateToolbar = function(){
    var tbcloseWidth=0,_wRt = $$D.windowRect();
    var winArea  = NtUtil.$("windows_area");
    var z = NtUtil.$("ico_zoom");
    $$D.css(winArea, "margin", "0px");
    if(this._Pattern == 0){
    	if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
    		tbcloseWidth = 30;
    	}
    	if(this.minWinCount==0){
    		$$D.css(winArea, "visibility", "hidden");
    		if($$B.ie6 || $$B.QuirksModel || $$B.maxthon){
    			$$D.css(winArea, "height", 1+'px');
    			$$D.css(winArea, "width", 1+'px');
    			$$D.css(NtUtil.$('bodylist'), "width", 1+'px');
    		}
    		NtUtil.$("Ntalkerbody").style.borderLeft = "none";
    	}else{
    		$$D.css(winArea, "visibility", "visible");
    		NtUtil.$('windows_area').scrollLeft = 0;
    		if($$B.ie6 || $$B.QuirksModel || $$B.maxthon){
    			$$D.css(winArea, "height", 28+'px');
    			$$D.css(winArea, "width", this._tbWidth[0][1]-55-($$B.ie6?3:0) + 'px');
    			$$D.css(NtUtil.$('bodylist'), "width", 2500 + 'px');
    		}
    	}
    	var _sysMsgNum    = this._systemMessageMenu._Hash.count();
        if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' || _sysMsgNum==0 ){
        	$$D.removeClass( z, "ico_minZoom");
        	$$D.replaceClass(z, "ico_maxZoom", "ico_minZoom_null");
        	NtUtil.$$(" div", z)[0].innerHTML = "";
        	var _tbWidth = this._tbWidth[0][0]+tbcloseWidth;
        }else{
        	$$D.removeClass(z,"ico_minZoom_null");
        	$$D.replaceClass(z,"ico_maxZoom", "ico_minZoom");
        	NtUtil.$$(" div", z)[0].innerHTML = "("+_sysMsgNum+")";
        	var _tbWidth = this._tbWidth[0][1]+tbcloseWidth;
        }
        $$D.css(NtUtil.$('Ntalkerbody'),    "width", _tbWidth+"px");
        $$D.css(NtUtil.$('NtalkerBg'),      "width", _tbWidth+"px");
        $$D.css(NtUtil.$('NtalkerToolbar'), "width", _tbWidth+"px");
        $$D.css(NtUtil.$('ico_buddylist'), "display", "none");
        $$D.css(NtUtil.$('ico_group'),     "display", "none");
        $$D.css(NtUtil.$('ico_msg'),       "display", "none");
        $$D.css(NtUtil.$('ico_bbshot'),    "display", "none");
        if($$O('ico_nquan')) $$D.css($$O('ico_nquan'),     "display", "none");
        var usercustoms = NtUtil.$$(".user_custom", NtUtil.$("Ntalkerbody"));
        for(var i=0; i<usercustoms.length; i++){
        	$$D.css(usercustoms[i], "display", "none");
        }
	    for(var k in this.minWindows._hash){
	    	var __minWnd = this.minWindows._hash[k];
	        if(__minWnd._focus){
	        	__minWnd.onClick(null, __minWnd.Element);
	        }
	    }    	if(im_myIMWindow) im_myIMWindow.close();
        NtUtil.cookie.save(Ntalker.tbModelKEY, this._Pattern);
    }else if(this._Pattern == 1){
        $$D.css(winArea, "visibility", "hidden");
        if($$B.ie6 || $$B.QuirksModel || $$B.maxthon){
            $$D.css(winArea, "width",  1+'px');
            $$D.css(winArea, "height", 1+'px');
            $$D.css(NtUtil.$('bodylist'), "width", 1+'px');
        }
        var __width = 0;
        if(Ntalker.variable.user_sid=="NtalkerGuestUserSessionID"){
        	__width = $$B.maxthon ? -3 : ($$B.ie6 ? -1 : 0);
        }
        if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
        	$$D.css(NtUtil.$('ico_buddylist'), "display", "none");
        	$$D.css(NtUtil.$('ico_msg'),       "display", "none");
        	if($$O('ico_nquan')) $$D.css($$O('ico_nquan'),     "display", "none");
        }else{
        	$$D.css(NtUtil.$('ico_buddylist'), "display", "block");
        	$$D.css(NtUtil.$('ico_msg'),       "display", "block");
        	if($$O('ico_nquan')) $$D.css($$O('ico_nquan'),     "display", "block");
        }
       	var w = this._tbWidth[1] - __width;
        $$D.css(NtUtil.$('Ntalkerbody'),    "width", w + "px");
        $$D.css(NtUtil.$('NtalkerBg'),      "width", w + "px");
        $$D.css(NtUtil.$('NtalkerToolbar'), "width", w + "px");
        $$D.css(NtUtil.$('ico_group'),      "display", "block");
        $$D.css(NtUtil.$('ico_bbshot'),     "display", "block");
        var usercustoms = NtUtil.$$(".user_custom", NtUtil.$("Ntalkerbody"));
        for(var i=0; i<usercustoms.length; i++){
        	$$D.css(usercustoms[i], "display", "block");
        }
        $$D.removeClass(z,  "ico_minZoom_null");
        $$D.replaceClass(z, "ico_minZoom", "ico_maxZoom");
        NtUtil.$$(" div", z)[0].innerHTML = "";
        if(this._align=="left"){
        	NtUtil.$("Ntalkerbody").style.borderRight = "1px solid #898989";
    	}else{
    		NtUtil.$("Ntalkerbody").style.borderLeft = "1px solid #898989";
    	}
    	NtUtil.cookie.save(Ntalker.tbModelKEY, this._Pattern);
    }else{
        $$D.css(winArea, "visibility", "visible");
        if($$B.ie6 || $$B.QuirksModel || $$B.maxthon){
        	$$D.css(winArea, "height", 28+'px');
        	$$D.css(winArea, "width", (_wRt.w - this._tbWidth[1] - 35)+'px');
        	$$D.css(NtUtil.$('bodylist'),       "width", 2500+'px');
        }
        $$D.css(NtUtil.$('Ntalkerbody'),    "width", $$B.ie6 ? (_wRt.w-3)+"px" : "100%");
        $$D.css(NtUtil.$('NtalkerBg'),      "width", $$B.ie6 ? (_wRt.w-3)+"px" : "100%");
        $$D.css(NtUtil.$('NtalkerToolbar'), "width", $$B.ie6 ? (_wRt.w-3)+"px" : "100%");
        if( Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' ){
        	$$D.css(NtUtil.$('ico_buddylist'), "display", "none");
        	$$D.css(NtUtil.$('ico_msg'),       "display", "none");
        	if($$O('ico_nquan')) $$D.css($$O('ico_nquan'),     "display", "none");
        }else{
        	$$D.css(NtUtil.$('ico_buddylist'), "display", "block");
        	$$D.css(NtUtil.$('ico_msg'),       "display", "block");
        	if($$O('ico_nquan')) $$D.css($$O('ico_nquan'),     "display", "block");
        }
        $$D.css(NtUtil.$('ico_group'),     "display", "block");
        $$D.css(NtUtil.$('ico_bbshot'),    "display", "block");
        var usercustoms = NtUtil.$$(".user_custom", NtUtil.$("Ntalkerbody"));
        for(var i=0; i<usercustoms.length; i++){
        	$$D.css(usercustoms[i], "display", "block");
        }
        $$D.removeClass(  z, "ico_minZoom_null");
        $$D.replaceClass( z,"ico_minZoom","ico_maxZoom");
        NtUtil.$$(" div", z)[0].innerHTML = "";
	    for(var k in this.minWindows._hash){
	    	var __minWnd = this.minWindows._hash[k];
	        if(__minWnd._focus){
	        	im_chat_window_manager.OnTBFocusWindow(__minWnd._destuid,__minWnd._chatType);
	        }
	    }
        NtUtil.cookie.save(Ntalker.tbModelKEY, 1);
    }
};
_p.onShowHost = function(){
    if(!Ntalker.Config.customparams['enablehot']) return;
    im_openWebchatWindow("bbshot", gLang.sd_HotWindow, null, 1, 'bbshot');
};
_p.onOverEvent = function(ev, nodeName){
    var current,btn,t;
    if(nodeName && NtUtil.$(nodeName)){
        btn = NtUtil.$(nodeName);
    }else{
        current = ev.currentTarget || window.event.srcElement;
        btn     = current.parentNode;
        if(!current.parentNode.id) btn = btn.parentNode;
    }
    t = gLang.tip;
    for(var k in t){
        if(btn.id && k == btn.id){
        	var effectsBtn = NtUtil.$$(".ico_button", NtUtil.$(k))[0];
            if(  ( (ev&&ev.type=="mouseover") || nodeName) ){
            	if(effectsBtn) $$D.addClass(effectsBtn, "hover");
                _showTip(k, t[k]);
            }else{
            	if(effectsBtn) $$D.removeClass(effectsBtn, "hover", "");
                _hiddenTip(k);
            }
            return;
        }
    }
    function _showTip(key, msg){
	    var _tbBtn   = NtUtil.$(key);
	    if(/pre_disable|next_disable/.test(_tbBtn.className) ) return;
	    if(!_tbBtn || IMToolBar.showMenu || !msg || NtUtil.$('imNt_tooltip_'+key)) return;
	    var _tip   = NtUtil.$("TOOLBARTIP"+key);
	    if(!_tip){
	        _tip   = $$D.create('div', {className:"NtalkerToolbarTip",id:"TOOLBARTIP"+key}, _tbBtn);
	    }
	    var _width = $$S.len(msg)*7 + ($$B.ie6 ? 20 : 15);
	    $$D.css(_tip, "width", _width + 'px');
	    var winRect = $$D.windowRect();
	    var btnRect = $$D.clientRect(_tbBtn);
	    var tipleft = btnRect.w/2-8;
	    if(btnRect.x+tipleft+_width > winRect.x+winRect.w){
	        _tip.innerHTML = '<ul id="ToolbarTip" class="Ntalker_fright"><li class="TipLeft"></li><li style="width:'+(_width-6)+'px" class="TipRight"><span>'+msg+'</span></li></ul>';
	        tipleft = parseInt(btnRect.w - _width - 12);
	    }else{
	        _tip.innerHTML = '<ul id="ToolbarTip" class="Ntalker_fleft"><li style="width:'+(_width-6)+'px" class="TipLeft"><span>'+msg+'</span></li><li class="TipRight"></li></ul>';
	    }
	    $$D.css(_tip, "left", tipleft + 'px');
	    $$D.css(_tip, "display", "block");
	}
	function _hiddenTip(key){
	    var _tbBtn   = NtUtil.$(key);
	    if(!_tbBtn) return;
	    var _tip   = NtUtil.$("TOOLBARTIP"+key);
	    if(_tip) $$D.css(_tip, "display", "none");
	}
};
_p.onResize = function(ev){
	IMToolBar.initScroll();
    if( !$$B.ie6 && !$$B.QuirksModel )  return;
    var _wRt = $$D.windowRect(); 
    if(ev && ev.type){
    	var w = IMToolBar._tbWidth[1];
        if(parseInt(_wRt.w) < parseInt(w) ){
            $$D.css(NtUtil.$('Ntalkerbody'),    "width", w+'px');
            $$D.css(NtUtil.$('NtalkerBg'),      "width", w+'px');
            $$D.css(NtUtil.$('NtalkerToolbar'), "width", w+'px'); 
        }
        else if(IMToolBar._Pattern==2){
            $$D.css(NtUtil.$('Ntalkerbody'),    "width", $$B.ie6 ? (_wRt.w-2)+"px" : "100%");
            $$D.css(NtUtil.$('NtalkerBg'),      "width", $$B.ie6 ? (_wRt.w-2)+"px" : "100%");
            $$D.css(NtUtil.$('NtalkerToolbar'), "width", $$B.ie6 ? (_wRt.w-2)+"px" : "100%"); 
            if($$B.ie6) $$D.css(NtUtil.$("windows_area"),   "width", (_wRt.w - w - 35)+'px');
        }
    }
    var wRt = $$D.windowRect();
    var minToolbarWidth = IMToolBar.minChatWidth * IMToolBar.minWinCount + 30;
    if(IMToolBar._Pattern==0 && minToolbarWidth>wRt.w){
    	IMToolBar.onMaximize();
    	return;
    }
};
_p.onScroll = function(ev){
	return;
	if(IMToolBar.resetCurTop){
		if($$B.StrictMode){
			_R5 = document.documentElement.scrollTop+document.documentElement.clientHeight-IMToolBar.Element.offsetHeight+2;
		    if (IMToolBar.Element.offsetParent == document.body) { 
		    	_R5 = _R5-IMToolBar.Element.offsetParent.offsetTop-IMToolBar.Element.offsetParent.clientTop;
		    }
		}
		else{
			_R5 = document.body.scrollTop+document.body.clientHeight-IMToolBar.Element.offsetHeight+2;
		}
		$$D.css(IMToolBar.Element, 'top', _R5 + 'px');
	}
};
_p.updateUserStatus = function(statusValue, message){
    var _status = "";
    var btnState = NtUtil.$("ico_state");
    if(!btnState) return;
    var items = NtUtil.$$(".act", NtUtil.$$(" ul", btnState)[0]);
    for(var i = 0; i < items.length; i++){
        if(statusValue==items[i].getAttribute("val"))
            $$D.addClass(items[i], "selected");
        else
            $$D.removeClass(items[i], "selected");
    }
    if(/9|10/g.test(statusValue)){this._tipMessage = gLang.tb_connect;}
    else if(message!=null) this._tipMessage = message==gLang.tb_connectFailure_Return ? gLang.tb_connectFailure_Message : message;
    //gLang.tip['ico_state'] = statusValue==2 ? gLang.tb_InvisibleStatus_Message : gLang.tip["cache"][2];
    switch(statusValue){
        case 1:_status = "ico_online";this.enable();break;
        case 2:_status = "ico_invisible";this.enable();
            this.onOverEvent(null, 'ico_state');            break;
        case 3:_status = "ico_busy";this.enable();break;
        case 4:_status = "ico_leave";this.enable();break;    }
    this._statusValue = statusValue>0&&statusValue<=4 ? statusValue : 0;
    btnState.getElementsByTagName("DIV")[0].className = _status;
    $$D.addClass(btnState.getElementsByTagName("DIV")[0], "ico_button");
};
_p.saveStatus = function(statusValue){
    this.overMenu = "";
    this.updateUserStatus(statusValue);
    var _presenceFlash = NtUtil.$("impresenceflash");
    if(_presenceFlash && _presenceFlash.switchUserStatus){
        _presenceFlash.switchUserStatus(statusValue);
    }
};
_p.updateUserNumber = function(onlineUser, totalUser){
    if(NtUtil.$("buddylist_span")) {
    	var buddyText = gLang.tb_BuddyListButton_text;
        NtUtil.$("buddylist_span").innerHTML = sprintf(buddyText, String(onlineUser), String(totalUser) );
    }
};
_p.toolbarHtml = function(){
    var htmls = [];
    var sessionid   = Ntalker.variable.user_sid;
    var enablegroup = Ntalker.Config.customparams['enablegroup'];
    var enableroom = Ntalker.Config.customparams['enableroom'];
    htmls.push('<div class="NtalkerBg" id="NtalkerBg"></div>');
    htmls.push('<div class="ntbody" id="Ntalkerbody">');    htmls.push('    <div id="NtalkerUL">');
    htmls.push('        <ul style="list-style:none;margin:0px;padding:0px;">');
    if( sessionid=='NtalkerGuestUserSessionID' ){
    	htmls.push('            <li id="ico_close" class="ico_close"><div class="ico_button"></div></li>');
    }
    htmls.push('            <li id="ico_zoom" class="ico_maxZoom"><div class="ico_button"></div></li>');
    htmls.push('            <li id="ico_buddylist">');
    htmls.push('                <div id="buddylist_span" class="ico_button">(0)</div>');
    htmls.push('                <div id="buddylist_tab" class="buddylist_tab"></div>');
    htmls.push('            </li>');
    if( enablegroup || enableroom ){
        htmls.push('            <li id="ico_group" class="ico_group">');
        htmls.push('                <div class="ico_button">(0)</div>');
        htmls.push('                <div id="group_tab" class="buddylist_tab"></div>');
        htmls.push('            </li>');
    }
    htmls.push('            <li id="ico_msg" class="ico_msg">');
    htmls.push('                <div class="ico_button">(0)</div>');
    htmls.push('            </li>');
    htmls.push('        </ul>');
    htmls.push('    </div>');
    htmls.push('    <div id="ico_pre" class="pre_enable"><div class="ico_button"></div></div>');
    htmls.push('    <div id="ico_next" class="next_enable"><div class="ico_button"></div></div>');
    htmls.push('    <div id="windows_area">');
    htmls.push('        <div id="bodylist">');
    htmls.push('            <ul id="windows_gp" style="list-style:none;margin:0px;padding:0px;">');
    htmls.push('            </ul>');
    htmls.push('            <div class="clearFolat"></div>');
    htmls.push('        </div>');
    htmls.push('    </div>');
    htmls.push('</div>');
    return htmls.join('');
};
_p.createHotButton = function(){
	var btnMsg = NtUtil.$('ico_msg');
	var enablehot = Ntalker.Config.customparams['enablehot'];
    if(!enablehot || Ntalker.temp.CHot || !btnMsg) return;
    Ntalker.temp.CHot = true;
    this._tbWidth[1] += 38;
    var _html = ['<li id="ico_bbshot" style="'+(this._Pattern>0 ? "display:block;" : "display:none;")+'">',
                 '  <div class="ico_button">&nbsp;</div>',
                 '</li>'].join('');
    if(btnMsg) $$D.insert(btnMsg, _html, 'afterend');
    if(this._Pattern>0) this.updateToolbar();
    var btnDIV = NtUtil.$$(".ico_button", NtUtil.$('ico_bbshot'))[0];
    if(btnDIV){
        $$E.addEvent(btnDIV, "click", this.onShowHost);
        $$E.addEvent(btnDIV, "mouseover", this.onOverEvent);
        $$E.addEvent(btnDIV, "mouseout",  this.onOverEvent);
    }
};_p.createCustomButton = function(){
	var _var = Ntalker.variable;
	var sessionid   = Ntalker.variable.user_sid;
	if( !(_var.user_sid && _var.user_name && _var.user_id && sessionid!='NtalkerGuestUserSessionID') )
		return;
	var cssText = [], Ht = [], button_span, button;
	IMToolBar._tbWidth[1] += 82;
	cssText.push('#ico_nquan{width:82px;cursor:pointer;}');
	cssText.push('.nquan-css{padding:0 5px 0 20px;text-align:right;background:url("' + Ntalker.variable.image_dir + 'skin_.gif") no-repeat scroll -390px -100px}');
	$$C.addSheet(cssText.join("\n"));
	Ht.push('<li id="ico_nquan" style="display:block;">');
	Ht.push(    '<div class="ico_button nquan-css">\u51a0\u76ca\u4e73\u5708</div>');
	Ht.push('</li>');	button_span = $$D.insert($$O("ico_msg"), Ht.join(""), 'afterend');
	var __openNQuanWindow = function(e){
		im_openWebchatWindow("2000000", "\u51a0\u76ca\u4e73\u5708", null, 1, 'nquan');
	};
	button = NtUtil.$$(".ico_button", button_span)[0];
	$$E.addEvent(button, "click", __openNQuanWindow);
    $$E.addEvent(button, "mouseover", IMToolBar.onOverEvent);
    $$E.addEvent(button, "mouseout",  IMToolBar.onOverEvent);
    IMToolBar.updateToolbar();
}
_p.onLeft = function(){
    var Element= NtUtil.$('windows_area');
    var _sLeft = Element.scrollLeft;
    if(IMToolBar.minWinCount*IMToolBar.minChatWidth - _sLeft > IMToolBar._viewRect.w){
        IMAnimate.animate(Element, "scrollLeft", {start:_sLeft,end:_sLeft+IMToolBar.minChatWidth,step:22}, function(){
            IMToolBar.initScroll();
        }, null, true);
    }
};
_p.onRight = function(){
    var Element= NtUtil.$('windows_area');
    var _sLeft = Element.scrollLeft;
    IMAnimate.animate(Element, "scrollLeft", {start:_sLeft,end:_sLeft-IMToolBar.minChatWidth,step:-22}, function(){
        IMToolBar.initScroll();
    }, null, true);
};
_p.initScroll = function(){
    var Element= NtUtil.$('windows_area');
    var _sLeft = Element.scrollLeft;
    if(IMToolBar.minWinCount*IMToolBar.minChatWidth <= IMToolBar._viewRect.w){
        $$D.replaceClass(NtUtil.$('ico_pre') , "pre_enable" ,  "pre_disable");
        $$D.replaceClass(NtUtil.$('ico_next'), "next_enable",  "next_disable");
    }else{
        if(_sLeft > 0 ){
            $$D.replaceClass(NtUtil.$('ico_next'),  "next_disable", "next_enable");
        }else{
            $$D.replaceClass(NtUtil.$('ico_next'), "next_enable",  "next_disable");
        }
        if(IMToolBar.minWinCount*IMToolBar.minChatWidth - _sLeft > IMToolBar._viewRect.w){
            $$D.replaceClass(NtUtil.$('ico_pre'),  "pre_disable", "pre_enable");
        }else{
            $$D.replaceClass(NtUtil.$('ico_pre'), "pre_enable",  "pre_disable");
        }
    }
};_p.initSystemMessage = function(){
	var _this = this;
	var __viewSystemMessage = function(target){_this.viewSystemMessage(target);};
	var __viewNoneSystemMessage = function(){
		_this.addSystemMessage('0', '', gLang.tb_notMessage, 0, '', '', 'null');
		_this._systemMessageMenu.show();
	};
	var __visibleCallFunction = function(ul){
		_this.customSystemMessage(ul);
		$$D.insert(ul, '<div class="bot_line"></div>', 'afterend');
		_this.Mutex('system');
	    $$D.css($$O("TOOLBARTIPico_msg"), "display", "none");
	};
	this._systemMessageMenu = _SM = new NtMenu();
	_SM.init(
		$$O('ico_msg'), 
		$$D.filter($$O('ico_msg').childNodes)[0],
		{tagName:'div', id:'Nt-SYSTEM-MENU',className:'ntalkermenu',style:'display:block'},
		{className:'hover'},
		{className:''},
		{callback:__viewSystemMessage},
		__viewNoneSystemMessage,
		__visibleCallFunction
	);	this.updateCustomSystemMessage();
}
_p.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 = '(' + _C + ')';
}
_p.customSystemMessage = function(ul){
	var _C = 0, _systemMessage = this._systemMessageMenu, _ExtMsg = Ntalker.variable.ExMsg, _Ht = [];	_systemMessage.remove('null0');
	for(var i=0; i<_ExtMsg.length; i++){
        _Ht.push('<LI onclick="IMToolBar.viewCurstomSystemMessage(\'' + _ExtMsg[i].url + '\');" class="act nomsg" 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');
	_Count = _systemMessage._Hash.count();
	_Count = _systemMessage.get('null0') && _Count==1 ? 0 : _Count;
	_Count = parseInt(_Count) + parseInt(_C);
	_systemMessage._Button.innerHTML = '(' + _Count + ')';
}
_p.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);
}
_p.viewSystemMessage = function(target){
	var _systemMessage = this._systemMessageMenu, _Count, 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');
        	this.removeSystemMessage("group" + notifyWnd.destuid);
        	break;
        case "null":
        	return;
        	break;
        default://alert
        	notifyWnd.BtnType = "alert";
        	objNotify.add(notifyWnd._curNotifyId, notifyWnd);
        	break;
	}
	_Count = _systemMessage._Hash.count();
	_Count += this._customMessageCount;
	_systemMessage._Button.innerHTML = '(' + _Count + ')';
}
_p.addSystemMessage = function(destuid, destname, message, chatid, headURL, content, type, srcuid, srcnick, chatType){
	var _systemMessage = this._systemMessageMenu, _Count;
	_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
		}
		});
	_Count = _systemMessage._Hash.count();
	_Count = _systemMessage.get('null0') && _Count==1 ? 0 : _Count;
	_Count += this._customMessageCount;
	_systemMessage._Button.innerHTML = '(' + _Count + ')';
	if( _Count > 0 ){
        this.enableflash('ico_msg', "ico_msg", "flash_msg");
    }else{
        this.disableFlash('ico_msg');
    }
};_p.removeSystemMessage = function(k){
	var _systemMessage = this._systemMessageMenu, _Count;
	_systemMessage.remove(k);
	_Count = _systemMessage._Hash.count();
	_Count += this._customMessageCount;
	_systemMessage._Button.innerHTML = '(' + _Count + ')';
}
_p.getSystemMessage = function(k){
	return this._systemMessageMenu.get(k);
}
_p.loadSystemMessage = function(){
	var _this = this, _K = Ntalker.ctKEY + Ntalker.variable.user_id, _V = NtUtil.cookie.load(_K), _Items;
    if(_V==null || _V=='') return;
    NtUtil.cookie.erase(_K);
	_Items = _V.split("|$|");
	$$A.forEach(_Items, function(Item){
		if(Item=='') return;
		try{
			var Json = eval('('+Item+')');
			if(Json){
				_this.addSystemMessage(Json.destuid, Json.destname, Json.message, Json.chatid, Json.headURL, Json.content, Json.type, Json.srcuid, Json.srcnick,json.chattype );
			}
		}catch(e){};
	});
};
_p.saveSystemMessage = function(){
	var _SM = this._systemMessageMenu, _K = Ntalker.ctKEY + Ntalker.variable.user_id, _Item, _Items = [];
	for(var k in _SM._Hash._hash){
		_Item = [];
		for(var m in _SM._Hash._hash[k]){
			if(/custom/.test(m)) continue; 
			if(_SM._Hash._hash[k][m]) _Item.push('"' + m + '":"' + (_SM._Hash._hash[k][m] ? _SM._Hash._hash[k][m] : '') + '"');
		}
		_Items.push('{' + _Item.join(',') + '}');
	}
	NtUtil.cookie.save(_K, _Items.join('|$|'));
};_p.initGroupMessage = function(){
	var _this = this;
	if( !$$O('ico_group') ){
		return;
	}
	var __viewGroupMessage = function(target){_this.viewGroupMessage(target);};
	var __viewNoneGroupMessage = function(){
		_this.onShowBuddylist(null, 2);
	};
	var __visibleCallFunction = function(ul){
		$$D.insert(ul, '<div class="bot_line"></div>', 'afterend');
		var MessageCount = _this._groupMessageMenu._Hash.count();
		_this.Mutex('group', MessageCount);
		$$D.css($$O("TOOLBARTIPico_group"), "display", "none");
	};
	this._groupMessageMenu = _GM = new NtMenu();
	_GM.init(
		$$O('ico_group'), 
		$$D.filter($$O('ico_group').childNodes)[0],
		{tagName:'div', id:'Nt-GROUP-MENU',className:'ntalkermenu',style:'display:block'},
		{className:'hover'},
		{className:''},
		{callback:__viewGroupMessage},
		__viewNoneGroupMessage,
		__visibleCallFunction
	);
}
_p.viewGroupMessage = function(target){
	var _groupMessage = this._groupMessageMenu, _Count, _groupObject, groupId, groupName;
	var k = target.getAttribute('k');
	_groupObject = _groupMessage.get(k);
	im_openWebchatWindow(_groupObject.groupid, _groupObject.groupname, null, 1, _groupObject.chattype);
	this.removeGroupMessage(k);
}
_p.addGroupMessage = function(groupId, groupName, srcuid, srcnick, msg, chattype){
	var _groupMessage = this._groupMessageMenu, _Count, _CP = Ntalker.Config.customparams;
	_groupMessage.add('group'+groupId, {
		text:groupName,
		groupid:groupId,
		groupname:groupName,		chattype:chattype});
	_Count = _groupMessage._Hash.count();
	_groupMessage._Button.innerHTML = '(' + _Count + ')';
    if(IMTipManager && !_CP['disablegrouptip'] && srcnick && msg){
    	try{
    		var groupdisplay = $$D.css($$O("ico_group"), "display");
    		groupspan = groupdisplay=="none" ? "ico_zoom" : "ico_group";
    		IMTipManager.addIMTip(groupspan, [{user:srcnick,msg:msg}], {step:5, wait:0, nextwait:3000},{roomid:groupId, roomname:groupName,usercount:"-"});
    	}catch(e){}
    }
	if(_Count>0){
    	if(_CP['disablegrouptip']){
   			_groupMessage._Button.style.color = '#ff0000';
    		window.setTimeout(function(){_groupMessage._Button.style.color = '#000000';}, 1000);
    	}else{
        	this.enableflash('ico_group', "ico_group", "flash_group");
        }
    }else{
        this.disableFlash('ico_group');
    }
}
_p.removeGroupMessage = function(k){
	var _groupMessage = this._groupMessageMenu, _Count;
	_groupMessage.remove(k);
	_Count = _groupMessage._Hash.count();
	_groupMessage._Button.innerHTML = '(' + _Count + ')';
}
_p.getGroupMessage = function(k){
	this._groupMessageMenu.get(k);
}
_p.loadGroupMessage = function(){
	var _this = this, _K = Ntalker.gpKEY + Ntalker.variable.user_id, _V = NtUtil.cookie.load(_K), _Items;
    if(_V==null || _V=='') return;
    NtUtil.cookie.erase(_K);
	_Items = _V.split("|$|");
	$$A.forEach(_Items, function(Item){
		if(Item=='') return;
		try{
			var Json = eval('('+Item+')');
			if(Json){
				_this.addGroupMessage(Json.groupid, Json.groupname, '', '', '', Json.chattype);
			}
		}catch(e){};
	});
};
_p.saveGroupMessage = function(){
	var _GM = this._groupMessageMenu, _K = Ntalker.gpKEY + Ntalker.variable.user_id, _Item, _Items = [], saveMessageCount = 3;
	if( !_GM ){
		return;
	}
	for(var k in _GM._Hash._hash){
		if( saveMessageCount <= 0  ){
			break;
		}
		_Item = [];
		for(var m in _GM._Hash._hash[k]){
			if(/custom|text/.test(m)) continue; 
			if(_GM._Hash._hash[k][m]) _Item.push('"' + m + '":"' + _GM._Hash._hash[k][m] + '"');
		}
		_Items.push('{' + _Item.join(',') + '}');
		saveMessageCount--;
	}
	NtUtil.cookie.save(_K, _Items.join('|$|'));
}function NtTopTbar(){
	this.element     = null;	this.buddylistSpanId = "buddylistSpan";
	this.chatwinID   = "topchatwindow";
	NtBaseTbar.prototype.constructor();
    this.cache_add    = NtBaseTbar.prototype.add;
    this.cache_remove = NtBaseTbar.prototype.remove;
}
NtTopTbar.prototype = new NtBaseTbar();
_p = NtTopTbar.prototype;
_p.init = function(span){
	var htmls = [];
    var sessionid   = Ntalker.variable.user_sid;
    var enablegroup = Ntalker.Config.customparams['enablegroup'];
    var enableroom  = Ntalker.Config.customparams['enableroom'];
	var b,bt,c,ct,s;
	this.element         = span;	ul = $$D.create('ul', {id:'NtalkerUL',style:'margin:0;padding:0;list-style:none;'}, span);
	htmls.push('<li id="ico_buddylist">');
    htmls.push(    '<div id="buddylist_span" class="ico_button">(0)</div>');
    htmls.push(    '<div id="buddylist_tab" class="buddylist_tab"></div>');
    htmls.push('</li>');
    if( enablegroup || enableroom ){
        htmls.push('<li id="ico_group" class="ico_group">');
        htmls.push(    '<div class="ico_button">(0)</div>');
        htmls.push(    '<div id="group_tab" class="buddylist_tab"></div>');
        htmls.push('</li>');
    }
    htmls.push('<li id="ico_msg" class="ico_msg">');
    htmls.push(    '<div class="ico_button">(0)</div>');
    htmls.push('</li>');
    ul.innerHTML = htmls.join('');
	var btnbuddylist = NtUtil.$$(" div", $$O('ico_buddylist'))[0] || $$O('ico_buddylist');
	var btnmsg = NtUtil.$$(" div", $$O('ico_msg'))[0] || $$O('ico_msg');
	var btngroup = NtUtil.$$(" div", $$O('ico_group'))[0] || $$O('ico_group');
	var _this= this;
	$$A.forEach([btnbuddylist, btngroup, btnmsg], function(_Button){
		$$E.addEvent(_Button, "mouseover", _this.onOverEvent);
		$$E.addEvent(_Button, "mouseout",  _this.onOverEvent);
	});
	$$E.addEvent(btnbuddylist, "click", _this.onShowBuddylist);	this.initSystemMessage();	this.initGroupMessage();
	if( sessionid=='NtalkerGuestUserSessionID' ){
		$$D.css(NtUtil.$('ico_buddylist'), "display", "none");
        $$D.css(NtUtil.$('ico_msg'),       "display", "none");
        if($$O('ico_nquan')) $$D.css($$O('ico_nquan'),     "display", "none");
	}
};
_p.add = function(uid, name, src, isAutoFocus, type, customModel){
	return;
}
_p.remove = function(uid, type){
	return;
	this.cache_remove(uid, type);
	var Num = this.minWinCount + 0;
}
_p.hiddenChatWind = function(){
	var chatWins = im_chat_window_manager._chatWndsArray, l = chatWins.length;
	for(var i=0; i<l; i++)
    	chatWins[i].hide();
}
_p.showMenu = function(menuId, type){
	var Menu = NtUtil.$(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";
}
_p.updateUserNumber = function(onlineUser, totalUser){
    if(NtUtil.$("buddylist_span")) {
    	var buddyText = gLang.tb_BuddyListButton_text;
        NtUtil.$("buddylist_span").innerHTML = sprintf(buddyText, String(onlineUser), String(totalUser) );
    }
};
_p.onOverEvent = function(ev, nodeName){
    var current,btn,t;
    if(nodeName && NtUtil.$(nodeName)){
        btn = NtUtil.$(nodeName);
    }else{
        current = ev.currentTarget || window.event.srcElement;
        btn     = current.parentNode;
        if(!current.parentNode.id) btn = btn.parentNode;
    }
    t = gLang.tip;
    for(var k in t){
        if(btn.id && k == btn.id){
        	var effectsBtn = NtUtil.$$(".ico_button", NtUtil.$(k))[0];
            if(  ( (ev&&ev.type=="mouseover") || nodeName) ){
            	if(effectsBtn) $$D.addClass(effectsBtn, "hover");
            }else{
            	if(effectsBtn) $$D.removeClass(effectsBtn, "hover", "");
            }
            return;
        }
    }
}_p.initSystemMessage = function(){
	var _this = this;
	var __viewSystemMessage = function(target){_this.viewSystemMessage(target);};
	var __viewNoneSystemMessage = function(){
		_this.addSystemMessage('0', '', gLang.tb_notMessage, 0, '', '', 'null');
		_this._systemMessageMenu.show();
	};
	var __visibleCallFunction = function(ul){
		_this.customSystemMessage(ul);
		$$D.insert(ul, '<div class="bot_line"></div>', 'afterend');
		_this.Mutex('system');
	};
	this._systemMessageMenu = _SM = new NtMenu();
	_SM.init(
		$$O('ico_msg'), 
		$$D.filter($$O('ico_msg').childNodes)[0],
		{tagName:'div', id:'Nt-SYSTEM-MENU',className:'ntalkermenu',style:'display:block'},
		{className:''},
		{className:''},
		{callback:__viewSystemMessage},
		__viewNoneSystemMessage,
		__visibleCallFunction
	);	this.updateCustomSystemMessage();
}
_p.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 = '(' + _C + ')';
}
_p.customSystemMessage = function(ul){
	var _C = 0, _systemMessage = this._systemMessageMenu, _ExtMsg = Ntalker.variable.ExMsg, _Ht = [];	_systemMessage.remove('null0');
	for(var i=0; i<_ExtMsg.length; i++){
        _Ht.push('<LI onclick="IMToolBar.viewCurstomSystemMessage(\'' + _ExtMsg[i].url + '\');" class="act nomsg" 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');
	_Count = _systemMessage._Hash.count();
	_Count = _systemMessage.get('null0') && _Count==1 ? 0 : _Count;
	_Count = parseInt(_Count) + parseInt(_C);
	_systemMessage._Button.innerHTML = '(' + _Count + ')';
}
_p.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);
}
_p.viewSystemMessage = function(target){
	var _systemMessage = this._systemMessageMenu, _Count, 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');
        	this.removeSystemMessage("group" + notifyWnd.destuid);
        	break;
        case "null":
        	return;
        	break;
        default://alert
        	notifyWnd.BtnType = "alert";
        	objNotify.add(notifyWnd._curNotifyId, notifyWnd);
        	break;
	}
	_Count = _systemMessage._Hash.count();
	_Count += this._customMessageCount;
	_systemMessage._Button.innerHTML = '(' + _Count + ')';
}
_p.addSystemMessage = function(destuid, destname, message, chatid, headURL, content, type, srcuid, srcnick, chatType){
	var _systemMessage = this._systemMessageMenu, _Count;
	_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
		}
		});
	_Count = _systemMessage._Hash.count();
	_Count = _systemMessage.get('null0') && _Count==1 ? 0 : _Count;
	_Count += this._customMessageCount;
	_systemMessage._Button.innerHTML = '(' + _Count + ')';
	if( _Count > 0 ){
        this.enableflash('ico_msg', "ico_msg", "flash_msg");
    }else{
        this.disableFlash('ico_msg');
    }
};_p.removeSystemMessage = function(k){
	var _systemMessage = this._systemMessageMenu, _Count;
	_systemMessage.remove(k);
	_Count = _systemMessage._Hash.count();
	_Count += this._customMessageCount;
	_systemMessage._Button.innerHTML = '(' + _Count + ')';
}
_p.getSystemMessage = function(k){
	return this._systemMessageMenu.get(k);
}
_p.loadSystemMessage = function(){
	var _this = this, _K = Ntalker.ctKEY + Ntalker.variable.user_id, _V = NtUtil.cookie.load(_K), _Items;
    if(_V==null || _V=='') return;
    NtUtil.cookie.erase(_K);
	_Items = _V.split("|$|");
	$$A.forEach(_Items, function(Item){
		if(Item=='') return;
		try{
			var Json = eval('('+Item+')');
			if(Json){
				_this.addSystemMessage(Json.destuid, Json.destname, Json.message, Json.chatid, Json.headURL, Json.content, Json.type, Json.srcuid, Json.srcnick,json.chattype );
			}
		}catch(e){};
	});
};
_p.saveSystemMessage = function(){
	var _SM = this._systemMessageMenu, _K = Ntalker.ctKEY + Ntalker.variable.user_id, _Item, _Items = [];
	for(var k in _SM._Hash._hash){
		_Item = [];
		for(var m in _SM._Hash._hash[k]){
			if(/custom/.test(m)) continue; 
			if(_SM._Hash._hash[k][m]) _Item.push('"' + m + '":"' + (_SM._Hash._hash[k][m] ? _SM._Hash._hash[k][m] : '') + '"');
		}
		_Items.push('{' + _Item.join(',') + '}');
	}
	NtUtil.cookie.save(_K, _Items.join('|$|'));
};_p.initGroupMessage = function(){
	var _this = this;
	if( !$$O('ico_group') )
		return;
	var __viewGroupMessage = function(target){_this.viewGroupMessage(target);};
	var __viewNoneGroupMessage = function(){
		_this.onShowBuddylist(null, 2);
	};
	var __visibleCallFunction = function(ul){
		$$D.insert(ul, '<div class="bot_line"></div>', 'afterend');
		var MessageCount = _this._groupMessageMenu._Hash.count();
		_this.Mutex('group', MessageCount);
	};
	this._groupMessageMenu = _GM = new NtMenu();
	_GM.init(
		$$O('ico_group'), 
		$$D.filter($$O('ico_group').childNodes)[0],
		{tagName:'div', id:'Nt-GROUP-MENU',className:'ntalkermenu',style:'display:block'},
		{className:''},
		{className:''},
		{callback:__viewGroupMessage},
		__viewNoneGroupMessage,
		__visibleCallFunction
	);
}
_p.viewGroupMessage = function(target){
	var _groupMessage = this._groupMessageMenu, _Count, _groupObject, groupId, groupName;
	var k = target.getAttribute('k');
	_groupObject = _groupMessage.get(k);
	im_openWebchatWindow(_groupObject.groupid, _groupObject.groupname, null, 1, _groupObject.chattype);
	this.removeGroupMessage(k);
}
_p.addGroupMessage = function(groupId, groupName, srcuid, srcnick, msg, chattype){
	var _groupMessage = this._groupMessageMenu, _Count, _CP = Ntalker.Config.customparams;
	_groupMessage.add('group'+groupId, {
		text:groupName,
		groupid:groupId,
		groupname:groupName,		chattype:chattype});
	_Count = _groupMessage._Hash.count();
	_groupMessage._Button.innerHTML = '(' + _Count + ')';
	if(_Count>0){
    	if(_CP['disablegrouptip']){
   			_groupMessage._Button.style.color = '#ff0000';
    		window.setTimeout(function(){_groupMessage._Button.style.color = '#000000';}, 1000);
    	}else{
        	this.enableflash('ico_group', "ico_group", "flash_group");
        }
    }else{
        this.disableFlash('ico_group');
    }
}
_p.removeGroupMessage = function(k){
	var _groupMessage = this._groupMessageMenu, _Count;
	_groupMessage.remove(k);
	_Count = _groupMessage._Hash.count();
	_groupMessage._Button.innerHTML = '(' + _Count + ')';
}
_p.getGroupMessage = function(k){
	this._groupMessageMenu.get(k);
}
_p.loadGroupMessage = function(){
	var _this = this, _K = Ntalker.gpKEY + Ntalker.variable.user_id, _V = NtUtil.cookie.load(_K), _Items;
    if(_V==null || _V=='') return;
    NtUtil.cookie.erase(_K);
	_Items = _V.split("|$|");
	$$A.forEach(_Items, function(Item){
		if(Item=='') return;
		try{
			var Json = eval('('+Item+')');
			if(Json){
				_this.addGroupMessage(Json.groupid, Json.groupname, '', '', '', Json.chattype );
			}
		}catch(e){};
	});
};
_p.saveGroupMessage = function(){
	var _GM = this._groupMessageMenu, 
		_K = Ntalker.gpKEY + Ntalker.variable.user_id, 
		_Item, _Items = [],
		saveMessageCount = 3;
	for(var k in _GM._Hash._hash){
		if( saveMessageCount <= 0  ){
			break;
		}
		_Item = [];
		for(var m in _GM._Hash._hash[k]){
			if(/custom|text/.test(m)) continue; 
			if(_GM._Hash._hash[k][m]) _Item.push('"' + m + '":"' + _GM._Hash._hash[k][m] + '"');
		}
		_Items.push('{' + _Item.join(',') + '}');
		saveMessageCount--;
	}
	NtUtil.cookie.save(_K, _Items.join('|$|'));
}function fIM_onPresenceReceiveSysMessage(msg){
	var _M = msg, _Index = _M.indexOf('ntalker://'), _JSON;
	if( _Index == -1 ){	}else{		try{
			_Message = _M.substring(0, _Index);
			_JSON = eval('(' + _M.substr(_Index+10) + ')');
			_Message = _Message ? _Message : _JSON.name;
			switch(_JSON.type)
			{
				case "nquan":
					IMToolBar.addSystemMessage(_JSON.id, _JSON.name, _Message, 0, _JSON.logourl, '', 'alert', '','','nquan');
					break;
				case "group":
					break;
				case "chatroom":
					break;
				case "chat":
					break;
			}
		}catch(e){}
	}
}
function fIM_updateUserHead(uid, src, intStatus, ct){
    IMAnimate.timer(function(){
        var miniWin = IMToolBar.get(uid, IMToolBar.type(ct));
        if(miniWin) miniWin.updateUserHead(src, intStatus);
    }, 50);
}
function fIM_updateUserStatus(statusValue,message){
    IMAnimate.timer(function(){
        if(statusValue>0 && statusValue<=4){
            im_openHistoryChatWindow();            if(Ntalker.Config.customparams['enablehot'] && false){
                var hotserver = Ntalker.temp.hotserver;
                Ntalker.temp.statusValue = true;
                var serverkey = Ntalker.openHotKEY+Ntalker.variable.user_id+"_ck";
                var checkKey  = NtUtil.cookie.load(serverkey);
                if( (checkKey=="" || checkKey==null || typeof(checkKey)=="undefined") && Ntalker.temp.versionValue){
                    NtUtil.cookie.save(serverkey, "1", 2*60*60);
                    $$C.script(hotserver);
                }else if(checkKey=="1"){
                    sIM_checkCreateHot("1", "N");
                }
            }
        }
    }, 50);
}
function fIM_updateUserNumber(onlineUser, totalUser){
    IMAnimate.timer(function(){
    	if(IMToolBar && IMToolBar.updateUserNumber){
	        IMToolBar.updateUserNumber(onlineUser, totalUser);
	        if(Ntalker.Config.isPopupWindow==1 && Ntalker.temp.OpenBuddyListWindow != true){
	            Ntalker.temp.OpenBuddyListWindow = true;
	            im_openBuddyListWindow(true);
	        }
        }
    }, 50);
}
var im_sendOpenChatWindowList = [];
function fIM_hiddenToolBar(){
    if(Ntalker.Config.isPopupWindow==1) return;
    var chatWins = im_chat_window_manager._chatWndsArray;
    if(Ntalker.variable.user_id && im_chat_window_manager && chatWins.length>0){
        im_sendOpenChatWindowList = [];
        for(var i=0; i<chatWins.length; i++){
            im_sendOpenChatWindowList.push([chatWins[i]._destuid, chatWins[i]._destnick, null, chatWins[i]._chatType]);
        }
        NtUtil.$("impresenceflash").runJSFunction("fIM_openPopupChatWindow", im_sendOpenChatWindowList, -1);
    }
    fIM_CloseIMWindow();
    im_chat_window_manager.closeAll();
    if(IMToolBar && IMToolBar.hidden) IMToolBar.hidden();
}
function fIM_visibleToolBar(){
    if( (NtUtil.cookie.load(Ntalker.tbClosedKEY)=="1" || (!Ntalker.Config.customparams['enablegroup'] && !Ntalker.Config.customparams['enableroom'] && !Ntalker.Config.customparams['enablehot'])) && Ntalker.variable.user_sid=='NtalkerGuestUserSessionID' )
        return;
    if(IMToolBar && IMToolBar.visible) IMToolBar.visible();
}
function fIM_openPopupChatWindow(arrWin, OpenType){
    if(Ntalker.Config.isPopupWindow==0) return;
    IMAnimate.timer(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 = NtUtil.$('impresenceflash');
    if(impresenceflash && impresenceflash.runJSFunction){
        impresenceflash.runJSFunction("fIM_disconnect");
    }
}
function fIM_disconnect(){
    var impresenceflash = NtUtil.$('impresenceflash');
    if(impresenceflash && impresenceflash.disconnect){
        impresenceflash.disconnect();
    }
}
function im_openHistoryChatWindow(){
    if(Ntalker.variable.openHistoryWindow) return;
    Ntalker.variable.openHistoryWindow = true;
	if(IMToolBar){
    	if(IMToolBar.loadSystemMessage)IMToolBar.loadSystemMessage();
    	if(IMToolBar.loadGroupMessage) IMToolBar.loadGroupMessage();
    }
    var k = Ntalker.unKey + Ntalker.variable.user_id;
    var v = NtUtil.cookie.load(k);
    NtUtil.cookie.erase(k);
    if(!v) return;
    var curid = 0,curtype = "chat";
    v = v.replace(/{/g, "").split("}");
    for(var k in v){
        if(!v[k]) continue; 
        if(IMToolBar && IMToolBar.onMaximize && IMToolBar._Pattern==1){
        	IMToolBar.onMaximize();
        }
        chatWindow = $$S.toArray(v[k]);
        if(typeof(chatWindow)=='undefined'|| !chatWindow) continue; 
        im_openWebchatWindow(chatWindow["uid"], chatWindow["nick"], null, -1, chatWindow["type"]);
        Ntalker.variable.onlineChat -= 1;
        if(chatWindow["current"]=="default"){
            curid = chatWindow["uid"];
            curtype = chatWindow["type"];
        }
    }
    if(im_chat_window_manager && Ntalker.Config.layout!='cascade'){        im_chat_window_manager.OnTBFocusWindow(0);
    }
}
function im_onUnload(){
	var user_id = Ntalker.variable.user_id;
    var _presenceFlashGoUrl = Ntalker.temp.presenceFlashGoUrl;
    var chatWins = im_chat_window_manager._chatWndsArray;
    var v = "";
    if(user_id && im_chat_window_manager && chatWins.length>0 && Ntalker.Config.isPopupWindow==0 ){
        for(var i=0; i<chatWins.length; i++){
            if(/group|chat|nquan/.test(chatWins[i]._chatType) && chatWins[i]._isFlashLoadSuccess){
            	v += "{uid:" + chatWins[i]._destuid+";nick:"+chatWins[i]._destnick+";type:"+chatWins[i]._chatType+";current:"+chatWins[i]._curWindMode+";}";
            }
        }
        if(v){
        	NtUtil.cookie.save(Ntalker.unKey+user_id, v);
        }
    }
    var flashobj = NtUtil.$('impresenceflash');
    if(flashobj){
        if(flashobj.closePresence) flashobj.closePresence();
        NtUtil.disposeFlashObj(flashobj);
        flashobj.parentNode.removeChild(flashobj);
    }
    if(IMToolBar){
    	if(IMToolBar.saveSystemMessage) IMToolBar.saveSystemMessage();
    	if(IMToolBar.saveGroupMessage)IMToolBar.saveGroupMessage();
    }
    if(_presenceFlashGoUrl) $$C.script(_presenceFlashGoUrl);
    if(im_chat_window_manager) im_chat_window_manager.closeAll();
    if(im_myIMWindow) im_myIMWindow.close();
}
function startGetMyIMStatus(imStatusUrl){
  if(imStatusUrl && Ntalker.variable.user_id)
    $$C.script(imStatusUrl+"?query=onlinenum&sitid="+Ntalker.variable.siteid+"&uid="+Ntalker.variable.user_id+"&imsid="+Ntalker.variable.imsid);
}
function im_runPresenceStart() {
    var flashServersText = null,_cfg = Ntalker.Config,_var = Ntalker.variable;
    $$E.addEvent(window, "unload", im_onUnload);
    wdkApplication = new WDK_IM_PACK.Application();
    wdkApplication.init();
    NotifyManager.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", NtUtil.$("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]);
    }
}
function im_conncetChatRoom(roomid, roomname)
{
    if( !roomid || !roomname || Ntalker.room.exec) return;
    var presenceFlash = NtUtil.$("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 = NtUtil.$("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|bbshot|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; };
_p = PromptWindow.prototype;
_p.init = function(){
    var _this = this;
    function _handleFocus(e){
        _this.handleFocus(e);
    }
    function _handleBlur(e){
        _this.handleBlur(e);
    }
    if($$B.ie){
        document.attachEvent("onfocusin", _handleFocus);
        document.attachEvent("onfocusout", _handleBlur);
    }
    $$E.addEvent(window, 'focus', _handleFocus);
    $$E.addEvent(window, 'blur', _handleBlur);
};
_p.dispose = function(){
};
_p.handleFocus = function(e){
    this.isfocus = true;
    var presenceFlash = $$O("impresenceflash");
    if(presenceFlash && presenceFlash.setPageFocus)
        presenceFlash.setPageFocus(true);
    if(this.autostop)
        this.stopPrompt();
}
_p.handleBlur = function(e){
    var newvar = 1;
    this.isfocus = false;
    var presenceFlash = $$O("impresenceflash");
    if(presenceFlash && presenceFlash.setPageFocus)
        presenceFlash.setPageFocus(false);
}
_p.startPrompt = function(destnick, proMsg, autostop){
    if(this.isprompting || this.isfocus)
        return;
    if(proMsg && proMsg.length>0){
    	this.promptMsg = sprintf(gLang.w_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+=gLang.zhBlank;
        }
        this.promptMsg2 = sprintf(gLang.w_promptTitle, this.promptMsg2, proMsg, this.originTitle);
    }
    var impresenceflash = document.getElementById('impresenceflash');
    if(impresenceflash && impresenceflash.playNotifySound){
        impresenceflash.playNotifySound();
    }
    if(autostop!=null)
        this.autostop = autostop;
    _this = this;
    var _changeWindowTitle = function(){ _this.changeWindowTitle(); };
    this.timerID = window.setInterval(_changeWindowTitle, 800);
    this.isprompting = true;
}
_p.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){}
}
_p.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){}
}
var promptwindow = null;
if(typeof(promptwindow)=="undefined" || !promptwindow){
	promptwindow = new PromptWindow();
    promptwindow.init();
}function debug(string){
	if(NtUtil.$('returnString')) NtUtil.$('returnString').innerHTML += string + "<br />";
	else{
		var __scrollDebug = function(e){
	var deSpan = NtUtil.$('returnString');
	if(!deSpan) return;
	var wRt = $$D.windowRect();
	$$D.css(deSpan, 'top', (wRt.y + 250) + 'px');
};
		var reSpan = $$D.create('div', {id:"returnString", style:"position:absolute;top:250px;left:500px;height:100px;width:240px;background:#666;color:#0c0;text-align:left;"});
		reSpan.innerHTML = "<a style='font-color:#fff;' href=\"javascript:clear_debug()\">clear</a>";
		$$E.addEvent(window, "scroll", __scrollDebug);
		debug(string);
	}
}
function clear_debug(){
	if(NtUtil.$('returnString'))
	NtUtil.$('returnString').innerHTML = "<a style='font-color:#fff;' href=\"javascript:clear_debug()\">clear</a>";
}var gLang = new (function () {
this.zhBlank       = "\u3000";
this.t_userIDHead   = "guest";
this.t_userNameHead = "\u6e38\u5ba2";
this.t_sessionID    = "NtalkerGuestUserSessionID";
this.popMenus = ["\u804a\u5929","\u6211\u7684\u597d\u53cb"];
this.m_pgroupTip = ["\u6253\u5f00%1","\u70b9\u51fb\u8fdb\u5165%1\u804a\u5929"];
this.m_pageAlt  = "\u8ddf\u6211\u804a\u5929";
this.m_groupTip = "\u8bf7\u70b9\u51fb\u8fd9\u91cc\u5f00\u59cb\u7fa4\u804a";
this.m_groupUser= "\u7ba1\u7406\u5458";
this.m_expression  = "[\u8868\u60c5]";
this.m_picture     = "[\u56fe\u7247]";
this.nt_requestSession = "\u8bf7\u6c42\u4f1a\u8bdd";
this.nt_requestSession_title = "\u8bf7\u6c42\u4e0e\u60a8\u4f1a\u8bdd";
this.nt_requestAddFriends = "\u8bf7\u6c42\u52a0\u597d\u53cb";
this.nt_requestAddFriends_title = "\u8bf7\u6c42\u52a0\u4e3a\u597d\u53cb";
this.nt_AddFriends = "\u52a0\u60a8\u4e3a\u597d\u53cb";
this.nt_AddFriends_title = "\u52a0\u60a8\u4e3a\u597d\u53cb";
this.nt_online = "\u521a\u521a\u4e0a\u7ebf";
this.w_AudioSession = "\u97f3\u89c6\u9891\u4f1a\u8bdd";
this.w_VideoSession = "\u97f3\u9891\u4f1a\u8bdd";
this.w_requestSession_title = "\u8bf7\u6c42\u4e0e\u4f60 %1";
this.w_Imagetrans_title = "\u4f20\u8f93\u6587\u4ef6";
this.w_ReceiveMessage_title  = "%1 \u8bf4\uff1a%2";
this.w_popupWindow_title  = "\u804a\u5929\u7a97\u53e3";
this.w_promptTitle        = "\u3010%1\u3011%2 - %3";
this.a_createFlashFailure = "flash\u521b\u5efa\u5931\u8d25\uff0c\u8bf7\u60a8\u786e\u5b9a\u6d4f\u89c8\u5668\u8bbe\u7f6e\u5141\u8bb8\u64ad\u653eflash\uff0c\u6216\u5237\u65b0\u6d4f\u89c8\u5668\u91cd\u8bd5\uff0c\u5982\u679c\u4ecd\u7136\u4e0d\u80fd\u6b63\u5e38\u4f7f\u7528\u8bf7\u91cd\u65b0\u5b89flash\u63d2\u4ef6.";
this.a_endAudioSession    = "\u60a8\u4e0e\u5bf9\u65b9\u6b63\u5728\u8fdb\u884c\u8bed\u97f3\u4f1a\u8bdd\uff0c\u5f39\u51fa\u804a\u7a97\u5c06\u4f1a\u4e2d\u65ad\u97f3\u9891\u4f1a\u8bdd\uff0c\u60a8\u786e\u5b9a\u5417\uff1f";
this.a_endVideoSession    = "\u60a8\u4e0e\u5bf9\u65b9\u6b63\u5728\u8fdb\u884c\u97f3\u89c6\u9891\u4f1a\u8bdd\uff0c\u5f39\u51fa\u804a\u7a97\u5c06\u4f1a\u4e2d\u65ad\u97f3\u89c6\u9891\u4f1a\u8bdd\uff0c\u60a8\u786e\u5b9a\u5417\uff1f";
this.a_endFiletrans       = "\u60a8\u4e0e\u5bf9\u65b9\u6b63\u5728\u8fdb\u884c\u6587\u4ef6\u4f20\u8f93\uff0c\u5f39\u51fa\u7a97\u53e3\u5c06\u4f1a\u4e2d\u65ad\u6587\u4ef6\u4f20\u8f93\uff0c\u60a8\u786e\u5b9a\u5417\uff1f";
this.a_popupWindowFailure = "\u65e0\u6cd5\u5f39\u51fa\u7a97\u53e3\uff0c\u8bf7\u68c0\u67e5\u6d4f\u89c8\u5668\u963b\u6b62\u5f39\u51fa\u7a97\u53e3\u8bbe\u7f6e\u6216\u9632\u706b\u5899\u8bbe\u7f6e\uff01";
this.f_noInstallFlash     = "\u60a8\u672a\u5b89\u88c5Flash\u63d2\u4ef6\u6216\u7248\u672c\u8fc7\u4f4e,\u73b0\u5728\u5b89\u88c5\u6216\u5347\u7ea7.";
this.f_loadFlashFailure   = "\u8bf7\u70b9\u51fb\u6b64\u5904\u91cd\u65b0\u8fde\u63a5...";
this.notLogin   = "\u60a8\u8fd8\u6ca1\u6709\u767b\u5f55\uff0c\u8bf7\u5148\u767b\u5f55\uff01";
this.connectErr = "\u8fde\u63a5\u5931\u8d25\uff0c\u8bf7\u7a0d\u5019\u91cd\u8bd5\uff01";
this.buddylist_title  = "\u597d\u53cb\u5217\u8868";
this.buddylist_open   = "\u60a8\u5c1a\u672a\u767b\u5f55\uff0c\u8bf7\u767b\u5f55\u540e\u518d\u4f7f\u7528\u597d\u53cb\u5217\u8868\uff01";
this.buddyentry_text  = "\u5728\u7ebf\u804a\u5929";
this.buddyentry_tip   = "\u70b9\u51fb\u8fd9\u91cc\u5f00\u59cb\u804a\u5929";
this.sd_Buddylist      = "\u597d\u53cb\u5217\u8868";
this.sd_closeHotWindow = "\u5173\u95ed\u575b\u70ed\u70b9";
this.sd_closeGroupWindow = "\u5173\u95ed\u7fa4\u804a\u7a97";
this.sd_closeNQuanWindow = "\u5173\u95ed\u80fd\u5708";
this.sd_closeChatWindow  = "\u5173\u95ed\u4e00\u5bf9\u4e00\u804a\u7a97";
this.sd_eventOpen   = "\u6253\u5f00";
this.sd_eventClose  = "\u5173\u95ed";
this.sd_HotWindow   = "\u575b\u70ed\u70b9";
this.sd_GroupWindow = "\u7fa4\u804a\u7a97";
this.sd_NQuanWindow = "\u80fd\u5708";
this.sd_ChatWindow  = "\u4e00\u5bf9\u4e00\u804a\u7a97";
this.sd_eventType = ["(\u4e3b)","(\u88ab)","(\u643a)"];
this.tb_notMessage      = "\u6682\u65e0\u6d88\u606f";
this.tb_minWindow_title = "\u4e0e %1 \u5bf9\u8bdd";
this.tb_minWindow_Session = "\u8bf4 %1";
this.tb_BuddyListButton_text = "\u597d\u53cb(%1/%2)";
this.tip                  = [];
this.tip["ico_copyright"] = "Powered by %1";
this.tip["ico_group"]     = "\u7fa4\u7ec4\u6d88\u606f";
this.tip["ico_buddylist"] = "\u6253\u5f00\u597d\u53cb\u5217\u8868";
this.tip["ico_msg"]       = "\u7cfb\u7edf\u6d88\u606f";
this.tip["ico_state"]     = "\u7528\u6237\u72b6\u6001";
this.tip["ico_zoom"]      = "\u6536\u8d77\u5de5\u5177\u6761";
this.tip["cache"]         = ["\u6536\u8d77\u5de5\u5177\u6761","\u5c55\u5f00\u5de5\u5177\u6761"];
this.tip["ico_close"]     = "\u5173\u95ed\u5de5\u5177\u6761";
this.tip["ico_pre"]       = "\u5411\u53f3\u6eda\u52a8";
this.tip["ico_next"]      = "\u5411\u5de6\u6eda\u52a8";
this.tip["ico_bbshot"]    = "\u575b\u70ed\u70b9";
this.tb_connect = "\u670d\u52a1\u5668\u8fde\u63a5\u4e2d\uff0c\u8bf7\u7b49\u5f85...";
this.tb_connectFailure_Return   = "\u9a8c\u8bc1\u7528\u6237\u5931\u8d25\uff01";
this.tb_connectFailure_Message  = "\u9a8c\u8bc1\u7528\u6237\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u9875\u9762\uff01";
this.tb_InvisibleStatus_Message = "\u60a8\u5904\u4e8e\u9690\u8eab\u72b6\u6001";
})();
var IFrame_applicationId = [];function createIFrame(frameID, webChatID)
{
	IFrame_applicationId[frameID] = frameID;
	var parentID = $$O(webChatID) || document.getElementByTagName("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;
	}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){
	var frame= $$O(frameID);
	if ( !frame ) 
		return;
	var src = $$B.ie6 ? 'about:blank' : url;	var _Ht = "<iframe id='" + iframeID + "' src='"+src+"' name='"+iframeID+"' onLoad='"+embedID+"."+frameID+"_load();' frameborder='0' scrolling='no'></iframe>";
	var iframe = $$D.insert(frame, _Ht);
	if( $$B.ie6 ){
		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;
	}
}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, iframeID)
{
	var iFrameDiv = document.getElementById(frameID);
	if ( $$B.ie6 ){
		iframe = $$O(iframeID || '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}}try{X.removeChild(aa);}catch(e){}Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
var im_flashVersion = swfobject.getFlashPlayerVersion().major;
var im_installFlashActionX = im_flashVersion<9 ? true : false;
