var im_user_id = null;
var im_user_name = null;
var im_user_sid = null;
var im_userparam = null;
var im_webchatURL = "";
var im_onlineuserURL = "";
var im_thisscript_path = "";
var im_img_path = "";
var im_thisscript_serverpath = "";

var im_divY = null;
im_la = new Array();
im_ow = new Object();
im_uid_display = "";
var im_at = null;
var im_agt = navigator.userAgent.toLowerCase();
var im_appVer = navigator.appVersion.toLowerCase();
var im_is_mac = im_agt.indexOf("mac") != -1;
var im_is_safari = im_agt.indexOf("safari") != -1 && im_is_mac;
var im_is_khtml = im_is_safari || im_agt.indexOf("konqueror") != -1;
var im_is_ie = im_appVer.indexOf("msie") != -1 && im_agt.indexOf("opera") == -1 && !im_is_khtml;
var im_is_win = im_is_mac ? false : (im_agt.indexOf("win") != -1 || im_agt.indexOf("16bit") != -1);
var im_is_win_ie = im_is_win && im_is_ie;
var im_webchatFullURL = "";
var im_alwaysNotify = false;
var im_ajax = null;
var im_keeponline_url = "";
var im_presenceFlash = null;
var im_flashServers = null;
var  im_userStatusServer = null;
var im_siteid = null;
var im_presenceFlashGoUrl = null;
var im_buddylistFlashGoUrl  = null;
var im_imSid = null;
var im_btoolTipShowed = false;
var im_presence_flash_version = "2.4.4";
var im_buddylist_flash_version = "2.4.3";
var im_webchat_flash_version = "2.4.3";
var im_not_showfloat_sites = new Array("haiguinet","cnmyspace","xiaonengtest");
var im_notShowFloat = false;
var im_notify_windows = new Object();
var im_notify_manager = null;
var im_notify_id = 0;
var im_chat_window_manager = null;
var im_entry_allways_float = false;
var im_userSpanArray = null;
var im_bHaveSetFlashServers = false;
var im_resetwintop = new Array();
var	wdkApplication = null;
var	im_myIMWindow = null;
var im_enable_log = false;
var im_logger = null;
var im_font_size = '12px';
var im_font_color = '#000000';
var im_mini_logo = new Image();//好友列表入口图标
var im_title_logo = new Image();
var im_user_logo = new Image();
var im_title_text = null;
var im_useron_logo = new Image();
var im_useroff_logo = new Image();
var im_wdkUtil = null;
var im_cookietime = 900; 
var im_recreatescript_num = 0;
var im_webchat_in_page = false;
var im_alway_notify = true;
var im_cache_serverinfo = true;
var im_no_float_logo = true;
var im_no_show_popmenu = true;
var im_no_show_tooltip = true;
var im_getserver_url = "http://webim.myspace.cn/getflashserver.php";
//var im_getserver_url = null;
var im_no_show_tooltip = true;

var im_Browser = {
	uA:navigator.userAgent.toLowerCase(),
	version: (navigator.userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1]
};
if (window.ActiveXObject){
	im_Browser.IE = im_Browser.uA.match(/msie ([\d.]+)/)[1];
	im_Browser.IE56 = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE") + 5)) >= 5.5 && typeof document.body.style.maxHeight == "undefined";
}else if (document.getBoxObjectFor)
	im_Browser.Firefox = im_Browser.uA.match(/firefox\/([\d.]+)/)[1];
else if (window.MessageEvent && !document.getBoxObjectFor)
	im_Browser.Chrome = im_Browser.uA.match(/chrome\/([\d.]+)/)[1];
else if (window.opera)
	im_Browser.Opera = im_Browser.uA.match(/opera.([\d.]+)/)[1];
else if (window.openDatabase)
	im_Browser.Safari = im_Browser.uA.match(/version\/([\d.]+)/)[1];
im_Browser.boxModel = !im_Browser.IE || document.compatMode == "CSS1Compat";

