﻿function doClick_up(o){
	 o.className="up_link";
	 var j;
	 var id;
	 var e;
	 for(var i=1;i<=3;i++){
	   id ="up"+i;
	   j = document.getElementById(id);
	   e = document.getElementById("up_con"+i);
	   if(id != o.id){
	   	 j.className="sp";
	   	 e.style.display = "none";
	   }else{
		e.style.display = "block";
	   }
	 }
	 }


var keyEnum={"enter":"13","ctrl":"17","space":"32","backspace":"8","shift":"16","esc":"27"};
root = typeof root == 'undefined' ? '' : root;
String.format = function() { var str = arguments[0]; for (var i = 1; i < arguments.length; i++) { var reg = new RegExp("\\{" + (i - 1) + "\\}", "ig"); str = str.replace(reg, arguments[i]); } return str; };

var BBSMAX = { AvatarDefault: root + '/assets/avatar/avatar_120.gif', ImageDefault: root + '/assets/images/NotFound.gif', CodeUrl: 'VerifyCode.aspx?type=', CodeLoadingImage: root + '/assets/images/loading.gif', MessageSoundPath: root + '/assets/sound-msg/', SpaceImage: root + '/assets/images/blank.gif', NetExistsExt: /^(accdb|as|asm|aspx|avi|bmp|c|cfc|chm|cpp|cs|css|db|default|dll|doc|docx|eip|fla|flv|gif|h|html|jpg|js|mdb|mp3|mpeg|mpg|msi|pdf|php|png|ppt|pptx|psd|rar|sln|swf|tif|txt|vb|vs|wav|wma|wmv|xls|xlsx|xml|zip)$/i, NetExistsPath: root + '/Images/FileIcons/48x48/', NetExistsWidth: 48, NetExistsHeight: 48, NetDefaultWidth: 70, NetDefaultHeight: 70, ImagePreviewBg: '/assets/Images/imagesPreview_percent_bg.gif' }

// Global
$Defined('Global'); var Global = { PATH: '/' }; Global.GetObject = function($_) { var d = document; return (d.all && d.all($_)) || (d.getElementById && d.getElementById($_)) || null; }
Global.GetDocWidth = function(d) { d = d || document; return Math.max(this.GetClientWidth(d), d.body.offsetWidth); }; Global.GetDocHeight = function(d) { d = d || document; return Math.max(this.GetClientHeight(d), d.body.offsetHeight); }; Global.GetScrollLeft = function(d) { d = d || document; return (d.documentElement ? d.documentElement.scrollLeft : d.body.scrollLeft); }; Global.GetScrollTop = function(d) { d = d || document; return (d.documentElement ? d.documentElement.scrollTop : d.body.scrollTop); }; Global.GetClientWidth = function(d) { d = d || document; return (window.innerWidth || d.documentElement && d.documentElement.clientWidth || d.body.clientWidth); }; Global.GetClientHeight = function(d) { d = d || document; return (window.innerHeight || d.documentElement && d.documentElement.clientHeight || d.body.clientHeight); }; Global.GetOffsetTop = function(el, p) {
    el = $(el); var _t = el.offsetTop; while (el = el.offsetParent) { if (el == p) break; _t += el.offsetTop; }
    return _t;
}; Global.GetOffsetLeft = function(el, p) {
    el = $(el); var _l = el.offsetLeft; while (el = el.offsetParent) { if (el == p) break; _l += el.offsetLeft; }
    return _l;
}; Global.Random = function() { return (new Date().getTime() + '_' + Math.floor(Math.random() * 10000000)); }; Global.FlashEnabled = function(startVersion, endVersion) {
    var enabled = false; var start = 6; var end = 11; if (typeof startVersion == 'number') { start = startVersion; end = endVersion ? (endVersion + 1) : (startVersion + 1); }
    try {
        if (window.ActiveXObject) {
            for (var i = start; i < end; i++) {
                if (new ActiveXObject('ShockwaveFlash.ShockwaveFlash.' + i))
                    break;
            }
            if (i < end) enabled = true;
        }
        else { var description = navigator.plugins['Shockwave Flash'].description; var arr = /^Shockwave\s+Flash\s+([0-9]+)/i.exec(description); if (arr && arr.length > 1 && arr[1] >= start && arr[1] < end) { enabled = true; } } 
    }
    catch (e) { enabled = false; }
    return (!!enabled);
}; Global.LoadScript = function(src) { document.write('<script type="text/javascript" src="' + src + '"><' + '/' + 'script>'); }; Array.prototype.push || (Array.prototype.push = function(arg) { this[this.length] = arg; }); function ToArray(obj, index) { return Array.prototype.slice.apply(obj).slice(index || 0); }
function TypeOf(obj) {
    if (typeof obj == 'undefined') return 'undefined'; var type = obj.constructor.name; if (obj.constructor && typeof (type) == 'undefined') {
        if (obj.constructor === Object)
            return 'object'; if (obj.constructor === Function)
            return 'function';
    }
    return (type ? type.toLowerCase() : 'string');
}; function $() {
    var $_ = arguments; if ($_.length == 1) { $_ = typeof $_[0] == 'string' ? Global.GetObject($_[0]) : $_[0]; }
    else if ($_.length > 1) { for (var i = 0; i < $_.length; i++) { $_[i] = typeof $_[i] == 'string' ? Global.GetObject($_[i]) : $_[i]; } }
    else { $_ = null; }
    return $_;
}
function $E(e, win) { win = win || window; return win.event || e || null; }
function $EO(e, win) { return e && (e.target || e.srcElement) || null; }
function $Defined(cls) {
    if (typeof eval(cls) != 'undefined')
        alert('变量' + cls + ' 重定义。');
}
window.onerror = function() { };

// String
String.prototype.Contains = function(str) { return (this.indexOf(str) > -1); }; String.prototype.Trim = function() { return this.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, ''); }; String.prototype.LTrim = function() { return this.replace(/^[ \t\n\r]*/g, ''); }; String.prototype.RTrim = function() { return this.replace(/[ \t\n\r]*$/g, ''); }; String.prototype.HtmlToStr = function() { return this.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;'); }; String.Space = function(num, htmlEntity) { var meta = htmlEntity ? '&nbsp;' : '\x20'; var str = ''; for (var i = 0; i < num; i++) str += meta; return str; }; $Defined('Browser'); var Browser = { s: navigator.userAgent.toLowerCase() }; (function(b) { b.IsIE = b.s.Contains('msie'); b.IsIE5 = b.s.Contains('msie 5'); b.IsIE6 = b.s.Contains('msie 6'); b.IsIE7 = b.s.Contains('msie 7'); b.IsIE56 = !b.IsIE7 && (b.IsIE6 || b.IsIE5); b.IsGecko = b.s.Contains('gecko'); b.IsSafari = b.s.Contains('safari'); b.IsOpera = b.s.Contains('opera'); b.IsMac = b.s.Contains('macintosh'); b.IsIELike = (b.IsIE || b.IsOpera); b.IsGeckoLike = (b.IsGecko || b.IsSafari); })(Browser);

// Events
$Defined('Events'); var Events = {}; Events.AttachEvent = function(obj, eventName, func, useCapture, _window) {
    obj = $(obj); if (!obj) return; useCapture = useCapture ? true : false; eventName = eventName.toLowerCase(); if (obj.addEventListener) { obj.addEventListener(eventName, func, useCapture); }
    else { var E = this; this._AttachEvent(obj, eventName, func); obj['on' + eventName] = function(e) { E._FireEvent(obj, eventName, e, _window); }; } 
}; Events.RemoveEvent = function(obj, eventName, func, useCapture) {
    obj = $(obj); if (!obj) return; useCapture = useCapture ? true : false; eventName = eventName.toLowerCase(); if (obj.removeEventListener) { obj.removeEventListener(eventName, func, useCapture); }
    else { if (obj.events && obj.events[eventName]) { var evts = obj.events[eventName]; for (var i = 0, len = evts.length; i < len; i++) { if (evts[i] && func && evts[i] === func) { evts.splice(i, 1); break; } } } } 
}; Events._AttachEvent = function(obj, eventName, func) { eventName = eventName.toLowerCase(); if (!obj.events) obj.events = {}; if (!obj.events[eventName]) obj.events[eventName] = []; var evts = obj.events[eventName]; evts[evts.length] = func; }; Events._FireEvent = function(obj, eventName, e, _window) {
    e = _window ? _window.event : $E(e); eventName = eventName.toLowerCase(); if (!obj || !obj.events || !obj.events[eventName]) return; var evts = obj.events[eventName]; for (var i = 0, len = evts.length; i < len; i++)
        evts[i] && evts[i].call(obj, e, obj);
}; Events.CancelBubble = function(e) { if (!e) return; e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); }; Events.CancelEvent = function(e) { if (!e) return; e.returnValue = false; if (e.preventDefault) e.preventDefault(); }; Events.CancelAll = function(e) { this.CancelBubble(e); this.CancelEvent(e); }; Events.Button = function(e) { if (e.button != undefined) return e.button; else if (e.which != undefined) return e.which; }; Events.OnLoadTasks = []; Events.AttachEvent(window, 'load', function() {
    for (var i = 0; i < Events.OnLoadTasks.length; i++) {
        if (typeof Events.OnLoadTasks[i] === 'function')
            Events.OnLoadTasks[i]();
    } 
});

// node
$Defined('oNode'); var oNode = {}; oNode.IsNode = function(el) {
    if (el && typeof el == 'object' && el.nodeType == 1)
        return true; return false;
}; oNode.IsNodeOrDocumentFragment = function(el) { return this.IsNode(el) || el && typeof el == 'object' && el.nodeType == 11; }
oNode.IsTextNode = function(el) {
    if (el && typeof el == 'object' && el.nodeType == 3)
        return true; return false;
}; oNode.CreateNode = function(tag) { return document.createElement(tag); }; oNode.CreateTextNode = function(str) { return document.createTextNode(str); }; oNode.AddNode = function(node, target) {
    target = target || document.body; if (this.IsNodeOrDocumentFragment(node) || this.IsTextNode(node)) { if (node.parentNode && this.IsNode(node.parentNode)) return false; target.appendChild(node); }
    else { this.AddNode(this.CreateTextNode(node.toString()), target); }
    return true;
}; oNode.RemoveNode = function(node, target) { if (!node || !node.parentNode || (node.parentNode && node.parentNode.nodeType != 1)) return null; return node.parentNode.removeChild(node); }; oNode.InsertBefore = function(node, target) { target.parentNode.insertBefore(node, target); }; oNode.CreateIframe = function(name) {
    var el; try { el = this.CreateNode('<iframe name="' + name + '">'); }
    catch (e) { el = this.CreateNode('iframe'); el.name = name; }
    el.id = name; return el;
}; oNode.CreateForm = function(name, method, enctype) {
    var el; try { el = this.CreateNode('<form name="' + name + '"' + (enctype ? 'enctype="' + enctype + '"' : '') + (method ? ' method="' + method + '"' : '') + '>'); }
    catch (e) { el = this.CreateNode('form'); method && (el.method = method); enctype && (el.enctype = enctype); el.name = name; }
    return el;
}; oNode.CreateInput = function(name) {
    var el; try { el = this.CreateNode('<input name="' + name + '">'); }
    catch (e) { el = this.CreateNode('input'); el.name = name; }
    return el;
};

// css
$Defined('CSS'); var CSS = { LEFT: 'left', RIGHT: 'right', BOTH: 'both' }; CSS.GetRe = function(c) { return new RegExp('^\\s*' + c + '\\s+|\\s+' + c + '\\s*$|\\s+' + c + '\\s+|^\\s*' + c + '\\s*$', ''); }; CSS.AddClass = function(el) { if (!oNode.IsNode(el)) return; var list = arguments; for (var i = 1, len = list.length; i < len; i++) { var c = list[i]; if (typeof c != 'string' || c == '') continue; var re = this.GetRe(c); if (!re.test(el.className)) { el.className += ((el.className ? '\x20' : '') + c).replace(/\s{2,}/g, '\x20'); } } }; CSS.RemoveClass = function(el) { if (!oNode.IsNode(el)) return; var list = arguments; for (var i = 1, len = list.length; i < len; i++) { var c = list[i]; if (typeof c != 'string' || c == '') continue; var re = this.GetRe(c); if (re.test(el.className)) { el.className = el.className.replace(re, '\x20').replace(/^\s{2,}$/, '\x20'); } } }; CSS.ReplaceClass = function(el, replaced, replacing) { this.RemoveClass(el, replaced); this.AddClass(el, replacing); }; CSS.HasClass = function(el, c) { if (!oNode.IsNode(el)) return false; if (typeof c != 'string' || c == '') return false; return this.GetRe(c).test(el.className); }; CSS.SetAlpha = function(el, opacity) {
    if (Browser.IsIE) {
        try { el.filters[0].Opacity = opacity; }
        catch (e) { el.style.filter = 'alpha(Opacity=' + opacity + ')'; } 
    }
    else { el.style.MozOpacity = opacity / 100; el.style.opacity = opacity / 100; } 
}; CSS.GetAlpha = function(el) {
    if (Browser.IsIE) {
        try { return el.filters[0].Opacity; }
        catch (e) { return 100; } 
    }
    else { return el.style.opacity * 100; } 
}; CSS.SetDisplay = function(el, display, unset) { el.style.display = !!display ? (unset ? 'block' : '') : 'none'; }; CSS.SetVisible = function(el, visible) { el.style.visibility = !!visible ? 'visible' : 'hidden'; }; CSS.SetFloat = function(el, dir) { el.style.styleFloat = dir; el.style.cssFloat = dir; }; CSS.AddClear = function(el, clear) { var node = oNode.CreateNode('div'); oNode.AddNode(node, el); node.style.overflow = 'hidden'; node.style.clear = clear; return node; }; CSS.SelectOn = function(doc) { doc = doc || document; doc.body.style.MozUserSelect = ''; doc.body.style.KhtmlUserSelect = ''; doc.onselectstart = null; }; CSS.SelectOff = function(doc) { doc = doc || document; doc.body.style.MozUserSelect = 'none'; doc.body.style.KhtmlUserSelect = 'none'; doc.onselectstart = function() { return false }; };
CSS.AddBack = function(el, insertBefore) {
    var BG = oNode.CreateNode('div'); if (el) el.$BG = BG; el && insertBefore ? oNode.InsertBefore(BG, el) : oNode.AddNode(BG); with (BG.style) { position = 'absolute'; zIndex = 1; left = '0px'; top = '0px'; background = 'transparent url(' + BBSMAX.SpaceImage + ') repeat 0 0'; }
    BG.Show = function() { this.style.width = Global.GetDocWidth() - (Browser.IsGecko && !Browser.IsSafari ? 18 : 0) + 'px'; this.style.height = Math.max(Global.GetDocHeight(), Global.GetClientHeight()) + 'px'; CSS.SetVisible(this, true); }; BG.Hide = function() { CSS.SetVisible(this, false); with (this.style) { width = '1px'; height = '1px'; } }; BG.Show(); return BG;
}; CSS.AddStyle = function(cssText) {
    var s = oNode.CreateNode('style'); s.type = 'text/css'; if (s.styleSheet) { s.styleSheet.cssText = cssText; }
    else { oNode.AddNode(cssText, s); }
    oNode.AddNode(s, document.getElementsByTagName('head')[0]); return s;
};

