﻿function $(id) { return document.getElementById(id); }
var Lbf = {};
var Lcookie = {
    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 == null) ? "" : "; path=" + path);
    },
    get: function (name, dv) {
        var arr = document.cookie.split("; ");
        var l = arr.length;
        for (var i = 0; i < l; i++) { var kv = arr[i].split("="); if (name == kv[0]) { return unescape(kv[1]); } }
        return dv;
    },
    remove: function (name) { document.cookie = name + "=; expires=Fri, 31 Dec 1000 23:59:59 GMT;"; },
    keys: function (name, isInt) {
        var objKey = {};
        var cookie = Lcookie.get(name, null);
        if (!cookie) { return objKey; }
        var arr = cookie.split(';');
        for (var i = 0, l = arr.length; i < l; i++) {
            var 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;
        }
    }
};
var Lad = { _ads: {}, _listAd: [], _txtAdPar: {}, _isBind: false };
Lad.append = function (id, type, uri, html, style, alttxt) {
    var arr = Lad._ads[id];
    if (!arr) { Lad._ads[id] = arr = []; }
    arr.push({ 'uri': uri, 'html': html, 'type': type, 'style': style, 'alttxt': alttxt });
};
Lad.parameter = function (par) {
    var arr = Lad._ads[par.id];
    if (!arr) { Lad._ads[par.id] = arr = []; }
    arr._count = par.count;
    arr._skippar = par.txtList;
    arr._fly = par.fly;
    arr._style = par.style;
};
Lad.analy = function (ad, type, style) {
    var txt = '', obj = type ? document.createElement(type) : null;
    style = ad.style || style;
    switch (ad.type) {
        case 'txt': case 'img':
            txt = ad.type == 'txt' ? ad.html : '<img src="' + ad.html + '" ' + (style ? 'style="' + style + '"' : '') + (ad.alttxt ? ' alt="' + ad.alttxt + '"' : '') + ' />';
            if (obj) {
                var str = '<a target="_blank" ';
                if (ad.uri) { str += 'href="' + ad.uri + '"'; }
                str += '>' + txt + '</a>';
                txt = str;
            } else {
                obj = document.createElement('a');
                if (ad.uri) { obj.href = ad.uri; }
                obj.target = '_blank';
                if (style) { obj.setAttribute('style', style); }
            }
            obj.innerHTML = txt;
            break;
        case 'swf':
            txt = '<embed src="' + ad.uri + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent" ' + (style ? 'style="' + style + '"' : '') + '></embed>';
            if (!obj) { obj = document.createElement('span'); }
            obj.innerHTML = txt;
            break;
    }
    return obj;
};
Lad.load = function () {
    var objAd = Lad._ads, divId = null;
    function append(obj, index) {
        if (index == 0) { obj.className = 'first'; }
        divId.appendChild(obj);
    }
    var adcount = 0;
    for (var id in objAd) {
        adcount++;
        if (typeof objAd[id] != 'object') { continue; }
        divId = $(id);
        if (!divId) { continue; }
        var arr = objAd[id];
        if (arr._skippar) { Lad.txtInit(arr, id); continue; }
        if (Lad._haveLoad) { continue; }
        divId.innerHTML = '';
        var nodeName = divId.nodeName;
        var index = 0,i,l;
        var type = '';
        switch (nodeName) {
            case 'UL': case 'OL': type = 'li'; break;
            case 'TR': type = 'td'; break;
            case 'DL': type = 'dd'; break;
        }
        for (i = 0, l = arr.length; i < l; i++) {
            var ad = arr[i];
            var obj = Lad.analy(ad, type, arr._style);
            if (!obj) { continue; }
            append(obj, index++);
        }
        var count = arr._count;
		divId.style.cssText+=';display:'+(l || (count && index<count)?'block;':'none;');
        if (!count || index >= count || !Lad._defaultTxt) { continue; }
        var nullAd = { 'uri': null, 'html': Lad._defaultTxt, 'type': 'txt' };
        for (i = index; i < count; i++) {
            var obj = Lad.analy(nullAd, type, arr._style);
            if (!obj) { continue; }
            append(obj, i);
        }
    }
    if (!adcount) {
        setTimeout(Lad.load, 1000);
        return;
    }
    Lad._haveLoad = true;
};
var Lbase = {};
Lbase.addfavorite = function () {
    if (document.all) {
        window.external.addFavorite(location.href, document.title);
    } else if (window.sidebar) {
        window.sidebar.addPanel(document.title, location.href, "");
    }
};
Lbase.sethome = function () {
    if (document.all) {
        document.body.style.behavior = ' url(#default#homepage) ';
        document.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);
    }
};
Lbase.event = function(o,name,call){
    if(window.attachEvent){
        o.attachEvent(name,call);
        return;
    }
    if(window.addEventListener){
        o.addEventListener(name.substr(2),call,false);
        return;
    }
    o[name] = call;
};
Lbase.removeEvent = function(o,name,call){
    if(window.detachEvent){
        o.detachEvent(name,call);
        return;
    }
    if(window.removeEventListener){
        o.removeEventListener(name,call,false);
        return;
    }
    o[name] = null;
};
Lbase.js = function (path, id, node) {
    var head, js;
    if (id) { js = $(id); if (js) { head = js.parentNode; head.removeChild(js); } }
    !head && (head = document.getElementsByTagName('head')[0]);
    js = document.createElement('script');
    js.type = 'text/javascript';
    js.src = path;
    id && (js.id = id);
    node && (head = node);
    head.appendChild(js);
    return js;
};
Lbase.element = function (type, node, par, par2) {
    var d = document.createElement(type), key;
    function setpar(par) { if (par) { for (key in par) { d[key] = par[key]; } } }
    setpar(par); setpar(par2);
    node && (node.appendChild(d));
    return d;
};
Lbase.hideElement = function (node, par) { return Lbase.element('input', node, { type: 'hidden' }, par); };
Lbase.menuout = function (e) {
    var bdiv = this.binddiv || this;
    bdiv._inttimeout = setTimeout(function () { bdiv.style.visibility = 'hidden'; }, 100);
};
Lbase.menuover = function (o) {
    o = this.binddiv || o.binddiv || o;
    if (o.iserror) { return; }
    if (!o.binddiv) {
        var div = o.binddiv = $(o.id + '_menu');
        if (!div) { o.iserror = true; return; }
        div.onmouseout = Lbase.menuout;
        div.onmouseover = Lbase.menuover;
        div.binddiv = div;
        div.style.cssText += ';left:' + (o.offsetLeft) + 'px;top:22px;';
        o.onmouseout = Lbase.menuout;
        o = div;
    }
    clearTimeout(o._inttimeout);
    o.style.visibility = 'visible';
};
var Lsearch = {};
Lsearch.exists = 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;
};
Lsearch.insert = function(txt,name,delnames){
    var arrNew = [];
    var objDel = {};
    var arr = name ? name.replace(/\s+/g,' ').split(' ') : [];
    for( var i = 0,l = arr.length; i != l; i++){
        objDel[arr[i]] = true;
    }
    if(delnames){
        var 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++){
        if(!objDel[arr[i]]){ arrNew.push(arr[i]);}
    }
    if(name){ arrNew.push(name); }
    return arrNew.join(' ');
};
Lsearch.del = function(txt,names){
    var arr = names.replace(/\s+/g,' ').split(' ');
    var objDel = {};
    var 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++){
        if(!objDel[arr[i]]){ arrNew.push(arr[i]);}
    }
    return arrNew.join(' ');
};
Lsearch.cssExists = function (obj, name) {
    if (!obj.className) { return false; }
    return Lsearch.exists(obj.className, name);
};
Lsearch.cssInsert = function(obj,name,delnames){
    obj.className = Lsearch.insert(obj.className,name,delnames);
};
Lsearch.cssDel = function(obj,names){
    obj.className = Lsearch.del(obj.className,names);
};
Lsearch.getPar = function(name,uri){
    if(!uri){ uri = location.href.toLowerCase();}
    uri = uri.split('?')[1]; if(!uri){return '';}
    uri = uri.split('&'); if(!uri){ return '';} 
    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(arr[0] != name){continue;}
        return arr[1];
    }
    return '';
};
Lsearch.replacePar = function(name,value,uri){
    uri = uri || location.href;
    var par = name + '=' + value;
    var link = uri.split('?')[1]; if(!link){return uri + '?' + 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;
};

var Lposition = {x:0,y:0};
Lposition.cursor = function (evt) {
    evt = evt ? evt : (window.event ? window.event : null);
    var ml = evt ? document.body.scrollLeft : document.documentElement.scrollLeft;
    var mt = evt ? document.body.scrollTop : document.documentElement.scrollTop;
    evt = evt ? evt : (window.event ? window.event : null);
    var x = evt.x != undefined ? evt.clientX : evt.pageX;
    var y = evt.y != undefined ? evt.clientY : evt.pageY;
    Lposition.x = x + ml;
    Lposition.y = y + mt;
    return { 'x': Lposition.x, 'y': Lposition.y };
};
Lposition.offset = function(o,o2,div,topAlign,offX,offY){
    var oo = o;
    var x = y = x2 = y2 = 0; 
    do{ x += o.offsetLeft || 0;y += o.offsetTop  || 0;o  = o.offsetParent;}while(o);
    if(o2){
        var w = o2.clientWidth;
        var h = o2.clientHeight;
        var dw = document.body.clientWidth;
        x2 = ((x + w > dw) ? dw - w : x);
        if(topAlign){
            y2 = (y - h < 1 ) ? 0 : y - h;
        }else{
            y2 = y + oo.clientHeight;
        }
        x2 ++;
    }else{
        x2 = x;
        y2 = y;
    }
    offX && (x2 += offX);
    offY && (y2 += offY);
    if(div){
        div.style.left = x2 + 'px';
        div.style.top = (y2 + 4) + 'px';
    }
    return {"x" : x, "y" : y , 'x2' : x2, 'y2' : y2};
};
var LimgPlay = {};
LimgPlay.insert = function(id,imgarr,reservation,inttime){
    //imgarr.push({url:'www.abc.com',txt:'hello,world!',img:'/i/abc.jpg'});
    var div = document.getElementById(id);
    var current,bimg,img,a,aindex = 0;
    if(!imgarr){
        var imgs = div.getElementsByTagName('a');
        imgarr = [];
        for(var i = 0;a = imgs[i++];){
            imgarr.push({url:a.href,txt:a.innerText || a.textContent,img:a.getElementsByTagName('img')[0].src});
        }
    }
    var count = imgarr.length - 1;
    if(count < 0){return;}
    if( !reservation){
        for(var i in imgarr){ img = imgarr[i]; break;}
        div.innerHTML = '<div class="imgPlayBig"><a href=" ' + img.url + '" target="_blank"><img class="imgPlayBimg" ' + (document.all ? 'style="filter: revealTrans(duration=1,transition=5);"' : '') + ' src="' + img.img + '"  title="' + img.txt + '" /></a></div><div class="imgPlayFlip"><div class="imgPlayTxtBg"></div><div class="imgPlayTxt"></div><div class="imgPlayLinks"></div></div>';
    }
    var ds = div.getElementsByTagName('div');
    var bigimg = ds[0],links = ds[4],bigtxt = ds[3];
    var _pause = false;
    bigimg._a = bigimg.getElementsByTagName('a')[0];
    bigimg._img = bigimg.getElementsByTagName('img')[0];
    function RePlay(){ _pause = false; }
    function NextPlay(temp,index){
        if(_pause){return;}
        aindex = index != undefined ? index : (aindex < count ? ++aindex : 0);
        img = imgarr[aindex];
        a = img._a;
        current && (current.className = '');
        a.className = 'sel';
        current = a;
        bigimg._a.href = img.url;
        bimg = bigimg._img;
        bimg.src = img.img;
        bimg.title = img.txt;
        bigtxt.innerHTML = img.txt;
        if(document.all){
		    bimg.filters.revealTrans.Transition=23;
		    bimg.filters.revealTrans.apply();
		    try{bimg.filters.revealTrans.play();}catch(ex){}
        }
    }
    function ChangeImg(){
        if(current == this){return;}
        NextPlay(0,this._index);
        _pause = true;
    }
    for(var i = 0,img; img = imgarr[i++];){
        a = document.createElement('a');
        a.innerHTML = i;
        a.onmouseover = ChangeImg;
        a.onmouseout = RePlay;
        a._index = i-1;
        links.appendChild(a);
        img._a = a;
    }
    NextPlay();
    setInterval(NextPlay,inttime || 5000);
};
var LtagPanel = {_stop:false};
LtagPanel.panelOver = function () {
    var a = this;
    var tag = a._tag;
    if (a == tag._current) { return; }
    function setcss(tag, a) {
        if (tag) {
            tag._current.className = '';
            tag._current._obj && (tag._current._obj.style.display = 'none');
        }
        if (a) {
            a.className = 'sel';
            a._obj && (a._obj.style.display = '');
        }
        tag && a && (tag._current = a);
    }
    setcss(tag, a);
    var relid = tag.getAttribute('relid');
    if (!relid) { return; }
    tag = $(relid);
    a = tag.arr[a._index];
    setcss(tag, a);

};
LtagPanel.autoLoad = function () {
    if (LtagPanel._stop) { return; }
    var index, tags, id, lce = Lsearch.cssExists, mm;
    function append(name) {
        tags = document.getElementsByTagName(name);

        for (var i = 0, tag; tag = tags[i++]; ) {
            if (!tag.id || !(lce(tag, 'xpanel') || lce(tag, 'mypanel') || lce(tag, 'autopanel'))) { continue; }
            id = tag.id;
            var as = tag.getElementsByTagName('a');
            mm = tag.getAttribute('mousetype') || 'onmouseover';
            index = 0;
            tag.arr = {};
            for (var j = 0, a; a = as[j++]; ) {
                a[mm] = LtagPanel.panelOver;
                a._index = index;
                a._obj = $(id + '-' + index);
                a._tag = tag;
                tag.arr[index] = a;
                !tag._current && (tag._current = a);
                index++;
            }
        }
    }
    var arr = 'ol'.split(',');
    for (var i = 0, tag; tag = arr[i++]; ) {
        append(tag);
    }
};
LtagPanel.init = function(){
	LtagPanel.autoLoad();
	LtagPanel._stop = true;
};
var Lpanel = { _sel: null, _outid: null };
Lpanel.selectReset = function () {
    var li = Lpanel._reset;
    if (!li) { return; }
    var n = li.parentNode;
    n._current = n._resetpanel;
    n._resetpanel._panel.style.display = '';
    li._panel && (li._panel.style.display = 'none');
    Lsearch.cssInsert(n._resetpanel, 'sel');
    Lsearch.cssDel(li, 'sel');
};
Lpanel.selectCancel = function () {
    if (Lpanel._outid) {
        clearTimeout(Lpanel._outid);
        Lpanel._outid = null;
    }
    var li = this._li || this;
    var n = li.parentNode; 
    if (!n._resetpanel || li == n._resetpanel) {
        Lpanel.selectReset();
        return;
    }
    Lpanel._outid2 = setTimeout(Lpanel.selectReset, 600);
    Lpanel._reset = li;
    Lpanel._skip = 0;
};
Lpanel.selectVisible = function () {
    var li = Lpanel._sel;
    var ul = li.parentNode;
    var cur = ul._current;
    if (cur) {
        cur._panel && (cur._panel.style.display = 'none');
        Lsearch.cssDel(cur, 'sel');
    }
    Lsearch.cssInsert(li, 'sel');
    ul._current = li;
    var x = li._panel || ul._resetpanel._panel;
    x && (x.style.display = '');
    x != ul._resetpanel._panel && (ul._resetpanel._panel.style.display = 'none');
};
Lpanel.selectTag = function () {
    Lpanel._sel = this._li || this;
    Lpanel._outid = setTimeout(Lpanel.selectVisible, 10);
    clearTimeout(Lpanel._outid2);
};
Lpanel.init = function (dmenu) {
    var d = document.body;
    var isreset = false;
    if (!dmenu) {
        dmenu = $('_HWL_DEFAULTMENU');
        dmenu && (dmenu = dmenu.value);
    } else {
        isreset = true;
    }
    function append(name, name2) {
        var ns = d.getElementsByTagName(name);
        var nid;
        for (var i = 0, n; n = ns[i++]; ) {
            if (n._bind || !n.className || !Lsearch.cssExists(n, 'xmenuin')) { continue; }
            n._bind = true;
            var ns2 = n.getElementsByTagName(name2);
            var index = 0, left = 0, p;
            var current, firstn2;
            var nwidth = n.offsetWidth;
            var offset = Lposition.offset(n);
            var x1 = offset.x;
            var pars = { left: 0, columnspace: 0 };
            if (n.title) {
                pars = eval('({' + n.title + '})');
                try {
                } catch (ex) { }
                n.removeAttribute('title');
            }
            nid = n.id || '';
            for (var i2 = 0, n2; n2 = ns2[i2++]; ) {
                if (n2.title == '') { continue; }
                n2._panel = p = $(nid + n2.title);
                if (p) {
                    n2._panel.onmouseover = n2.onmouseover = Lpanel.selectTag;
                    n2._panel.onmouseout = n2.onmouseout = Lpanel.selectCancel;
                    n2._panel._li = n2;
                } else {
                    n2.onmouseover = Lpanel.selectTag;
                    n2.onmouseout = Lpanel.selectCancel;
                }
                if (index++ == 0) {
                    current = firstn2 = n2;
                }
                if (dmenu == n2.title) {
                    current = n2;
                }
                n2.removeAttribute('title');
                if (!p) { continue; }
                n2._panel.style.cssText += ';height:1px;display:block;position:absolute;';
                var width = p.offsetWidth;
                offset = Lposition.offset(n2);
                var x = parseInt(offset.x + (n2.offsetWidth / 2) + parseInt(pars.columnspace) - x1 - (width / 2)) - (i2 * 8);
                x = nwidth - x > width ? x : nwidth - width;
                (x < 1 || !x) && (x = pars.left);
                n2._panel.style.cssText += ';height:auto;display:none;position:static;padding-left:' + x + 'px';
            }
            if (current) {
                n._current = current;
                isreset && (n._resetpanel = current);
                current._panel.style.display = '';
                Lsearch.cssInsert(current, 'sel');
            }
            if (current != firstn2) {
                firstn2.className = '';
                firstn2._panel.style.display = 'none';
            }
        }
    }
    append('ol', 'li');
};


Lbf.setLoginOk = function (uid, name, pwd, mids, expar) {
    var buri = 'http://bbs.boti.com/';
    var d = [], wu = Wuser;
    name = decodeURIComponent(name);
    d.push('<li>欢迎您，<b onmouseover="Lbase.menuover(this);" id="mymenu1">' + name + '</b>');
    d.push('<div class="popupmenu_popup headermenu_popup hmenu" id="mymenu1_menu">');
    d.push('<ul class="sel_my">');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=space&amp;view=admin">我的主页</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=space&amp;do=friend">我的好友</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=space&amp;do=thread&amp;view=me">我的主题</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=space&amp;do=thread&amp;view=me&amp;type=reply">我的帖子</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'search.php?mod=forum&amp;adv=yes">我的精华</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=space&amp;do=favorite&amp;view=me">我的收藏</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=space&uid='+uid+'&do=profile">我的资料</a></li>');
    expar.photo && (d.push('<li class="myalbum"><a target="_blank" href="' + buri + 'home.php?mod=space&uid='+uid+'&do=album&view=me&from=space">我的相册</a></li>'));
    d.push('<li style="height:10px;overflow:hidden;border:none;"></li></ul>');
    d.push('</div>');
    d.push('<ul id="usercenter1_menu" class="p_pop hmenu" >');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=spacecp&amp;ac=avatar">设置头像</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=spacecp&amp;ac=profile">个人资料</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=spacecp&amp;ac=profile&amp;op=password">更改密码</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=spacecp&amp;ac=usergroup">用户组</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=space&amp;do=favorite&amp;view=me">收藏夹</a></li>');
    d.push('<li><a target="_blank" href="' + buri + 'home.php?mod=spacecp&amp;ac=credit">积分</a></li>');
    d.push('</ul>');

    d.push(' | <a target="_blank" id="pm_ntc" href="' + buri + 'home.php?mod=space&amp;do=pm" title="' + (expar.pms ? '您有' + expar.pms + '条新短消息' : '您没有新短消息') + '">短消息' + (expar.pms ? '(' + expar.pms + ')' : '') + '</a>');
    d.push(' | <a target="_blank" id="pm_ntc" href="' + buri + 'home.php?mod=space&amp;do=notice" title="' + (expar.notices ? '您有' + expar.notices + '条新提醒' : '您没有新提醒') + '">提醒' + (expar.notices ? '(' + expar.notices + ')' : '') + '</a>');
    d.push(' | <a target="_blank" id="usercenter1" onmouseover="Lbase.menuover(this);"  href="' + buri + 'home.php?mod=spacecp&ac=profile">用户中心</a>');
    expar.adminid == 1 && (d.push(' | <a target="_blank" href="'+buri+'admin.php">管理中心</a>'));
    d.push(' | <a target="_blank" id="bbs"  href="' + buri + '">进入社区</a>');
    d.push(' | <a onclick="Lbf.setLogin();">退出</a><input type="hidden" name="userName" value="' + name + '" />');
    d.push('</li>');
    wu.logintxt = d.join('');
    wu.userid = uid;
    wu.username = name;
    wu.pwd = pwd;
    Wuser.init();
};
Lbf.setLogin = function () {
    var jss = Wuser.jss, js, i;
    for (i = 0; js = jss[i++]; ) {
        if (!js._login) { continue; }
        js._login = 0;
        js.innerHTML = js._back;
    }
    Lbase.js('http://bbs.boti.com/api.php?mod=sync&act=logout&userkey=' + Wuser.pwd + '&rnd='+Math.random(), 'jslogout');
};
var Wuser = { username: null, userid: 0,pwd:null, logintxt: '',jss:[] };
Wuser.load = function () {
    Lbase.js('http://bbs.boti.com/api.php?mod=sync&act=statusinfo&rnd=' + Math.random());
    var id = 'hideframe'; if ($(id)) { return; }
    var div = document.createElement('div'), d = document.body;
    div.innerHTML = '<iframe style="width:1px;height:1px;position:absolute;left:-1px;border:none;" id="' + id + '" name="' + id + '" frameborder="0" ></iframe>';
    div.style.cssText += 'width:1px;height:1px;position:absolute;left:-1px;border:none;overflow:hidden;';
    d.insertBefore(div, d.childNodes[0]);
};
Wuser.init = function () {
    var i, img, imgs = document.getElementsByTagName('img');
    for (i = 0; img = imgs[i++]; ) { img.alt && !img.title && (img.title = img.alt); }
    if (!Wuser.userid) { return; }
    var d = document, jss = d.getElementsByTagName('ul'), js, i, wu = Wuser;
    for (i = 0; js = jss[i++]; ) {
        if (js._login || !js.id || js.id.substr(0, 6) != 'login_') { continue; }
        js._back = js.innerHTML;
        js._login == undefined && (wu.jss.push(js));
        js._login = 1;
        js.innerHTML = wu.logintxt;
    }
};
Wuser.login = function (f) {
    if (!f._isinit) {
        f._isinit = 1;
        var d = document, ins = f.getElementsByTagName('input'), i, x, fins = f.fins = {}, lp = d.createElement('input');
        for (i = 0; x = ins[i++]; ) {
            x.name && (fins[x.name] = x);
        }
        lp.type = 'hidden';
        lp.name = 'loginpath';
        lp.value = 'http://www.boti.com/ajax.aspx?action=login&id={0}&name={1}&key={2}&ids={3}&par={4}';
        
        f.appendChild(lp);
        f.action = 'http://bbs.boti.com/api.php?mod=sync&act=login';
        f.target = 'hideframe';
        f.method = 'post';
    }
    function error(o, txt) { if (!o.value) { o.focus(); alert(txt); return 0; } return 1; }
    var ff = f.fins;
    if (!error(ff.username, '请输入用户名')) { return 0; }
    if (!error(ff.password, '请输入密码')) { return 0; }
    f.submit();
};
Wuser.load();
var Windex = {_cs:null,styleframe:null,_defaultstyle:window['_defaultStyle'],_defaultcolor: 'yellow'};
Windex.setStyle = function (ck) {
    var wi = Windex, ps = wi._cspath;
    !ck && (ck = wi._defaultstyle || Lcookie.get('pagestyle', wi._defaultcolor));
    if (!ps) {
        ps = wi._cspath = document.createElement('link');
        ps.rel = "stylesheet";
        ps.type = "text/css";
        var head = document.getElementsByTagName('head')[0];
        head.appendChild(ps);
    }
    ps.href = '/c/style_' + ck + '.css';
};
Windex.changeStyle = function () {
    var wi = Windex;
    if (wi._cs == this) { return; }
    wi._cs && (wi._cs.className = '');
    wi._cs = this;
    wi._cs.className = 'sel';
    var ck = this._name;
    !wi._defaultstyle && (Lcookie.set('pagestyle', ck, 1000));
    wi.setStyle(ck);
//    var i, fs, f = wi.styleframe, arr = [];
//    if (!fs) {
//        fs = document.getElementsByTagName('iframe');
//        for (i = 0; f = fs[i++]; ) { Lsearch.cssExists(f, 'refstyle') && (arr.push(f)); }
//        wi.styleframe = fs = arr;
//    }
//    for (i = 0; f = fs[i++]; ) { f.src = f.src; }
	var ls=window.livescoreThemeChange;if(ls)ls(ck);
	var fs=document.getElementsByTagName('iframe');for(var i=0;i<fs.length;i++){var f=fs[i].contentWindow.reloadStyle;if(f)f(ck)}
};
Windex.initStyle = function () {
    var wi = Windex, style = $('wPageStyle');
    if (style) {
        var ck = wi._defaultstyle || Lcookie.get('pagestyle', wi._defaultcolor), as = style.getElementsByTagName('a');
        for (var i = 0, a; a = as[i++]; ) {
            a.onclick = wi.changeStyle;
            a._name = a.getAttribute('xname');
            a.innerHTML = '&nbsp;';
            if (a._name == ck) {
                a.className = 'sel';
                wi._cs = a;
            }
        }
    }
};
Windex.copyUrl=function(){
	if(!document.all){return;}
	var txt = document.title + '\r\n' + location.href;
	window.clipboardData.setData("Text",txt);
	alert("复制成功！");
};
Windex.setStyle();
var Wnews = {};
Wnews.search = function (f) {
    var o = f.keyinput, v;
    if (!o) { f.keyinput = o = f.getElementsByTagName('input')[0]; }
    if (o.value == '' || o.value == '请输入关键词') { o.focus(); return false; }
    if (!f.nosite) {
        f.keyinput.backvalue = v = f.keyinput.value;
        f.keyinput.value = 'site:boti.com ' + v;
    }
    f.submit();
    !f.nosite && (f.keyinput.value = v);
};
Wnews.clickkey = function (o) { o.value == '请输入关键词' && (o.value = ''); o.style.color = 'black'; };
Wnews.changekey = function (o) { if (!o.value) { o.value = '请输入关键词'; o.style.color = 'gray'; } };
Wnews.searchtype = function (o, e) {
    var div = o.div, ele = e.target || e.srcElement, f;
    if (!div) {
        o.div = div = o.getElementsByTagName('div')[0]; o.txt = o.childNodes[0];
        f = o; while (f.nodeName != 'FORM') { f = f.parentNode; };
        o.form = f;
    }
    o.div.style.visibility = o.isopen ? 'hidden' : 'visible';
    o.isopen = !o.isopen;
    if (ele.nodeName == 'A') {
        o.txt.data = ele.innerHTML;
        o.form.nosite = o.txt.data != '新闻' ;
    }
};

