﻿/*hwl-2.0.js 2011-9-5 */
(function (window, undefined) {
    window.$$ = (function (id, o) {
        if (o && o.nodeName) { return o; }
        if (typeof id === 'object') { return id; }
        return id ? document.getElementById(id) : null;
    });
    $$.addfavorite = function () { if (document.all) { window.external.addFavorite(location.href, document.title); } else if (window.sidebar) { window.sidebar.addPanel(document.title, location.href, ""); } };
    $$.sethome = function () {
        var d = document;
        if (d.all) {
            d.body.style.behavior = ' url(#default#homepage) '; d.body.setHomePage(location.href);
        } else if (window.sidebar) {
            if (window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege(" UniversalXPConnect "); } catch (e) { return; } }
            var prefs = Components.classes[' @mozilla.org/preferences-service;1 '].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref(' browser.startup.homepage ', location.href);
        }
    };
    $$.info = { _gc: 0, _r20: /%20/g, _jsfiles: {}, _hideframe: null };
    $$.gc = function () { if (document.all && $$.info._gc++ > 10) { CollectGarbage(); $$.info._gc = 0; } };
    $$.parent = function (o, n1, n2, n3) { while (o) { switch (o.nodeName) { case n1: case n2: case n3: return o; break; default: o = o.parentNode; } } return o; };
    $$.parent.level = function (o, level) { while (o && level-- > 0) { o = o.parentNode; } return o; };
    $$.load = function (o, c, ap) { o = $$(o); if (o.length && !o.nodeName) { for (var i in o) { ap[0] = o[i]; c.apply(null, ap); } return 1; } else { return 0; } };
    $$.shadow = function () {
        $$.each(arguments, function (o, id) {
            o = $$(id); if (!o) { return; }
            !o.shadow && (o.shadow = $$.follow($$.styles($$.att($$.el('img'), 'src', '/Lresources/i/shadow.png'), 'position:absolute;left:0;top:0;z-index:0;'), o));
            var x = $$.pos.all(o);
            $$.styles(o.shadow, 'width:' + (x.w + 80) + 'px;height:' + (x.h + 80) + 'px;left:' + (x.x - 35) + 'px;top:' + (x.y - 35) + 'px;');
        });
    };
    $$.isfun = function (o) { return o && typeof o === 'function'; };
    $$.ischange = function () {
        var ischange = false;
        $$.each(arguments, function (i, o) { if (o.value != o.lastvalue) { ischange = true; o.lastvalue = o.value; } });
        return ischange;
    };
    $$.isnull = function (o) { if (!$$.trim(o.value)) { o.focus(); return true; } else { return false; } };
    $$.jquery = function () {
        var exist, path = '/Lresources/jquery.js';
        $$.each($$.by(document, 'script'), function (i, sc) { if (sc.src.toLowerCase() === path) { exist = true; return true; } });
        if (!exist) { $$.el.script(path); }
    };
    $$.mask = function (isopen) {
        var mk = $$.mask.mk, db = document.body;
        if (!mk && !isopen) { return; }
        if (!mk) { mk = $$.mask.mk = $$.opacity($$.styles($$.el('div', db), 'position:fixed;_position:absolute;background-color:#fff;z-index:1000;width:100%;height:100%;top:0;left:0;'), 68); }
        $$.display(mk, isopen);
    };
    $$.prompt = function (o) {
        o = $$(o, this);
        var div = $$($$.att(o, 'for'));
        if (!div) { return; }
        div.style.cssText += ';visibility:visible;top:-' + div.clientHeight + 'px;width:' + (o.clientWidth - 14) + 'px';
        var _timeout,
        callhide = function () { o.onclick = $$.msg.prompt; o.onmouseover = null; $$.none(div); },
        callset = function () { div.style.cssText += ';top:-' + div.clientHeight + 'px;'; };
        o.onmouseout = div.onmouseout = function () { _timeout = setTimeout(callhide, 700); };
        o.onclick = o.onmouseover = div.onmouseover = function () { _timeout && (clearTimeout(_timeout)); $$.vis(div); };
        setTimeout(callset, 100);
    };
    $$.box = function (title, txt, o, btpar, css, hidetime, name, isclose, ismask, nocancel, noupdate) {
        var ob, oa = o, kn = name || 'box', box = $$.box[kn];
        if (box) { while (oa && oa != box) { oa = oa.parentNode; } }
        if (box && oa) { ob = box; box = $$.box.box2; kn = 'box2'; }
        if (!box) {
            box = $$.box[kn] = $$.text($$.css($$.el('div'), 'wl_box'), '<div class="wl_box_border"></div>');
            box.name = name;
            var ds = $$.byc(box, 'div');
            $$.text(ds, '<a class="wl_box_close">X</a><div class="wl_box_head"></div><div class="wl_box_txt"></div><div class="wl_box_bt"></div>');
            ds = $$.by(ds, 'div');
            box.head = ds[0]; box.txt = ds[1]; box.bt = ds[2];
            box.close = function () { $$.hide(box, box.ob); (o && o.focus) && (o.focus()); $$.mask(false); };
            box.aclose = $$.byc(box, 'a');
            box.aclose.onclick = box.close;
            $$.insert(box);
            ob && (ob.ob = box);
        } else if (noupdate) {
            $$.show(box);
            return box;
        }
        box.o = o;
        box.close();
        box._sthide && (clearTimeout(box._sthide));
        $$.zindex(box);
        if (!(btpar === undefined || btpar === null)) {
            if (typeof btpar === 'string') { btpar = { 'js': btpar }; } else if (typeof btpar === 'function') { btpar = { 'call': btpar }; }
            $$.text(box.bt, '<span ' + (btpar.js ? 'onclick="' + btpar.js + '"' : '') + ' class="wl_box_btok">' + (btpar.ok || '确定') + '</span><span class="wl_box_btcancel">' + (btpar.cancel || '取消') + '</span>');
            var sp = $$.by(box.bt, 'span');
            if (!btpar.js && !btpar.call) { $$.hide(sp[1]); sp[0].onclick = box.close; } else { sp[1].onclick = box.close; if (btpar.call) { sp[0].onclick = btpar.call; } }
            sp[0].txt = box.txt;
            if (nocancel) { $$.hide(sp[1]); }
            var i = 0, doc = $$.doc();
            $$.each(btpar.bts, function (n, v, x, x1) {
                x1 = typeof v === 'function';
                x = $$.doc('<span' + (!x1 ? ' onclick="' + v + '"' : '') + '  class="wl_box_bts" id="wl_box_bts_' + (i++) + '">' + n + '</span>');
                x1 && ($$.child(x).onclick = v);
                doc.appendChild(x);
            });
            if (i) { $$.insert(doc, sp[0]); }
            $$.each($$.by(box.bt, 'span'), function (i, span) { span.txt = box.txt; });
            $$.styles(box.bt, 'text-align:' + (i ? 'right;' : 'center;'));
            if (o) { var tr = $$.parent(o, 'TR', 'LI', 'DD'); if (tr) { $$.css.add(tr, 'wl_deling'); box.tr = tr; } }
        }
        (o && o.focus) && (o.focus());
        (!(ismask == undefined || ismask == null)) && ($$.mask(ismask));
        title && ($$.text(box.head, title));
        if (txt) {
            if (typeof txt === 'object') {
                $$.text(box.txt, '');
                $$.append(txt, box.txt);
            } else {
                $$.text(box.txt, txt);
            }
            $$.css(box.txt, css ? 'wl_box_txt ' + css : 'wl_box_txt');
        }
        $$.display([box.head, box.aclose], title);
        $$.display(box.bt, btpar);
        $$.display(box.txt, txt);
        if (!isclose) {
            $$.each($$.by(box.txt, 'input'), function (i, inp) { if (inp.type == 'text' && !inp.disabled) { inp.focus(); return true; } });
            $$.show(box);
        }
        o ? $$.pos.follow(o, box) : $$.pos.center(box);
        if (typeof hidetime === 'number' && hidetime > 0) { box._sthide = setTimeout(box.close, hidetime); }
        return box;
    };
    $$.box.fixed = function (title, txt, o, btpar, name, css, ismask, nocancel) { return $$.box(title, txt, o, btpar, css, null, name, null, ismask, nocancel, true); };
    $$.box.create = function (name, title, txt, btpar, css, isopen) { return $$.box(title, txt, null, btpar, css, null, name, !isopen); };
    $$.box.close = function (name) { var b = name && name.nodeName ? name : $$.box[name || 'box']; b && (b.close()); };
    $$.box.open = function (name, o) { var b = name && name.nodeName ? name : $$.box[name || 'box']; if (b) { !o && (o = b.o); $$.show(b); o ? $$.pos.follow(o, b) : $$.pos.center(b); } };
    $$.msg = function (msg, o, css, hidetime) { return $$.box(null, msg, o, '', css, hidetime === null ? null : hidetime || 10000); };
    $$.status = function (msg, o, css) { return $$.box(null, msg, o, null, css); }

    $$.ajax = { _initId: null, _index: 0, _hashXml: {}, _hashName: {}, _arrXmlHttp: ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"], SP: '--<<<*LAJAX*>>>--' };
    $$.ajax.pick = function (txt) {
        var akey = $$.ajax.SP, k = txt.indexOf(akey);
        k != -1 && (txt = txt.substr(k + akey.length));
        return txt;
    };
    $$.ajax.result = function (type, txt, par) {
        txt = $$.ajax.pick(txt);
        switch (type) {
            case 'json': return $$.json.parse(txt);
            case 'script': $$.eval(txt, par ? par.istrim : false);
            default: return txt;
        }
    };
    $$.ajax.change = function () {
        if (this.readyState == 4) {
            var s = this.status;
            if (s >= 200 && s < 300 || s === 304) {
                var v = $$.ajax.result(this._type, this.responseText, this._par)
                this._call && (this._call(v, this._par));
            }
            delete $$.ajax._hashName[this._name];
            $$.gc();
        }
        try {
        } catch (ex) { alert(ex); }
    };
    $$.ajax.initialize = function (name, call, par, type) {
        var ajax = null, isNew = false;
        switch (this._initId) {
            case -100: break;
            case -2: ajax = new window.XMLHttpRequest(); isNew = true; break;
            case null:
                var id = null;
                if (window.XMLHttpRequest) {
                    ajax = new window.XMLHttpRequest();
                    isNew = true;
                    id = -2;
                } else {
                    id = -100;
                    for (var i = 0, arr = this._arrXmlHttp, x; x = arr[i]; i++) {
                        try { ajax = new ActiveXObject(x); id = i; break; } catch (e) { }
                    }
                }
                this._initId = id;
                break;
            default: ajax = new ActiveXObject(this._arrXmlHttp[this._initId]); break;
        }
        if (ajax) {
            if (isNew) {
                ajax._type = type; ajax._call = call; ajax._par = par; ajax._name = name; ajax.onreadystatechange = this.change;
            } else {
                ajax.onreadystatechange = this._hashXml[name] = function () {
                    if (ajax.readyState == 4) {
                        var s = ajax.status;
                        if (s >= 200 && s < 300 || s === 304) {
                            var v = $$.ajax.result(type, ajax.responseText, par);
                            call && (call(v, par));
                        }
                        ajax = null;
                        $$.ajax.del(name);
                    }
                    try { } catch (ex) { alert(ex); }
                };
            }
        }
        return ajax;
    };
    $$.ajax.del = function (name) { delete this._hashXml[name]; delete this._hashName[name]; $$.gc(); };
    $$.ajax.url = function (uri) { return uri + (uri.indexOf('?') == -1 ? '?' : '&') + 'rnd=' + Math.random(); };
    $$.ajax.init = function (name, call, par, type) {
        if (name && this._hashName[name]) { return false; }
        return this._hashName[name] = this.initialize(name, call, par, type);
    };
    $$.ajax.get = function (uri, call, name, par, type) {
        var ajax = this.init(name, call, par, type); if (!ajax) { return; }
        ajax.open('GET', this.url(uri), !document.all);
        ajax.send(null);
        ajax = null;
    };
    $$.ajax.post = function (uri, data, call, name, par, type) {
        var ajax = this.init(name, call, par, type); if (!ajax) { return; }
        ajax.open('POST', this.url(uri), true);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
        ajax.setRequestHeader("If-Modified-Since", "0");
        ajax.send(data ? $$.todata(data) : null);
    };
    $$.arr = function () { };
    $$.arr.un = function (arr) { var d = [], i = arr.length - 1; while (i > -1) { d.push(arr[i--]); } return d; };
    $$.color = function () {
        var carr = function () {
            var c = $$.color._color;
            if (c) { return c; }
            c = $$.color._color = [];
            for (var i = 0; i < 10; i++) { c.push(i); }
            for (var i = 0, a, arr = 'A,B,C,D,E,F'.split(','); a = arr[i++]; ) { c.push(a); }
            return c;
        };
        var i, d = ['#'], c = carr(), clen = c.length, index, k = 0;
        for (i = 0; i < 6; i++) {
            index = parseInt(Math.random() * clen);
            if (i == 5) { index = k < 20 ? index = clen / 2 : 1; }
            d.push(c[index]);
            !(i % 2) && (k += index);
        }
        return d.join('');
    };
    $$.split = function (str, arrpar) { var d = []; $$.each(arrpar, function (i, s) { if (str.indexOf(s) == -1) { return; } d = str.split(s); return true; }); return d; };
    $$.text = function (div, text) { if (text === undefined) { return $$.text.get(div); } div = $$(div); (div != undefined && text != undefined) && (div.innerHTML = text); return div; };
    $$.text.get = function (id) { id = $$(id); return id ? id.innerHTML.replace(/^\s+|\s+$/g, '') : undefined; };
    $$.text.insert = function (div, text) { if (text) { var d = $$.doc(text), fd = div.firstChild; if (fd) { $$.insert(d, fd); } else { $$.append(d, div); } } return div; };
    $$.text.append = function (div, text) { text && ($$.append($$.doc(text), div)); return div; };
    $$.txt = function (div, txt) {
        var n = document.all ? 'innerText' : 'textContent';
        if (typeof div === 'string') { div = $$.text($$.el('div'), div); txt = undefined; }
        if (txt === undefined) { return div[n].replace(/^\s+|\s+$/g, ''); } else { div[n] = txt; return div; }
    };
    $$.txt.exist = function (txt, name) {
        var arr = txt ? txt.split(' ') : [];
        for (var i = 0, l = arr.length; i != l; i++) { if (arr[i] == name) { return true; } }
        return false;
    };
    $$.txt.insert = function (txt, name, delnames) {
        var arrNew = [], objDel = {}, arr = name ? name.replace(/\s+/g, ' ').split(' ') : [], arrDel;
        for (var i = 0, l = arr.length; i != l; i++) { objDel[arr[i]] = true; }
        if (delnames) {
            arrDel = delnames.replace(/\s+/g, ' ').split(' ');
            for (var i = 0, l = arrDel.length; i != l; i++) { objDel[arrDel[i]] = true; }
        }
        txt = txt || '';
        arr = txt.replace(/\s+/g, ' ').split(' ');
        for (var i = 0, l = arr.length; i != l; i++) { !objDel[arr[i]] && (arrNew.push(arr[i])); }
        if (name) { arrNew.push(name); }
        return arrNew.join(' ');
    };
    $$.txt.del = function (txt, names) {
        var arr = names.replace(/\s+/g, ' ').split(' '), objDel = {}, arrNew = [];
        for (var i = 0, l = arr.length; i != l; i++) { objDel[arr[i]] = true; }
        arr = txt.replace(/\s+/g, ' ').split(' ');
        for (var i = 0, l = arr.length; i != l; i++) { !objDel[arr[i]] && (arrNew.push(arr[i])); }
        return arrNew.join(' ');
    };
    $$.txt.split = function () {
        var key, i, l, d = [], arg = arguments, txt = arg[0], key = arg[1];
        if (!txt || !key) { return txt ? [txt] : d; }
        for (i = 2, l = arg.length; i < l; i++) {
            if (arg[i]) {
                txt = txt.replace(new RegExp(arg[i], 'gim'), key);
            }
        }
        return txt.split(key);
    };
    $$.select = function (o) { o = $$(o); return o.options[o.selectedIndex].value; };
    $$.select.set = function (o, v) { $$.each(o.childNodes, function (i, c) { if (c.value == v) { o.selectedIndex = i; return true; } }); };
    $$.select.text = function (o) { o = $$(o); return o.options[o.selectedIndex].text; };
    $$.uri = function (url, par) { return url + (url.indexOf('?') == -1 ? '?' : '&') + par; };
    $$.uri.request = function (n, v) { return $$.uri.get(n, '', v); };
    $$.uri.req = function (n, v) { return $$.uri.get(n, '', v); };
    $$.uri.get = function (name, uri, v) {
        if (!uri) { uri = location.href.toLowerCase(); }
        v === undefined && (v = '');
        var p = name ? v : {};
        uri = uri.split('#')[0];
        uri = uri.split('?'); uri = uri[uri.length - 1]; if (!uri) { return p; }
        uri = uri.split('&'); if (!uri) { return p; }
        name && (name = name.toLowerCase());
        for (var i = 0, l = uri.length; i < l; i++) {
            if (uri[i].length < 2) { continue; }
            var arr = uri[i].split('=');
            if (arr[0].length < 1) { continue; }
            if (!name) { p[arr[0]] = arr[1]; continue; }
            if (arr[0] != name) { continue; }
            return arr[1] || v;
        }
        return p;
    };
    $$.uri.replace = function (name, value, uri) {
        uri = uri || location.href;
        var par = name + '=' + value, link = uri.split('?')[1], s;
        if (!link) {
            s = uri.substr(uri.length - 1, 1);
            if (s == '?' || s == '&') { s = ''; } else if (s.indexOf('?') == -1) { s = '?'; } else { s = '&'; }
            return uri + s + par;
        }
        var d = link.split('&');
        for (var i = 0, l = d.length; i < l; i++) {
            if (d[i].length < 2) { continue; }
            var arr = d[i].split('=');
            if (arr[0].length < 1) { continue; }
            if (arr[0] != name) { continue; }
            return uri.replace(d[i], par);
        }
        return uri + '&' + par;
    };
    $$.regexp = function (regexp, value) { return new RegExp(regexp).test(value); };
    $$.isemail = function (email) { return $$.regexp('^([a-zA-Z0-9_-]+)(\.[a-zA-Z0-9_-]+)*@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$', email); };
    $$.js = function (path, id, node, istry) {
        var head, js;
        if (id) { js = $$(id); if (js) { if (istry) { return; } head = js.parentNode; head.removeChild(js); } }
        !head && (head = document.getElementsByTagName('head')[0]);
        js = document.createElement('script');
        js.type = 'text/javascript';
        js.src = path.indexOf('rnd=') === -1 ? $$.uri(path, 'rnd=' + Math.random()) : path;
        id && (js.id = id);
        node && (head = node);
        head.appendChild(js);
        return js;
    };
    $$.jstry = function (path, id) { !id && (id = $$.formatname(path)); $$.js(path, id, null, true); };
    $$.css = function (obj, name) {
        if (!obj) { return; }
        if (typeof obj === 'string') {
            var css = $$.el('link'); css.type = 'text/css'; css.rel = 'stylesheet'; css.href = obj; return $$.append.head(css);
        } else {
            if (name != undefined) { obj.className = name; return obj; } else { return obj.className; }
        }
    };
    $$.css.exist = function (obj, name) { obj = $$(obj); if (!obj.className) { return false; } return $$.txt.exist(obj.className, name); };
    $$.css.add = function (obj, name, delnames) { obj = $$(obj); obj.className = $$.txt.insert(obj.className, name, delnames); return obj; };
    $$.css.del = function (obj, names) { obj = $$(obj); obj.className && (obj.className = $$.txt.del(obj.className, names)); return obj; };
    $$.css.clear = function (o) { o = $$(o); o.className = ''; return o; };
    $$.css.over = function (o, css) { o = $$(o); o.cssback === undefined && (o.cssback = o.className || ''); css && (o.className = css); };
    $$.css.out = function (o, css) { o = $$(o); o === css === undefined && (o = this); o.className = css || o.cssback || ''; };
    $$.css.sw = function (o, css1, css2) { o = $$(o); o.className = o.className === css1 ? css2 || '' : css1; };
    $$.cookie = {
        set: function (name, value, day, hour, minute, path) {
            var expires = new Date();
            if (typeof (day) == "number") { expires.setDate(expires.getDate() + day); }
            if (typeof (hour) == "number") { expires.setHours(expires.getHours() + hour); }
            if (typeof (minute) == "number") { expires.setMinutes(expires.getMinutes() + minute); }
            document.cookie = name + "=" + escape(value) + ";" + (day || hour || minute ? " expires=" + expires.toGMTString() : "") + "; path=" + (path || '/');
            return value;
        },
        get: function (name, dv) {
            var arr = document.cookie.split("; "), l = arr.length, kv, i;
            for (i = 0; i < l; i++) { kv = arr[i].split("="); if (name == kv[0]) { return unescape(kv[1]); } }
            return dv;
        },
        remove: function (name, path) { document.cookie = name + "=; expires=Fri, 31 Dec 1000 23:59:59 GMT;path=" + (path || '/'); },
        keys: function (name, isInt) {
            var objKey = {}, cookie = this.get(name, null);
            if (!cookie) { return objKey; }
            var arr = cookie.split(';'), d, i, l;
            for (i = 0, l = arr.length; i < l; i++) { d = arr[i].split('='); objKey[d[0]] = isInt ? parseInt(d[1] || 0) : (d[1] || ''); }
            return objKey;
        },
        value: function (objs, name, dv) {
            var v = objs[name];
            if (v == undefined) { return dv; }
            switch (typeof dv) {
                case 'number': return parseFloat(v);
                case 'boolean': return v != '';
                default: return v;
            }
        }
    };
    $$.cookie.goal = { _cookie: {} };
    $$.cookie.goal.set = function (name, value, area) {
        !area && (area = 'a');
        var arr = [], g = $$.cookie.goal._cookie, cookie = g[area];
        if (!cookie) { cookie = g[area] = $$.cookie.keys('L.g.' + area); }
        cookie[name] = value;
        for (var key in cookie) { arr.push(key + '=' + cookie[key]); }
        $$.cookie.set('L.g.' + area, arr.join(';'), 1000);
    };
    $$.cookie.goal.get = function (name, defaultvalue, area) {
        !area && (area = 'a');
        var g = $$.cookie.goal._cookie, cookie = g[area];
        if (!cookie) { cookie = g[area] = $$.cookie.keys('L.g.' + area); }
        var value = cookie[name];
        return value === undefined ? defaultvalue : value;
    };
    $$.key = { code: function (evt) { evt = evt ? evt : (window.event ? window.event : null); return evt ? evt.keyCode : null; }, enter: function (evt) { return $$.key.code(evt) === 13; } };
    $$.event = function (o, name, call) {
        typeof name === 'string' && (name = [name]);
        if (!o) { o = document.all ? document.body : document; }
        $$.each(name, function (i, v) {
            if (window.addEventListener) { o.addEventListener(v.substr(2), call, false); return; }
            o[v] = call;
            /*if (window.attachEvent) { o.attachEvent(v, call); return; }*/
        });
        return o;
    };
    $$.event.remove = function (o, name, call) {
        typeof name === 'string' && (name = [name]);
        $$.each(name, function (i, v) {
            if (window.detachEvent) { o.detachEvent(name, call); return; }
            if (window.removeEventListener) { o.removeEventListener(name, call, false); return; }
            o[name] = null;
        });
        return o;
    };
    $$.mouseover = function (o, call) { return $$.event(o, ['onmouseover'], call); };
    $$.mouseout = function (o, call) { return $$.event(o, ['onmouseout'], call); };
    $$.pos = {};
    $$.pos.cursor = function (evt) {
        evt = evt ? evt : (window.event ? window.event : null);
        var db = document.body, dd = document.documentElement, ml, mt, x, y;
        ml = evt ? db.scrollLeft : dd.scrollLeft;
        mt = evt ? db.scrollTop : dd.scrollTop;
        evt = evt ? evt : (window.event ? window.event : null);
        x = evt.x != undefined ? evt.clientX + ml : evt.pageX;
        y = evt.y != undefined ? evt.clientY + mt : evt.pageY;
        return { 'x': x, 'y': y };
    };
    $$.pos.xy = function (o) { !o && (o = document.body); var ol = o.offsetLeft, ot = o.offsetTop, cl = o.clientLeft, ct = o.clientTop; return { x: ol > cl ? ol : cl, y: ot > ct ? ot : ct }; };
    $$.pos.wh = function (o) { !o && (o = document.body); var ow = o.offsetWidth, cw = o.clientWidth, oh = o.offsetHeight, ch = o.clientHeight; return { w: ow > cw ? ow : cw, h: oh > ch ? oh : ch }; };
    $$.pos.all = function (o) { var xy = $$.pos.xy(o), wh = $$.pos.wh(o); return { x: xy.x, y: xy.y, w: wh.w, h: wh.h }; };
    $$.pos.top = function () { var d = document, dt = d.body.scrollTop, et = d.documentElement.scrollTop; return dt > et ? dt : et; };
    $$.pos.y = function (evt) { evt = evt ? evt : (window.event ? window.event : null); return evt.y != undefined ? evt.y + $$.pos.top() : evt.pageY; };
    $$.pos.offset = function (o, p) { var x = 0, y = 0; do { x += o.offsetLeft || 0; y += o.offsetTop || 0; o = o.offsetParent; } while (o != p); return { "x": x, "y": y }; };
    $$.pos.follow = function (o, div, topAlign, offX, offY) {
        var po = $$.pos.offset(o), x = po.x, y = po.y, dwh = $$.pos.wh(div);
        var w = dwh.w, h = dwh.h, dw = $$.pos.wh().w;
        x = ((x + w > dw) ? dw - w : x);
        y = topAlign ? ((y - h < 1) ? 0 : y - h) : (y + $$.pos.wh(o).h);
        offX && (x += offX); offY && (y += offY);
        $$.styles(div, 'left:' + x + 'px;top:' + (y - 1) + 'px;');
        return div;
    };
    $$.pos.center = function (o, vis, box) {
        var db = document.body, isspace = typeof box === 'number', oo = $$.pos.wh(o), dd = $$.pos.wh(box), x, y, top = $$.pos.top(), dh = db.clientHeight;
        x = dd.w > oo.w ? (dd.w - oo.w) / 2 : 0;
        y = top + (oo.h < dh ? (dh - oo.h) / 2 : 0);
        if (vis != false) {
            o.style.cssText += ';left:' + x + 'px;top:' + y + 'px;';
            if (isspace) {
                var arr = $$.pos.center.arr;
                if (!arr) {
                    $$.pos.center.arr = arr = {};
                    $$.event(window, ['onscroll', 'onresize'], function () {
                        $$.each(arr, function (i, v) { !v.hide && ($$.pos.center(v, true, box)); });
                    });
                }
                !arr[0] && (arr[o] = o);
            }
            return o;
        }
        return { x: x, y: y };
    };
    $$.pos.hide = function (o) { o.style.cssText += ';left:-1000px;top:-1000px;visibility:hidden;'; };
    $$.fly = {};
    $$.fly.bottom = function (o, onlyie) {
        if (onlyie && !document.all) { return; }
        var call = function () { $$.each(o, function (i, x) { x.style.top = $$.pos.top() + ($$.pos.wh().h - $$.pos.wh(x).h) + 'px'; }); };
        $$.event(window, ['onscroll', 'onsize'], call);
        setTimeout(call, 0);
    };
    $$.support = { _scriptEval: null };
    $$.support.eval = function () {
        if (this._scriptEval === null) {
            var root = document.documentElement, script = $$.el("script"), id = "script" + $$.now();
            try { script.appendChild(document.createTextNode("window." + id + "=1;")); } catch (e) { }
            root.insertBefore(script, root.firstChild);
            if (window[id]) { _scriptEval = true; delete window[id]; } else { _scriptEval = false; }
            root.removeChild(script);
        }
        return _scriptEval;
    };
    $$.doc = function (txt) {
        var d = document.createDocumentFragment ? document.createDocumentFragment() : $$.el('div'); /*ie5 does not support*/
        if (!txt) {
            return d;
        } else {
            return $$.each($$.text($$.el('div'), txt).childNodes, function (i, v) { if (v) { d.appendChild(v); return -1; } }, d);
        }
    };
    $$.doc.append = function (nodes) {
        if (!nodes || nodes.length === undefined) { return nodes; }
        var doc = $$.doc();
        return $$.each(nodes, function (i, n) { doc.appendChild(n); }, doc);
    };
    $$.frame = function (par, name) {
        var fs = $$.frame.frames, f = name ? fs[name] : null;
        if (!f) {
            var d = $$.el('div');
            !par && (par = {});
            d.innerHTML = '<iframe name="' + (name || par.name) + '"' + (par.src ? ' src="' + par.src + '"' : '') + (par['class'] ? ' class="' + par['class'] + '"' : '') + (par['hide'] ? '  style="width:1px;height:1px;overflow:hidden;left:-1px;top:-1;z-index:1;position:absolute;border:none;"' : '') + ' frameBorder="0"><\/iframe>';
            f = fs[name] = $$.by(d, 'iframe')[0];
            $$.append(f, par.node);
        }
        return f;
    };
    $$.frame.frames = {};
    $$.hideframe = function () { return $$.frame({ 'hide': true }, 'hideframe').name; };
    $$.format = function (s) { return s ? s.replace(/\"/gi, '').replace(/\'/gi, '').replace(/\=/gi, '').replace(/\,/gi, '').replace(/\|/gi, '') : ''; }; /*.replace(/\:/gi, '')*/
    $$.objs = function (txt, sp1, sp2) {
        txt = $$.ajax.pick(txt);
        var arr = txt.split(sp1 || '\r\n'), objs = {}, index, v, i;
        !sp2 && (sp2 = '=');
        for (i in arr) {
            txt = arr[i]; if (!txt) { continue; }
            index = txt.indexOf(sp2);
            if (index < 1) { continue; }
            v = txt.substr(index + 1);
            v != '' && (objs[txt.substr(0, index)] = v);
        }
        return objs;
    };
    $$.data = function (txt, key, sp1, sp2) {
        var o = { m: {}, f: function (n) { return this.m[n] || ''; } };
        if (!txt) { return o; }
        !sp1 && (sp1 = ','); !sp2 && (sp2 = '=');
        var i = txt.indexOf(';'), s1 = i > 0 ? txt.substr(0, i) : txt, s2 = txt.substr(i + 1), m = {};
        if (key && key != s1) { return o; }
        if (s2) {
            var n, a, l, arr = s2.split(sp1);
            for (i = 0, l = arr.length; i < l; i++) {
                a = arr[i]; if (!a) { continue; }
                n = a.split(sp2);
                if (n.length != 2) { m[n[0]] = n[0]; } else { m[n[0]] = n[1]; }
            }
        }
        o.n = s1; o.v = s2; o.m = m;
        return o;
    };
    $$.data.view = function (o, isAlert) {
        var d = [];
        for (var k in o) { d.push(k + '=' + o[k]); }
        if (isAlert) { alert(d.join('\n')); }
        return d;
    };
    $$.now = function () { return (new Date()).getTime(); };
    $$.todata = function (d) {
        var s = [];
        $$.each(d, function (k, v) { s.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); });
        return s.join("&").replace($$.info._r20, "+");
    };
    $$.child = function (o) {
        o = $$(o); if (!o) { return undefined; }
        $$.each(o.childNodes, function (i, c) { if (c.nodeName != '#text') { o = c; return true; } });
        return o;
    };
    $$.child.by = function (o, name, index) {
        var n = name.toUpperCase(), d = [];
        $$.each($$(o).childNodes, function (i, c) { if (c.nodeName === n) { d.push(c); } });
        if (index === undefined) { return d; }
        if (index < 0) {
            index = index + d.length;
            if (index > -1) { return d[index]; }
        } else if (index < d.length) { return d[index]; }
        return undefined;
    };
    $$.child.byc = function (o, name) { return $$.child.by(o, name, 0); };
    $$.insert = function (nodes, node) {
        !node && (node = document.body.childNodes[0]);
        if (!node) { return $$.append(nodes, node); }
        nodes && (node.parentNode.insertBefore($$.doc.append(nodes), node));
        return nodes;
    };
    $$.insert.child = function (nodes, node) { return $$.insert(nodes, node.childNodes[0]); };
    $$.insert.head = function (nodes) { return $$.insert(nodes, $$.by(document, 'head', 0)); };
    $$.follow = function (nodes, node) {
        if (node) {
            if (node.nextSibling) { node = node.nextSibling; } else { return $$.append(nodes, node.parentNode); }
        } else { node = document.body.childNodes[0]; }
        if (!node) { return $$.append(nodes, node); }
        nodes && (node.parentNode.insertBefore($$.doc.append(nodes), node));
        return nodes;
    };
    $$.next = function (node, name) { if (node) { do { node = node.nextSibling; } while (node && node.nodeName != name); } return node; };
    $$.prev = function (node, name) { if (node) { do { node = node.previousSibling; } while (node && node.nodeName != name); } return node; };
    $$.append = function (nodes, node) {
        !node && (node = document.body);
        nodes && (node.appendChild($$.doc.append(nodes)));
        return nodes;
    }
    $$.append.head = function (nodes) { return $$.append(nodes, $$.by(document, 'head', 0)); };
    $$.exitalert = function (txt) { window.onbeforeunload = txt ? function () { return txt; } : null; };
    $$.att = function (o, n, v) {
        if (!n) { return o; }
        if (v === undefined) {
            v = o.getAttribute(n);
            v = typeof v === 'string' ? v : (v ? v.cssText : '');
            return v.toLowerCase();
        } else {
            if (v == '') { o.removeAttribute(n); } else { o.setAttribute(n, v); }
            return o;
        }
    };
    $$.atts = function (o, par) { $$.each(par, function (n, v) { o.setAttribute(n, v); }); return o; };
    $$.styles = function (o, txt) { (o && txt) && (o.style.cssText += ';' + txt); return o; };
    $$.styles.select = function (o, txt) { return $$.styles(o, '-moz-user-select:' + txt + ';'); };
    $$.el = function (name, node, insert) {
        var o;
        if (typeof name === 'string') {
            o = document.createElement(name);
        } else {
            var div = document.createElement('div'), t = name.type || 'hidden';
            if (t === 'textarea') {
                div.innerHTML = '<textarea></textarea>';
                o = $$.by(div, t)[0];
            } else {
                div.innerHTML = '<input type="' + t + '"/>';
                o = $$.by(div, 'input')[0];
            }
            $$.each(name, function (n, v) { if (n != 'type') { $$.att(o, n, v); } });
        }
        if (!node && !insert) { return o; }
        if (insert) { insert.parentNode.insertBefore(o, insert) } else { node.appendChild(o); }
        return o;
    };
    $$.el.script = function (src, id) {
        var sc = $$.el('script');
        if (id && $$(id)) { return; }
        id && (sc.id = id);
        sc.src = src;
        sc.type = 'text/javascript';
        $$.append.head(sc);
    };
    $$.formatname = function (str) { return (str || '').replace(/\//g, '_').replace(/\\/g, '_').replace(/\?/g, '_').replace(/\&/g, '_'); };
    $$.find = function (txt, s1, s2) {
        if (!txt) { return ''; }
        var x1 = txt.indexOf(s1);
        if (x1 == -1) { return ''; }
        x1 += s1.length;
        var x2 = txt.indexOf(s2, x1);
        if (x2 < x1) { return ''; }
        return txt.substr(x1, x2 - x1);
    };
    $$.scriptload = function (files, fun) {
        var x = 0, count = files.length, call = function () { if (++x === count) { fun(); } };
        $$.each(files, function (i, url) { $$.scriptfile(url, call); });
    };
    $$.script = function (url, call, name, par) { return $$.ajax.get(url, call, name, par, 'script'); };
    $$.post = function (uri, data, call, type, name, par) { return $$.ajax.post(uri, data, call, name, par, type); };
    $$.json = function (url, call, name, par) { return $$.ajax.get(url, call, name, par, 'json'); };
    $$.json.parse = function (data) {
        if (typeof data !== "string" || !data) { return { result: 0, msg: 'Invalid JSON' }; }
        try { return (new Function("return " + data))(); } catch (ex) { return { result: 0, msg: 'JSON fromat error' }; }
    };
    $$.json.msg = function (json, o) { if (json.msg) { $$.msg.write(json.msg, o); } if (json.js) { $$.eval(json.js); } };
    $$.scriptfile = function (url, call, name, par) {
        var fs = this.info._jsfiles; if (fs[url]) { call && (call()); return fs[url]; }
        fs[url] = $$.now();
        return $$.ajax.get(url, call, name, par, 'script');
    };
    $$.filterJs = function (data) { return $$.find(data, '/*--jhwl:start--*/', '/*--jhwl:end--*/') };
    $$.filterHtml = function (data) { return $$.find(data, '<!--jhwl:start-->', '<!--jhwl:end-->') };
    $$.eval = function (data, istrim) {
        if (!data) { return; }
        var d = document, head = d.head || this.by(d, "head")[0] || d.documentElement, script = this.el("script");
        istrim && (data = $$.filterJs(data));
        if (!data) { return; }
        if (this.support.eval()) { script.appendChild(document.createTextNode(data)); } else { script.text = data; }
        head.insertBefore(script, head.firstChild);
        head.removeChild(script);
    };
    $$.panel = function (head, isme, nodeName, par) {
        if ($$.load(head, $$.panel, arguments)) { return; }
        var _t = head.web = this, cp, p, ps = head.parentNode, pss = [], i, a, ass = $$.by(head, 'li'), isover, _stover, _ci;
        !par && (par = {});
        !par.mouse && (par.mouse = 'onmouseover');
        !par.index && (par.index = 0);
        if (typeof nodeName === 'object') {
            $$.each(ass, function (i) { p = $$(head.id + '_' + i); p && (pss.push(p)); });
        } else {
            pss = $$.by(ps, nodeName || 'ul');
        }
        isover = par.mouse === 'onmouseover';
        if (!par.index) { $$.each(pss, function (i, ps) { if (ps.hide === 0) { par.index = i; return true; } }); }
        var hidden = function (p) { if (!p) { return; } p.style.display = 'none'; p.a && (p.a.className = ''); };
        var visible = function () { p = pss[this.i === undefined ? _ci : this.i]; if (!p || p == cp) { return; } hidden(cp); p.style.display = ''; p.a && (p.a.className = 'sel'); cp = p; };
        var visible2 = function () { _ci = this.i; _stover = setTimeout(visible, 100); };
        var clearover = function () { _stover && (clearTimeout(_stover)); };
        for (i = 0; a = ass[i]; i++) { !i && !a.className && (a.className = 'sel'); a.i = i; a[par.mouse] = isover ? visible2 : visible; isover && (a.onmouseout = clearover); }
        for (i = 0; p = pss[i]; i++) { p.a = ass[i]; if (i === par.index) { cp = p; } else { hidden(p); } }
        isme && (head.onmouseover = null);
        if (!(isme === true || isme === false)) {
            isme = $$.target(isme);
            (isme && typeof isme[par.mouse] === 'function') && (isme[par.mouse]());
        }
    };
    $$.onmouseover = function (obj, nodename, call, par, waitime) {
        if (!waitime) { waitime = 100; }
        var _stover, _ci, exec = function () { (nodename === _ci.nodeName) && (call(_ci, par)); };
        obj.onmouseover = function (e) { _ci = $$.target(e); _stover = setTimeout(exec, waitime); };
        obj.onmouseout = function (e) { _stover && (clearTimeout(_stover)); };
    };
    $$.oncall = function (obj, nodename, eventnames, call, par, e, debug) {
        obj = $$.event(obj); nodename = ',' + nodename + ',';
        typeof eventnames === 'string' && (eventnames = [eventnames]);
        $$.each(eventnames, function (i, eventname) {
            obj[eventname] = function (e) {
                var o = $$.target(e);
                if (debug) { document.title = 'node:' + (o ? o.nodeName : 'null') + ',name:' + nodename; }
                if (o && nodename.indexOf(',' + o.nodeName + ',') != -1) { call(o, par, eventname); }
            };
            obj[eventname](e);
        });
    };
    $$.totext = function (txt) { return txt.replace(/\</g, '&lt;').replace(/\>/g, '&gt;'); };
    $$.show = function () { return $$.loop(arguments || [this], function (i, o) { o.hide = 0; o.style.display = ''; }); };
    $$.hide = function () { return $$.loop(arguments || [this], function (i, o) { o.hide = 1; o.style.display = 'none'; }); };
    $$.display = function (arr, vis) { return vis ? $$.show(arr) : $$.hide(arr); }
    $$.display.bind = function (o, id) {
        (!o || !o.nodeName) && (o = this);
        var box = id ? $$(id) : $$.child(o); if (!box) { return; }
        var a = $$.child.by(o, 'a', -1), cover = o.call_over, cout = o.call_out, stout, ct = function () { stout && (clearTimeout(stout)); };
        var over = function () { ct(); if (cover && !cover(o, box, a)) { return; } $$.show(box, a); };
        var out = function () { ct(); if (cout && !cout(o, box, a)) { return; } stout = setTimeout(out2, 0); };
        var out2 = function () { if (cout && !cout(o, box, a)) { return; } $$.hide(box, a); };
        if (a) {
            a = $$.css($$.att($$.text($$.el('a'), a.innerHTML), 'href', a.href), 'overa');
            var s = $$.att(box, 'style');
            (s.indexOf('left:') != -1 || s.indexOf('right:') != -1) && ($$.styles(a, 'left:' + (box.style.left ? box.style.left : 'auto') + ';right:' + (box.style.right ? box.style.right : 'auto')));
            o.call_a && (o.call_a(o, a));
            $$.insert.child(a, o);
        }
        o.call_box && (o.call_box(o, box));
        box.onmouseover = o.onmouseover = over;
        box.onmouseout = o.onmouseout = document.all ? out2 : out;
        o.close && (o.close.onclick = out);
        over();
    };
    $$.vis = function () { return $$.loop(arguments, function (i, o) { o.hide = 0; $$.styles(o, 'visibility:visible;'); }); };
    $$.none = function () { return $$.loop(arguments, function (i, o) { o.hide = 1; $$.styles(o, 'visibility:hidden;'); }); };
    $$.visibility = function (arr, vis) { return vis ? $$.vis(arr) : $$.none(arr); }
    $$.farnone = function (o) { $$.none($$.styles(o, 'left:-10000px;top:-10000px;')); };
    $$.by = function (o, name, i) {
        var os = $$(o || document.body).getElementsByTagName(name);
        if (i === undefined) { return os; }
        i = parseInt(i) || 0;
        var k = os.length + i;
        return i < 0 ? os[k > -1 ? k : 0] : os[i];
    };
    $$.byc = function (o, name) { return $$.by(o, name)[0]; };
    $$.remove = function () { return $$.loop(arguments, function (i, n) { if (n && n.parentNode) { n.isdel = true; n.parentNode.removeChild(n); } }); };
    $$.opacity = function (div, num) { $$.styles(div, '-moz-opacity:' + (num * 0.01) + ';opacity:' + (num * 0.01) + ';filter :alpha(Opacity=' + num + ')'); return div; };
    $$.trim = function (str) { var isobj = typeof str === 'object', s = str; if (isobj) { s = str.value; } s = s.replace(/^\s+|\s+$/g, ''); if (isobj) { str.value = s; return str; } else { return s; } };
    $$.lower = function (str) { return $$.trim(str.toLocaleLowerCase()); };
    $$.upper = function (str) { return $$.trim(str.toLocaleUpperCase()); };
    $$.each = function (arr, fun, returnArr, isdesc) {
        !returnArr && (returnArr = arr);
        if (!arr) { return returnArr; }
        if (arr.nodeName && arr.nodeName != 'SELECT') { fun(-1, arr); return returnArr; }
        if (typeof arr === 'string') { fun(-1, $$(arr)); return returnArr; }
        if (arr.length != undefined) {
            for (var i = isdesc ? arr.length - 1 : 0, k; isdesc ? i > -1 : i < arr.length; isdesc ? i-- : i++) {
                if (arr[i] === undefined) { continue; }
                k = fun(i, arr[i]);
                if (k === true) { break; }
                if (k === -1) { i--; }
            }
        } else {
            for (var i in arr) {
                if (i === undefined || arr[i] === undefined) { continue; }
                if (fun(i, arr[i])) { break; }
            }
        }
        return returnArr;
    };
    $$.loop = function (arr, fun) {
        if (!arr) { return null; } /*|| arr[0] === undefined*/
        $$.each(arr, function (i, o) {
            if (!o) { return; }
            if (typeof o === 'string') { o = $$(o); }
            if (o.nodeName) { return fun(i, o); }
            $$.each(o, fun);
        });
        return arr.length ? arr[0] : arr;
    };
    $$.istrue = function (arr, fun) { for (var i = 0, o; o = arr[i++]; ) { if (fun(o)) { return true; } } return false; };
    $$.target = function (e) { if (e && e.nodeName) { return e; } !e && (e = window.event); return e ? e.srcElement || e.target : null; };
    $$.zindex = function (o, index) { o.style.zIndex = index ? index : ++$$.zindex.index; return o; };
    $$.zindex.index = 80000000;
    $$.win = { _arrFun: [], _isrun: false, _zindex: 1000,
        onload: function () { $$.each(arguments, function (i, o) { $$.win._arrFun.push(o); }); },
        onloading: function () {
            if ($$.win._isrun) { return; } $$.win._isrun = true;
            $$.each($$.win._arrFun, function (i, fun) { if (!fun._ISEXEC) { fun._ISEXEC = true; fun(); } });
            var callblur = function () { this.blur(); };
            $$.each($$.by(document.body, 'a'), function (i, a) { a.onfocus = callblur; });
        }
    };
    window.onload = $$.win.onloading;
})(window);