// oajax
function oAjax() { this.req = null; this.url = ''; this.content = ''; this.type = 'text'; this.encode = ''; this.asyn = true; this.action = 'get'; this.error = false; }
oAjax.prototype.init = function() {
    if (window.XMLHttpRequest) { this.req = new XMLHttpRequest(); }
    else if (window.ActiveXObject) {
        try { this.req = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e) {
            try { this.req = new ActiveXObject("Microsoft.XMLHTTP"); }
            catch (e) { this.req = false; } 
        } 
    }
    var self = this; if (this.req) { this.req.onreadystatechange = function() { self.listener() }; } 
}; oAjax.prototype.listener = function() {
    if (this.req.readyState == 4) {
        if (this.req.status == 200) {
            try { this.callback(Browser.IsIE && this.encode == 'gb2312' ? oAjax.gb2utf8(this.req.responseBody) : (this.type == 'text' ? this.req.responseText : this.req.responseXML)); }
            catch (e) { this.halt('[callback] ' + e.name + ':' + e.message); } 
        }
        else { this.halt('[callback error] ' + this.req.status); } 
    } 
}; oAjax.prototype.send = function(url) {
    this.init(); url = this.url = url || this.url || ''; this.content = !!this.content ? this.content : ''; this.encode = this.encode ? this.encode.toLowerCase() : ''; this.asyn = this.asyn == undefined ? true : !!this.asyn; this.action = (this.action == undefined || this.action == 'get') ? 'Get' : 'Post'; this.error = this.error == undefined ? false : !!this.error; if (!url && this.error) { alert('Ajax请求URL不能为空。'); return; }
    try { this.req.open(this.action, url, this.asyn); }
    catch (e) { this.halt('[open] ' + e.name + ':' + e.message); return; }
    try {
        this.req.setRequestHeader('Connection', 'close'); this.req.setRequestHeader('Accept-Encoding', 'gzip, deflate'); this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded' + (this.encode ? ';charset=' + this.encode : '')); if (this.req.overrideMimeType && this.encode) { this.req.overrideMimeType('text/xml' + (this.encode ? ';charset=' + this.encode : '')); }
        this.req.send(this.content);
    }
    catch (e) { this.halt('[open] ' + e.name + ':' + e.message + '\n** 检查是否为跨域访问。'); } 
}; oAjax.prototype.callback = function(content) { }; oAjax.prototype.abort = function() { this.req.abort(); }; oAjax.prototype.halt = function(description) { this.error && alert(description); }; oAjax.gb2utf8 = function(data) {
    var glbEncode = []; gb2utf8_data = data; execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript"); var t = escape(gb2utf8_data).replace(/%u/g, "").replace(/(.{2})(.{2})/g, "%$2%$1").replace(/%([A-Z].)%(.{2})/g, "@$1$2"); t = t.split("@"); var i = 0, j = t.length, k; while (++i < j) {
        k = t[i].substring(0, 4); if (!glbEncode[k]) { gb2utf8_char = eval("0x" + k); execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript"); glbEncode[k] = escape(gb2utf8_char).substring(1, 6); }
        t[i] = glbEncode[k] + t[i].substring(4);
    }
    gb2utf8_data = gb2utf8_char = null; return unescape(t.join("%"));
}

// Url
$Defined('Url'); var Url = { l: location }; Url.Get = function() {
    var $_ = arguments; if ($_.length == 1) { ($_ = ($_[0] in this.QS()) ? this.QS()[$_[0]] : ''); }
    else if ($_.length > 1) { for (var i = 0; i < $_.length; i++) { $_[i] = $_[i] in this.QS() ? this.QS()[$_[i]] : ''; } }
    else { $_ = ''; }
    return $_;
}
Url.Set = function(name, value) { this.QueryString[name] = value; }; Url.Retrieve = function() {
    var _url = ''; for (var item in this.QueryString) {
        var cur = this.QueryString[item]; if (_url != '') _url += '&'; if (typeof (cur) == 'object') { for (var i = 0, len = cur.length; i < len; i++) { if (_url != '') _url += '&'; _url += item + '=' + encodeURIComponent(cur[i]); } }
        else { _url += item + '=' + encodeURIComponent(cur); } 
    }
    return _url;
}
Url.QS = function() {
    if (typeof this.QueryString == 'undefined') {
        this.QueryString = {}; var query = this.l.search; query = query.substr(1); query = query.split('&'); for (var i = 0, len = query.length; i < len; i++) {
            var item = query[i].split('='); var name = item[0]; var value = decodeURIComponent(item[1] || ''); if (typeof this.QueryString[name] == 'undefined') { this.QueryString[name] = value; }
            else if (typeof (this.QueryString[name]) == 'object') { this.QueryString[name].push(value); }
            else { var _value = this.QueryString[name]; this.QueryString[name] = [_value, value]; } 
        } 
    }
    return this.QueryString;
}
Url.Reload = function(url) {
    if (!/^https?:\/\//i.test(url)) {
        var index = this.l.href.lastIndexOf(url); if (url != '/' && index > 0 && url != this.l.href.substr(index))
            this.l.reload(true); else
            this.l.href = url;
    }
    else
        this.l.href = url;
}; Url.ClearAnchor = function(url) { url = url || this.l.href; return url.substring(0, url.indexOf('#')); }; Url.GetAnchor = function(url) { url = url || this.l.href; return url.substr((url.lastIndexOf('#') + 1) || url.length); }; Url.GotoAnchor = function(name) { if (name == '') return; this.l.hash = name; }; Url.Add = function(url, name, value) { if (!value) return url; url = url.indexOf('?') > -1 ? '&' : '?'; url += name + '=' + encodeURIComponent(value); return url; }; Url.Escape = function(str) { return escape(this.UTF8Encode(str)); }; Url.UTF8Encode = function(str) {
    str = str.toString().replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < str.length; n++) {
        var c = str.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); }
        else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); }
        else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } 
    }
    return utftext;
}; Url.UTF8Decode = function(utftext) {
    var str = ''; var i = 0; var c = c1 = c2 = 0; utftext = utftext.toString(); while (i < utftext.length) {
        c = utftext.charCodeAt(i); if (c < 128) { str += String.fromCharCode(c); i++; }
        else if ((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); str += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; }
        else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); str += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } 
    }
    return str;
}; Url.QS();

// PopUp
$Defined('PopUp'); var PopUp = {}; PopUp.Index = 1; PopUp.Panel = function(item, w, h, p) {
    var leaf = oNode.IsNode(item) && item.parentNode; var panel = leaf ? item : oNode.CreateNode('div'); panel.tabIndex = "-1"; panel.style.position = 'absolute'; panel.style.left = '-10000px'; panel.style.top = '-10000px'; panel.style.zIndex = 2; if (leaf) panel.$Parent = panel.parentNode; panel.Center = function(center) {
        if (center || p) {
            if (leaf) { panel.style.display = 'block'; w = panel.offsetWidth; h = panel.offsetHeight; }
            w = w || panel.offsetWidth; h = h || panel.offsetHeight; panel.$P = p; panel.style.left = ((Global.GetClientWidth() || Global.GetDocWidth()) - w) / 2 + 'px'; panel.style.top = Global.GetScrollTop() + ((Global.GetClientHeight() || Global.GetDocHeight()) - h) / 2 + 'px'; function move() {
                if (w != panel.offsetWidth) w = panel.offsetWidth; if (h != panel.offsetHeight) h = panel.offsetHeight; panel.style.left = ((Global.GetClientWidth() || Global.GetDocWidth()) - w) / 2 + 'px'; panel.style.top = Global.GetScrollTop() + ((Global.GetClientHeight() || Global.GetDocHeight()) - h) / 2 + 'px'; if (panel.$D) { panel.$D.Show(); }
                if (panel.$M) { panel.$M.style.left = panel.style.left; panel.$M.style.top = panel.style.top; } 
            }
            panel.$Move = move; Events.AttachEvent(window, 'resize', move);
        } 
    }; panel.Center(); if (typeof item != 'string') { if (!leaf) oNode.AddNode(item, panel); }
    else { panel.innerHTML = item; }
    return panel;
}; PopUp.AddPopUp = function(node, modal, target) {
    oNode.AddNode(node, target); if (modal) var D = node.$D = CSS.AddBack(node, true); if (node.gradual) {
        var alpha = 0; var gradual = function() {
            if (alpha > 100) { CSS.SetAlpha(node, 100); return; }
            CSS.SetAlpha(node, alpha); alpha += 15; setTimeout(gradual, 0);
        }
        gradual();
    }
    return node.$D;
}; PopUp.AddMask = function(node) { if (!Browser.IsIE56) return; var M = node.$M = oNode.CreateNode('iframe'); oNode.InsertBefore(M, node); M.frameBorder = 0; M.scrolling = 'no'; with (M.style) { position = 'absolute'; left = node.style.left; top = node.style.top; width = node.offsetWidth + 'px'; height = node.offsetHeight + 'px'; opacity = 0; filter = 'alpha(opacity=0)'; } }; PopUp.RemovePopUp = function(node, target) { target = target || document.body; if (node.parentNode != target) return false; oNode.RemoveNode(node, target); if (node.$D) oNode.RemoveNode(node.$D, node.$D.parentNode); if (node.$M) oNode.RemoveNode(node.$M, node.parentNode); if (node.$BG) oNode.RemoveNode(node.$BG); if (node.$P) Events.RemoveEvent(window, 'resize', node.$Move); }; PopUp.RestorePopUp = function(node) { node.style.left = '-10000px'; node.style.top = '-10000px'; PopUp.RemovePopUp(node, node.parentNode); node.$Parent && oNode.AddNode(node, node.$Parent); }; PopUp.SetXY = function(node, x, y) { node.style.left = typeof x == 'string' ? x : x + 'px'; node.style.top = typeof y == 'string' ? y : y + 'px'; if (node.$M) { node.$M.style.left = node.style.left; node.$M.style.top = node.style.top; } }; PopUp.ResetXY = function(node) { if (node.$M) { node.$M.style.left = node.style.left; node.$M.style.top = node.style.top; } }
PopUp.SetSize = function(node, w, h) { this.SetSizeW(node, w); this.SetSizeH(node, h); }; PopUp.SetSizeW = function(node, w) { w = typeof w == 'string' ? w : w + 'px'; node.style.width = w; this.ResetSize(node); }; PopUp.SetSizeH = function(node, h) { h = typeof h == 'string' ? h : h + 'px'; node.style.height = h; this.ResetSize(node); }; PopUp.ResetSize = function(node) { if (node.$M) { node.$M.style.width = node.offsetWidth + 'px'; node.$M.style.height = node.offsetHeight + 'px'; } }; PopUp.SetVisible = function(node, visible) { visible = visible ? 'visible' : 'hidden'; node.style.visibility = visible; if (node.$D) node.$D.style.visibility = visible; if (node.$M) node.$M.style.visibility = visible; if (node.$BG) node.$BG.style.visibility = visible; }; PopUp.SetDisplay = function(node, display) { display = display ? 'block' : 'none'; node.style.display = display; if (node.$D) node.$D.style.display = display; if (node.$M) node.$M.style.display = display; if (node.$BG) node.$BG.style.display = display; }; PopUp.HideModal = function(node) { if (node.$D) CSS.SetAlpha(node.$D, 0); }

// Effects
$Defined('Effects'); var Effects = {}; Effects.Trans = function(container, list, time_min, time_max) {
    if (!oNode.IsNode(container)) return; if (typeof list != 'object' || !list.length) return; var _container = document.createElement('div'); container.appendChild(_container); with (_container.style) { position = 'relative'; left = 0; top = 0; width = '100%'; height = '100%'; }
    for (var i = 0; i < list.length; i++) {
        var c = document.createElement('div'); _container.appendChild(c); with (c.style) { position = 'absolute'; left = 0; top = 0; width = '100%'; height = '100%'; textAlign = 'center'; opacity = 0; filter = 'alpha(opacity=0)'; }
        c.innerHTML = list[i]; list[i] = c;
    }
    var interval; var current = 0; var previous = 0; time_min = time_min || 100; time_max = time_max || 1000; function run() {
        if (CSS.GetAlpha(list[previous]) >= 100) { CSS.SetAlpha(list[previous], 0); }
        var cur = list[current]; var alpha = CSS.GetAlpha(cur) + 10; CSS.SetAlpha(cur, alpha); var pause = false; if (alpha >= 100) { pause = true; previous = current; current = (current + 1) % list.length; }
        interval = setTimeout(run, pause ? time_max : time_min);
    }; run();
}; Effects.TransColor = function(container, colors, time) {
    if (!oNode.IsNode(container)) return; var len = colors.length; for (var i = 0; i < len; i++) { colors[i] = Color.GetNumFromColor(colors[i]); }
    var interval; var current = 0; var cur_color = colors[0]; var step = 100; function run() {
        if (cur_color + step > colors[(current + 1) % len]) { current = (current + 1) % len; cur_color = colors[current]; }
        else { cur_color += step; }
        container.style.color = Color.GetColorFromNum(cur_color); interval = setTimeout(run, time);
    }; run();
}
Effects.Roll = function() { }; Effects.Switch = function(list, butFocusCss, butBlurCss) {
    for (var i = 0, len = list.length; i < len; i++) { if (!oNode.IsNode(list[i][0])) list[i][0] = $(list[i][0]); if (!oNode.IsNode(list[i][1])) list[i][1] = $(list[i][1]); }
    var cur = 0; function _click(e, th) { th = th || this; if (cur == th.index) return; var cur_but = list[cur][0]; CSS.RemoveClass(cur_but, butFocusCss); CSS.AddClass(cur_but, butBlurCss); list[cur][1].style.display = 'none'; cur_but = list[th.index][0]; CSS.RemoveClass(cur_but, butBlurCss); CSS.AddClass(cur_but, butFocusCss); list[th.index][1].style.display = ''; cur = th.index; Events.CancelAll(e); }
    for (var i = 0, len = list.length; i < len; i++) { var _cur = list[i]; var cur_but = _cur[0]; cur_but.index = i; Events.AttachEvent(cur_but, 'click', _click); _cur[1].style.display = i == 0 ? '' : 'none'; }
    list[0][1].style.display = '';
}; Effects.Move = function(bar, panel, arg) {
    var is_down = false; var p = []; var X = 0, Y = 0; var x = 0, y = 0; var z_index = 10000; var topmost = false, modal = false, move, top, right, bottom, left, width, height, down_func, move_func, up_func, relateBody; if (arg) { topmost = arg.topmost; modal = arg.modal; move = arg.move == undefined ? true : arg.move; top = arg.top; right = arg.right; bottom = arg.bottom; left = arg.left; width = arg.width; height = arg.height; down_func = typeof arg.downFunc == 'function' ? arg.downFunc : null; move_func = typeof arg.moveFunc == 'function' ? arg.moveFunc : null; up_func = typeof arg.upFunc == 'function' ? arg.upFunc : null; relateBody = typeof arg.relateBody == 'undefined' ? true : arg.relateBody; }
    bar.ondrag = function() { return false }; bar.onselectstart = function() { return false }; var back = null; function mouse_down(e) {
        is_down = true; p[0] = e.clientX, p[1] = e.clientY; x = e.clientX + (relateBody ? Global.GetScrollLeft() : 0); y = e.clientY + (relateBody ? Global.GetScrollTop() : 0); X = parseInt(panel.style.left); Y = parseInt(panel.style.top); down_func && down_func(e); if (!panel.$D) { if (!back) back = CSS.AddBack(panel); CSS.SetAlpha(back, 0); back.Show(); }
        Events.CancelAll(e);
    }
    function mouse_move(e) {
        if (is_down) {
            var xy = getXY(e); if (modal) {
                var modal_panel = panel.modal_panel; if (!modal_panel) { modal_panel = panel.modal_panel = oNode.CreateNode('div'); oNode.AddNode(modal_panel, panel.parentNode); with (modal_panel.style) { position = 'absolute'; move ? (cursor = 'move') : ''; zIndex = panel.style.zIndex; width = panel.offsetWidth + 'px'; height = panel.offsetHeight + 'px'; border = '1px dotted #000'; } }
                if (topmost && !panel.zIndex) { panel.zIndex = panel.style.zIndex; modal_panel.style.zIndex = z_index; }
                modal_panel.style.left = xy[0]; modal_panel.style.top = xy[1];
            }
            else {
                if (topmost && !panel.zIndex) { panel.zIndex = panel.style.zIndex; panel.style.zIndex = z_index; }
                panel.style.left = xy[0]; panel.style.top = xy[1];
            }
            move_func && move_func(e);
        }
        return false;
    }
    function mouse_up(e) {
        p[2] = e.clientX, p[3] = e.clientY; if (is_down) {
            is_down = false; if (modal && panel.modal_panel) {
                if (topmost) { panel.zIndex = 0; }
                panel.style.left = panel.modal_panel.style.left; panel.style.top = panel.modal_panel.style.top; oNode.RemoveNode(panel.modal_panel, panel.parentNode); panel.modal_panel = null;
            }
            else {
                if (topmost) { panel.style.zIndex = panel.zIndex; panel.zIndex = 0; }
                var xy = getXY(e); panel.style.left = xy[0]; panel.style.top = xy[1];
            }
            PopUp.ResetXY(panel); back && back.Hide(); up_func && up_func(e, p);
        }
        else { } 
    }
    function getXY(e) {
        var x_t = X + e.clientX - x; var y_t = Y + e.clientY - y; var w_t = panel.offsetWidth - Global.GetClientWidth(); var h_t = panel.offsetHeight - Global.GetClientHeight(); var _w_t = panel.offsetWidth - Global.GetClientWidth() / 2; var _h_t = panel.offsetHeight - Global.GetClientHeight() / 2; if (_w_t > 0) { left = -(panel.offsetWidth - Global.GetClientWidth() / 2); right = Global.GetClientWidth() / 2; }
        else { left = 0; right = -w_t; }
        if (_h_t > 0) { top = -(panel.offsetHeight - Global.GetClientHeight() / 2); bottom = Global.GetClientHeight() / 2; }
        else { top = 0; bottom = -h_t; }
        if (x_t < left) x_t = left; else if (x_t > right) x_t = right; if (y_t < top) y_t = top; else if (y_t > bottom) y_t = bottom; x_t = x_t + (relateBody ? Global.GetScrollLeft() : 0) + 'px'; y_t = y_t + (relateBody ? Global.GetScrollTop() : 0) + 'px'; return [x_t, y_t];
    }
    Events.AttachEvent(bar, 'mousedown', mouse_down); Events.AttachEvent(document, 'mousemove', mouse_move); Events.AttachEvent(bar, 'mouseup', mouse_up); panel.RemoveEvent = function() { Events.RemoveEvent(bar, 'mousedown', mouse_down); Events.RemoveEvent(document, 'mousemove', mouse_move); Events.RemoveEvent(bar, 'mouseup', mouse_up); }
    if (panel.style.position != 'absolute') { var _l = Global.GetOffsetLeft(panel); var _t = Global.GetOffsetTop(panel); panel.style.position = 'absolute'; panel.style.zIndex = 1; panel.style.left = _l + 'px'; panel.style.top = _t + 'px'; }
    if (move && bar) bar.style.cursor = 'move';
}

