﻿/// <reference path="jquery-vsdoc.js" /> 
/// <reference path="prototypes.js" /> 

String.prototype.getCnLen = function(){ return this.replace(/[^\x00-\xff]/g,"--").length;};
String.prototype.htmlEncode = function(){ var re = this; var q1 = [/\x26/g,/\x3C/g,/\x3E/g,/\x20/g]; var q2 = ["&amp;","&lt;","&gt;","&nbsp;"]; for(var i=0;i<q1.length;i++) re = re.replace(q1[i],q2[i]); return re;};
String.prototype.format = function() { var args = arguments; return this.replace(/{(\d{1})}/g, function() { return args[arguments[1]]; }); };
String.prototype.toDateTime = function() { var val = this.replace(/[-]/g,"/"); if (val.isDate() || val.isDateTime()) return new Date(Date.parse(val)); var r = this.match(/(\d+)/); if (r) return new Date(parseInt(r)); return new Date(val); };
String.prototype.sub = function(n,ext) { ext = ext || ''; var r = /[^\x00-\xff]/g; if(this.replace(r, "mm").length <= n) return this; var m = Math.floor(n/2); for(var i=m; i<this.length; i++) { if(this.substr(0, i).replace(r, "mm").length>=n) { return this.substr(0, i) + ext; } } return this; };
String.prototype.trim = function(){ return this.replace(/(^\s+)|(\s+$)/g,""); };
Date.prototype.format = function(fmt) { var o = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, "H+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), "S": this.getMilliseconds() }; var week = { "0": "\u65e5", "1": "\u4e00", "2": "\u4e8c", "3": "\u4e09", "4": "\u56db", "5": "\u4e94", "6": "\u516d" }; if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); }; if (/(E+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]); }; for (var k in o) { if (new RegExp("(" + k + ")").test(fmt)) { fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); }; }; return fmt; };

$.fn.destroy = function() { var d, el; if (this[0] && this[0].tagName != 'BODY') { this.each(function() { el = this; $(el).unbind(); if (livexy.isIe()) { d = d || document.createElement('div'); d.appendChild(el); d.innerHTML = ''; d.outerHTML = ''; } else { if (el.parentNode) el.parentNode.removeChild(el); }; }); }; el = d = null; };
$.fn.drag = function(obj, moveCode, downCode) { obj = obj || null; moveCode = moveCode || null; downCode = downCode || null; return this.each(function() { var draging = false; var startLeft, startTop; var startX, startY; $(this).css('cursor', 'move'); $(this).mousedown(function(event) { livexy.preventDefaults(event, true); if (downCode) downCode(); var offset = $(this).offset(); startLeft = offset.left; startTop = offset.top; startX = event.clientX; startY = event.clientY; draging = true; livexy.cancelEvent(event); }).mousemove(function(event) { if (draging == false && moveCode) moveCode(this.id); if (draging == false) return; var deltaX = event.clientX - startX; var deltaY = event.clientY - startY; var left = startLeft + deltaX; var top = startTop + deltaY; if (obj) { var m = obj.offset(); if (left < m.left) left = m.left; if (top < m.top) top = m.top; var width = obj.width() - $(this).width(); var height = obj.height() - $(this).height(); if (left > (m.left + width)) left = m.left + width; if (top > (m.top + height)) top = m.top + height; }; $(this).css('left', left + 'px').css('top', top + 'px'); }).mouseup(function(event) { draging = false; }); }); };

var livexy = { };
livexy.agent = navigator.userAgent.toLowerCase();
livexy.agentVersion = navigator.productSub;
livexy.isIe = function() { return (this.agent.indexOf("msie") != -1 && this.agent.indexOf("opera") == -1) };
livexy.isIe6 = function() { return (this.agent.indexOf("msie 6.0") != -1 && this.agent.indexOf("opera") == -1) };
livexy.isSafari = function(A) { if (A) { return this.agent.indexOf("khtml") }; return (this.agent.indexOf("khtml") != -1 && this.agent.match(/3\.\d\.\d safari/) == null); };
livexy.isOpera = function() { return this.agent.indexOf("opera") != -1 };
livexy.isMozilla = function() { return (this.agent.indexOf("gecko") != -1 && this.agentVersion >= 20030210) };
livexy.isMac = function() { return (this.agent.indexOf("macintosh") != -1) };
livexy.isCamino = function() { return (this.agent.indexOf("camino") != -1) };
livexy.isChrome = function() { return (this.agent.indexOf("chrome") != -1) };
livexy.padLeft = function (len, str) { var str2 = ''; for (var i = 0; i < len; i++) { str2 += str; }; return str2; };
livexy.getWinSize = function (obj) { obj = obj || document; var width, height; if (self.innerHeight) { width = self.innerWidth; height = self.innerHeight } else { if (obj.documentElement && obj.documentElement.clientHeight) { width = obj.documentElement.clientWidth; height = obj.documentElement.clientHeight } else { if (obj.body) { width = obj.body.clientWidth; height = obj.body.clientHeight } } } return { w: width, h: height} };
livexy.getMousePos = function(e) { var _x = 0; var _y = 0; e = e || window.event; if (e.pageX || e.pageY) { _x = e.pageX; _y = e.pageY } else { if (e.clientX || e.clientY) { _x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; _y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop } } return { x: _x, y: _y} };
livexy.getScrollTop = function() { var _top; if (document.documentElement && document.documentElement.scrollTop) { _top = document.documentElement.scrollTop } else { if (document.body) _top = document.body.scrollTop; } return _top };
livexy.addFavorite = function (url, title) { try { window.external.addFavorite(url, title); } catch (e) { try { window.sidebar.addPanel(title, url, ""); } catch (e) { alert("加入收藏失败，请使用Ctrl+D进行添加"); }; }; };
livexy.setHome = function (obj,url){ try{ obj.style.behavior='url(#default#homepage)';obj.setHomePage(url); } catch(e){ if(window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e)  { alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); }; var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage',url); }; }; };
livexy.copyToClipboard = function(txt) { if(window.clipboardData) { clipboardData.clearData(); clipboardData.setData("Text", txt); } else if(navigator.userAgent.indexOf("Opera") != -1) { window.location = txt; } else if (window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'"); }; var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); if (!clip) return;  var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); if (!trans) return; trans.addDataFlavor('text/unicode'); var str = new Object();  var len = new Object(); var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); var copytext = txt; str.data = copytext; trans.setTransferData("text/unicode",str,copytext.length*2); var clipid = Components.interfaces.nsIClipboard; if (!clip) return false; clip.setData(trans,null,clipid.kGlobalClipboard); }; }; 
livexy.chkRadioCheckByName = function(str) { var obj = document.getElementsByName(str); for (var i = 0; i < obj.length; i++) { if (obj[i].checked) { return true; }; }; return false; };
livexy.selectAllCheckBoxByName = function(str, checked) { var obj = document.getElementsByName(str); for (var i = 0; i < obj.length; i++) { obj[i].checked = checked; }; };
livexy.getCheckBoxValueByName = function(str) { var val = ""; var obj = document.getElementsByName(str); for (var i = 0; i < obj.length; i++) { if (obj[i].checked) { val = val + obj[i].value + ","; }; }; return val=='' ? '' : val.left(val.length-1); };
livexy.getValueByName = function(str) { var val = ""; var obj = document.getElementsByName(str); for (var i = 0; i < obj.length; i++) { val = val + obj[i].value + ","; }; return val=='' ? '' : val.left(val.length-1); };
livexy.toForm = function(str, ext) { var obj = "({{0}{1}})"; var list = str.split(','); var val = ""; if (str.length > 0) { str = ""; ext = "," + ext || ""; for (var i = 0; i < list.length; i++) { val = (list[i].left(3) == 'chk' || list[i].left(3) == 'rdo') ? $('#' + list[i]).get(0).checked.toString() : $('#' + list[i]).val(); str = str + "'{0}':'{1}',".format(list[i], val.replace(/\n/g,"\\n").replace(/\'/g,"\\\'")); }; }; return eval(obj.format(str.left(str.length - 1), ext)); };
livexy.preventDefaults = function(e, selection) { e = e || window.event; if(e.preventDefault) e.preventDefault(); e.returnValue = false; if(selection && document.selection) document.selection.empty();	};
livexy.cancelEvent = function(e) { e = e || window.event; if(e.stopPropagation) e.stopPropagation(); e.cancelBubble = true; };
livexy.extend = function() { var source, key, len = arguments.length, destination = arguments[0], isbool = typeof arguments[len-1] == 'boolean' , override = isbool ? arguments[len-1] : true; if (len <= 1) return null; for (var i = 1,len = isbool ? len - 1 : len; i < len; i++) { source = arguments[i]; for (key in source) { if (override || !(key in destination)) destination[key] = source[key]; }; }; return destination; };
livexy.selectBoxN = function(arr, sel, val, hide) { var me = this; hide = typeof hide == 'boolean' ? hide : true; this.$ = function(o) { return document.getElementById(o); }; this.sub = function(i, pid) { for (var j = i + 1; j < sel.length; j++) { me.$(sel[j]).length = 0; me.$(sel[j]).options[0] = new Option("请选择", ""); }; for (var j = 0; j < arr.length; j++) { if (arr[j][1] == pid) me.$(sel[i + 1]).options[me.$(sel[i + 1]).length] = new Option(arr[j][2], arr[j][0]); }; }; this.init = function() { me.sub(-1, "root"); for (var i = 0; i < sel.length; i++) { if (i < val.length) { me.$(sel[i]).value = val[i]; me.sub(i, val[i]); if (hide) { if (me.$(sel[i]).value.length > 0 && i != sel.length - 1) me.$(sel[i + 1]).style.display = 'inline'; else if (i != sel.length - 1) me.$(sel[i + 1]).style.display = 'none'; }; }; if (i < sel.length - 1) { me.$(sel[i]).onchange = function() { var i; for (i = 0; me.$(sel[i]) != this; i++); me.sub(i, me.$(sel[i]).value); if (hide) { if (me.$(sel[i]).value.length > 0) me.$(sel[i + 1]).style.display = 'inline'; else me.$(sel[i + 1]).style.display = 'none'; }; }; }; }; }; this.init(); };
livexy.selectBoxN2 = function(arr, sel, val, hide) { var me = this; hide = typeof hide == 'boolean' ? hide : true; this.getID = function(o) { return document.getElementById(o); }; this.sub = function(i, pid) { for (var j = i + 1; j < sel.length; j++) { me.getID(sel[j]).length = 0; me.getID(sel[j]).options[0] = new Option("请选择", ""); }; for (var j = 0; j < arr.length; j++) { if (!me.getID(sel[i + 1])) continue; if (arr[j]['parent'] == pid) me.getID(sel[i + 1]).options[me.getID(sel[i + 1]).length] = new Option(arr[j]['name'], arr[j]['id']); }; }; this.init = function() { me.sub(-1, "0"); for (var i = 0; i < sel.length; i++) { if (i < val.length) { me.getID(sel[i]).value = val[i]; me.sub(i, val[i]); if (hide) { if (me.getID(sel[i]).value.length > 0 && i != sel.length - 1) me.getID(sel[i + 1]).style.display = 'inline'; else if (i != sel.length - 1) me.getID(sel[i + 1]).style.display = 'none'; }; }; if (i < sel.length - 1) { me.getID(sel[i]).onchange = function() { var i; for (i = 0; me.getID(sel[i]) != this; i++); me.sub(i, me.getID(sel[i]).value); if (hide) { if (me.getID(sel[i]).value.length > 0) me.getID(sel[i + 1]).style.display = 'inline'; else me.getID(sel[i + 1]).style.display = 'none'; }; }; }; }; }; this.init(); };
livexy.selectBoxN3 = function (arr, sel, val) { var me = this; var html = '<option value="0">请选择</option>'; this.init = function (arr1, level) { for (var i = 0; i < arr1.length; i++) { html += '<option value="' + arr1[i].id + '">' + livexy.padLeft(level, '　') + arr1[i].name + '</option>'; if (arr1[i].node.length > 0) this.init(arr1[i].node, level + 1); }; }; this.init(arr, 0); $(sel).append(html); $(sel).val(val); html = null; };
livexy.arrayCount = function (a, f, v) { var count = 0; for (var i = 0, len = a.length; i < len; i++) if (a[i][f] == v) count++; return count; };
livexy.reg = function(ns) { var d = ns.split("."); var o = window[d[0]] = window[d[0]] || {}; for (var i = 1; i < d.length; ++i) o = o[d[i]] = o[d[i]] || {}; return o; };

livexy.request = {};
livexy.request.get = function(paramName) { var aParams = document.location.search.substr(1).split('&'); for (i = 0; i < aParams.length; i++) { var aParam = aParams[i].split('='); if (paramName.toLowerCase() == aParam[0].toLowerCase()) return aParam[1].trim(); }; return ""; };
livexy.request.getUrl = function() { return top.location.href; };
livexy.request.getRef = function() { return document.referrer; };

livexy.menu = {};
livexy.menu.showMenu = function(floatID) { $(floatID).show(); };
livexy.menu.show = function(floatID, fixID, left, top) { floatID = floatID || null; fixID = fixID || null; left = left || 0; top = top || 0; if (!floatID || !fixID) return false; if ($(floatID).css("display") != "none") return false; var objOffset = $(fixID).offset(); $(floatID).css("left", objOffset.left + left); $(floatID).css("top", objOffset.top + top); setTimeout("livexy.menu.showMenu('" + floatID + "')", 50); $(floatID).mousemove(function() { $(this).addClass("mousemove"); }); objOffset = null; return true; };
livexy.menu.hide = function(floatID) { $(floatID).css("display", "none"); $(floatID).removeClass("mousemove"); return  false; };

livexy.flash = {};
livexy.flash.play = function (divID, width, height, url, imgurl, params) { imgurl = imgurl || null; params = params || ''; var html = '<embed wmode="opaque"  type="application/x-shockwave-flash" id="player2" name="player2" src="{2}" width="{0}" height="{1}" allowscriptaccess="always" allowfullscreen="true"{3} {4} />'; if (imgurl) html = html.format(width, height, '/resources/js/player.swf', ' flashvars="file={0}&image={1}"'.format(url, imgurl), params); else html = html.format(width, height, url, '', params); $(divID + " *").remove().destroy(); $(divID).html(html); };

livexy.user = new function() {
    this.userID = 0;
    this.nickName = "";
    this.header = "";
    this.sex = 0;
    this.init = function(userID,nickName,header,sex){ this.userID = userID || 0; this.nickName = nickName || ""; this.header = header || ""; this.sex = sex || 0; };
    this.getHeader = function(url){ url = url.trim(); if (url.toLowerCase().indexOf('http://')==0) return url; if (url.length==0) return "/resources/images/no_photo.gif"; return url; };
};

livexy.drag = {};
livexy.drag.init = function(o, e) { var e = window.event || e; var _x = e.offsetX || e.layerX; var _y = e.offsetY || e.layerY; document.onmousemove = function(e) { var e = window.event || e; o.style.left = e.clientX - _x + "px"; o.style.top = e.clientY - _y + "px"; }; document.onmouseup = function(e) { document.onmousemove = null; }; };

livexy.tab = {};
livexy.tab.active = function(obj, maxs, prefix){ var index = parseInt(obj.id.replace(prefix,'')); for(var i=1; i<=maxs; i++) { $("#" + prefix + i).removeClass('active'); $("#" + prefix + "_box" + i).css('display','none'); }; $(obj).addClass('active'); $("#" + prefix + "_box" + index).css('display',''); };

livexy.page = {};
livexy.page.GetPager = function(curPage, countPage, callscript, extendPage) { if (countPage < 2) return ""; var startPage = 1, endPage = 1, t1 = "<a href=\"#\" onclick=\"" + callscript.format(1) + ";return false;\">&laquo;</a>&nbsp;", t2 = "<a href=\"#\" onclick=\"" + callscript.format(countPage) + ";return false;\">&raquo;</a>&nbsp;"; if (countPage < 1) countPage = 1; if (extendPage < 3) extendPage = 2; if (countPage > extendPage) { if (curPage - (extendPage / 2) > 0) { if (curPage + (extendPage / 2) < countPage) { startPage = curPage - (extendPage / 2); endPage = startPage + extendPage - 1; } else { endPage = countPage; startPage = endPage - extendPage + 1; t2 = ""; }; } else { endPage = extendPage; t1 = ""; }; } else { startPage = 1; endPage = countPage; t1 = ""; t2 = ""; }; var s = t1; for (var i = startPage; i <= endPage; i++) { if (i == curPage) { s = s + "&nbsp;<span>"; s = s + i; s = s + "</span>&nbsp;"; } else { s = s + "&nbsp;<a href=\"#\" onclick=\""; s = s + callscript.format(i); s = s + ";return false;\">"; s = s + i; s = s + "</a>&nbsp;"; }; }; s = s + t2; return s; };
livexy.page.GetPager2 = function(curPage, countPage, callscript, extendPage) { if (countPage < 2) return ""; var startPage = 1, endPage = 1, t1 = "<a href=\"#\" class=\"first firstenable\" onclick=\"" + callscript.format(1) + ";return false;\"></a>", t2 = "<a href=\"#\" class=\"last lastenable\" onclick=\"" + callscript.format(countPage) + ";return false;\"></a>"; if (countPage < 1) countPage = 1; if (extendPage < 3) extendPage = 2; if (countPage > extendPage) { if (curPage - (extendPage / 2) > 0) { if (curPage + (extendPage / 2) < countPage) { startPage = curPage - (extendPage / 2); endPage = startPage + extendPage - 1; } else { endPage = countPage; startPage = endPage - extendPage + 1; t2 = t2.replace(" lastenable", ""); }; } else { endPage = extendPage; t1 = t1.replace(" firstenable", ""); }; } else { startPage = 1; endPage = countPage; t1 = t2.replace(" lastenable", ""); t2 = t1.replace(" firstenable", ""); }; var s = t1; for (var i = startPage; i <= endPage; i++) { if (i == curPage) { s = s + "<a href=\"#\" class=\"active\"></a>"; } else { s = s + "<a href=\"#\" onclick=\""; s = s + callscript.format(i); s = s + ";return false;\"></a>"; }; }; s = s + t2; return s; };

livexy.msg = {};
livexy.msg.zindex = 4000;
livexy.msg.hide = function(id, code) { id = id || "_sysmsg_"; code = code || null; $("#" + id).remove().destroy(); $("#" + id + "_gray").remove().destroy(); if (code) { code(); }; code = null; };
livexy.msg.goUrl = function(url) { self.location = url; };
livexy.msg.tableTemplate = '<table class="_sysmsgtable_" cellpadding="0" cellspacing="0"><tr><td><div class="{1}">{0}</div></td></tr></table>';
livexy.msg.operatorTemplate = '<div class="{1}">{0}</div><div class="operator">{2}<input id="btnCancel" name="btnCancel" class="btnCancel" type="button" value="取消" /></div>';
livexy.msg.showHTML = function(id, title, html, width, height, okClick, cancelClick, isTitle, isClose, isDrag) {
    if (id && typeof (id) == 'object') { title = id.title; html = id.html; width = id.width; height = id.height; okClick = id.okClick; cancelClick = id.cancelClick; isTitle = id.isTitle; isClose = id.isClose; isDrag = id.isDrag; if (html.indexOf('<div class="operator">') == -1 && okClick) { html = this.operatorTemplate.replace('取消', id.cancelTitle || "取消").format(html, 'operatorBox', '<input id="btnOK" name="btnOK" class="btnOK" type="button" value="' + (id.okTitle ? id.okTitle : '保存') + '" /> ') }; id = id.id; };
    id = id || "_sysmsg_"; title = title || "系统提示"; width = width || 300; height = height || 0; okClick = okClick || null; cancelClick = cancelClick || null; isTitle = typeof isTitle == 'boolean' ? isTitle : true; isClose = typeof isClose == 'boolean' ? isClose : true; isDrag = typeof isDrag == 'boolean' ? isDrag : true;
    $("#" + id).remove().destroy(); $("#" + id + "_gray").remove().destroy();

    var htmlTemplate = '<div id="{0}_gray" class="livexy_msg_gray"></div><div id="{0}" class="livexy_msg" style="width:{1}px"><div class="msg_top" onselectstart="event.returnValue=false;return false;" ondragstart="return false;" onselect="document.selection.empty();"><div class="msg_rt"><a href="#" class="msg_close2"></a></div><div class="msg_lt"></div><div class="msg_ct" style="width:{2}px"><div class="close"></div><div class="title">{5}</div></div></div><div class="msg_mid" style="min-width:{2}px;"><div class="msg_rm">&nbsp;</div><div class="msg_lm">&nbsp;</div><div class="msg_cm" style="width:{2}px;">{4}</div></div><div class="msg_bott"><div class="msg_rb"></div><div class="msg_lb"></div><div class="msg_cb" style="width:{2}px"></div></div></div>';
    htmlTemplate = htmlTemplate.format(id, width + 26, width, height, html, title);
    if (livexy.isIe6()) $("body").append(htmlTemplate); else $("body").prepend(htmlTemplate);

    $("html").addClass("livexy_html");
    if (!isTitle) { $("#" + id + " .msg_top,#" + id + " .msg_rt,#" + id + " .msg_lt,#" + id + " .msg_ct").addClass("msgheight"); $("#" + id + " .msg_ct *:not(.close)").remove().destroy(); $("#" + id + " .close").hide(); $("#" + id + " .msg_close2").show(); };
    if (!isClose) $("#" + id + " .msg_close2").hide();

    $("#" + id + " .close").click(function() { if (cancelClick) cancelClick(); $("html").removeClass("livexy_html"); $("#" + id).remove().destroy(); $("#" + id + "_gray").remove().destroy(); okClick = cancelClick = htmlTemplate = null; }).hover(function() { $("#" + id + " .close").addClass("active"); }, function() { $("#" + id + " .close").removeClass("active"); });
    $("#" + id + " .msg_close2").click(function() { $("#" + id + " .close").click(); return false; });
    $("#" + id).css('position', 'fixed'); $("#iframe_" + id).css('width', width + 'px').css('height', height + 'px');
    if (height > 0) { $("#" + id + " .icon").css('height', (height - 76) + 'px').css('min-height', (height - 76) + 'px'); if ($("#" + id + " .icon").length == 0) $("#" + id + " .msg_cm").css('height', height + 'px').css('min-height', height + 'px'); };
    $("#" + id + " .operator #btnCancel").click(function() { $("#" + id + " .close").click(); }).focus();
    $("#" + id + " .operator #btnOK").click(function() { if (okClick) { $("html").removeClass("livexy_html"); if (okClick() == false) return false; }; $("#" + id).remove().destroy(); $("#" + id + "_gray").remove().destroy(); okClick = cancelClick = htmlTemplate = null; });
    livexy.msg.zindex = livexy.msg.zindex + 1; $("#" + id + "_gray").css("z-index", livexy.msg.zindex); livexy.msg.zindex = livexy.msg.zindex + 1; $("#" + id).css("z-index", livexy.msg.zindex);

    $("#" + id + " .msg_lm,#" + id + " .msg_rm").height($("#" + id + " .msg_cm").height());
    if (isClose) $(document).keypress(function(e) { e = window.event || e; if (e.keyCode == 27) { $("#" + id + " .close").click(); $(document).unbind("keypress"); } });
    var winSize = livexy.getWinSize();
    $("#" + id).css('left', ((winSize.w - width + 26) / 2 - 20) + 'px');
    $("#" + id).css('top', ((winSize.h - ($("#" + id + " .msg_cm").height() + 10)) / 2 - 13) + 'px');
    if (livexy.isIe6()) { $("#" + id).css('top', (document.documentElement.scrollTop) + 'px'); $("#" + id + " .msg_cm").width($("#" + id + " .msg_cm").width() - 2); $("#" + id).css('position', 'absolute'); $("#" + id + "_gray").css('position', 'absolute'); $("#" + id + "_gray").css('width', $("body").width()); $("#" + id + "_gray").css('height', $("body").height()); if ($("#" + id).offset().top - document.documentElement.scrollTop == 0) $("#" + id).css('top', (document.documentElement.scrollTop + 100) + 'px'); };
    if (isDrag) $("#" + id).drag();
    htmlTemplate = null;
};
livexy.msg.alert = function(id, title, text, width, height, cancelClick, isTitle, isClose) { var cancelTitle = ""; if (id && typeof (id) == 'object') { text = id.text; cancelTitle = id.cancelTitle }; var html = this.operatorTemplate.replace("取消", cancelTitle || "关闭").format('<div class="left alert">&nbsp;</div><div class="text">{0}</div>'.format(text || "无提示"), 'icon', ''); if (id && typeof (id) == 'object') { id.html = html; }; this.showHTML(id, title, html, width, height, null, cancelClick, isTitle, isClose); html = null; };
livexy.msg.confirm = function(id, title, text, width, height, okClick, cancelClick, isTitle, isClose) { var cancelTitle = "", okTitle = ""; if (id && typeof (id) == 'object') { text = id.text; cancelTitle = id.cancelTitle; okTitle = id.okTitle }; var html = this.operatorTemplate.replace("取消", cancelTitle || "取消").format('<div class="left confirm">&nbsp;</div><div class="text">{0}</div>'.format(text || "无提示"), 'icon', '<input id="btnOK" name="btnOK" class="btnOK" type="button" value="' + (okTitle || "确定") + '" /> '); if (id && typeof (id) == 'object') { id.html = html; }; this.showHTML(id, title, html, width, height, okClick, cancelClick, isTitle, isClose); html = null; };
livexy.msg.show = function(id, title, src, width, height, cancelClick, isTitle) { var id2; if (id && typeof (id) == 'object') { text = id.text; src = id.src; id2 = id.id; } else id2 = id; id2 = id2 || "_sysmsg_"; var html = '<iframe id="iframe_{0}" src="{1}" frameborder="0" style="border:none;"></iframe>'.format(id2, src); if (id && typeof (id) == 'object') { id.html = html; }; this.showHTML(id, title, html, width, height, null, cancelClick, isTitle); html = null; };
livexy.msg.notice = function(id, text, type, interval, style, istop) { if (!text) { $(id + " *").remove().destroy(); return false; }; var divID = "#_sysnotice_" + Math.random().toString().replace("0.", ""); var typeList = "ok,warning,error,process,"; interval = interval || 0; id = id || ""; type = type || "ok"; style = style || ""; istop = istop || false; if (typeList.indexOf(type + ",") == -1) type = "ok"; var html = '<table id="{3}" style="{1}" class="_sysmsgtable_" cellpadding="0" cellspacing="0"><tr><td><div class="{0}Msg">{2}</div></td></tr></table>'.format(type, style, text, divID.replace("#", "")); if (interval == 0) $(id + " *").remove().destroy(); if (istop) $(id).prepend(html); else $(id).append(html); if (interval > 0) { setTimeout(function() { $(divID).fadeOut(1500); setTimeout(function() { $(divID).remove().destroy(); }, 1000); }, interval * 1000); }; html = text = style = type = null; };
livexy.msg.tooltip = function(id, text, type, width, left, top){ $("#" + type + "Msg").remove().destroy(); if (!id) return false; var typeList = "ok,warning,error,process,"; type = type || "ok"; width = width || 0; if (typeList.indexOf(type + ",")==-1) type = "ok"; var html = '<div class="{0}Msg" id="{0}Msg" style="position:absolute;z-index:2000;display:none;width:{1};">{2}</div>'.format(type,width==0 ? "100%" : (width+"px"),text); $("body").prepend(html); livexy.menu.show("#" + type + "Msg", id, left, top); html = text = type = null; };
livexy.msg.popup = function(align, text, width, height, cancelClick) { align = align || 'rb'; width = width || 300; height = height || 200; cancelClick = cancelClick || null; };
livexy.msg.process = function(id, text) { text = text || null; $(id + " *").remove().destroy(); $(id).html(this.tableTemplate.format(text || "正在处理数据，请等待...", "processMsg")); };
livexy.msg.loading = function(id, text) { livexy.msg.process(id, text || "正在加载数据..."); };
livexy.msg.popupProcess = function(id, text, width) { text = text || null; $(id + " *").remove().destroy(); livexy.msg.showHTML(id, null, '<div class="processMsg" style="border:0px;background-color:#fff;margin:5px; 0px;">{0}</div>'.format(text || "正在处理数据，请等待..."), width || 250, null, null, null, false, false); };
livexy.msg.popupLoading = function(id, text, width) { livexy.msg.popupProcess(id, text || "正在加载数据...", 150); };
livexy.msg.chkFormData = function(txtObjStr, divObjStr, minLength, maxLength, titleStr, isSubmit, isNVarchar) { var txtObjLength = (isNVarchar) ? $(txtObjStr).val().length : $(txtObjStr).val().getCnLen(); if (txtObjLength == 0 && minLength != 0) { if (divObjStr != "") { $(divObjStr + " *").remove().destroy(); livexy.msg.notice(divObjStr, titleStr + "不能为空", "error"); try { if (isSubmit) { $(txtObjStr).focus(); }; } catch (e) { }; } else { livexy.msg.alert("divMsg", "系统提示", titleStr + "不能为空！", null, null, function() { if (isSubmit) { $(txtObjStr).focus(); } }); }; return false; } else if (txtObjLength < minLength) { if (divObjStr != "") { $(divObjStr + " *").remove().destroy(); livexy.msg.notice(divObjStr, titleStr + "不能少于" + minLength + "位", "error"); if (isSubmit) { $(txtObjStr).focus(); }; } else { j.msg.alert("divMsg", "系统提示", titleStr + "不能少于" + minLength + "位", null, null, function() { if (isSubmit) { $(txtObjStr).focus(); } }); }; return false; } else if (txtObjLength > maxLength) { if (divObjStr != "") { $(divObjStr + " *").remove().destroy(); livexy.msg.notice(divObjStr, titleStr + "不能大于" + maxLength + "位", "error"); if (isSubmit) { $(txtObjStr).focus(); }; } else { livexy.msg.alert("divMsg", "系统提示", titleStr + "不能大于" + maxLength + "位", null, null, function() { if (isSubmit) { $(txtObjStr).focus(); } }); }; return false; } else { if (divObjStr != "") { $(divObjStr + " *").remove().destroy(); $(divObjStr).html(this.tableTemplate.format("&nbsp;", "okMsg border0")); }; }; return true; };
livexy.msg.setEnable = function (obj, disable) { $(obj).get(0).disabled = disable; };

livexy.initDateBox = function(sltArray, defArray) { if (sltArray.length == 0 || sltArray.length > 3) return false; g = function(o) { return document.getElementById(o); }; var t = 'year'; for (var i = 0; i < sltArray.length; i++) { if (t == 'year') { var p = 0; for (var y = 1949; y <= (new Date()).getFullYear(); y++, p++) { g(sltArray[i]).options[p] = new Option(y == 1949 ? '请选择' : y, y == 1949 ? '' : y); }; t = 'month'; } else if (t == 'month') { for (var m = 0; m <= 12; m++) { g(sltArray[i]).options[m] = new Option(m == 0 ? '请选择' : m, m == 0 ? '' : m); }; t = 'day'; } else { for (var d = 0; d <= 31; d++) { g(sltArray[i]).options[d] = new Option(d == 0 ? '请选择' : d, d == 0 ? '' : d); }; }; }; if (defArray.length != sltArray.length) return false; for (var s = 0; s < sltArray.length; s++) { g(sltArray[s]).value = defArray[s]; }; };
livexy.initComboBox = function(api, cboArray, defArray, ext, success) { ext = ext || ""; success = success || null; $.post("/ajax/initcombobox.ashx", { "api": api, "cboArray": cboArray, "defValue": defArray, "ext": ext }, function(data) { eval(data); if (success) success(); data = success = null; }); };
livexy.initComboBox2 = function (data, cboArray, defArray, ext, success) { ext = ext || ""; success = success || null; if (success) success(); var initList = new livexy.selectBoxN2(data, cboArray, defArray); data = success = initList = null; };
livexy.initComboBox3 = function (data, cboArray, defArray, ext, success) { ext = ext || ""; success = success || null; if (success) success(); var initList = new livexy.selectBoxN3(data, cboArray, defArray); data = success = initList = null; };
livexy.initLMSComboBox = function (api, cboArray, defArray, ext, success) { ext = ext || ""; success = success || null; $.post("/ajax/initlmscombobox.ashx", { "api": api, "cboArray": cboArray, "defValue": defArray, "ext": ext }, function (data) { eval(data); if (success) success(); data = success = null; }); };

$(window).bind("unload", function() { $("*").add(document).unbind(); $("*").add(document).unbind(); $("body *").destroy(); $("body").get(0).innerHTML = ""; if (livexy.isIe()) CollectGarbage(); });
setInterval(function(){ if (livexy.isIe()) CollectGarbage(); },10000);
if (livexy.isIe()) document.execCommand('BackgroundImageCache', false, true);

$.fn.AutoComplete = function(api, width, height) {
    if (api && typeof (api) == 'object') { width = api.width; height = api.height; api = api.api; };
    this.each(function() {
        var obj = this, $obj = $(obj), obj_offset = $obj.offset();
        var loadAjax = function() { $(obj).addClass("AutoCompleteLoad"); $.post(api, { active: obj.id }, function(data) { obj.add = data.add; obj.edit = data.edit; obj.del = data.del; obj.data = data.data; if (parseInt($obj.attr("idvalue")) > 0) { $(obj.data).each(function() { if (this.id == parseInt($obj.attr("idvalue"))) obj.value = this.name; }); }; $(obj).removeClass("AutoCompleteLoad"); }, "json"); };
        loadAjax();
        var showList = function(info) {
            $(obj).addClass("AutoCompleteLoad"); $("#AutoCompleteAdd").remove();
            var html = '<div id="{0}List" class="AutoCompleteList">'.format(obj.id);
            $obj.attr("idvalue", "0");
            $(obj.data).each(function() {
                if (this.name.indexOf(info) >= 0) html += '<div class="{0}Item" id="{0}Item{1}" edit="0"><input class="AutoCompleteDel" type="button" value="" title="删除" del="{3}" /><input class="AutoCompleteEdit" type="button" value="" title="修改" /><input class="AutoCompleteSave" type="button" value="" title="保存" /><input class="AutoCompleteCancel" type="button" value="" title="取消" /><input type="text" class="AutoCompleteInput" value="{4}" /><span>{2}</span></div>'.format(obj.id, this.id, info == "" ? this.name : this.name.replace(info, "<b>{0}</b>".format(info)), this.del ? "1" : "0", this.name);
                if (this.name == obj.value.trim()) $obj.attr("idvalue", this.id);
            });
            html += '</div>';
            $("#{0}List".format(obj.id)).remove();
            $("body").append(html);
            var $objList = $("#{0}List".format(obj.id))
            obj_offset = $obj.offset();
            $objList.css({
                "left": obj_offset.left,
                "top": obj_offset.top + $obj.height() + parseInt($obj.css("padding-top")) + parseInt($obj.css("padding-bottom")) + parseInt($obj.css("border-top-width")) + parseInt($obj.css("border-bottom-width")) - 1,
                "width": width || ($obj.width() + parseInt($obj.css("padding-left")) + parseInt($obj.css("padding-right"))),
                "max-height": height || 200
            }).find("div").unbind().click(function() {
                $obj.val($(this).find("span").text()).attr("idvalue", parseInt(this.id.replace("AutoCompleteItem", "")));
                $objList.hide();
                $obj.focusout().blur();
                return false;
            }).hover(function() {
                $(this).addClass("AutoCompleteItemHover");
                if ($(this).attr("edit") == "1") return false;
                if (obj.edit) $(this).find(".AutoCompleteEdit").show();
                if (obj.del && $(this).find(".AutoCompleteDel").attr("del") == "1") $(this).find(".AutoCompleteDel").show();
            }, function() {
                $(this).removeClass("AutoCompleteItemHover");
                if (obj.edit) $(this).find(".AutoCompleteEdit").hide();
                if (obj.del) $(this).find(".AutoCompleteDel").hide();
            }).parent().show();
            if ($objList.find("div").length == 0) $objList.hide(); else {
                if (obj.edit) $objList.find(".AutoCompleteEdit").unbind().click(function() {
                    $(this).parent().find("span").hide().parent().find(".AutoCompleteInput").show().focus().select().parent().find(".AutoCompleteEdit,.AutoCompleteDel").hide().parent().find(".AutoCompleteSave,.AutoCompleteCancel").show().parent().attr("edit", "1");
                    return false;
                });
                if (obj.del) $objList.find(".AutoCompleteDel").unbind().click(function() {
                    var $this = $(this);
                    var old = $this.parent().find("span").text();
                    var idv = parseInt($this.parent().attr("id").replace("AutoCompleteItem", ""));
                    $(obj).addClass("AutoCompleteLoad");
                    $.post(api, { active: obj.id + ".Del", "id": parseInt($(this).parent().attr("id").replace("AutoCompleteItem", "")) }, function(data) {
                        if (parseInt(data) != 1) { $obj.removeClass("AutoCompleteLoad"); alert("删除失败！"); return false; };
                        $(obj.data).each(function(i) { if (this.id == idv) obj.data.splice(i, 1); });
                        $this.parent().remove();
                        if (obj.value == old) obj.value = "";
                        $obj.focus().removeClass("AutoCompleteLoad");
                    });
                    return false;
                });
                $objList.find(".AutoCompleteInput").unbind().click(function() { return false; });
                $objList.find(".AutoCompleteCancel").unbind().click(function() { $(this).parent().find("span").show().parent().find(".AutoCompleteInput").hide().parent().find(".AutoCompleteSave,.AutoCompleteCancel").hide().parent().attr("edit", "0").find(".AutoCompleteInput").val($(this).parent().find("span").text()); return false; });
                $objList.find(".AutoCompleteSave").unbind().click(function() {
                    var $this = $(this);
                    if ($this.parent().find(".AutoCompleteInput").val().trim() == "") return false;
                    var old = $this.parent().find("span").text();
                    $(obj).addClass("AutoCompleteLoad");
                    $.post(api, { active: obj.id + ".Edit", "name": $this.parent().find(".AutoCompleteInput").val(), "id": parseInt($this.parent().attr("id").replace("AutoCompleteItem", "")) }, function(data) {
                        if (parseInt(data) != 1) { $obj.removeClass("AutoCompleteLoad"); alert("修改失败！"); return false; };

                        $this.parent().find("span").text($this.parent().find(".AutoCompleteInput").val()).parent().find(".AutoCompleteCancel").click();
                        var idv = parseInt($this.parent().attr("id").replace("AutoCompleteItem", "")), val = $this.parent().find("span").text();
                        $(obj.data).each(function(i) { if (this.id == idv) obj.data[i].name = val; });
                        if (obj.value == old) obj.value = $this.parent().find("span").text();

                        $(obj).removeClass("AutoCompleteLoad");
                    });
                    return false;
                });
            };
            //$("#AutoCompleteMsg").html($obj.val() + "|" + $obj.attr('idvalue'));
            if (parseInt($obj.attr('idvalue')) == 0 && $obj.val().trim() != "") {
                if (obj.add) {
                    $("body").append('<input id="AutoCompleteAdd" class="AutoCompleteAdd" type="button" value="" title="添加" />');
                    $("#AutoCompleteAdd").css({
                        "left": obj_offset.left + $obj.width() + parseInt($obj.css("padding-right")) - 10,
                        "top": obj_offset.top + ($obj.height() + parseInt($obj.css("padding-top")) + parseInt($obj.css("padding-bottom")) + parseInt($obj.css("border-top-width")) + parseInt($obj.css("border-bottom-width")) - 12) / 2
                    }).unbind().click(function() {
                        if (obj.value.trim() == "") return false;
                        $(obj).addClass("AutoCompleteLoad");
                        $.post(api, { active: obj.id + ".Add", "name": obj.value }, function(data) {
                            if (parseInt(data) <= 0) { $obj.removeClass("AutoCompleteLoad"); alert("添加失败！"); return false; };
                            obj.data[obj.data.length] = { "id": parseInt(data), "name": obj.value, "del": true };
                            $("#AutoCompleteAdd").remove();
                            $(obj).removeClass("AutoCompleteLoad");
                        });
                        return false;
                    });
                };
            };
            $(obj).removeClass("AutoCompleteLoad");
        };

        $(obj).focus(function() {
            if (!obj.data) { loadAjax(); return false; };
            showList(obj.value);
        }).blur(function() {
            $(obj).removeClass("AutoCompleteLoad");
            $(obj.data).each(function() { if (this.name == obj.value.trim()) { $obj.attr("idvalue", this.id); $("#AutoCompleteAdd").remove(); }; });
            //$("#AutoCompleteMsg").html($obj.val() + "|" + $obj.attr('idvalue'));
        }).keyup(function(e) {
            e = window.event || e;
            if (e.keyCode == 40) { if ($("#{0}List .AutoCompleteItemHover".format(obj.id)).length == 0) $("#{0}List div:first".format(obj.id)).addClass("AutoCompleteItemHover"); else $("#{0}List .AutoCompleteItemHover".format(obj.id)).removeClass("AutoCompleteItemHover").next().addClass("AutoCompleteItemHover"); return false; };
            if (e.keyCode == 38) { if ($("#{0}List .AutoCompleteItemHover".format(obj.id)).length == 0) $("#{0}List div:last".format(obj.id)).addClass("AutoCompleteItemHover"); else $("#{0}List .AutoCompleteItemHover".format(obj.id)).removeClass("AutoCompleteItemHover").prev().addClass("AutoCompleteItemHover"); return false; };
            if (e.keyCode == 13) { $("#{0}List .AutoCompleteItemHover".format(obj.id)).click(); return false; };
            showList(obj.value);
        }).click(function() { return false; });
        $("body").click(function() { $("#{0}List".format(obj.id)).hide(); });
    });
};

$.fn.CheckComboBox = function(api, width, height) {
    if (api && typeof (api) == 'object') { width = api.width; height = api.height; api = api.api; };
    this.each(function() {
        var obj = this, $obj = $(obj), obj_offset = $obj.offset();
        var loadAjax = function() {
            $(obj).addClass("AutoCompleteLoad");
            $.post(api, { active: obj.id }, function(data) {
                obj.add = data.add;
                obj.edit = data.edit;
                obj.del = data.del;
                obj.data = data.data;
                var html = '<div id="{0}List" class="AutoCompleteList">'.format(obj.id), html2 = "";
                $(obj.data).each(function() {
                    html2 += '<div class="{0}Item" id="{0}Item{1}" edit="0"><input class="AutoCompleteDel" type="button" value="" title="删除" del="{3}" /><input class="AutoCompleteEdit" type="button" value="" title="修改" /><input class="AutoCompleteSave" type="button" value="" title="保存" /><input class="AutoCompleteCancel" type="button" value="" title="取消" /><input type="text" class="AutoCompleteInput" value="{4}" /><label><input type="checkbox" id="chk{0}Item{1}" value="{1}"> <span>{2}</span></label></div>'.format(obj.id, this.id, data == "" ? this.name : this.name.replace(data, "<b>{0}</b>".format(data)), this.del ? "1" : "0", this.name);
                });
                html += html2 + '</div>';
                if ($("#{0}List".format(obj.id)).length == 0) $("body").append(html); else { $("#{0}List *".format(obj.id)).remove(); $("#{0}List".format(obj.id)).append(html2); };
                var $objList = $("#{0}List".format(obj.id))
                obj_offset = $obj.offset();
                $objList.css({
                    "left": obj_offset.left,
                    "top": obj_offset.top + $obj.height() + parseInt($obj.css("padding-top")) + parseInt($obj.css("padding-bottom")) + parseInt($obj.css("border-top-width")) + parseInt($obj.css("border-bottom-width")) - 1,
                    "width": width || ($obj.width() + parseInt($obj.css("padding-left")) + parseInt($obj.css("padding-right"))),
                    "max-height": height || 200
                }).find("div").hover(function() {
                    $(this).addClass("AutoCompleteItemHover");
                    if ($(this).attr("edit") == "1") return false;
                    if (obj.edit) $(this).find(".AutoCompleteEdit").show();
                    if (obj.del && $(this).find(".AutoCompleteDel").attr("del") == "1") $(this).find(".AutoCompleteDel").show();
                }, function() {
                    $(this).removeClass("AutoCompleteItemHover");
                    if (obj.edit) $(this).find(".AutoCompleteEdit").hide();
                    if (obj.del) $(this).find(".AutoCompleteDel").hide();
                }).find(":checkbox").unbind().change(function() {
                    var objval = ";" + $obj.val(), idval = "," + $obj.attr("idvalue");
                    var thisval = $(this).parent().find("span").text() + ";", thisid = this.id.replace("chk" + obj.id + "Item", "") + ",";

                    $obj.val((objval.replace(";" + thisval, ";")).substring(1)); $obj.attr("idvalue", (idval.replace("," + thisid, ",")).substring(1));
                    if (this.checked) { $obj.val($obj.val() + thisval); $obj.attr("idvalue", $obj.attr("idvalue") + thisid); }
                    $obj.attr("title", $obj.val());
                    //$("#AutoCompleteMsg").html($obj.val() + "|" + $obj.attr('idvalue'));
                    //return false;
                });
                if ($obj.attr("idvalue").length > 0) {
                    $(obj.data).each(function() { if (("," + $obj.attr("idvalue")).indexOf("," + this.id + ",") >= 0) { $("#chk" + obj.id + "Item" + this.id).attr("checked", "checked").change(); } });
                };
                if ($objList.find("div").length == 0) $objList.hide(); else {
                    if (obj.edit) $objList.find(".AutoCompleteEdit").unbind().click(function() {
                        $(this).parent().find("label").hide().parent().find(".AutoCompleteInput").show().focus().select().parent().find(".AutoCompleteEdit,.AutoCompleteDel").hide().parent().find(".AutoCompleteSave,.AutoCompleteCancel").show().parent().attr("edit", "1");
                        return false;
                    });
                    if (obj.del) $objList.find(".AutoCompleteDel").unbind().click(function() {
                        var $this = $(this);
                        var old = $this.parent().find("span").text();
                        var idv = parseInt($this.parent().attr("id").replace("AutoCompleteItem", ""));
                        $(obj).addClass("AutoCompleteLoad");
                        $.post(api, { active: obj.id + ".Del", "id": parseInt($(this).parent().attr("id").replace("AutoCompleteItem", "")) }, function(data) {
                            if (parseInt(data) != 1) { $obj.removeClass("AutoCompleteLoad"); alert("删除失败！"); return false; };
                            $(obj.data).each(function(i) { if (this.id == idv) obj.data.splice(i, 1); });
                            $this.parent().remove();
                            obj.value = (";" + obj.value).replace(";" + old + ";", ";").substring(1);
                            $obj.attr("idvalue", (',' + $obj.attr("idvalue")).replace("," + idv + ",", ",").substring(1));
                            $obj.focus().removeClass("AutoCompleteLoad");
                            //$("#AutoCompleteMsg").html($obj.val() + "|" + $obj.attr('idvalue'));
                        });
                        return false;
                    });
                    $objList.find(".AutoCompleteInput").unbind().click(function() { return false; });
                    $objList.find(".AutoCompleteCancel").unbind().click(function() { $(this).parent().find("label").show().parent().find(".AutoCompleteInput").hide().parent().find(".AutoCompleteSave,.AutoCompleteCancel").hide().parent().attr("edit", "0").find(".AutoCompleteInput").val($(this).parent().find("span").text()); return false; });
                    $objList.find(".AutoCompleteSave").unbind().click(function() {
                        var $this = $(this);
                        if ($this.parent().find(".AutoCompleteInput").val().trim() == "") return false;
                        var old = $this.parent().find("span").text();
                        $(obj).addClass("AutoCompleteLoad");
                        $.post(api, { active: obj.id + ".Edit", "name": $this.parent().find(".AutoCompleteInput").val(), "id": parseInt($this.parent().attr("id").replace("AutoCompleteItem", "")) }, function(data) {
                            if (parseInt(data) != 1) { $obj.removeClass("AutoCompleteLoad"); alert("修改失败！"); return false; };
                            $this.parent().find("span").text($this.parent().find(".AutoCompleteInput").val()).parent().parent().find(".AutoCompleteCancel").click();
                            var idv = parseInt($this.parent().attr("id").replace("AutoCompleteItem", "")), val = $this.parent().find("span").text();
                            $(obj.data).each(function(i) { if (this.id == idv) obj.data[i].name = val; });
                            if (obj.value == old) obj.value = $this.parent().find("span").text();
                            $(obj).removeClass("AutoCompleteLoad");
                        });
                        return false;
                    });
                };
                $objList.hover(function() { $(this).addClass("mousemove"); }, function() { $(this).removeClass("mousemove"); });
                if (obj.add) {
                    $objList.append('<div class="{0}Item" id="{0}Item0"><input type="checkbox" id="chk{0}All" class="chkSelectAll"><input class="AutoCompleteAdd2" type="button" value="" title="添加" /><input type="text" class="AutoCompleteInput" style="display:inline;width:50%" /></div>'.format(obj.id));
                    $objList.find(".AutoCompleteAdd2").click(function() {
                        var objval = $(this).parent().find(".AutoCompleteInput").val();
                        if (objval.trim() == "") return false;
                        $(obj).addClass("AutoCompleteLoad");
                        $.post(api, { active: obj.id + ".Add", "name": objval }, function(data) {
                            if (parseInt(data) <= 0) { $obj.removeClass("AutoCompleteLoad"); alert("添加失败！"); return false; };
                            obj.data[obj.data.length] = { "id": parseInt(data), "name": objval, "del": true };
                            $(obj).removeClass("AutoCompleteLoad");
                            loadAjax();
                            return false;
                        });
                        return false;
                    }).parent().find("#chk{0}All".format(obj.id)).change(function() {
                        var $this = this;
                        $objList.find(":checkbox:not('#chk{0}All')".format(obj.id)).each(function() { if ($this.checked) { this.checked = true; $(this).change(); } else { this.checked = false; $(this).change(); } });
                    });
                };
                $(obj).removeClass("AutoCompleteLoad");
            }, "json");
        };
        loadAjax();

        $(obj).attr("readonly", "readonly").click(function() { $("#{0}List".format(obj.id)).show(); return false; });
        $("body").click(function() { if (!$("#{0}List".format(obj.id)).hasClass("mousemove")) $("#{0}List".format(obj.id)).hide(); });
    });
};