var Wtalk = { rdiv: null };
Wtalk.replycancel = function () { var rd = Wtalk.rdiv; rd.style.display = 'none'; rd._curli = null; rd.parentNode.removeChild(rd); };
Wtalk.reply = function (o,plid) {
    var wt = Wtalk, rd = wt.rdiv, d = document.body, li = o;
    while (li.nodeName != 'LI') { li = li.parentNode; }
    if (!rd) {
        wt.rdiv = rd = document.createElement('div');
        d.insertBefore(rd, d.childNodes[0]);
        rd.className = 'ntalknew rel';
        rd.style.display = 'none';
        rd.innerHTML = $('talknew').innerHTML.replace('发表评论', '引用回复');
        var f2 = rd.getElementsByTagName('form')[1].getElementsByTagName('div')[0], bc = document.createElement('input');
        bc.type = 'button'; bc.className = 'btred'; bc.onclick = wt.replycancel; bc.value = '取消';
        f2.appendChild(bc);
    }
    var f3=rd.getElementsByTagName('form')[1];
    if(f3&&f3.refId)f3.refId.value=plid;
    if (rd._curli == li) { return; }
    li.appendChild(rd);
    rd.style.display = '';
    rd._curli = li;
};

var Lwindow = {
    _arrFun: [],
    _isonload: false,
    onload: function () { for (var i = 0, l = arguments.length; i != l; i++) { Lwindow._arrFun.push(arguments[i]); } },
    onloading: function (source) {
        var arr = Lwindow._arrFun;
        for (var i = 0, l = arr.length; i < l; i++) { arr[i](); }
    }
};
window.onload = Lwindow.onloading;
Lwindow.onload(Lpanel.init,LtagPanel.init,Wuser.init,Lad.load);