// common
function userMsg() {
    var user_msg = $('user_msg'); if (!user_msg) return; var tip = user_msg.tip; if (!tip) {
        if (!$('user_message') || !$('user_msg_close')) return; $('user_message')._html = $('user_message').innerHTML; $('user_message').innerHTML = ''; var content = $('user_message')._html; tip = user_msg.tip = PopUp.Panel(content); PopUp.AddPopUp(tip, false, document.forms[0]); PopUp.AddMask(tip); function user_msg_resize() { var l = Global.GetOffsetLeft(user_msg) - 287 + 75; var t = Global.GetOffsetTop(user_msg) + 15; PopUp.SetXY(tip, l, t); }
        user_msg_resize(); Events.AttachEvent(window, 'resize', user_msg_resize); var close = userMsg.close = function(e) { Events.RemoveEvent(window, 'resize', user_msg_resize); Events.RemoveEvent($('user_msg_close'), 'click', close); PopUp.RemovePopUp(tip, tip.parentNode); e && Events.CancelAll(e); } 
    } 
}
function userMsgReply(th, messageId) {
    var p = th.parentNode.parentNode; var reply = $('user_message_reply'); oNode.RemoveNode(reply, reply.parentNode); if (th.parentNode.parentNode.nextSibling) { oNode.InsertBefore(reply, th.parentNode.parentNode.nextSibling); }
    else { oNode.AddNode(reply, p.parentNode); }
    reply.style.display = ''; $('topHiddenMessageID').value = messageId;
}
BindPopup.currentMenu = null; BindPopup.back = null; function BindPopup(binderId, popupId, align, offsetX, offsetY, delay) {
    var binder = $(binderId); if (!binder) return; var popup = $(popupId); if (!popup) return; popup.style.position = 'absolute'; popup.style.visibility = 'visible'; popup.style.zIndex = 10; if (!offsetX) offsetX = 0; if (!offsetY) offsetY = 0; var back = BindPopup.back; if (Browser.IsIE56 && !back) { back = BindPopup.back = oNode.CreateNode('iframe'); oNode.InsertBefore(back, popup); back.style.position = 'absolute'; back.style.left = '-1000px'; back.style.top = '-1000px'; CSS.SetAlpha(back, 0); }
    var interval; Events.AttachEvent(binder, 'mouseover', function() {
        if (delay)
            binder.interval = setTimeout(show, 500); else
            show();
    }); Events.AttachEvent(binder, 'mouseout', function() {
        if (delay) { clearTimeout(binder.interval); hide(); }
        else
            hide();
    }); Events.AttachEvent(popup, 'mouseover', function() { clearTimeout(interval); }); Events.AttachEvent(popup, 'mouseout', function() { hide(); }); function show() {
        if (interval) clearTimeout(interval); if (BindPopup.currentMenu && BindPopup.currentMenu != popup)
            BindPopup.currentMenu.hide(); popup.style.zIndex = 10; popup.style.display = ''; move(); BindPopup.currentMenu = popup;
    }
    function move() {
        popup.style.top = Global.GetOffsetTop(binder) + binder.offsetHeight + 'px'; var left = Global.GetOffsetLeft(binder); align = align || 'left'; switch (align.toString().toLowerCase()) { case 'left': break; case 'center': left += (binder.offsetWidth - popup.offsetWidth) / 2; break; case 'right': left += binder.offsetWidth - popup.offsetWidth; break; }
        popup.style.left = left + offsetX + 'px'; if (back) { back.style.left = popup.style.left; back.style.top = popup.style.top; back.style.width = popup.offsetWidth + 'px'; back.style.height = popup.offsetHeight + 'px'; } 
    }
    function hide() { interval = setTimeout(_hide, 500); }
    function _hide() {
        popup.style.display = 'none'; popup.style.zIndex = 1; if (back) { back.style.left = '-1000px'; back.style.top = '-1000px'; }
        Events.RemoveEvent(window, 'resize', move);
    }
    popup.hide = _hide;
}
function resetPopup(el) {
    if (el.tagName.toLowerCase() == 'div')
        return el; var c = document.createElement('div'); c.innerHTML = el.innerHTML; oNode.RemoveNode(el); oNode.AddNode(c); c.style.display = 'none'; return c;
}
function Switch(num, tag) {
    for (var x = 1; x < num; x++) {
        var list = []; var heads = $('head_' + x).getElementsByTagName('a'); var bodys = $('body_' + x).getElementsByTagName(tag ? tag[x - 1] : 'ul'); for (var i = 0, len = heads.length; i < len; i++) { list[i] = [heads[i], bodys[i]]; }
        Effects.Switch(list, 'current', '');
    } 
}
function FormSubmit(th) { setTimeout(function() { th.disabled = true }, 100); return true; }
function itemClick(th) {
    try { var p = th.parentNode.parentNode; th.checked ? CSS.AddClass(p, 'current') : CSS.RemoveClass(p, 'current'); }
    catch (e) { } 
}
function itemMouseOver(th) { CSS.AddClass(th, 'hover'); th.onmouseout || (th.onmouseout = function() { CSS.RemoveClass(th, 'hover'); }); }
function imageScale(th, dw, dh, nonMargin) {
    var ow = th.offsetWidth, oh = th.offsetHeight; th.ow = ow; th.oh = oh; if (ow / oh > dw / dh) {
        if (ow > dw) { th.style.width = dw + 'px'; th.style.height = dw / ow * oh + 'px'; nonMargin || (th.style.marginTop = (dh - dw / ow * oh) / 2 + 'px'); }
        else { nonMargin || (th.style.marginTop = (dh - oh) / 2 + 'px'); } 
    }
    else {
        if (oh > dh) { th.style.height = dh + 'px'; th.style.width = dh / oh * ow + 'px'; }
        else { nonMargin || (th.style.marginTop = (dh - oh) / 2 + 'px'); } 
    } 
}
function imageTip(pCss) {
    var tip = new Tip(); tip.Condition = function(e) {
        var obj = $EO(e); while (obj) { if (obj.className && obj.className.indexOf(pCss) > -1) break; obj = obj.parentNode; }
        if (obj) obj = $EO(e); if (!obj || obj.tagName.toLowerCase() != 'img') { this.display = false; }
        else {
            if (imageTip.src != obj.src) { imageTip.src = obj.src; this.text = '<img src="' + obj.src + '" />'; }
            this.display = true;
        }
        return true;
    }; tip.Change = function(e, flow) { var imgs = flow.getElementsByTagName('img'); if (imgs && imgs[0]) { var ow = imgs[0].width, oh = imgs[0].height; var w = 300; if (w < ow) { imgs[0].width = w - 20; imgs[0].height = (w - 20) / ow * oh; } } }; tip.Create(); tip.css.tip = 'image-tip';
}
function clearEditorContent(str) { str = str.replace(/(<img[^>]+?)onload="[^"]+?"([^>]*?>)/gi, '$1$2'); str = str.replace(/(<img[^>]+?)onerror="[^"]+?"([^>]*?>)/gi, '$1$2'); return str; }
function validateClear(validate_id, input_name, panel_id) { validateReset(validate_id); input_name = document.getElementsByName(input_name); input_name.length > 0 && (input_name[0].value = ''); AjaxRequest.Clear('ap_checkvcode'); }
function validateReset(id) { var p = $(id); if (!p) return; var img = p.getElementsByTagName('img')[0]; if (!img) return; if (!img._src) img._src = img.src; img.src = img._src + '&rnd=' + Math.random(); }
function reloadImage(th) { if (!th._src) th._src = th.src; var src = th._src + (th._src.indexOf('?') > -1 ? '&' : '?'); th.src = src + 'rnd=' + Math.random(); }
DomEvent.events = {}; DomEvent.list = []; DomEvent.saved = true; DomEvent.EventExecuteAble = true; DomEvent.EventExecuteFunc = new Function(); function DomEvent() {
    var isShift, isCtrl, isAlt; var type = 0; function keyEvent(e) {
        var num = 0; var EnterNum = 0; isShift = e.shiftKey; isCtrl = e.ctrlKey; isAlt = e.altKey; var es = DomEvent.events; for (var item in es) {
            if ((!es[item][0].isShift && !es[item][0].isCtrl && !es[item][0].isAlt && !isShift && !isCtrl && !isAlt && es[item][0].keyCode == e.keyCode && e.keyCode == 13 && (type = 1)) || (isShift && isShift == es[item][0].isShift && es[item][0].keyCode == e.keyCode && (type = 2)) || (isCtrl && isCtrl == es[item][0].isCtrl && es[item][0].keyCode == e.keyCode && (type = 3)) || (isAlt && isAlt == es[item][0].isAlt && es[item][0].keyCode == e.keyCode && (type = 4))) {
                num++; if (type == 1 && !DomEvent.EventExecuteAble) { DomEvent.EventExecuteFunc && DomEvent.EventExecuteFunc(); return false; }
                if (type == 1 && $EO(e).tagName.toLowerCase() == 'textarea') { if (Widget.InfoNum == 1) { Events.CancelAll(e); DomEvent.DefaultClose(); } return false; }
                if (Widget.InfoNum == 1) { DomEvent.DefaultClose(); Events.CancelAll(e); return false; }
                else {
                    if (type == 1 && es[item][2] && $(es[item][2]) && $(es[item][2]).type == 'submit')
                        continue; if (es[item][2] && $(es[item][2]))
                        es[item][1].call($(es[item][2])); else
                        es[item][1]();
                } 
            } 
        } 
    }
    if (Browser.IsOpera)
        Events.AttachEvent(document, 'keypress', keyEvent); else
        Events.AttachEvent(document, 'keydown', keyEvent); DomEvent.AttachDefault();
}
DomEvent.AttachDefault = function() { DomEvent.events['InfoClose_' + Global.Random()] = [{ isShift: false, isCtrl: false, isAlt: false, keyCode: 13 }, DomEvent.DefaultClose]; }; DomEvent.DefaultClose = function() { Widget && Widget.InfoClose(); AjaxRequest.IsSubmited = false; }; DomEvent.Clear = function(retrieve) {
    this.events = {}; this.saved = false; if (retrieve) { this.saved = true; for (var i = 0, len = this.list.length; i < len; i++) { var l = this.list[i]; setShortcut.apply(null, l); } }
    DomEvent.AttachDefault();
}; function setShortcut(buttonName, eventName, shortcut, func) {
    buttonName = buttonName && buttonName.id || buttonName; this.saved && this.list.push([buttonName, eventName, shortcut, func]); if (typeof shortcut == 'string') shortcut = [shortcut.toLowerCase()]; for (var i = 0, len = shortcut.length; i < len; i++) {
        var arr = /(shift|ctrl|alt)\+([a-z0-9]+)/i.exec(shortcut[i]); if (!arr && shortcut[i] != 'enter') return; if (shortcut[i] == 'enter') arr = ['', '', 'enter']; arr[1] = arr[1].toLowerCase(); arr[2] = arr[2].toLowerCase(); var _shortcut = { isShift: arr[1] == 'shift', isCtrl: arr[1] == 'ctrl', isAlt: arr[1] == 'alt', keyCode: arr[2] == 'enter' ? 13 : arr[2].charCodeAt(0) }; if (_shortcut.keyCode >= 97 && _shortcut.keyCode <= 121) { _shortcut.keyCode -= 32; }
        var hasAttach = false; for (var item in DomEvent.events) { if (!item[1]) continue; if (item[1].toString() == func.toString() && item[0].isShift == _shortcut.isShift && item[0].isCtrl == _shortcut.isCtrl && item[0].isAlt == _shortcut.isAlt && item[0].keyCode == _shortcut.key) { hasAttach = true; break; } }
        if (!hasAttach)
            DomEvent.events[buttonName + '_' + Global.Random()] = [_shortcut, func, buttonName];
    }
    var but = buttonName && $(buttonName); but && Events.AttachEvent(but, eventName, func);
}
function ubbCopy(th) { var txt = th.parentNode.parentNode.getElementsByTagName('code')[0].innerHTML; txt = txt.replace(/&lt;/g, '<'); txt = txt.replace(/&gt;/g, '>'); txt = txt.replace(/&nbsp;/g, ' '); txt = txt.replace(/&amp;/g, '&'); copyToClipboard(txt); }
function ubbRun(th) { var txt = th.parentNode.parentNode.getElementsByTagName('code')[0].innerHTML; var win = window.open('about:blank'); txt = txt.replace(/&lt;/g, '<'); txt = txt.replace(/&gt;/g, '>'); txt = txt.replace(/&amp;/g, '&'); win.document.open(); win.document.write(txt); win.document.close(); }
function hideMenu(menu) { Events.AttachEvent(menu, 'click', function() { this.style.visibility = 'hidden'; Events.AttachEvent(this, 'click', arguments.callee); }); }
function selectedMenuItem() { var sidebar = $('sidebar_content'); if (!sidebar) return; var links = sidebar.getElementsByTagName('a'); for (var i = links.length - 1; i > -1; i--) { if (location.href.indexOf(links[i].href) > -1) { CSS.AddClass(links[i], 'current'); break; } } }
function undisabledSubmit() { var inputs = document.getElementsByTagName('input'); for (var i = 0, len = inputs.length; i < len; i++) { if (inputs[i].type == 'submit') inputs[i].disabled = false; } }
function postTo(url) { url = url.toLowerCase(); if (url.indexOf(root.toLowerCase() + '/?') == 0) { url = url.replace('/?', '/default.aspx?') } else if (url.indexOf('?') == 0) { url = url.replace('?', 'default.aspx?') } document.forms[0].action = url; document.forms[0].submit(); }
function go(url) { location.href = url; }
function Reload(url) {
    var href = Url.ClearAnchor(location.href); var arr = /^http(?:s)?:\/\/[^\/]+\:(\d+)\//i.exec(href); var _url = '://' + location.host + (arr && arr[1] ? ':' + arr[1] : '') + Url.ClearAnchor(url); if (href == 'http' + _url || href == 'https' + _url) {
        if (url.indexOf('#') == -1) { location.href = url; }
        else { location.href = '/go.aspx?url=' + encodeURIComponent(url); } 
    }
    else { location.href = url; } 
}
function QQChat(qq) { openFile('Tencent://Message/?menu=yes&exe=&uin=' + qq + '&websiteName=bbsmax&info='); }
function WLMChat(msn) { openFile('msnim:chat?contact=' + msn); }
function WangWang(id) { openFile('wangwang:SendIM?' + id + '&uid_t=' + id); }
function Skype(id) { openFile('skype:' + id + '?call'); }
function Gtalk(gmail) { openFile('gtalk:chat?jid=' + gmail); }
function openFile(url) {
    var self = arguments.callee; var frame = self.frame; if (!frame) { frame = self.frame = oNode.CreateIframe('im_' + Global.Random()); oNode.AddNode(frame); frame.style.display = 'none'; }
    window.open(url, frame.name);
}
Events.AttachEvent(window, 'load', function() {
    if (typeof (pageID) != 'undefined')
        pageID = pageID.toLowerCase(); DomEvent(); selectedMenuItem(); undisabledSubmit();
}); onlineUserTip.xOffset = 2; onlineUserTip.yOffset = 2; onlineUserTip.Event = false; onlineUserTip.flow = null; onlineUserTip.hasOver = false; onlineUserTip.nonHideUser = false; onlineUserTip.interval = 0; onlineUserTip.delay = 200; onlineUserTip.userLoading = false; onlineUserTip.userLoaded = false; onlineUserTip.guestLoading = false; onlineUserTip.guestLoaded = false; function onlineUserTip(th, id) {
    var isUser = false, isGuest = false; var _id = id; if (/.{32}/.test(id)) { isGuest = true; id = 'online_guest_' + id; }
    else { isUser = true; id = 'online_user_' + id; }
    if (isUser && !onlineUserTip.userLoading) { onlineUserTip.userLoading = true; AjaxRequest.Render('', 'ap_online_users', function() { onlineUserTip.userLoaded = true; onlineUserTip(th, _id); }); }
    if (isGuest && !onlineUserTip.guestLoading) { onlineUserTip.guestLoading = true; AjaxRequest.Render('', 'ap_online_guests', function() { onlineUserTip.guestLoaded = true; onlineUserTip(th, _id); }); }
    if (!onlineUserTip.userLoaded && isUser || !onlineUserTip.guestLoaded && isGuest)
        return; var flow = onlineUserTip.flow; if (!flow) { flow = onlineUserTip.flow = PopUp.Panel($('online_tip')); PopUp.AddPopUp(flow); PopUp.AddMask(flow); flow.onmouseover = function() { clearTimeout(onlineUserTip.interval) }; flow.onmouseout = function() { onlineUserTip.interval = setTimeout(function() { onlineUserTip.hide(flow); }, onlineUserTip.delay) }; }
    var obj = $(id); if (!obj) return; if (isUser && !obj.isChange) { obj.isChange = true; var userName = obj.getElementsByTagName('li')[0]; oNode.RemoveNode(userName); if (userName.innerHTML.Trim() != '') { obj.isShow = true; var li = oNode.CreateNode('li'); oNode.AddNode(li, obj); CSS.AddClass(li, 'member-info-buttons'); li.innerHTML = $('online_tip_btn').innerHTML.replace(/\{realname\}/gi, userName.innerHTML); var info = li.getElementsByTagName('a')[2]; if (info) info.href = info.href.replace(/userid=\d+/i, 'UserID=' + _id); else li.style.display = 'none'; } }
    onlineUserTip.nonHideUser = isUser && obj.isShow; flow.getElementsByTagName('ul')[0].innerHTML = obj.innerHTML; if (!th.isCreate) {
        th.isCreate = true; th.onmouseout = function() {
            onlineUserTip.hasOver = false; if (onlineUserTip.nonHideUser) { onlineUserTip.interval = setTimeout(function() { onlineUserTip.hide(flow); }, onlineUserTip.delay); }
            else { onlineUserTip.hide(flow); } 
        };
    }
    onlineUserTip.hasOver = true; onlineUserTip.hasShow = false; clearTimeout(onlineUserTip.interval); if (!onlineUserTip.Event) {
        onlineUserTip.Event = true; flow.style.display = ''; Events.AttachEvent(document, 'mousemove', function(e) {
            if (!onlineUserTip.hasOver) return; var obj = $EO(e); var isOver = false; while (obj) {
                if (obj.onmouseover && /onlineUserTip/.test(obj.onmouseover.toString())) { isOver = true; break; }
                obj = obj.parentNode;
            }
            if (!isOver) return; onlineUserTip.hasShow || onlineUserTip.show(e, onlineUserTip.flow); if (onlineUserTip.nonHideUser)
                onlineUserTip.hasShow = true;
        });
    } 
}
onlineUserTip.show = function(e, flow) {
    var x = e.clientX + onlineUserTip.xOffset; var y = e.clientY + onlineUserTip.yOffset; var W = Global.GetClientWidth(); var H = Global.GetClientHeight(); var w = flow.offsetWidth; var h = flow.offsetHeight; if (x + w > W) { x = e.clientX - w - onlineUserTip.xOffset; }
    if (x < 0) x = 0; if (y + h > H) { y = e.clientY - h - onlineUserTip.yOffset; }
    if (y < 0) y = 0; x += Global.GetScrollLeft(); y += Global.GetScrollTop(); PopUp.SetXY(flow, x, y);
}; onlineUserTip.hide = function(flow) { flow.style.left = '-1000px'; flow.style.top = '-1000px'; }; function sameSetting(th, tagId) { $(tagId).style.display = !th.checked ? '' : 'none'; }
function copyToClipboard(txt) {
    if (window.clipboardData) { window.clipboardData.clearData(); window.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'"); return; }
        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; clip.setData(trans, null, clipid.kGlobalClipboard);
    }
    alert("复制成功！");
}
function AvatarLoaded(th, nonMargin) {
    th.onload = null; th.onerror = null; function reload() {
        if (th.width == 0 && th.height == 0) { setTimeout(reload, 10); return; }
        th.style.visibility = 'inherit'; var w = th.width, h = th.height; th.style.width = 'auto'; th.style.height = 'auto'; w && h && imageScale(th, w, h, !!nonMargin); th.parentNode && (th.parentNode.style.backgroundImage = 'url(' + BBSMAX.SpaceImage + ')');
    }
    reload();
}
function AvatarError(th, defaultImage) { th.onload = null; th.onerror = null; th.src = BBSMAX.SpaceImage; th.parentNode && (th.parentNode.style.background = 'url(' + (defaultImage || BBSMAX.AvatarDefault) + ') no-repeat center center'); }
function PictureError(th) { var value = th.src; var index = value.lastIndexOf('.'); var ext; ext = BBSMAX.NetExistsPath + 'exe.gif'; th.parentNode.innerHTML = '<img src="' + ext + '" style="margin: ' + (BBSMAX.NetDefaultHeight - BBSMAX.NetExistsHeight) + 'px 0 0;" />'; }
function ImageLoaded(th, w, h) {
    if (th.width == 0 && th.height == 0) { setTimeout(function() { ImageLoaded(th, w, h) }, 10); return; }
    if (typeof ImageLoaded.List == 'undefined')
        ImageLoaded.List = []; ImageLoaded.List.push({ src: th.src, ow: th.width, oh: th.height }); th.index = ImageLoaded.List.length - 1; if (typeof ImageLoaded.container == 'undefined') { var c = ImageLoaded.container = oNode.CreateNode('div'); c.innerHTML = ['<!-- 帖子图片浮动提示层 -->', '<div id="image_tip_container" class="imageviewer-tips" style="position:absolute;left:0;top:0;display:none;">', '    <span id="image_tip_save_container"><a href="javascript:;" id="image_tip_save">保存</a> - </span><a href="javascript:;" id="image_tip_newin">在新窗口打开</a>', '</div>', '<!-- 帖子图片浏览 -->', '<div id="image_viewer_container" style="position:absolute;left:0;top:0;">', '<div id="image_viewer" class="imageviewer" style="display:none;">', '    <p class="imageviewer-control" style="position:absolute;z-index:1;">', '        <a href="javascript:;" id="image_viewer_zoomin" class="imageviewer-zoomin" title="放大">放大</a>', '        <a href="javascript:;" id="image_viewer_zoomout" class="imageviewer-zoomout" title="缩小">缩小</a>', '        <a href="javascript:;" id="image_viewer_origin" class="imageviewer-origin" title="实际大小">原始大小</a>', '        <a href="javascript:;" id="image_viewer_intro" class="imageviewer-screensize" title="推荐大小">原始推荐大小</a>', '        <a href="javascript:;" id="image_viewer_open" class="imageviewer-open" title="新窗口打开">新窗口打开</a>', '        <a href="javascript:;" id="image_viewer_close" class="imageviewer-closer" title="关闭">关闭</a>', '    </p>', '    <div id="image_viewer_move" style="position:absolute;left:0;top:0;background-image:url(\'' + BBSMAX.SpaceImage + '\');"></div>', '    <div id="image_viewer_img"></div>', '</div>', '</div>'].join(''); }
    Events.OnLoadTasks[Events.OnLoadTasks.length] = function() {
        oNode.AddNode(ImageLoaded.container); if (s.w <= 100 && s.w <= 100) return; th.style.border = '1px solid #fff'; th.style.padding = '2px'; var tip = $('image_tip_container'); th.onmouseover = function() { show(); tip.style.left = Global.GetOffsetLeft(this) + 'px'; tip.style.top = Global.GetOffsetTop(this) + 'px'; tip.onmouseover = function() { show(); }; tip.onmouseout = function() { hide(); }; var _self = /Attachment\.aspx\?ID=\d+(?:&\?mode=image)?/i.test(th.src); $('image_tip_save_container').style.display = _self ? '' : 'none'; $('image_tip_save').onclick = function() { window.open(th.src.replace(/&?mode=image/i, ''), Browser.IsIE56 ? '_blank' : '_self'); }; $('image_tip_newin').onclick = function() { newin(); }; }; th.onmouseout = function() { hide(); }; function show() {
            if (ImageLoaded.interval) { clearTimeout(ImageLoaded.interval); ImageLoaded.intervalFunc(); }
            th.style.background = '#fff'; th.style.borderColor = '#666'; tip && (tip.style.display = '');
        }
        function hide() {
            ImageLoaded.intervalFunc = function() { tip && (tip.style.display = 'none'); th.style.background = 'transparent'; th.style.borderColor = '#fff'; }
            ImageLoaded.interval = setTimeout(ImageLoaded.intervalFunc, 100);
        } 
    }; function newin() { var win = window.open('about:blank'); win.document.open(); win.document.write('<img src="' + th.src + '">'); win.document.close(); }
    th.onload = null; th.onerror = null; th.style.backgroundImage = 'url(' + BBSMAX.SpaceImage + ')'; var img = new Image(); img.src = th.src; var W = img.width; var H = img.height; var ow = w = th.width; var oh = h = th.height; var s = oImage.Scale(w, h, Global.GetClientWidth() * 0.9, h); th.width = s.w; th.height = s.h; s = oImage.Scale(w, h, Global.GetClientWidth() * 0.9, Global.GetClientHeight() * 0.9); var iw = w = s.w; var ih = h = s.h; if (W > 100 || H > 100)
        th.onclick = function() {
            var panel = PopUp.Panel($('image_viewer')); PopUp.AddPopUp(panel, true); PopUp.AddMask(panel); panel.style.display = ''; panel.style.backgroundColor = '#fff'; $('image_viewer_img').innerHTML = '<img id="image_viewer_object" src="' + th.src + '" width="' + w + '" height="' + h + '" />'; panel.Center(true); var node = $('image_viewer_object'); var alpha = 0; var gradual = function() {
                if (alpha > 100) { CSS.SetAlpha(node, 100); return; }
                CSS.SetAlpha(node, alpha); alpha += 15; setTimeout(gradual, 0);
            }
            gradual(); panel.$D.style.background = '#000'; var _alpha = 60; CSS.SetAlpha(panel.$D, _alpha); var relateBody = true; var moveObj = $('image_viewer_move')
            Effects.Move(moveObj, panel, { modal: false, relateBody: relateBody, upFunc: function(e, p) {
                if (p[0] == p[2] && p[1] == p[3]) { _close(); return; }
                ox = parseInt(panel.style.left) + panel.offsetWidth / 2; oy = parseInt(panel.style.top) + panel.offsetHeight / 2;
            } 
            }); moveObj.style.width = panel.offsetWidth + 'px'; moveObj.style.height = panel.offsetHeight + 'px'; moveObj.style.lineHeight = panel.offsetHeight + 'px'; moveObj.style.fontWeight = 'bolder'; moveObj.style.textAlign = 'center'; moveObj.style.color = '#fff'; PopUp.ResetSize(panel); Events.AttachEvent(window, 'resize', function() { panel.$D.Show(); PopUp.ResetXY(panel); })
            $('image_viewer_zoomin').onclick = function() { zoomIn(); }; $('image_viewer_zoomout').onclick = function() { zoomOut(); }; $('image_viewer_origin').onclick = function() { _w = ow; _h = oh; resize(); }; $('image_viewer_intro').onclick = function() { _w = iw; _h = ih; resize(); }; $('image_viewer_open').onclick = function() { newin(); }; $('image_viewer_close').onclick = function() { _close(); }; function _close() {
                panel.RemoveEvent(); mw.RemoveEvent(); var node = panel.$D; var alpha = _alpha; var gradual = function() {
                    if (alpha < 0) { panel.$D.Hide(); CSS.SetAlpha(node, 0); PopUp.RestorePopUp(panel); return; }
                    CSS.SetAlpha(node, alpha); alpha -= 25; setTimeout(gradual, 0);
                }
                gradual(); panel.style.display = 'none';
            }
            var _w = w, _h = h; var mw = new MouseWheel(); mw.Handle = function(delta) { delta < 0 ? zoomOut() : zoomIn(); }; var zoom = ''; function zoomIn() {
                _w += _w * 0.1; _h += _h * 0.1; if (_w >= 3 / 2 * w || _h >= 3 / 2 * h) { _w = 3 / 2 * w; _h = 3 / 2 * h; zoom = '150'; }
                else { zoom = ''; }
                resize();
            }
            function zoomOut() {
                _w -= _w * 0.1; _h -= _h * 0.1; if (_w <= w / 2 || _h <= h / 2) { _w = w / 2; _h = h / 2; zoom = '50'; }
                else { zoom = ''; }
                resize();
            }
            var interval; var ox = parseInt(panel.style.left) + panel.offsetWidth / 2; var oy = parseInt(panel.style.top) + panel.offsetHeight / 2; function resize() { clearTimeout(interval); CSS.SetAlpha(moveObj, alpha = 60); var img = $('image_viewer_object'); img.style.width = _w + 'px'; img.style.height = _h + 'px'; panel.style.left = ox - panel.offsetWidth / 2 + 'px'; panel.style.top = oy - panel.offsetHeight / 2 + 'px'; moveObj.style.width = panel.offsetWidth + 'px'; moveObj.style.height = panel.offsetHeight + 'px'; moveObj.style.lineHeight = panel.offsetHeight + 'px'; moveObj.innerHTML = '<strong style="padding: 50px;background:transparent url(' + BBSMAX.ImagePreviewBg + ') no-repeat center center;">' + (zoom || Math.floor(_w * 100 / ow)) + '%' + '</strong>'; PopUp.ResetSize(panel); interval = setTimeout(setAlpha, 2000); }
            var alpha = 60; function setAlpha() { if (alpha <= 0) return; alpha -= 5; CSS.SetAlpha(moveObj, alpha); interval = setTimeout(setAlpha, 8); } 
        };
}
function ImageError(th) { th.error = true; th.onload = null; th.onerror = null; th.src = BBSMAX.ImageDefault; th.style.width = 'auto'; th.style.height = 'auto'; th.style.background = 'url()'; }
function showAttachment(th) {
    var tip = $('attachment'); if (!tip.ispopup) { tip.ispopup = true; PopUp.Panel(tip); PopUp.AddPopUp(tip); }
    tip.style.display = 'block'; tip.style.left = Global.GetOffsetLeft(th) + 'px'; tip.style.top = Global.GetOffsetTop(th) + 20 + 'px'; function mouseout() { tip.style.display = 'none'; Events.RemoveEvent(th, 'mouseout', mouseout); }
    Events.AttactEvent(th, 'mouseout', mouseout);
}
showVCode.c = null; showVCode.current = null; showVCode.tip = null; function showVCode(th, src) {
    var c = showVCode.c; if (c && showVCode.current != th) { showVCode.current = th; showVCode.tip.style.display = ''; c.src = src; c._src = ''; reloadImage(c); }
    if (!c) { c = showVCode.c = oNode.CreateNode('img'); oNode.AddNode(c); c.style.position = 'absolute'; c.style.cursor = 'pointer'; c.style.left = '-100px'; c.style.top = '-100px'; c.title = '看不清，点击刷新'; c.src = src; Events.AttachEvent(c, 'click', function() { reloadImage(c); }); c.onload = function() { c.style.border = '1px solid #ccc'; showVCode.show(c, th); showVCode.tip.style.display = 'none'; }; var mousedown = showVCode.mousedown = function(e) { var obj = $EO(e); if (obj == showVCode.current || obj == showVCode.c) return; showVCode.hide(); }; Events.AttachEvent(document, 'mousedown', mousedown); }
    var tip = showVCode.tip; if (!tip) { tip = showVCode.tip = oNode.CreateNode('div'); oNode.AddNode(tip); CSS.AddClass(tip, 'validcode-loader'); tip.style.position = 'absolute'; tip.style.zIndex = 11; tip.innerHTML = '载入验证码...'; tip.style.left = Global.GetOffsetLeft(th) + 'px'; tip.style.top = Global.GetOffsetTop(th) - tip.offsetHeight + 'px'; c.style.display = 'none'; }
    if (showVCode.current != th) { reloadImage(c); showVCode.current = th; }
    c.style.zIndex = 10; showVCode.show(c, th);
}
showVCode.show = function() { c = showVCode.c; th = showVCode.current; c.style.display = 'block'; c.style.left = Global.GetOffsetLeft(th) + 'px'; c.style.top = Global.GetOffsetTop(th) - c.offsetHeight + 'px'; }; showVCode.hide = function() { this.c.style.display = 'none'; }; showVCode.clear = function() { this.c = null; this.current = null; this.tip && oNode.RemoveNode(this.tip); this.tip = null; this.mousedown && Events.RemoveEvent(document, 'mousedown', this.mousedown); }; function selectListAll(th, name) { var list = document.getElementsByName(name); for (var i = 0, len = list.length; i < len; i++) { list[i].checked = th.checked; var p = list[i].parentNode.parentNode; list[i].c = th; th.checked ? CSS.AddClass(p, 'current') : CSS.RemoveClass(p, 'current'); } }
function selectListOne(th) { var p = th.parentNode.parentNode; th.checked ? CSS.AddClass(p, 'current') : CSS.RemoveClass(p, 'current'); th.c && (th.c.checked = false); }
function cancelSelected() { $('selecteAll').checked = false; }
PostViewStyle.current_css = ''; function PostViewStyle(th, css) {
    var current_css = PostViewStyle.current_css; while (th) {
        if (th.tagName.toLowerCase() == 'table') {
            th = th.getElementsByTagName('div'); for (var i = 0, len = th.length; i < len; i++) { if (th[i].className.indexOf('post-content') > -1 || th[i].className.indexOf('post-attach') > -1) { CSS.RemoveClass(th[i], current_css); CSS.AddClass(th[i], css); PostViewStyle.current_css = css; break; } }
            break;
        }
        th = th.parentNode;
    } 
}
function ImageScalePost() {
    var posts = []; var divs = document.getElementsByTagName('div'); for (var i = 0, len = divs.length; i < len; i++) { if (divs[i].className.indexOf('post-content') > -1|| divs[i].className.indexOf('post-attach') > -1) { posts.push(divs[i]); } }
    for (i = 0, len = posts.length; i < len; i++) { var imgs = posts[i].getElementsByTagName('img'); for (var j = 0, _len = imgs.length; j < _len; j++) { var border = parseInt(imgs[j].style.borderWidth) * 2; border = isNaN(border) ? 0 : border; imgs[j].w = imgs[j].width - border; imgs[j].h = imgs[j].height - border; imgs[j].width = 1; } }
    for (i = 0, len = posts.length; i < len; i++) {
        var W = posts[i].offsetWidth; var H = posts[i].offsetHeight; var imgs = posts[i].getElementsByTagName('img'); for (var j = 0, _len = imgs.length; j < _len; j++) {
            var w, h; if (imgs[j].w > W) { w = W * 0.9; h = imgs[j].h * W / imgs[j].w * 0.9; }
            else { w = imgs[j].w; h = imgs[j].h; }
            imgs[j].width = w; imgs[j].height = h;
        } 
    } 
}
function showMemberInfo(th) {
    var mouseover = function(e) { if (th.process) return; th.process = true; th.interval = setTimeout(show, 200); }; var mouseout = function(e) { hide(); }; var show = function() {
        if (th.display) return; th.display = true; if (Browser.IsIE) { th.parentNode.style.height = th.parentNode.offsetHeight + 'px'; }
        else { th.parentNode.style.borderWidth = '1px'; th.parentNode.style.height = th.parentNode.offsetHeight - 2 + 'px'; }
        if (th.parentNode != null) { th.parentNode.style.position = 'relative'; } th.style.zIndex = 10; CSS.AddClass(th, 'author-infolist-expand');
    }; var hide = function() { clearTimeout(th.interval); th.process = false; th.display = false; th.style.zIndex = 0; if (th.parentNode != null) { th.parentNode.style.position = 'static'; } CSS.RemoveClass(th, 'author-infolist-expand'); if (th.parentNode != null) { th.parentNode.style.height = 'auto'; } }; th.onmouseover = mouseover; Events.AttachEvent(document, 'mousemove', function(e) {
        var obj = $EO(e); while (obj) { if (obj == th) break; obj = obj.parentNode; }
        if (!obj) hide();
    });
}
function scrollFaceTitle() {
    var list = $('face_title_list'); if (!list) return; var w = 0; var titles = list.getElementsByTagName('div'); for (var i = 0; i < titles.length; i++) {
        if (i == 0) { titles[i].className = 'focus'; viewGroup.current = titles[i]; }
        w += titles[i].offsetWidth + 2;
    }
    w += 2; list.style.width = w + 'px'; list.style.left = '0'; $('face_title').style.overflow = 'hidden'; var scope = $('face_title').offsetWidth - $('control').offsetWidth; if (w < scope) { $('face_prev').style.display = 'none'; $('face_next').style.display = 'none'; return; }
    var step = 60; $('face_prev').onclick = function() { var l = parseInt(list.style.left); if (l + step > 0) l = 0; else l += step; list.style.left = l + 'px'; }; $('face_next').onclick = function() { var l = parseInt(list.style.left); if (l - step + w < scope) l = scope - w; else l -= step; list.style.left = l + 'px'; };
}
function viewGroup(th, url) {
    if (viewGroup.current)
        viewGroup.current.className = ''; viewGroup.current = th; th.className = 'focus'; AjaxRequest.Render(url);
}