function im_getIMOnlineStatus(siteid, webchaturl, onlineuserurl){
  im_siteid = siteid;
  im_webchatURL = webchaturl;
  im_onlineuserURL = onlineuserurl;
 	if(im_siteid=="tianya" || im_siteid=="tianya_v2"){
	  im_title_text = "天涯聊聊";
	  im_mini_logo.src = im_img_path + "tianya.gif";
	  im_title_logo.src = im_img_path + "tianya_s.gif";
	  im_user_logo.src = im_img_path + "tianyadefault.jpg";
	  im_useron_logo.src = im_img_path + "tianya_on.gif";
	  im_useroff_logo.src = im_img_path + "tianya_off.png";
	}
	else if(im_siteid=="cnmyspace" || im_siteid=="xiaonengtest"){ 
	  im_title_text = "聚友在线聊天";
	  im_mini_logo.src = im_img_path + "logo_mini.gif";
	  im_title_logo.src = im_img_path + "logo_xiao.gif";
	  im_user_logo.src = im_img_path + "myspace_default.jpg";
	  im_useron_logo.src = im_img_path + "mysonline.gif?v=2.42";
	  im_useroff_logo.src = im_img_path + "xnoffline.gif";
  }
	else{
	  im_title_text = "小能";
	  im_mini_logo.src = im_img_path + "logo_mini.gif";
	  im_title_logo.src = im_img_path + "logo_xiao.gif";
	  //im_user_logo.src = im_img_path + "ts_iduser.gif";
	  im_user_logo.src = im_img_path + "xndefault.gif";
	  im_useron_logo.src = im_img_path + "xnonline.gif";
	  im_useroff_logo.src = im_img_path + "xnoffline.gif";
  }
  var userStatusServer = null;
  if(im_cache_serverinfo)
    userStatusServer = im_wdkUtil.GetCookie("userstatusserver");
  if(!userStatusServer){
    var getServerUrl = im_getserver_url?im_getserver_url:(im_thisscript_path+"/func/getflashserver.php");
	  im_createScript(getServerUrl+"?siteid="+siteid+"&resulttype=2&rand="+Math.random());
  }
  else{
    im_onGetFlashServer(userStatusServer, '2', true);
  }
}
WdkUtil = function(){
    this.Domain = location.hostname;
    this.Path   = "/";
}
_p = WdkUtil.prototype;
_p.setDomain = function(domain){
    if(domain){
        var _ed     = domain.indexOf("/");
        var _len    = domain.length;
        if(_ed>=0){
            this.Domain = domain.substr(0, _ed);
            this.Path   = domain.substr(_ed, _len);
        }else{
            this.Domain = domain.substr(0, _len);
        }
    }
}
_p.SetCookie = function(name, value){
    var expdate = new Date();
    var argv = arguments;
    var argc = arguments.length;
    var expires = (argc > 2) ? argv[2] : im_cookietime;
    var path = (argc > 3) ? argv[3] : this.Path;
    var domain = (argc > 4) ? argv[4] : this.Domain;
    var secure = (argc > 5) ? argv[5] : false;
    if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
    document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
    +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
    +((secure == true) ? "; secure" : "");
}
_p.DelCookie = function(name){
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var domain = this.Domain ? this.Domain : "";
  var path = this.Path ? this.Path : "";
  var cval = this.GetCookie (name);
  document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString() +
    "; path=" + path + "; domain=" + domain;
}
_p.GetCookieVal = function(offset){
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
_p.GetCookie = function(name){
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen)
  {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return this.GetCookieVal(j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}
_p.CreateDiv = function(divid){
	var newDiv = null;
	if(document.body.insertAdjacentHTML){
		var divHtml = "<div id=\""+divid+"\"></div>"
		document.body.insertAdjacentHTML("afterBegin", divHtml);
		newDiv = document.getElementById(divid);
	}
	else if(typeof(document.body.innerHTML)!="undefined" && document.createElement && document.body.appendChild){
		var el = document.createElement("div");
	  if(el){
		  el.id = divid;
		  document.body.appendChild(el);
		  newDiv = el;
		}
	}
	return newDiv;
}
_p.EncodeSpecialChar = function(strSource){
 var stEncodeResult = strSource;
 //空字符串
 if(stEncodeResult.length==0)
   return stEncodeResult;
 //把字符串中的 "&" 字符替换成 "&amp;"
 //替换时，一定得先替换 "&" 字符，否则，会把 "<" 等编码中的 "&" 也进行替换，从而产生错误的结果
 var regExpInfo = /&/g; //利用正则表达式全局标识设置的 "&"，把该字符串中所有的 "&" 替换成 "&amp;"
 stEncodeResult = stEncodeResult.replace(regExpInfo,"＆"); 
 //把 ' 替换成 "‘" 
 regExpInfo= /'/g;
 stEncodeResult = stEncodeResult.replace(regExpInfo,"’");
 //把 " 替换成 "“" 
 regExpInfo= /"/g;
 stEncodeResult = stEncodeResult.replace(regExpInfo,"“");
 //把 < 替换成 "《" 
 regExpInfo= /</g;
 stEncodeResult = stEncodeResult.replace(regExpInfo,"《");
 //把 > 替换成 "》" 
 regExpInfo= />/g;
 stEncodeResult = stEncodeResult.replace(regExpInfo,"》");
 //把 % 替换成 "％" 
 regExpInfo= /%/g;
 stEncodeResult = stEncodeResult.replace(regExpInfo,"％");
 regExpInfo= /\\/g;
 stEncodeResult = stEncodeResult.replace(regExpInfo,"\\\\");
 return stEncodeResult;
}
_p.disposeFlashObj = function(flashObj){
	 //把 flash 暴露给 js 的所有方法清空
    if(!flashObj)
      return;
    for(var id in flashObj){
        if(typeof(flashObj[id]) == "function"){
            if(im_Browser.IE)
                eval("flashObj."+id+"=null");//清除DOM对象上面绑定的脚本对象
            else
                flashObj.removeAttribute(id);
        }
    }
};
/*---class WdkUtil end---*/
function im_initim(){
  var scriptobjs = window.document.getElementsByTagName("script");
  var scriptobj = scriptobjs[scriptobjs.length - 1];
  var scriptpath = scriptobj.getAttribute("src");
  if(scriptpath && scriptpath.length>0){
     var pos = scriptpath.lastIndexOf("/");
     if(pos>=0)
        im_thisscript_path = scriptpath.substring(0,pos);
     else
        im_thisscript_path = "";

     var pos = scriptpath.indexOf("//");
     if(pos>0){
         var pos2 = scriptpath.indexOf("/", pos+2);
         if(pos2>pos)
            im_thisscript_serverpath = scriptpath.substring(0,pos2);
     }
     else
       im_thisscript_serverpath = "";
  }
  else{
     im_thisscript_path = "";
     im_thisscript_serverpath = "";
  }
  im_img_path = im_thisscript_path+"/images/";
  im_wdkUtil = new WdkUtil();
  im_wdkUtil.setDomain("myspace.cn");
  /*var cookieVal = im_wdkUtil.GetCookie("imtest");
  if(cookieVal)
   alert(cookieVal);
 else
    im_wdkUtil.SetCookie("imtest", "oktest222");*/
  
}
_p.Event = {
    listEvents: [],
    addEvent: function( obj, type, fn ) {
        if (obj.addEventListener) {
            obj.addEventListener( type, fn, false );
            this.listEvents.push(arguments);
        }
        else{
            obj.attachEvent( "on"+type, fn);
            this.listEvents.push(arguments);
        }
    },
    removeEvent: function( obj, type, fn ){
        if( obj.removeEventListener ){
            obj.removeEventListener(type, fn, false);
        }
        else{
            obj.detachEvent("on"+type, fn) ;
        }
    },
    flush : function(){
        var i, item;
        for(i = this.listEvents.length - 1; i >= 0; i = i - 1){
            item = this.listEvents[i];
            if(item[0].removeEventListener){
                item[0].removeEventListener(item[1], item[2], item[3]);
            };
            if(item[1].substring(0, 2) != "on"){
                item[1] = "on" + item[1];
            };
            if(item[0].detachEvent){
                item[0].detachEvent(item[1], item[2]);
            };
            item[0][item[1]] = null;
        };
    }
};
im_initim();
function im_createScript(scriptSrc){
	/*if(im_Browser.IE && document.readyState!="complete"){//?测试
    document.write('<script type="text/javascript" src="'+scriptSrc+'"></script>');
	}*/
	//else{
    var script = window.document.createElement("script");
  	document.getElementsByTagName("HEAD")[0].appendChild(script);
  	script.type = "text/javascript";
  	script.src = scriptSrc;
	//}
}
function im_onGetFlashServer(responseText, type, iscookievalue){
	 if(responseText=="-1" || responseText=="-2")
	    return;

   if(type=="2"){
     im_userStatusServer = responseText;
	 if(typeof(iscookievalue)=="undefined" || !iscookievalue)//从服务器端返回的数据才写cookie
	   im_wdkUtil.SetCookie("userstatusserver", im_userStatusServer, im_cookietime);
     StartGetUsersStatus(im_userStatusServer);
   }
   else if(type=="1"){
     im_presenceFlash =  document.getElementById("impresenceflash");
	 im_flashServers = responseText.split(",");
	 if(typeof(iscookievalue)=="undefined" || !iscookievalue)//从服务器端返回的数据才写cookie
	   im_wdkUtil.SetCookie("flashservers", responseText, im_cookietime);
	 //startGetMyIMStatus(im_flashServers[8]);
	 setFlashServerToPresence();
   }
}
function StartGetUsersStatus(userStatusServer){
	statusSpans = document.getElementsByTagName("SPAN");
  spanindex = 0;

  im_userSpanArray = new Array();
  var userStatusUrl = userStatusServer+"?result=js&sitid="+im_siteid+"&uids=";
  for(i=0; i<statusSpans.length; i++){
    statusSpan = statusSpans[i];
  	if(statusSpan.className=="wdk_user_status_span" && statusSpan.id){
  	  pos = statusSpan.id.indexOf("wdk_user_");
      if(pos>=0){
        var newStatusObj = new Object();
   	    newStatusObj.destuid = statusSpan.id.substring(pos+"wdk_user_".length, statusSpan.id.length);
  	 	  newStatusObj.destnick = im_wdkUtil.EncodeSpecialChar(statusSpan.title);
  	 	  newStatusObj.spanElement = statusSpan;
  	 	  im_userSpanArray.push(newStatusObj);
  	 	  if(im_userSpanArray.length>1)
  	 	    userStatusUrl += ",";
  	 	  userStatusUrl += encodeURIComponent(newStatusObj.destuid);
  	 	 }
  	 }
  }

  //天涯专用，解析看帖页面用户链接
  var curURL = window.location.href.toLowerCase();
  var isNeedPaser = false;
  if(im_userSpanArray.length==0 && (im_siteid=="tianya" || im_siteid=="tianya_v2")){
    var allowURLList = new Array("/publicforum/content/","/techforum/content/");
    for(i=0;i<allowURLList.length;i++){
  	  if(curURL.indexOf(allowURLList[i])>=0){
  	    isNeedPaser = true;
  	    break;
  	  }
    }
  }
  if(!isNeedPaser){
    var pattern = /content.*\.asp\?/i;
    if(curURL.match(pattern))
       isNeedPaser = true;
  }

  if(isNeedPaser){
    var lnks = document.links;
    for(var i=0;i<lnks.length;i++){
      //match = lnks[i].href.match(/Listwriter\.asp\?vwriter=(.*)&?/i);
	  match = lnks[i].href.match(/Listwriter\.asp\?(vid=(.*)&)?vwriter=(.*)&?/i);
      if(typeof match != "undefined" && match){
        var chatSpan = window.document.createElement("span");
        //chatSpan.style.cssText = "padding-left:10px;";
        chatSpan.className = "wdk_user_status_span";
        chatSpan.id = "wdk_user_"+lnks[i].innerHTML;
        chatSpan.title = lnks[i].innerHTML;
        lnks[i].parentNode.appendChild(chatSpan);

        var newStatusObj = new Object();
   	    newStatusObj.destuid = lnks[i].innerHTML;
  	 	  newStatusObj.destnick = im_wdkUtil.EncodeSpecialChar(lnks[i].innerHTML);
  	 	  newStatusObj.spanElement = chatSpan;
  	 	  im_userSpanArray.push(newStatusObj);
  	 	  if(im_userSpanArray.length>1)
  	 	    userStatusUrl += ",";
  	 	  userStatusUrl += encodeURIComponent(newStatusObj.destuid);
  	 	  if(im_userSpanArray.length>60)
  	 	    break;
  	 	 }
  	 }
  }
  userStatusUrl += "&unum="+im_userSpanArray.length;
  if(im_userSpanArray.length>0)
    im_createScript(userStatusUrl);
}
//状态服务器返回脚本调用，传递用户列表状态值，用户状态值以,分开，每个值0代表离线，1代表在线
function im_onGetUserStatus(responseText){
  if(responseText=="-1" || responseText=="-2")
	    return;
  userStatusArray = responseText.split(",");

  for(i=0;i<im_userSpanArray.length;i++){
    var imgsrc;
    switch(userStatusArray[i]){
      case "0":
        imgsrc = im_useroff_logo.src;
        break;
      case "1":
        imgsrc = im_useron_logo.src;
        break;
    }
    if((im_siteid=="cnmyspace" || im_siteid=="xiaonengtest") && userStatusArray[i]==0)
       continue;
       
    alttext="跟我聊天";
  	chatLinkStr =  "<a  href=\"#\" target=\"_blank\" style=\"display:inline;padding:0px; overflow:visible;\" alt=\""+alttext+"\" onClick=\"javascript: im_openWebchatWindow('"+im_userSpanArray[i].destuid+"', '"+im_userSpanArray[i].destnick+"'); return false;\"";
  	if(!im_no_show_popmenu)
  	  chatLinkStr += "onmouseover=\"im_popMenu(this,'"+im_userSpanArray[i].destuid+"','"+im_userSpanArray[i].destnick+"');\" onmouseout=\"im_beginCloseMenu(this);\"";
  	chatLinkStr += "><img name=\"wdk_presence_image\"";
  	if(i==0){
  		chatLinkStr += " tip=\"点击这里开始聊天\" style=\"left:0px;top:0px;\"";
  		if(!im_no_show_tooltip)
  		   chatLinkStr += " onload=\"im_showTip('wdk_presence_"+im_userSpanArray[i].destuid+"')\" ";
  	}
  	
  	chatLinkStr += " id=\"wdk_presence_"+im_userSpanArray[i].destuid+"\" border=\"0\" style=\"display:inline\" src=\""+imgsrc+"\" />";
    chatLinkStr += "</a>";
 
    im_userSpanArray[i].spanElement.innerHTML = chatLinkStr;
    im_userSpanArray[i].spanElement.title = "在线聊天";
  }
}

function im_runPresence(userparam, siteid, userid, username, sessionid, flashserver, webchatpageurl, keeponline_url, keeponline_time) {
	im_webchatURL = webchatpageurl;
	im_siteid = siteid;
	im_user_id = userid;
	im_user_name = im_wdkUtil.EncodeSpecialChar(username);
	im_user_name = username;
	im_user_sid = sessionid;
	im_userparam = userparam;
	var pageurl = "nodata";

	document.write("<div id=\"wdk_mini_state\" style=\"display:none; \"></div>");
  flashvars = '?sessionid='+encodeURIComponent(im_user_sid)+'&userid='+encodeURIComponent(im_user_id)+'&username='+encodeURIComponent(im_user_name)
    +'&siteid='+encodeURIComponent(im_siteid)+"&version="+im_presence_flash_version;
  if(im_userparam)
    flashvars += "&userparam="+encodeURIComponent(im_userparam);
  var flashurl;
  if(typeof(im_presence_path)!="undefined" && im_presence_path.length>0)
    flashurl = im_presence_path+"/impresence.swf"+flashvars;
  else
    flashurl = im_thisscript_path+"/impresence.swf"+flashvars;

	im_divY = -200;
	if (im_user_sid != "") {
		  var flashnodehtml = '<div id="im_presence_div" style=\"position:absolute; width:100px; z-index:9996; top: -200px;\">';
		  if(im_Browser.IE){
  	      flashnodehtml +=
    	      '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" \
    	  	     		  id="impresenceflash"  width="10" height="10" title="在线状态"> \
    	   			 		<param name="movie" value="'+flashurl+'" /> \
    	    		 		<param name="allowscriptaccess" value="always" /> \
    	  			</object>' ;
	  	}
	  	else{
	  			flashnodehtml +=
  	  			'<embed src="'+flashurl+
  	  			  '" id="impresenceflash" name="在线状态" width="10" height="10" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> \
  	    		</embed>';
	    }
      flashnodehtml += '</div>' ;
		  document.write(flashnodehtml);
  }
  //动态装载imchat.js
  try{
   	if(im_enable_log)
  	  im_createScript(im_thisscript_path+"/log4javascript/log4javascript.js");
  	im_createScript(im_thisscript_path+"/imchat_utf8.js?v=2.46");
  }
  catch(e){
  }

}
function presenceFlashReady(){
  setFlashServerToPresence();
  return "success";
}
function setFlashServerToPresence(){
  if(!im_flashServers || im_bHaveSetFlashServers)
	     return;

	 //im_presenceFlash = im_is_win_ie? document.getElementById("impresenceflash") : document.getElementById("impresenceflashembed");
	 im_presenceFlash = document.getElementById("impresenceflash");
   if(im_presenceFlash && im_presenceFlash.setFlashServerInfo){
      //if(im_siteid=="tianya" || im_siteid=="tianya_v2")
      //  im_presenceFlash.setFlashServerInfo(im_flashServers[0],im_flashServers[1],im_flashServers[2],im_flashServers[3],im_flashServers[4],
      //     im_flashServers[5],im_flashServers[6],im_flashServers[7],im_flashServers[8],im_flashServers[9],im_flashServers[10]);
      //else
      im_presenceFlash.setFlashServerInfo(im_flashServers[0],im_flashServers[1],im_flashServers[2],im_flashServers[3],im_flashServers[4],
         im_flashServers[5],im_flashServers[6],im_flashServers[7],im_flashServers[8]);
 	    im_bHaveSetFlashServers = true;
	 }
}

function im_openWebchatWindow(destuid, destname, chatid){
  return im_openWebchat(im_user_id, im_user_name, im_user_sid, im_siteid, destuid, destname, chatid, im_userparam, !im_webchat_in_page, im_thisscript_path);
}
function im_openBuddyListWindow(){
  if(im_myIMWindow)
    im_myIMWindow.showWindow();
  else{
    var notifystr = "%u60A8%u5C1A%u672A%u767B%u5F55%uFF0C%u8BF7%u767B%u5F55%u540E%u518D%u4F7F%u7528%u597D%u53CB%u5217%u8868%uFF01";
    alert(unescape(notifystr));
  }
}
var im_menuTimer = -1;
function im_getPosition(e) {
    var offsetX = e.offsetLeft;
    var offsetY = e.offsetTop;
		if(e.offsetParent!=null){
	    parentPos = im_getPosition(e.offsetParent);
	    offsetX += parentPos[0];
	    offsetY += parentPos[1];
	  }
	  return new Array(offsetX, offsetY);
}

function im_initPopMenu(){
	document.write("<div id='im_popMenuid' style='display:none;text-align:left;position:absolute;z-index:10001;'></div>");

	var cssTag = document.getElementById('im_popmenu_css');
  var head = document.getElementsByTagName('head').item(0);
  if(cssTag)
    return;
    //head.removeChild(cssTag);
  cssTag = document.createElement('link');
  cssTag.href = im_thisscript_path+"/impopmenu.css?v=2.5";
  cssTag.rel = 'stylesheet';
  cssTag.type = 'text/css';
  cssTag.id = 'im_popmenu_css';
  head.appendChild(cssTag);
}
im_initPopMenu();

function im_popMenu(obj, destuid, destnick){
	if(im_menuTimer>=0){
		clearTimeout(im_menuTimer);
		im_menuTimer = -1;
	  return;
	}
	var menudiv = document.getElementById('im_popMenuid');
	var pos = im_getPosition(obj);
	menux = pos[0]+obj.offsetWidth;
	menuy = pos[1];

	chatLinkStr = "<a  href=\"#\" target=\"_blank\"  style=\"overflow:visible;font-size:12px;font-weight:100;padding-left:5px;padding-top:5px;overflow:visible;\" onClick=\"javascript: im_openWebchatWindow('"+destuid+"', '"+destnick+"'); return false;\">聊天</a>";
	menuStr = "<div>" + chatLinkStr + "</div>";
	buddylistLinkStr = "<a  href=\"#\" target=\"_blank\"  style=\"overflow:visible;font-size:12px;padding:5px;font-weight:100;\" onClick=\"javascript: im_openBuddyListWindow(); return false;\">我的好友</a>";
	menuStr += "<div>"+buddylistLinkStr+"</div>";
	if(im_onlineuserURL && im_onlineuserURL.length>0){
	  onlineLinkStr = "<a  href=\""+im_onlineuserURL+"\" target=\"_blank\"  style=\"font-size:12px;font-weight:100;padding-left:5px; overflow:visible;\" >在线会员</a>";
	  menuStr += "<div>"+onlineLinkStr+"</div>";
	}

  menuStr += "</div>";
  menudiv.innerHTML = menuStr;
	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){
	im_menuTimer = setTimeout(im_closeMenu, 300);
}

function im_closeMenu(obj){
	 var menudiv = document.getElementById('im_popMenuid');
	 menudiv.style.display = 'none';
	 im_menuTimer = -1;
}

var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"&&J.parentNode){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();

Number.prototype.Timer = function(func, iT, bUrge){
	if(!this.value || bUrge)
		this.value = window.setTimeout(func, iT);
}
Number.prototype.EndTimer = function(){
	if(this.value){
		window.clearTimeout(this.value);
		this.value = 0;
	}
}
var im_flashVersion = swfobject.getFlashPlayerVersion().major;
var im_installFlashActionX = im_flashVersion<9 ? true : false;
//---------------------------------------[ToolTip]---------------------------------
var im_Config = {
	FONTCOLOR		: '#000044',
	FONTFACE		: 'Verdana,Geneva,sans-serif',
	FONTSIZE		: '8pt',
	FONTWEIGHT		: 'normal',
	TEXTALIGN		: 'left',
	PADDING			: 2,
	sPath			: im_thisscript_path + '/tip_balloon/',
	tipElements		: ['img','abbr','acronym'],
	getImg: function (){
		var asImg = ["background", "lt", "t", "rt", "r", "rb", "b", "lb", "l", "stemt", "stemb"],
		n = asImg.length,
		aImg = new Array(n),
		img;
		while(n){
			--n;
			img = aImg[n] = new Image();
			img.src = this.sPath + asImg[n] + ".gif";
		}
		return aImg;
	},
	Img:[],
	DEBUG			: true
};
im_Config.Img = im_Config.getImg();//载入图片
var Tip_Cache = {
	_xy		: [],
	_Obj	: Object,
	_Ids	: [],
	_Tips	: [],
	_Time	: [],
	_opac	: [],
	_step	: [],
	_iTimerID:[],
	//全局
	isShow	: []
};

function im_hiddenTip(e){
	if(typeof(e)=='string'){evObj = document.getElementById(e);
	}else {evObj = this;}
	var key = (typeof(e)=='string') ? e : (evObj.id ? 'imiT'+evObj.id : 'imiTToolTip');

	im_tipFade(Tip_Cache._opac[key], key, false);

	clearInterval(Tip_Cache._iTimerID[((typeof(e)=='string') ? e : evObj.id)]);
}
function im_showTip(e){
	if(typeof(e)=='string'){
		evObj = document.getElementById(e);
		im_createTip(e);
	}else{
		evObj = e;
		im_createTip(evObj.id ? evObj.id : 'ToolTip');
	}
	var key = evObj.id ? evObj.id : 'ToolTip';
	evObj.onload = null;

	Tip_Cache._Obj[key]= evObj;
	if (typeof(e)=='string'){
		Tip_Cache._xy[key] = getOffsetLeftTop(e);
		Tip_Cache._step[key] = 10;
	}else{
		Tip_Cache._xy[key] = getOffsetLeftTop(evObj.id);
	}
	Tip_Cache._Time[key][1].Timer("im__showTip('"+key+"')", 100, true);
}

//
function im__showTip(key){
	var evObj = Tip_Cache._Obj[key];
	var xy    = Tip_Cache._xy[key];
	var Tip_left  = 0;

	//Tip_Cache._Tips[key].style.width = '100px';
	Tip_Cache._Tips[key].innerHTML = im_createTipString( evObj.getAttribute('tip'), key);

	//位置
	var _y = xy.y - (Tip_Cache._Tips[key].offsetHeight+0);
	Tip_Cache._Tips[key].style.top = _y+'px';
	var bALlOOnB_obj =  getOffsetLeftTop('bALlOOnB_'+key);

	if ( parseInt(xy.w) < parseInt(xy.x + Tip_Cache._Tips[key].offsetWidth + 20) ) {
		Tip_left = parseInt(xy.x-(Tip_Cache._Tips[key].offsetWidth-20));
		Tip_Cache._Tips[key].style.left = Tip_left + 'px';
		bALlOOnB_left = document.compatMode=="BackCompat" || bALlOOnB_obj.x<Tip_left || bALlOOnB_obj.x>(Tip_left + Tip_Cache._Tips[key].offsetWidth ) ?
										(Tip_Cache._Tips[key].offsetWidth-28) + 'px' :
										(Tip_Cache._Tips[key].offsetWidth/2 -16) + 'px';
		document.getElementById('bALlOOnB_'+key).style.left = bALlOOnB_left;
	} else {
		Tip_left = xy.x;
		Tip_Cache._Tips[key].style.left = Tip_left + 'px';
		bALlOOnB_left = document.compatMode=="BackCompat" || bALlOOnB_obj.x<Tip_left || bALlOOnB_obj.x>(Tip_left + Tip_Cache._Tips[key].offsetWidth ) ?
										'0px' :
										(16 - Tip_Cache._Tips[key].offsetWidth/2) + 'px';
		document.getElementById('bALlOOnB_'+key).style.left = bALlOOnB_left;
	}

	Tip_Cache._Tips[key].style.visibility = 'visible';
	Tip_Cache._Tips[key].style.opacity = '.1';

	im_tipFade(10, key, true);
}

function im_tipFade(opac, key, exeType){
	var passed = parseInt(opac);
	if( exeType == true ){
		var newOpac = parseInt(passed+10);
		if ( newOpac <= 80 ) {
			Tip_Cache._Tips[key].style.opacity = '.'+newOpac;
			Tip_Cache._Tips[key].style.filter = "alpha(opacity:"+newOpac+")";
			Tip_Cache._Time[key][1].Timer("im_tipFade('"+newOpac+"', '"+key+"', true)",100, true);
			Tip_Cache._opac[key] = newOpac;
		}
		else {
			Tip_Cache._Time[key][1].EndTimer();
			Tip_Cache._Tips[key].style.opacity = '.80';
			Tip_Cache._Tips[key].style.filter = "alpha(opacity:80)";
			Tip_Cache._Time[key][2].Timer("im_hiddenTip('"+key+"')", 5000,true);
		}
	}else{
		var newOpac = parseInt(passed-Tip_Cache._step[key]);
		if ( newOpac >=10 ) {
			Tip_Cache._Tips[key].style.opacity = '.'+newOpac;
			Tip_Cache._Tips[key].style.filter = "alpha(opacity:"+newOpac+")";
			Tip_Cache._Time[key][1].Timer("im_tipFade('"+newOpac+"', '"+key+"', false)",50, true);
		}
		else {
			Tip_Cache._Time[key][1].EndTimer();
			Tip_Cache._Time[key][2].EndTimer();
			Tip_Cache._Tips[key].style.visibility = 'hidden';
		}
	}
}
//return create ToolTip div, Return Element Object
function im_createTip(El){
	if(im_gElt("imiT"+El)) return true;
	var im_body = (document.getElementsByTagName ? document.getElementsByTagName("body")[0]
				: (document.body || null));
	if(im_body.insertAdjacentHTML){
		im_body.insertAdjacentHTML("afterBegin", im_MkMainDivHtm("imiT"+El));
	}else if(typeof im_body.innerHTML != "undefined" && document.createElement && im_body.appendChild){
		im_body.appendChild(im_MkMainDivDom("imiT"+El));
	}
	var im_Elt = im_gElt("imiT"+El);
	if(im_Elt){
		im_Elt.style.visibility = 'hidden';
		im_Elt.style.position = 'absolute';
		im_Elt.style.zIndex = '999';

		Tip_Cache._Tips[El] = im_Elt;
		Tip_Cache._Ids[El]  = im_Elt.id;
		Tip_Cache._Time[El] = [new Number(),new Number(),new Number()];
		Tip_Cache._step[El] = 30;

		if ( El=='wdk_mini_state_img' ) {
			if(window.addEventListener){
				window.addEventListener("scroll", im_scroll, false);
				window.addEventListener("resize", im_scroll, false);
			}else{
				window.attachEvent("onscroll", im_scroll);
				window.attachEvent("onresize", im_scroll);
			}
		}
		return true;
	}return false;
}
function im_MkMainDivHtm(el){//??
	return('<div id="' + el + '"></div>' +
			(im_Browser.IE56 ? ('<iframe id="imtT' + el + 'IfRm" src="javascript:false" scrolling="no" frameborder="0" style="filter:Alpha(opacity=0);position:absolute;top:0px;left:0px;display:none;"></iframe>')
			: ''));
}
function im_MkMainDivDom(el){
	var im_Element = document.createElement("div");
	if(im_Element)
		im_Element.id = el;
	return im_Element;
}
function im_gElt(el){
	return(document.getElementById ? document.getElementById(el)
			: document.all ? document.all[el]
			: null);
}
function im_scroll(ev){
	var o = document.getElementById('wdk_mini_state_img');
	var tip = document.getElementById('imiTwdk_mini_state_img');
	if ( o ){
		var _xy = getOffsetLeftTop('wdk_mini_state_img');
		tip.style.top = parseInt(_xy.y-tip.offsetHeight) + 'px';
		tip.style.left = ( parseInt(_xy.w) < parseInt(_xy.x + tip.offsetWidth + 20) ) ?
						parseInt(_xy.x - tip.offsetWidth + 20) + 'px' :
						_xy.x + 'px';
	}
}
//return create ToolTip HTMLstring
function im_createTipString(strTip,tipID){
	sCssCrn = ' style="position:relative;width:6px;padding:0px;margin:0px;overflow:hidden;line-height:0px;';
	sVaT = 'vertical-align:top;" valign="top"';
	sVaB = 'vertical-align:bottom;" valign="bottom"';
	sCssImg = 'padding:0px;margin:0px;border:0px;';
	sImgZ = '" style="' + sCssImg + '" />';

	tt_sContent = '<table border="0" cellpadding="0" cellspacing="0" style="width:auto;padding:0px;margin:0px;left:0px;top:0px;"><tr>'
				// Left-top corner
				+ '<td' + sCssCrn + sVaB + '>'
				+ '<img src="' + im_Config.Img[1].src + '" width="6" height="6' + sImgZ
				+ '</td>'
				// Top border
				+ '<td valign="bottom" style="position:relative;padding:0px;margin:0px;overflow:hidden;">'
				+ '<img id="bALlOOnT_'+tipID+'" style="position:relative;top:1px;z-index:1;display:none;' + sCssImg + '" src="' + im_Config.Img[9].src + '" width="15" height="19" />'
				+ '<div style="position:relative;z-index:0;padding:0px;margin:0px;overflow:hidden;width:auto;height:6px;background-image:url(' + im_Config.Img[2].src + ');">'
				+ '</div>'
				+ '</td>'
				// Right-top corner
				+ '<td' + sCssCrn + sVaB + '>'
				+ '<img src="' + im_Config.Img[3].src + '" width="6" height="6' + sImgZ
				+ '</td>'
				+ '</tr><tr>'
				// Left border
				+ '<td style="position:relative;padding:0px;margin:0px;width:6px;overflow:hidden;background-image:url(' + im_Config.Img[8].src + ');">'
				// Redundant image for bugous old Geckos that won't auto-expand TD height to 100%
				+ '<img width="6" height="100%" src="' + im_Config.Img[8].src + sImgZ
				+ '</td>'
				// Content
				+ '<td id="bALlO0nBdY" style="position:relative;line-height:normal;'
				+ ';background-image:url(' + im_Config.Img[0].src + ')'
				+ ';color:' + im_Config.FONTCOLOR
				+ ';font-family:' + im_Config.FONTFACE
				+ ';font-size:' + im_Config.FONTSIZE
				+ ';font-weight:' + im_Config.FONTWEIGHT
				+ ';text-align:' + im_Config.TEXTALIGN
				+ ';padding:' + im_Config.PADDING + 'px'
				+ ';width:auto'
				+ ';">' + strTip + '</td>'
				// Right border
				+ '<td style="position:relative;padding:0px;margin:0px;width:6px;overflow:hidden;background-image:url(' + im_Config.Img[4].src + ');">'
				// Image redundancy for bugous old Geckos that won't auto-expand TD height to 100%
				+ '<img width="6" height="100%" src="' + im_Config.Img[4].src + sImgZ
				+ '</td>'
				+ '</tr><tr>'
				// Left-bottom corner
				+ '<td' + sCssCrn + sVaT + '>'
				+ '<img src="' + im_Config.Img[7].src + '" width="6" height="6' + sImgZ
				+ '</td>'
				// Bottom border
				+ '<td valign="top" style="position:relative;padding:0px;margin:0px;overflow:hidden;text-align:left;">'
				+ '<div style="position:relative;left:0px;top:0px;padding:0px;margin:0px;overflow:hidden;width:auto;height:6px;background-image:url(' + im_Config.Img[6].src + ');"></div>'
				+ '<img id="bALlOOnB_'+tipID+'" style="position:relative;top:-1px;left:0px;z-index:1;display:inline;' + sCssImg + '" src="' + im_Config.Img[10].src + '" width="15" height="19" />'
				+ '</td>'
				// Right-bottom corner
				+ '<td' + sCssCrn + sVaT + '>'
				+ '<img src="' + im_Config.Img[5].src + '" width="6" height="6' + sImgZ
				+ '</td>'
				+ '</tr></table>';
	return tt_sContent;
}

//return event [offsetX offsetY,offsetWidth,offsetHeight,screenWidth,screenHeight]
function getOffsetLeftTop(elm){
	elm = typeof(elm)=='string' ? document.getElementById(elm) : elm;

	x = getLeft(elm);
	y = getTop(elm);

	var rec = GetViewportRect();
	w_cl = im_Browser.IE ? rec.w : (rec.w-17);
	h_cl = rec.h;

	return {x:x,y:y,w:w_cl,h:h_cl};
}
//获取元素的纵坐标
function getTop(e){
	var offset=e.offsetTop;
	if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
	return offset;
}
//获取元素的横坐标
function getLeft(e){
	var offset=e.offsetLeft;
	if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
	return offset;
}

function GetViewportRect(){
  var clientbody=window.document.documentElement.clientHeight==0?window.document.body:window.document.documentElement;
  var rect = new Object();
  if(window.pageXOffset) {
      rect.x=window.pageXOffset;
  }
  else if(document.documentElement&&document.documentElement.scrollLeft) {
      rect.x=document.documentElement.scrollLeft;
  }
  else if(document.body) {
      rect.x=document.body.scrollLeft; //author: meizz
  }

  if(window.pageYOffset) {
      rect.y=window.pageYOffset;
  }
  else if(document.documentElement&&document.documentElement.scrollTop) {
      rect.y=document.documentElement.scrollTop;
  }
  else if(document.body) {
      rect.y=document.body.scrollTop;
  }

  if(window.innerWidth) {
      rect.w=window.innerWidth;
  }
  else if(document.documentElement&&document.documentElement.clientWidth) {
      rect.w=document.documentElement.clientWidth;
  }
  else if(document.body) {
      rect.w=document.body.clientWidth; //author: meizz
  }

  if(window.innerHeight) {
      rect.h=window.innerHeight;
  }
  else if(document.documentElement&&document.documentElement.clientHeight) {
      rect.h=document.documentElement.clientHeight;
  }
  else if(document.body) {
      rect.h=document.body.clientHeight;
  }
  return rect;
};