function addFace(shortcut, isDefault) {
    var enableEmoticons = $('enableEmoticon');
    //    var str='';
    //    if(enableEmoticons.checked)
    //    {
    //        if(isDefault){str='[em:'+emotionID+']';}
    //        else{str='[face:'+emotionID+']';}
    //    }
    if (enableEmoticons.checked) {
        var editor = $('Editor')
        editor && (editor.value += shortcut);
    }
}
function showPreview(th, src) { var preview = $('face_preview'); var container = $('preview_container'); var img = oNode.CreateNode('img'); oNode.AddNode(img, container); img.onload = function() { if (!this.parentNode) return; AvatarLoaded(this); preview.style.visibility = 'visible'; }; img.width = preview.offsetWidth; img.height = preview.offsetHeight; img.src = src; var l = Global.GetOffsetLeft(th, $('face_list')); preview.style.left = l > 100 ? '10px' : 'auto'; preview.style.right = l > 100 ? 'auto' : '10px'; th.onmouseout || (th.onmouseout = hidePreview); }
function hidePreview() { $('preview_container').innerHTML = ''; $('face_preview').style.visibility = 'hidden'; }

// AjaxRequest
var AjaxRequest = { FormIndex: 0 }; AjaxRequest.SetFormIndex = function(index) {
    if (typeof index == 'number') { this.FormIndex = index; }
    else if (index == 'last') { this.FormIndex = document.forms.length - 1; } 
}; AjaxRequest.Callback = function(content, url, callback, ButtonName) {
    var arr; var op_state = '', op_content = '', defaultRedirect = { index: -1, url: '', time: 0 }; if (/^\[(success|error|alert|url)\][\s\S]+?\[returnurl(?:=\d+)?\][\s\S]+?/i.test(content)) {
        arr = /\[(success|error|alert|url)\]([\s\S]+?)\[returnurl(?:=\d+)?\]([\s\S]+?)\{.{8}\-.{4}\-.{4}\-.{4}\-.{12}\}/.exec(content); if (!arr) arr = /\[(success|error|alert|url)\]([\s\S]+?)\[returnurl(?:=\d+)?\]([\s\S]+)/.exec(content); op_state = arr[1]; var index; var returnurl = content.match(/\[returnurl(?:=\d+)?\]/gi); for (var i = 0, len = returnurl.length; i < len; i++) { var item = /\[returnurl=(\d+)\]/i.exec(returnurl[i]); if (item) { defaultRedirect = { index: i, url: '', time: item[1] }; break; } }
        var _arr = arr[3].split(/\[returnurl(?:=\d+)?\]/i); for (var i = 0, len = _arr.length; i < len; i++) {
            var item = _arr[i].split('|'); op_content += ('<a href="' + item[1] + '"'); if (item[1].indexOf('javascript:') != 0)
                op_content += (' onclick="Url.Reload(this.href);return false;"'); op_content += ('>' + item[0] + '</a><br />'); if (i == defaultRedirect.index) defaultRedirect.url = item[1];
        }
        op_content = arr[2] + '<p>' + op_content + '</p>'; Widget.InfoCloseAble = false; DomEvent.EventExecuteAble = false; DomEvent.EventExecuteFunc = function() { Url.Reload(_arr[0].split('|')[1]); } 
    }
    else {
        if (/\{.{8}\-.{4}\-.{4}\-.{4}\-.{12}\}/.test(content)) {
            arr = /^\[(success|error|alert|url)\]([\s\S]+?)\{.{8}\-.{4}\-.{4}\-.{4}\-.{12}\}/i.exec(content); var len = 0; if (arr) { op_state = arr[1]; op_content = arr[2]; len = op_state.length + 2 + op_content.length; }
            content = content.substr(len);
        }
        else {
            arr = /^\[(success|error|alert|url)\]([\s\S]*)/i.exec(content); if (arr) { op_state = arr[1]; op_content = arr[2]; }
            content = '';
        } 
    }
    if (op_state == 'url') { Url.Reload(op_content); return; }
    Widget.HideLoading(); content = content == '' ? [] : content.split(content.substr(0, 38)); for (var i = 0, len = content.length; i < len; i++) { if (content[i]) { var index = content[i].indexOf('|'); var id = 'ajaxpanel_' + content[i].substr(0, index); var obj = $(id); if (!obj) continue; obj.innerHTML = content[i].substr(index + 1).replace(/\r|\n/g, '').replace(/ +/g, ' '); } }
    if (defaultRedirect.index > -1)
        setTimeout(function() { Url.Reload(defaultRedirect.url); }, defaultRedirect.time * 1000); callback ? callback(op_state, op_content, ButtonName) : Widget.Auto(op_state, op_content, ButtonName); Widget.Resize(); if (content == '') return; for (var i = 0, len = document.forms.length; i < len; i++) { url && (document.forms[i].action = url); } 
}; AjaxRequest.Render = function(url, id) { if (Widget.InfoNum) return; var ids = ToArray(arguments, 1); var callback = ids[ids.length - 1]; if (typeof callback == 'function') ids = ids.slice(0, ids.length - 1); else callback = null; var _ids = ids.length > 0 ? ids.join(',') : '*'; url = url || (document.forms[this.FormIndex] && document.forms[this.FormIndex].action) || this.ClearUrl(location.href); var ajax = new oAjax(); ajax.url = url; ajax.content = '_AjaxPanelId=' + _ids; ajax.action = 'post'; ajax.error = !true; ajax.callback = function(content) { setTimeout(function() { AjaxRequest.Callback(content, url, callback); for (var i = 0, len = ids.length; i < len; i++) { var obj = $('ajaxpanel_' + ids[i]); if (!obj) continue; var loading = $('ajaxloading_' + obj.loadingid); loading && (loading.style.display = 'none'); } }, 0); }; ajax.send(); for (var i = 0, len = ids.length; i < len; i++) { var obj = $('ajaxpanel_' + ids[i]); if (!obj) continue; if (!obj._lastupdate) obj._lastupdate = 0; obj._lastupdate2 = new Date().getTime(); } }; AjaxRequest.IsSubmited = false; AjaxRequest.Submit = function(ButtonName, id) {
    if (Widget.InfoNum) return; if (this.IsSubmited) return; this.IsSubmited = true; var f = document.forms[this.FormIndex]; if (!f) return; var ids = Array.prototype.slice.apply(arguments).slice(1); var callback = ids[ids.length - 1]; if (typeof callback == 'function') ids = ids.slice(0, ids.length - 1); else callback = null; var _ids = ids.length > 0 ? ids.join(',') : '*'; var list; if (this.FormIndex) {
        for (var i = 0; i < 2; i++) {
            var _list = this.GetFieldEnum(document.forms[i]); for (var item in _list) {
                if (!list)
                    list = _list; else
                    list[item] = _list[item];
            } 
        } 
    }
    else { list = this.GetFieldEnum(f); }
    if (ButtonName != '') { ButtonName = list['ButtonProxy'] = [ButtonName == '*' ? this.GetFirstSubmit(f) : ButtonName]; ButtonName = ButtonName[0]; }
    AjaxRequest.DisableButton(ButtonName, true); var query = ''; for (var item in list) { for (var i = 0, len = list[item].length; i < len; i++) { if (query != '') query += '&'; query += item + '=' + encodeURIComponent(list[item][i]); } }
    var url = f.action || this.ClearUrl(location.href); var ajax = new oAjax(); ajax.url = url; ajax.content = query + '&_AjaxPanelId=' + _ids; ajax.action = 'post'; ajax.error = false; ajax.callback = function(content) { setTimeout(function() { AjaxRequest.Callback(content, url, callback, ButtonName); AjaxRequest.IsSubmited = false; }, 0); }; ajax.send(); for (var i = 0, len = ids.length; i < len; i++) { var obj = $('ajaxpanel_' + ids[i]); if (!obj) continue; if (!obj._lastupdate) obj._lastupdate = 0; obj._lastupdate2 = new Date().getTime(); } 
}; AjaxRequest.GetFieldEnum = function(f) {
    var list = {}; for (var i = 0, len = f.elements.length; i < len; i++) {
        var item = f.elements[i]; var name = item.name; if (item.disabled) continue; if (!list[name]) list[name] = []; switch (item.tagName.toLowerCase()) {
            case 'input': switch (item.type) { case 'text': case 'hidden': case 'password': list[name].push(item.value); case 'radio': case 'checkbox': if (item.checked) list[name].push(item.value); break; }
                break; case 'textarea': list[name].push(item.value); break; case 'select': list[name].push(item.options[item.selectedIndex].value); break;
        } 
    }
    return list;
}; AjaxRequest.GetFirstSubmit = function(f) {
    var inputs = f.getElementsByTagName('input'); for (var i = 0, len = inputs.length; i < len; i++) {
        if (inputs[i].type == 'submit' || inputs[i].type == 'image')
            return inputs[i].name;
    }
    return '';
}; AjaxRequest.DisableButton = function(ButtonName, disabled) {
    try {
        var but = ButtonName && $(ButtonName); if (!but) return; but.disabled = disabled; if (disabled) { but._onclick || (but._onclick = but.onclick); but._href || (but._href = but.href); but.onclick = function() { }; but.href = 'javascript:void(0);'; }
        else { but.onclick = but._onclick; but.href = but._href; } 
    }
    catch (e) { } 
}; AjaxRequest.ClearUrl = function(url) { url = url.substring(0, url.indexOf('#')) || url; return url; }; AjaxRequest.Clear = function() { for (var i = 0, len = arguments.length; i < len; i++) { var obj = $('ajaxpanel_' + arguments[i]); obj && (obj.innerHTML = ''); } }; var Request = { FormIndex: 0 }; Request.Submit = function(ButtonName, Target) {
    var f = document.forms[this.FormIndex]; if (!f) return; Target && (f.target = Target); if (!f.elements['ButtonProxy']) { var but = oNode.CreateInput('ButtonProxy'); but.type = 'hidden'; oNode.AddNode(but, f); }
    f.elements['ButtonProxy'].value = [ButtonName || AjaxRequest.GetFirstSubmit(f)]; f.method = 'post'; f.submit(); this.FormIndex = 0;
};

// Widget
var Widget = { InfoNum: 0, InfoCloseAble: true, Success: function(t, c, callback) { var p = this.Info(t, c, callback); var p_canel = $('popup_info_canel'); CSS.RemoveClass(p, 'error', 'alert'); CSS.AddClass(p, 'valid'); CSS.SetDisplay(p_canel, false); }, Error: function(t, c, callback) { var p = this.Info(t, c, callback); var p_canel = $('popup_info_canel'); CSS.RemoveClass(p, 'valid', 'alert'); CSS.AddClass(p, 'error'); CSS.SetDisplay(p_canel, false); }, Alert: function(t, c, callback) { var p = this.Info(t, c, callback); var p_canel = $('popup_info_canel'); CSS.RemoveClass(p, 'valid', 'error'); CSS.AddClass(p, 'alert'); CSS.SetDisplay(p_canel, false); }, Confirm: function(t, c, func, callback) {
    var p = this.Info(t, c, function() {
        var returnValue = false; if (p._returnValue) { returnValue = true; func(); }
        callback && callback(returnValue);
    }); CSS.RemoveClass(p, 'valid', 'error'); CSS.AddClass(p, 'alert'); var p_canel = $('popup_info_canel'); CSS.SetDisplay(p_canel, true);
}, Info: function(title, content, callback) {
    var p = $('popup_info'); var p_bar = $('popup_info_bar'); var p_title = $('popup_info_title'); var p_content = $('popup_info_content'); var p_close = $('popup_info_close'); var p_confirm = $('popup_info_confirm'); var p_canel = $('popup_info_canel'); p_close.style.display = ''; p_confirm.style.display = ''; if (p._display) PopUp.RestorePopUp(p); p._returnValue = false; p_title.innerHTML = title; content && (p_content.innerHTML = content); if (this.InfoCloseAble) {
        function _confirm() { p._returnValue = true; _close(); }
        var _close = Widget.InfoClose = function(e) { p._display = false; Widget.InfoNum = 0; e && Events.CancelAll(e); PopUp.RestorePopUp(p); Events.RemoveEvent(p_close, 'click', _close); Events.RemoveEvent(p_canel, 'click', _close); Events.RemoveEvent(p_confirm, 'click', _confirm); Events.RemoveEvent(window, 'scroll', scroll); callback && callback(); }; Events.AttachEvent(p_close, 'click', _close); Events.AttachEvent(p_canel, 'click', _close); Events.AttachEvent(p_confirm, 'click', _confirm); p_confirm.parentNode.style.display = '';
    }
    else { p_close.style.display = 'none'; p_confirm.parentNode.style.display = 'none'; }
    Effects.Move(p_bar, p, { modal: !true }); PopUp.Panel(p, 0, 0, true); PopUp.AddPopUp(p, true); PopUp.AddMask(p); p.style.zIndex = 10; p._display = true; p.focus(); function scroll() { PopUp.SetXY(p, p.style.left, Global.GetScrollTop() + (Global.GetClientHeight() - p.offsetHeight) / 2); }
    Events.AttachEvent(window, 'scroll', scroll); this.InfoNum = 1; return p;
}, InfoClose: function() { }, ContentNum: 0, Content: function(title, content, width, callback) {
    DomEvent.Clear(); AjaxRequest.SetFormIndex(1); this.ContentNum = 1; var w = $('popup_win'); var w_bar = $('popup_win_bar'); var w_title = $('popup_win_title'); var w_content = $('popup_win_content'); var w_close = $('popup_win_close'); if (oNode.IsNode(content)) {
        if (!content._innerHTML) { content._innerHTML = content.innerHTML; content.innerHTML = ''; }
        content = content._innerHTML;
    }
    if (w._display) PopUp.RestorePopUp(w); title && (w_title.innerHTML = title); content && (w_content.innerHTML = content); w.style.width = (width || 400) + 'px'; w._close = function(e) { DomEvent.Clear(true); Widget.ContentNum = 0; AjaxRequest.FormIndex = 0; callback && callback(); w.RemoveEvent(); w._display = false; e && Events.CancelAll(e); w_content.innerHTML = ''; PopUp.RestorePopUp(w); Events.RemoveEvent(w_close, 'click', w._close); }; this.Close = w._close; Events.AttachEvent(w_close, 'click', w._close); w.gradual = !true; PopUp.Panel(w, 0, 0, true); PopUp.AddPopUp(w, true); PopUp.AddMask(w); w._display = true; this.Resize(); Effects.Move(w_title, w, { modal: !true }); this.Focus(w); return w;
}, Focus: function(w) { w = w || $('popup_win'); var inputs = w.getElementsByTagName('input'); if (inputs && inputs[0] && inputs[0].type == 'text') inputs[0].focus(); }, Resize: function(resize, nogradual) {
    if (!this.ContentNum) return;
    resize || $('popup_win').$Move();
}, Show: function() { PopUp.SetVisible($('popup_win'), true); }, Hide: function() { PopUp.SetVisible($('popup_win'), false); }, Close: function() { }, Auto: function(state, content, ButtonName) {
    AjaxRequest.DisableButton(ButtonName, false); if (state == 'success') {
        try { Widget.Close(); }
        catch (e) { } 
    }
    switch (state) { case 'success': Widget.Success('操作成功', content); break; case 'error': Widget.Error('错误', content); break; case 'alert': Widget.Alert('警告', content); break; } 
}, LoadingNum: 0, ShowLoading: function(id, p) {
    id = id || 'popup_loading'; var w = $(id); if (!w) return; this.HideLoading(); this.LoadingNum++; var w_close = $(id + '_close'); var w_back = $(id + '_back'); var w_retry = $(id + '_retry'); if (w && w_close && w_back && w_retry) { PopUp.Panel(w, 0, 0, true); PopUp.AddPopUp(w, true); PopUp.AddMask(w); p && PopUp.SetXY(w, Global.GetOffsetLeft($(p)), Global.GetOffsetTop($(p))); var HideLoading = this.HideLoading = function() { this.HideLoading1(w); }; Events.AttachEvent(w_close, 'click', HideLoading); }
    else {
        w.style.display = ''; if (p) { w.style.left = Global.GetOffsetLeft($(p)) + 'px'; w.style.top = Global.GetOffsetTop($(p)) + 'px'; }
        this.HideLoading = function() { this.HideLoading2(w); };
    } 
}, HideLoading: function() { }, HideLoading1: function(w) { this.LoadingNum--; if (this.LoadingNum > 1 && this.HideLoading == this.HideLoading1) return; this.LoadingNum = 0; w && PopUp.RestorePopUp(w); w = null; }, HideLoading2: function(w) { this.LoadingNum--; w.style.display = 'none'; } 
};

// Roll
$Defined('Roll'); var Roll = {}; Roll.Left = function(el, content) { }; Roll.Right = function(el, content) { }; Roll.Top = function(el, content, args) {
    if (!el || !content) return; if (typeof args != 'object') args = {}; if (typeof args.scrollamount != 'number')
        args.scrollamount = 30; if (typeof args.scrolldelaymin != 'number')
        args.scrolldelaymin = 50; if (typeof args.scrolldelaymax != 'number')
        args.scrolldelaymax = 2000; with (el.style) { position = 'relative'; overflow = 'hidden'; }
    var listStyle = 'position:absolute;'; var one; if (oNode.IsNode(content)) { one = content; }
    else { one = oNode.CreateNode('div'); oNode.AddNode(one, el); one.innerHTML = content; }
    with (one.style) { position = 'absolute'; top = 0; }
    var onlyLine = function() { return Math.floor(one.offsetHeight / args.scrollamount) < 2; }; var childs = one.getElementsByTagName('li'); for (var i = 0, len = childs.length; i < len; i++) { childs[i].style.height = args.scrollamount + 'px'; }
    var two = one.cloneNode(true); oNode.AddNode(two, el); with (one.style) { position = 'absolute'; top = one.offsetHeight + 'px'; }
    var mouseover = false; var overState = 0; var delay1 = args.scrolldelaymin; var delay2 = args.scrolldelaymax; var amount1 = args.scrollamount || 20; var amount2 = 0; var interval; function roll() {
        if (!onlyLine() || parseInt(one.style.top) != 0 && parseInt(two.style.top) != 0) {
            if (amount2 == 0) {
                overState = 1; if (mouseover) return; if (parseInt(one.style.top) < -one.offsetHeight) { one.style.top = parseInt(two.style.top) + two.offsetHeight + 'px'; }
                if (parseInt(two.style.top) < -two.offsetHeight) { two.style.top = parseInt(one.style.top) + one.offsetHeight + 'px'; }
                amount2 = amount1; interval = setTimeout(roll, delay2); return;
            }
            overState = 0; amount2--; if (parseInt(one.style.top) > parseInt(two.style.top)) { two.style.top = parseInt(two.style.top) - 1 + 'px'; one.style.top = parseInt(two.style.top) + two.offsetHeight + 'px'; }
            else { one.style.top = parseInt(one.style.top) - 1 + 'px'; two.style.top = parseInt(one.style.top) + one.offsetHeight + 'px'; } 
        }
        interval = setTimeout(roll, delay1);
    }
    roll(); Events.AttachEvent(window, 'resize', function() { clearTimeout(interval); roll(); }); Events.AttachEvent(el, 'mouseover', function() {
        mouseover = true; if (overState == 1)
            clearTimeout(interval);
    }); Events.AttachEvent(el, 'mouseout', function() { mouseover = false; if (overState == 1) { clearTimeout(interval); interval = setTimeout(roll, delay2); } });
}; Roll.Bottom = function(el, content) { };

// oImage
$Defined('oImage'); var oImage = {}; oImage.Scale = function(ow, oh, dw, dh, mt) {
    var s = { w: 0, h: 0, mt: 0 }; if (ow / oh > dw / dh) {
        if (ow > dw) { s.w = dw; s.h = dw / ow * oh; mt && (mt = (dh - dw / ow * oh) / 2); }
        else { s.w = ow; s.h = oh; mt && (mt = (dh - oh) / 2); } 
    }
    else {
        if (oh > dh) { s.h = dh; s.w = dh / oh * ow; }
        else { s.w = ow; s.h = oh; mt && (mt = (dh - oh) / 2); } 
    }
    mt && (s.mt = Math.floor(mt)); return s;
}

// Cookie
$Defined('Cookie'); var Cookie = { cookies: {}, path: '/', domain: typeof (cookieDomain) != 'undefined' ? cookieDomain : '' }; Cookie.Get = function() { var cookie = document.cookie; if (!cookie) return; cookie = cookie.replace(/\s+/g, ''); cookie = cookie.split(';'); for (var i = 0; i < cookie.length; i++) { if (cookie[i].indexOf('=') == -1) return; var _cookie = cookie[i].split('='); this.cookies[_cookie[0]] = unescape(_cookie[1]); } }; Cookie.Set = function(name, value, expiration, path, domain) {
    if (!expiration)
        expiration = new Date(new Date().getTime() + 25 * 365 * 24 * 60 * 60 * 1000); domain = domain || this.domain || ''; domain = domain ? ';domain=' + domain : ''; document.cookie = name + '=' + escape(value) + ';expires=' + expiration.toGMTString() + ';path=' + (path || this.path) + domain;
}; Cookie.Del = function(name) { Cookie.Set(name, '', new Date(new Date().getTime() - 1)); }; Cookie.Get();

// MouseWheel
function MouseWheel() {
    var self = this; var wheel = this.wheel = function(e) { self.Wheel(e); }
    if (window.addEventListener) { window.addEventListener('DOMMouseScroll', wheel, false); }
    Events.AttachEvent(document, 'mousewheel', wheel);
}
MouseWheel.prototype.RemoveEvent = function() {
    if (window.addEventListener) { window.removeEventListener('DOMMouseScroll', this.wheel, false); }
    Events.RemoveEvent(document, 'mousewheel', this.wheel);
}; MouseWheel.prototype.Wheel = function(e) {
    var delta = 0; if (e.wheelDelta) { delta = e.wheelDelta / 120; }
    else if (e.detail) { delta = -e.detail / 3; }
    if (delta) this.Handle(delta); Events.CancelEvent(e);
}; MouseWheel.prototype.Handle = function(delta) { if (delta < 0); else; };

// base64
var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "="; function encode64(input) {
    input = escape(input); var output = ""; var chr1, chr2, chr3 = ""; var enc1, enc2, enc3, enc4 = ""; var i = 0; do {
        chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; }
        output = output +
keyStr.charAt(enc1) +
keyStr.charAt(enc2) +
keyStr.charAt(enc3) +
keyStr.charAt(enc4); chr1 = chr2 = chr3 = ""; enc1 = enc2 = enc3 = enc4 = "";
    } while (i < input.length); return output;
}
function decode64(input) {
    var output = ""; var chr1, chr2, chr3 = ""; var enc1, enc2, enc3, enc4 = ""; var i = 0; var base64test = /[^A-Za-z0-9\+\/\=]/g; if (base64test.exec(input)) { alert("There were invalid base64 characters in the input text.\n" + "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" + "Expect errors in decoding."); }
    input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); do {
        enc1 = keyStr.indexOf(input.charAt(i++)); enc2 = keyStr.indexOf(input.charAt(i++)); enc3 = keyStr.indexOf(input.charAt(i++)); enc4 = keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); }
        if (enc4 != 64) { output = output + String.fromCharCode(chr3); }
        chr1 = chr2 = chr3 = ""; enc1 = enc2 = enc3 = enc4 = "";
    } while (i < input.length); return unescape(output);
}
function processUrl(str) { window.open(decode64(str)); return false; }
function displayUrl(th, str) {
    if (th.onmouseout) return false; th.href = decode64(str); th.onmouseout = function() { window.status = ''; }
    return true;
}


//---- 对话框------------------------------------

String.prototype.contains = function(str) { return (this.indexOf(str) > -1); };
String.prototype.trim = function(s) { if (s) return this.trimEnd(s).trimStart(s); else return this.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, ''); };
String.prototype.trimEnd = function(s) { if (this.endsWith(s)) { return this.substring(0, this.length - s.length); } return this; };
String.prototype.trimStart = function(s) { if (this.startsWith(s)) { return this.slice(s.length); } return this; };
String.prototype.startsWith = function(str) { return (this.indexOf(str) == 0); };
String.prototype.endsWith = function(str) { return (str.length <= this.length && this.substr(this.length - str.length, str.length) == str); };
String.format = function() { var str = arguments[0]; for (var i = 1; i < arguments.length; i++) { var reg = new RegExp("\\{" + (i - 1) + "\\}", "ig"); str = str.replace(reg, arguments[i]); } return str; };
String.isNullOrEmpty = function(str) { return str; };

var stringBuilder = function(str) { this.arr = new Array(); if (str) this.arr.push(str); if (!stringBuilder.created) { stringBuilder.prototype.append = function(str) { this.arr.push(str); }; stringBuilder.prototype.clear = function() { this.arr.splice(0, this.arr.length); }; stringBuilder.prototype.toString = function() { return this.arr.join(''); }; stringBuilder.created = true; } }

var max = {
    browser: {
        isIE: navigator.userAgent.toLowerCase().contains('msie'),
        isIE5: navigator.userAgent.toLowerCase().contains('msie 5'),
        isIE6: navigator.userAgent.toLowerCase().contains('msie 6'),
        isIE7: navigator.userAgent.toLowerCase().contains('msie 7'),
        isGecko: navigator.userAgent.toLowerCase().contains('gecko'),
        isSafari: navigator.userAgent.toLowerCase().contains('safari'),
        isOpera: navigator.userAgent.toLowerCase().contains('opera')
    },
    global: {
        getClientWidth: function() { return ((document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth); },
        getClientHeight: function() { return ((document.documentElement && document.documentElement.clientHeight) || document.body.clientHeight); },
        getScrollTop: function() { return ((document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop); },
        getScrollLeft: function() { return ((document.documentElement && document.documentElement.scrollLeft) || document.body.scrollLeft); },
        getFullHeight: function() { if (document.documentElement.clientHeight > document.documentElement.scrollHeight) return document.documentElement.clientHeight; else return document.documentElement.scrollHeight; },
        getFullWidth: function() { return document.documentElement.scrollWidth; },
        getBrowserRect: function() { var r = new Object(); r.left = this.getScrollLeft(); r.top = this.getScrollTop(); r.width = this.getClientWidth(); r.height = this.getClientHeight(); r.bottom = r.top + r.height; r.right = r.left + r.width; return r; }
    },

    coor: {
        left: function(e, left) { if (typeof (left) == "number") { e.style.position = "absolute"; e.style.left = left + "px"; } else { var offset = e.offsetLeft; if (e.offsetParent != null) offset += Left(e.offsetParent); return offset; } },
        top: function(e, top) { if (typeof (top) == "number") { e.style.position = "absolute"; e.style.top = top + "px"; } else { var offset = e.offsetTop; if (e.offsetParent != null) offset += Top(e.offsetParent); return offset; } },
        width: function(e, w) { if (typeof (w) == "number") { e.style.width = w + "px"; } else { return e.offsetWidth; } },
        height: function(e, h) { if (typeof (h) == "number") { e.style.height = h + "px"; } else { return e.offsetHeight; } },
        getRect: function(e) { var r = new Object(); r.left = getLeft(e); r.top = getTop(e); r.width = getWidth(e); r.height = getHeight(e); r.bottom = r.top + r.height; r.right = r.left + r.width; return r; }
    }
};

//根据id得到指定的对象
function $(id) { return (typeof id == 'string' ? document.getElementById(id) : id); }

//根据name得到一组对象
function $$(name) { return (typeof name == 'string' ? document.getElementsByName(name) : null); }

//根据tagname得到一组对象
function $T(name) { return (typeof name == 'string' ? document.getElementsByTagName(name) : null); }

//设置对象的样式
//例如 : setStyle($('id'),{ display:'none',position : 'absolute',zIndex : 999 });
function setStyle(e, s) { for (var k in s) { e.style[k] = s[k]; } }

//新建一个HTML节点
//tagName : 
//parent  : 父节点
function addElement(t, p) { var e = document.createElement(t); if (typeof (p) != 'undefined') p.appendChild(e); else document.body.appendChild(e); return e; }

///移除节点
//e       : 节点
function removeElement(elm) { var p; if (typeof (elm) == 'string') elm = $(elm); p = elm.parentNode; p.removeChild(elm); };

//设置/获取节点的属性
//value 未传的时候是获取属性
//element : 节点
//attrName: 属性名称
//[value] : 值（如果为空就返回属性值）
function attr(element, attrName, value) { if (value) element.setAttribute(attrName, value); else return element.getAttribute(attrName); }

//对象事件注册
//elm   :节点
//n     :事件名称比如click,dbclick,change,可以在前面带on也可以不带
//h     :事件处理函数
function addHandler(elm, n, h) {
    if (n.indexOf('on', 0) >= 0) {
        n = n.substring(2, n.length);
    }
    if (!max.browser.isIE) {
        elm.addEventListener(n, h, false);
    }
    else {
        elm.attachEvent("on" + n, h);
    }
};


//设置对象的透明度
function opacity(e, o) { setStyle(e, { opacity: o / 100, MozOpacity: (o / 100), KhtmlOpacity: (o / 100), filter: "alpha(opacity=" + o + ")" }); };

///移除事件注册
//e :节点
//n :事件名称比如click,change
//h :事件处理函数
function removeHandler(e, n, h) {
    if (n.indexOf('on', 0) >= 0) {
        n = n.substring(2, n.length);
    }
    if (!max.browser.isIE) {
        e.removeEventListener(n, h, false);
    }
    else {
        e.detachEvent("on" + n, h);
    }
}

///判断一个变量或者函数是否已经定义
//variable : 
function isUndefined(v) { return typeof (v) == 'undefined' ? true : false; }

//获取元素的纵坐标
//顶部距离文档顶部的高度 
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 getWidth(e) { return e.offsetWidth; }
//获取一个对象的高度
function getHeight(e) { return e.offsetHeight; }

//时钟
var timer = function(i, ontick) {
    this.counter = 0;
    this.interval = i;
    this.ontick = ontick;
}
timer.prototype.start = function() { var _this = this; if (this.interval > 0) { if (this.ontick != null) this.ontick(++this.counter); window.setTimeout(function() { _this.start() }, _this.interval); } }
timer.prototype.stop = function() { this.interval = 0; }


function hasQuery(url) {
    if (url.contains('/?')) {
        var index = url.toString().indexOf('/?');
        return (url.toString().indexOf('?', index + 2) != -1);
    }
    else {
        return url.contains('?');
    }
}



openDialog.obj = null;
//打开指定的对话框，如果打开成功，返回false，否则返回true。
//这样做的目的是：方便进行nojavascript兼容
//例如：<a href="对话框页.html" onclick="return openDialog()">打开对话框</a>
//这样写就可以让脚本正常的情况下打开对话框，脚本不正常的情况下以普通链接的形式打开
function openDialog() {
	
    var args = arguments;
    if (args.length < 1) return true;
    var settings;
	//alert(args.length);
    if (typeof args[0] == 'string') {

        settings = { src: args[0] };

        if (args.length = 2) {
            if (typeof args[1] == 'function')
                settings.return_handler = args[1];
            else (typeof (args[1] == 'object'))
            settings.trigger = args[1];
        }
        if (args.length = 2) {
            if (typeof args[1] == 'function') {
                settings.return_handler = args[1];
                settings.trigger = args[2];
            }
            else {
				//alert("here"+args[2]);
                settings.return_handler = args[2];
                settings.trigger = args[1];
            }
        }
    }
    else
        settings = args[0];

    if (hasQuery(settings.src))
        settings.src += '&isdialog=1';
    else
        settings.src += '?isdialog=1';
	//alert(settings.src);

    if (!openDialog.obj)
		openDialog.obj = new max.dialog(settings);
	else
		openDialog.obj.setSettings(settings);
		
	//alert(openDialog.obj.iframePage);

    openDialog.obj.load_complete_handler = function() {
        var d = openDialog.obj.iframePage.dialog;

		

        if (settings.width) {
			
            openDialog.obj.resize(settings.width, settings.height);
        }
        else {
				
            if (d) {
				
             openDialog.obj.resize(d.width, d.height);
            }
			//alert(d.width+"-"+d.height);

			//openDialog.obj.resize(300, 260);
        }
    };

	
    openDialog.obj.show();

    return false;
}




/******************************* 自动弹出菜单 *********************************/
var popupCollection = function() {
    //    this.back=addElement("iframe");
    //    var s=this.back.style;
    //    s.display = 'none';
    //    s.zIndex = 9;
    //    s.position='absolute';//**加个iframe可以避免在IE下菜单被flash挡住的问题，但不是解决问题的根本
    if (!popupCollection.innerList)
        popupCollection.innerList = new Array();
}

popupCollection.prototype.add = function(obj) {
    obj.onShow = this.onshow;
    obj.onHide = this.onhide;
    popupCollection.innerList.push(obj);
}

popupCollection.prototype.onhide = function(obj) {
    if (obj.focus) {
        //this.back.style.display='none';
        obj.focus = false;
    }
}
popupCollection.prototype.onshow = function(obj) {
    var t;
    for (var i = 0; i < popupCollection.innerList.length; i++) {
        t = popupCollection.innerList[i];
        if (t.list.id != obj.list.id) {
            t.hide();
        }
    }
    //    var s=this.back.style;
    //    var r = max.coor.getRect(obj.list);
    //    s.display='';
    //    s.left=r.left +"px";
    //    s.top=r.top +"px";
    //    s.width=r.width +"px";
    //    s.height=r.height +"px";
}

//下拉菜单
//listid:下拉菜单的那个容器ID
//triggerid:触发下拉菜单弹出的那个对象的ID
//autoPop:如果是true那么只要鼠标滑过就弹出， 否则需要点击才弹出
//position:位置
var popup = function(listid, triggerid, autoPop, onSelectClass, pos) {
    this.focus = false;
    if (!window.popupMenuCollection)
        window.popupMenuCollection = new popupCollection();
    this.list = $(listid);
    this.trigger = $(triggerid);
    this.triggerStyle = onSelectClass;
    if (pos)
        this.position = pos;
    else
        this.position = 'auto';

    var _this = this;
    var s = this.list.style;
    s.position = 'absolute';
    s.zIndex = 100;
    addHandler(this.trigger, autoPop ? 'mouseover' : 'click', function(e) { _this.show(); });


    if (autoPop) {
        addHandler(this.list, autoPop ? 'mouseover' : 'click', function(e) { _this.focus = true; });
        addHandler(this.trigger, "mouseout", function() { hideList(_this) });
        addHandler(this.list, "mouseout", function() { hideList(_this) });
    }
    else {
        addHandler(this.trigger, "mouseout", function() { _this.focus = false; });
        addHandler(this.list, "mouseout", function() { _this.focus = false; });
        addHandler(this.trigger, "mouseover", function() { _this.focus = true; });
        addHandler(this.list, "mouseover", function() { _this.focus = true; });
        addHandler(document.documentElement, "click", function() { if (_this.focus == false) _this.hide(); })
    }
    window.popupMenuCollection.add(this);
}
function hideList(e) {
    window.setTimeout(function() { if (e.focus == false) e.hide(); }, 1000);
    e.focus = false;
}
popup.prototype.onShow = null;
popup.prototype.onHide = null;
popup.prototype.show = function() {

	  
    var s = this.list.style;
    s.display = '';
    //  alert(s.display);
    var t, l;
    var rt = max.coor.getRect(this.trigger)
    var rl = max.coor.getRect(this.list);
    var rw = max.global.getBrowserRect();

    if (rt.bottom + rl.height > rw.bottom)
        t = rt.top - rl.height;
    else
        t = rt.bottom;
    if (this.position == 'auto') {
        if (rt.left + rl.width > rw.right)

            l = rt.right - rl.width;
        //l=rw.right - rl.width-10;
        else
            l = rt.left;
    }
    else {
        l = (rt.left + rt.width / 2) - rl.width / 2;
    }

    this.focus = true;
    s.left = l + "px";
    s.top = t + "px";

    var cn = this.triggerStyle;
    if (cn)
        if (this.trigger.className.indexOf(cn) < 0)
        this.trigger.className += " " + cn;

    if (this.onShow) this.onShow.call(window.popupMenuCollection, this);
  
}

popup.prototype.hide = function() {
    var s = this.list.style;
    s.display = 'none';
    var cn = this.triggerStyle;
    if (cn)
        if (this.trigger.className.indexOf(cn) >= 0)
        this.trigger.className = this.trigger.className.replace(cn, '').trim();

    if (this.onHide) this.onHide.call(window.popupMenuCollection, this);
}

/*************************************************************************/









/*
JMAX 0.1
by zzbird
copyright (c) Max Labs
#2008.10.15#
*/


//浏览器屏蔽层
var background = function() {
    var e, selects = false;
    e = addElement("div");
    setStyle(e, { backgroundColor: 'black', position: 'absolute', top: '0px', left: '0px', zIndex: 50 });
    autoSize();
    opacity(e, 10);
    addHandler(window, "resize", autoSize);
    if (max.browser.isIE6) {
        var temp;
        temp = $T("select");
        if (temp.length > 0) {
            selects = new Array(); var ti;
            for (var i = 0; i < temp.length; i++) {
                ti = temp[i];
                if (ti.style.display != "none" && ti.style.visibility != "hidden") {
                    selects.push(ti);
                    ti.style.visibility = "hidden";
                }
            }
        }
        temp = null;
    }
    function autoSize() {
        var g = max.global;
        e.style.height = g.getFullHeight() + "px";
        e.style.width = g.getFullWidth() + "px";
    }
    return {
        destroy: function() {
            removeHandler(document, "resize", autoSize);
            if (selects) {
                for (var i = 0; i < selects.length; i++) {
                    selects[i].style.visibility = '';
                }
                selects = null;
            }
            removeElement(e);
            e = null;
        }
    }
};

var maxdialog = max.dialog = function(settings) {
    this.setSettings(settings);
    this.init();
};

maxdialog.prototype.setSettings = function(settings) {
    var s = settings;
    var ds = max.dialog.defaultSettings;
    if (!s) s = {};
    if (!ds) ds = {};
    this.x = s.x || ds.x;
    this.y = s.y || ds.y;
    this.panelId = s.panelId || ds.panelId || '';
    this.src = s.src || ds.src || '';
    this.isajax = s.isajax || ds.isajax || false;
    this.width = ds.width;
    this.height = ds.height;
    this.template = s.template || ds.template;
    this.template_closeButton = s.template_closeButton || ds.template_closeButton;
    this.template_moveArea = s.template_moveArea || ds.template_moveArea;
    this.init_handler = s.init_handler || ds.init_handler;
    this.before_show_handler = s.before_show_handler || ds.before_show_handler;
    this.after_show_handler = s.after_show_handler || ds.after_show_handler;
    this.load_start_handler = s.load_start_handler || ds.load_start_handler;
    this.load_complete_handler = s.load_complete_handler || ds.load_complete_handler;
    this.before_close_handler = s.before_close_handler || ds.before_close_handler;
    this.after_close_handler = s.after_close_handler || ds.after_close_handler;
    this.return_handler = s.return_handler || ds.return_handler;
    this.canDrag = s.canDrag || ds.canDrag;
    this.loadingTemplate = s.loadingTemplate || ds.loadingTemplate;
    this.showMask = s.showMask || ds.showMask;
    this.timeoutTemplate = s.timeoutTemplate || ds.timeoutTemplate;
    this.ownerDocument = document;
    this.ownerWindow = window;
    this.trigger = s.trigger;
    this.form = s.form;
    this.formdata = s.formdata;
    this.param = s.param;
}


//对话框初始化
maxdialog.prototype.init = function() {

    var t = this, d;
    var instance = '1';
    var instanceName = 'max_dialog' + instance;
    this.loadingNode = null;
    this.innerFrmaeId = "max_dialog_iframe_" + instance;
    this.maskLayer = null;
    this.inited = false;

    d = t.obj = $(instanceName);
    if (!d) {
        d = t.obj = document.createElement('div');
        d.id = instanceName;
        setStyle(d, { display: 'none', position: 'absolute', zIndex: 999 });

        var html = t.template.replace("{loading}", '<div id="_dialogloading' + instance + '"></div>');

		
        html = html.replace('{body}', '<iframe style="display : none ;" id="' + this.innerFrmaeId + '" name="' + this.innerFrmaeId + '" src="about:blank" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>');
        d.innerHTML = html;

		//alert(html);

		 try {
            document.body.insertBefore(d, document.body.firstChild);
			
        }
        catch (ex) { }

        this.loadingNode = $('_dialogloading' + instance);
        this.loadingNode.innerHTML = this.loadingTemplate;
        t.iframeObj = $('max_dialog_iframe_' + instance);
		//alert("here"+'max_dialog_iframe_' + instance);
        t.iframePage = t.iframeObj.contentWindow;
		//alert(t.iframePage.style.display);
        t.init_handler && t.init_handler();

		
    }
}


//显示对话框
maxdialog.prototype.show = function() {

	
    var bs = this.before_show_handler;
    var as = this.after_show_handler;
    var ls = this.load_start_handler;
    var lc = this.load_complete_handler;
    var f = this.iframeObj;
    var d = this.obj;
    var h = this.height;
    var fId = this.innerFrmaeId;
    var drag = this.canDrag;
    var l = this.lodingNode;
    this.cancel = false;
    var brect = max.global.getBrowserRect();

    if (h == -1) {
        h = 35;
    }

    if (this.trigger) {
        var rect = max.coor.getRect(this.trigger);
        this.x = rect.left;
        this.y = rect.bottom;

        /***** ie 6 fix ******/
        if (max.browser.isIE6) {
            var fixDiv = document.body.childNodes[1];
            if (fixDiv.className == 'iefix') {
                this.x = event.clientX + 8; this.y = event.clientY + 8;
            }
        }
        /*** end ie 6 fix *****/
    }

    d.style.width = this.width + 'px';
    d.style.height = h + 'px';

    if (this.x) { if (this.x + this.width > brect.right) this.x = brect.right - this.width - 5; d.style.left = this.x + 'px'; }
    else {
        if (this.inited == false) d.style.left = ((max.global.getClientWidth() - this.width) / 2 + max.global.getScrollLeft()) + 'px';
    }

    if (this.y) {
        if (this.y + h > brect.bottom) this.y = brect.bottom - h - 5;
        d.style.top = this.y + 'px';
    }
    else {
        if (this.inited == false) d.style.top = ((max.global.getClientHeight() - h) / 2 + max.global.getScrollTop()) + 'px';
    }



    bs && bs();
	//alert(d.style.display);
    d.style.display = '';

    if (max.browser.isIE) {
        f.onreadystatechange = function() {
            if ('complete' == f.readyState || f.readyState == "loaded") {
                loadComplete();
            }
        };
    }
    else
        f.onload = loadComplete;

    var formAttr = {}; //记录表单的参数
    var form = null;
    if (this.form) {

		
        form = document.forms[this.form];

        formAttr.target = form.target;
        formAttr.method = form.method;
        formAttr.action = form.action;

        form.target = fId;
        form.method = 'post';
        if (this.src) form.action = this.src;

        form.submit();
        //还原表单被修改的属性
        form.target = formAttr.target;
        form.method = formAttr.method;
        form.action = formAttr.action;
    }
    else {
        f.src = this.src;
		
    }

    as && as();

    ls && ls();



    var ts = this;

    function loadComplete() {

        if (lc) lc();
        if (drag)
		{
			
            if (!max.browser.isOpera)//opera浏览器移动对话框出现抖动现象， 暂时屏蔽这行代码
            addHandle(window.frames[fId].document.body, window.frames[fId], d);
		}

			
        showMask.call(ts);
    };
    function showMask() {
        if (this.showMask) if (!this.maskLayer) this.maskLayer = new background(); //屏蔽层
    }
    var timeoutval = this.timeout;
    var ttemp = this.timeoutTemplate; ;
};

maxdialog.prototype.resize = function(width, height) {

    this.isOpen = true;
    var d = this.obj;
    var wStep, hStep;
    var f = this.iframeObj;
    var l = this.loadingNode;
    var fid = this.innerFrmaeId;
    this.animation = null;
    if (height == null || height == 0) {
        f.style.display = '';
        height = window.frames[this.innerFrmaeId].document.body.offsetHeight + 30;
    }
    if (this.cancel) return;
    if (this.inited == false) {
        l.style.display = 'none';
    }
    else {
        var s = d.style;
        s.width = width + "px";
        if (max.browser.isIE6) {
            d = $('dialog_body');
            d.style.height = height + "px";
            f.height = height;
            $('dialog_container').style.height = height + "px";
        }
        else {
            s.height = height + "px";
        }
        if (this.x) s.left = this.x + "px"; if (this.y) s.top = this.y + "px";
    }

    var ami;
    if (this.animation) ami = this.animation; else { ami = new animation(d); this.animation = ami };
    ami.oncomplete(function() { f.style.display = ''; ami = null });
    ami.open(width, height, this.x, this.y);
    // this.inited = true;

};

//关闭对话框
maxdialog.prototype.close = function() {
    var bc = this.before_close_handler;
    var ac = this.after_close_handler;
    var re = this.return_handler;
    var l = this.loadingNode;
    var scale;
    var f, d;
    d = this.obj; f = this.iframeObj;


    bc && bc();

    var resultData;

    try {
        resultData = this.iframePage.result;
    }
    catch (ex) { }
    if (max.browser.isIE) this.iframeObj.onreadystatechange = null;
    else this.iframeObj.onload = null;

    f.src = 'about:blank';
    f.style.display = 'none';

    ac && ac();
    var d = this.obj;
    /*animation*/
    var anim;
    if (this.animation) anim = this.animation; else anim = new animation(d);
    f.style.display = 'none';
    l.style.display = 'none';

    anim.oncomplete(function() {
        l.style.display = '';
        d.style.display = 'none';
        anim = null;
        if (re && resultData) re(resultData); //关闭对话框回调
    });
    anim.close();
    /*animation*/

    if (this.showMask) { this.maskLayer.destroy(); this.maskLayer = null }
    this.inited = false;
};


maxdialog.prototype.closetimeout = function(timeout) {
    var _this = this;
    if (timeout < 1) _this.close();
    setTimeout(function() { _this.close() }, timeout * 1000);
}

var animation = function(elm) {
    var complete = null, re = max.coor.getRect(elm), timeLength = 50, interval = 5, w = re.width, h = re.height, lf = re.left, tp = re.top
        , x, y, fix, width, height
        , wStep = w / (timeLength / interval)
        , hStep = h / (timeLength / interval);

    action = function(a) {
        var brect = max.global.getBrowserRect();
        if (a < 0) lf = parseInt(elm.style.left), tp = parseInt(elm.style.top);
        var n = 0;
        var date = new Date();
        var begin = date.getTime();

        var now;
        //begin +=now.getSeconds()*1000;
        while (true) {
            //                    date=new Date();
            //                    now=date.getTime();
            //                    if( now-begin < interval)
            //                    {
            //                        //alert("aa");
            //                        continue;
            //                    }
            //                    begin=now;

            // var t=new timer(interval,function(n){
            n++;
            w += wStep * a;
            h += hStep * a;
            lf = x ? x : lf -= wStep * a / 2;
            tp = y ? y : tp -= hStep * a / 2;
            if (lf + w > brect.right) lf = brect.right - w - 5;
            if (tp + h > brect.bottom) tp = brect.bottom - h - 12;
            w = Math.floor(w); h = Math.floor(h); lf = Math.floor(lf); tp = Math.floor(tp);
            if (n > timeLength / interval || w < 0 || h < 0 || w > width || h > height) {
                if (complete) complete();
                //alert("hello");
                // t.stop();
                if (a > 0) {
                    if (!x) lf = (re.width - width) / 2 + re.left;
                    if (!y) tp = (re.height - height) / 2 + re.top;
                    setStyle(elm, { width: width + 'px', height: height + 'px', left: lf + 'px', top: tp + 'px' });
                }
                return;
            }
            setStyle(elm, { width: w + 'px', height: h + 'px', left: lf + 'px', top: tp + 'px' });
        };
        //t.start();
    };
    return {
        close: function() { action(-1) },
        open: function(pw, ph, sx, sy) {
            width = pw; height = ph;
            wStep = (width - w) / (timeLength / interval);
            hStep = (height - h) / (timeLength / interval);
            x = sx; y = sy; action(1);
        },
        oncomplete: function(f) { complete = f; }
    }
}


/******************************* 移动iframe对话框的代码  @_@  **********************************/
var dragging = false;
var iframeObject = new Object();
var iframeMouseLeft = new Object();
var iframeMouseTop = new Object();
var pageMouseLeft = new Object();
var pageMouseTop = new Object();
var handles = null;
var allowDragOffScreen = false;
var frameParent = null;
var mover = null;

function addHandle(o, win, oParent) {
    if (arguments.length == 2 && win == window) {
        var p = win;
        while (p = p.parent) {
            if (p.addHandle) { p.addHandle(o, win, true); return; }
            if (p == win.top) { return; }
        }
        return;
    }
    frameParent = oParent;
    var topRef = win;
    var topRefStr = "window";
    while (topRef.parent && topRef.parent != window) {
        topRef = topRef.parent;
        topRefStr = topRefStr + ".parent";
    }
    if (typeof (win.DIF_mainHandlersAdded) == "undefined" || !win.DIF_mainHandlersAdded) {
        with (win) {
            eval("function OnMouseDownHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}" + topRefStr + ".parent.DIF_begindrag(evt, " + topRefStr + ") }");
            addHandler(document.body, 'mousedown', OnMouseDownHandler);
            eval("function OnMouseUpHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}" + topRefStr + ".parent.DIF_enddrag(evt, " + topRefStr + ") }");
            addHandler(document.body, 'mouseup', OnMouseUpHandler);
            eval("function OnMouseMoveHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}" + topRefStr + ".parent.DIF_iframemove(evt, " + topRefStr + ") }");
            addHandler(document.body, 'mousemove', OnMouseMoveHandler);
            win.DIF_handlersAdded = true;
            win.DIF_mainHandlersAdded = true;
        }
    }
    if (typeof (window.DIF_handlersAdded) != "undefined" || !window.DIF_handlersAdded) {
        eval("function OnMouseMoveHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}DIF_mouseMove(evt, window) }");
        addHandler(document.body, 'mousemove', OnMouseMoveHandler);
        window.DIF_handlersAdded = true;
    }
    var titleBar = win.document.getElementById('dialogTitleBar');
    //如果内部有标题条就用标题条移动
    if (titleBar != null) {
        handles = titleBar;
    }
    else {
        handles = o;
    }
}

function DIF_getEventPosition(evt) {
    var pos = new Object();
    pos.x = 0;
    pos.y = 0;
    evt = evt || window.event;
    if (typeof (evt.pageX) == 'number') {
        pos.x = evt.pageX;
        pos.y = evt.pageY;
    }
    else {
        pos.x = evt.clientX;
        pos.y = evt.clientY;
        if (!top.opera) {
            if ((!window.document.compatMode) || (window.document.compatMode == 'BackCompat')) {
                pos.x += window.document.body.scrollLeft;
                pos.y += window.document.body.scrollTop;
            }
            else {
                pos.x += window.document.documentElement.scrollLeft;
                pos.y += window.document.documentElement.scrollTop;
            }
        }
    }
    return pos;
}


function DIF_getObjectXY(o) {
    var res = new Object();
    res.x = 0; res.y = 0;
    if (o != null) {
        res.x = parseInt(frameParent.style.left);
        res.y = parseInt(frameParent.style.top);
    }
    return res;
}

function getSrcElement(e) {
    var tgt = e.target;
    while (tgt.nodeType != 1) { tgt = tgt.parentNode; }
    return tgt;
}

function isHandleClicked(handle, objectClicked) {
    if (handle == objectClicked) { return true; }
    while (objectClicked.parentNode != null) {
        if (objectClicked == handle) {
            return true;
        }
        objectClicked = objectClicked.parentNode;
    }
    return false;
}

function DIF_begindrag(e, win) {
    if (handles == null) {
        return;
    }
    var isHandle = false;
    var t = e.srcElement || getSrcElement(e);
    if (isHandleClicked(handles, t)) {
        isHandle = true;
    }

    if (!isHandle) { return false; }
    dragging = true;
    var pos = DIF_getEventPosition(e);
    iframeMouseLeft = pos.x;
    iframeMouseTop = pos.y;
    var o = DIF_getObjectXY(iframeObject);
    pageMouseLeft = o.x - 0 + pos.x;
    pageMouseTop = o.y - 0 + pos.y;
}

function DIF_enddrag(e) {
    dragging = false;
}

function DIF_mouseMove(e) {
    if (dragging) {
        var pos = DIF_getEventPosition(e);
        DIF_drag(pos.x - pageMouseLeft, pos.y - pageMouseTop);
    }
}

function DIF_iframemove(e) {
    if (dragging) {
        var pos = DIF_getEventPosition(e);
        DIF_drag(pos.x - iframeMouseLeft, pos.y - iframeMouseTop);
    }
}

function DIF_drag(x, y) {
    var o = DIF_getObjectXY(iframeObject);
    var newPositionX = o.x - 0 + x;
    var newPositionY = o.y - 0 + y;
    //限制移动范围不超出浏览器
    //	    if (!allowDragOffScreen) {
    //		    if (newPositionX < 0) { newPositionX=0; }
    //		    if (newPositionY < 0) { newPositionY=0; }
    //		    }
    frameParent.style.left = newPositionX + "px";
    frameParent.style.top = newPositionY + "px";
    pageMouseLeft += x;
    pageMouseTop += y;
}






max.dialog.defaultSettings = {
    template: '\
<div class="dialog" id="dialog_container">\
<div class="dialog-inner" id="dialog_body">\
    {loading}\
    {body}\
</div>\
</div>',

    loadingTemplate: '<div style="position:relative;width:270px;height:90px;overflow:hidden;"><p style="position:absolute;top:50%;left:70px;margin-top:-20px;height:40px;line-height:40px;padding-left:50px;background:url(' + root + '/assets/images/loading.gif) no-repeat 0 50%;">正在加载...</p></div>',
    timeoutTemplate: '打开页面超时, 请刷新页面. <a href="jsvascript:void(dialog.close())>点击关闭</a>"',


    //表示弹出式对话框的关闭按钮
    template_closeButton: 'max_dialog_close',
    template_moveArea: 'max_dialog_title',
    width: 280,
    height: 90,

    //表示对话框在页面上第一次被调用时，初始化触发的事件
    init_handler: null,

    before_show_handler: null,

    after_show_handler: null,

    //表示对话框显示并开始加载内容触发的事件
    load_start_handler: null,

    //表示对话框内容加载完成触发的事件
    load_complete_handler: null,

    before_close_handler: null,

    after_close_handler: null,

    return_handler: null,

    canDrag: true,

    //是否屏蔽浏览器
    showMask: false,

    //超时
    timeout: 40
};

//刷新页面
function refresh() {
    var href = location.href;

    if (href.indexOf('#', 0) > -1) {
        href = href.substring(0, href.indexOf('#', 0))
    }
    location.replace(href);
}

function initEditor(config) {
    KE.init(config);
    KE.create(config.id);
}


//==========================================================菜单

/******************************* 弹出菜单容器 *********************************/
var popupCollection = function() { var c = popupCollection; if (!c.innerList) c.innerList = new Array(); }
popupCollection.prototype.add = function(obj) { obj.onShow = this.onshow; popupCollection.innerList.push(obj); }
popupCollection.prototype.onshow = function(obj) { var cc = popupCollection; for (var i = 0; i < cc.innerList.length; i++) { if (cc.innerList[i] != obj) { cc.innerList[i].hide(); } } }
popupCollection.instance = function() { if (!window.dropCollection) window.dropCollection = new popupCollection(); return window.dropCollection; }

//**弹出菜单基类
var popupBase = function(listid, trigger, autopopup) { this.list = $(listid); this.auto = autopopup; if (trigger instanceof Object) this.trigger = trigger; else this.trigger = $(trigger); }
popupBase.prototype.show = null;
popupBase.prototype.hide = null;
popupBase.prototype.onShow = null;
popupBase.prototype.onHide = null;

/******************************* 下拉菜单 *********************************/
//下拉菜单
//listid:下拉菜单的那个容器ID
//triggerid:触发下拉菜单弹出的那个对象的ID
//autoPop:如果是true那么只要鼠标滑过就弹出， 否则需要点击才弹出
//position:位置目前只支持'auto'和'center'
var popup = function(listid, trigger, autoPop, onSelectClass, pos) {
    this.focus = false;
    popupBase.call(this, listid, trigger, autoPop);

    this.triggerStyle = onSelectClass;
    if (pos)
        this.position = pos;
    else
        this.position = 'auto';

    var _this = this;
    var s = this.list.style;
    s.position = 'absolute';
    s.zIndex = 9999;

    addHandler(this.trigger, this.auto ? 'mouseover' : 'click', function(e) { _this.show(); });
    if (this.auto) {
        addHandler(this.list, 'mouseover', function(e) { _this.focus = true; });
        addHandler(this.trigger, "mouseout", function() { hideList(_this) });
        addHandler(this.list, "mouseout", function() { hideList(_this) });
    }
    else {
        addHandler(this.trigger, "mouseout", function() { _this.focus = false; });
        addHandler(this.list, "mouseout", function() { _this.focus = false; });
        addHandler(this.trigger, "mouseover", function() { _this.focus = true; });
        addHandler(this.list, "mouseover", function() { _this.focus = true; });
        addHandler(document.documentElement, "click", function() { if (_this.focus == false) _this.hide(); })
    }
    popupCollection.instance().add(this);
}
function hideList(e) {
    window.setTimeout(function() { if (e.focus == false) e.hide(); }, 1000);
    e.focus = false;
}

popup.prototype.show = function() {
    var s = this.list.style;
    s.display = '';
    var t, l;
    rt = max.coor.getRect(this.trigger)
    rl = max.coor.getRect(this.list);
    rw = max.global.getBrowserRect();


    if (rt.bottom + rl.height > rw.bottom)
        t = rt.top - rl.height;
    else
        t = rt.bottom;
    if (this.position == 'auto') {
        if (rt.left + rl.width > rw.right)
            l = rt.right - rl.width;
        else
            l = rt.left;
    }
    else {
        l = (rt.left + rt.width / 2) - rl.width / 2;
    }

    this.focus = true;
    s.left = l + "px";
    s.top = t + "px";
    s.zIndex = 50;

    var cn = this.triggerStyle;
    if (cn)
        if (this.trigger.className.indexOf(cn) < 0)
        this.trigger.className += " " + cn;

    if (this.onShow) this.onShow.call(popupCollection.instance(), this);
}

popup.prototype.hide = function() {
    var s = this.list.style;
    s.display = 'none';
    var cn = this.triggerStyle;
    if (cn)
        if (this.trigger.className.indexOf(cn) >= 0)
        this.trigger.className = this.trigger.className.replace(cn, '').trim();
    if (this.onHide) this.onHide.call(popupCollection.instance(), this);
}

/**************************************用户菜单***********************************/

var userMenus = {};
var userMenu = function(id, trigger, exclu) {
    var list;
    var menu;
    var d = new Date();
    var controlId = 'user_menu_' + d.getMilliseconds();
    // list = $(controlId);
    // if(list==null)
    // {
    var sb = new stringBuilder();
    list = addElement("ul");//, trigger.parentNode);
    list.className = 'usermenu';
    list.id = controlId;
    for (var mn in menuItems) {
        if (mn == exclu) continue;
        if (menuItems[mn])
            sb.append(String.format(menuItems[mn], id));
    }

    list.innerHTML = sb.toString();
    list.style.display = 'none';
    // }
    return new popup(list.id, trigger, false);
}

function createUserMenu(e, userid, exclu) {
    var ums = userMenus[userid.toString()];
    if (ums) {

        var f = false;
        for (var i = 0; i < ums.length; i++) {
            if (ums[i] == e) {
                f = true;
                break;
            }
        }


        if (f == false) getUserMenu.call(e);
        return false;
    }
    else {

        ums = new Array();
        userMenus[userid.toString()] = ums;
        getUserMenu.call(e);
        return false;
    }

    function getUserMenu() {
        try {
            var menu = new userMenu(userid, this, exclu);
            ums.push(this);
            menu.show();
        }
        catch (e) { }
    }
}

function setHeader(menu)
{
	 j = document.getElementById(menu);
	 j.className = "choose";
}


function search()
{
	if(event.keyCode==13 || event.keyCode==0 || event.type=='click') 
	{
		var keystr = encodeURIComponent(window.document.all.q.value);
		var keytype = encodeURIComponent(window.document.all.searchtype.value);
		if(keytype=='0')
			window.open('/search.aspx?key='+keystr);
		else
			window.open('/searchblog.aspx?key='+keystr);

	}
}

