﻿var datalist;
var playerno = 0;
var Runpath = "/";
var Iimage = Runpath + "main/item/";
var War3main = Runpath + "war3main/";
var Uimage = Runpath + "main/units/";
var Simage = Runpath + "main/skills/";
var des = new Object();

var msg;
var timer;
var msgo;
var rid;
var ateam = 0;
var pageobj = new Array();
var onpagepart = 0;
var loadend = false;
function initReplayPage(replayid) {
    rid = replayid;
    parseReplayData();
    initPageMenu();
    initPageObject();
    pagemenuclick(0);
}
function initReplayPack(replayid) {
    rid = replayid;
}
function showwinner() {
    var win = "Winner is :\r\n\r\n"
    for (var i = 1 ; i < 13 ; i ++) {
        var o = datalist[i];
        if (!o) continue;
        if (o.teamid == WinTeam) win += "\t" + o.playername + "　　　　　　　\r\n";
    }
    
    alert(win);
}
function nicegame() {
    httpRequest(Runpath + "comment.aspx","replayid=" + rid + "&type=commend",setnicegame);
    //alert("评分成功！\r\n您是第" + CommendNo + "位用户评定该录像很强大。");
}
function setnicegame(doc) {
    var r = getValue(doc.lastChild.childNodes[0]);
    if (r == "repeat") {
        alert("您已经对该录像进行评分，不能重复操作。\r\n已经有 " + CommendNo + "位 用户评定该录像很强大。");
        return;
    }
    if (r == "2") {
        if (confirm("用户未登录或已经超时。\r\n已经有 " + CommendNo + "位 用户评定该录像很强大。\r\n\r\n请点击确定进行登录操作。"))
            window.open("http://bbs.replays.net/login.aspx");
        return;
    }
    if (r == "5") {
        alert("系统判定用户已经被锁定，评分失败。");
        return;
    }
    if (r == "succeed") {
        CommendNo++;
        var cno = $("commendshow");
        cno.innerHTML = CommendNo;
        cno.title = "已经有" + CommendNo + "位玩家评定该录像很强大.";
        alert("评分成功！\r\n您是 第" + CommendNo + "位 用户评定该录像为很强大。");
    }
}
function pagemenuclick(index) {
    var menus = $("replaymenu").getElementsByTagName("li");
    menus[onpagepart].className = "";
    menus[index].className = "clickit";
    if (pageobj[index]) {
        showpagepart(index);
        return;
    }
    showpagepart(index);
    if (index == 0) {
        insertPlayerData();
        insertPlayerHero();
    } else if (index == 1){
        insertPlayerAction();
        insertApmImage();
    } else if (index == 2){
        insertGamedata();
    } else if (index == 3){
    
    }
    pageobj[index] = true;
    
}

function showpagepart(open) {
    $("pagepart" + onpagepart).style.display = "none";
    $("pagepart" + open).style.display = "block";
    onpagepart = open;
}

function initPageMenu() {
    var lis = $("replaymenu").getElementsByTagName("li");
    for (var i = 0 ; i < lis.length ; i ++) {
        lis[i].onmouseover = function() {
            if (this.className != "clickit")
                this.className = "mouseover";
        }
        lis[i].onmouseout = function() {
            if (this.className != "clickit")
                this.className = "";
        }
    }
}
function initPageObject() {
    msg = $("messagebox");
    if (ie) {
        $("msgtitle").style.backgroundImage = "none";
        $("msgcontent").style.backgroundImage = "none";
        $("msgbottom").style.backgroundImage = "none";
    }
}
var commentno = 0;
var commentcolor = ["#ffffcc","#ffffdd","#ffffee"];
function insertCObj(commentid,good,bad) {
    if (good > 0 && commentno < commentcolor.length) {
        $("citem" + commentid).parentNode.parentNode.style.backgroundColor = commentcolor[commentno];
        commentno++;
    }
    if (good == 0) commentno = commentcolor.length;
    var il = $C("ul");
    il.id = "commento" + commentid;
    il.className = "commento";
    il.innerHTML = "<li><img src='" + War3main + "good.gif' onclick='addctype(this,1," + commentid + ")' alt='Good' /></li><li style='margin-right:5px;'>x" + good + "</li><li><img src='" + War3main + "bad.gif' alt='Bad' onclick='addctype(this,0," + commentid + ")' /></li><li>x" + bad + "</li>";
    $("citem" + commentid).appendChild(il);
    if (bad - good > 4)
        hideladder(commentid);
    ReplaceData($('ccontent' + commentid));
}
function hideladder(commentid) {
    
    var vs = $("ccontent" + commentid);
    var hide = $C("div");
    hide.className = "ccontent";
    hide.innerHTML = "显示被屏蔽的评论内容";
    hide.style.cursor = "pointer";
    hide.onclick = function() {
        var ns = this.nextSibling.style;
        if (ns.display == "none") {
            ns.display = "block";
            this.innerHTML = "屏蔽本楼评论内容";
        } else {
            ns.display = "none";
            this.innerHTML = "显示被屏蔽的评论内容";
        }
    }
    vs.parentNode.insertBefore(hide,vs);
    vs.style.display = "none";
}
function addctype(o,t,cid) {
    $("commento" + cid).innerHTML = "<li class='co_m'>Update ...</li><li class='co_l'></li>";
    var o = new Object();
    o.cid = cid;
    o.parseXml = function(doc) {
        var c = doc.lastChild.childNodes;
        var si = getValue(c[0]);
        var ss = getValue(c[1]).split(",");
        if (si == "3" || si == "0") {
            $("commento" + this.cid).innerHTML = "<li class='co_m'>Error ...</li><li class='co_l'></li>";
            alert("该评论不存在或已经删除。");
            return;
        }
        if (si == "2") {
            if (confirm("用户未登录或已经超时。\r\n\r\n请点击确定进行登录操作。"))
                window.open("http://bbs.replays.net/login.aspx");

        } else if (si == "4")
            alert("不允许重复投票。");
        else if (si == "5")
            alert("投票失败，系统判定你的用户或者IP已被锁定。");
        else
            alert("投票成功，谢谢参与！");
        $("commento" + this.cid).innerHTML = "<li><img src='" + War3main + "good.gif' onclick='addctype(this,1," + this.cid + ")' alt='Good' /></li><li style='margin-right:5px;'>x" + ss[0] + "</li><li><img src='" + War3main + "bad.gif' alt='Bad' onclick='addctype(this,0," + this.cid + ")' /></li><li>x" + ss[1] + "</li>";
    }
    if (t == 1) {
        httpRequest(Runpath + "comment.aspx","revertid=" + cid + "&type=good",o);
    } else {
        httpRequest(Runpath + "comment.aspx","revertid=" + cid + "&type=bad",o);
    }
    
}
function parseReplayData() {
    if (datalist) return;

    datalist = new Array();
    for (var i = 1 ; i < 13 ; i ++) {
        var o = $("playerdata" + i);
        if (!o) return;
        playerno ++;
        var hero = new Array();
        var skill = new Array();
        var build = new Array();
        var unit = new Array();
        var item = new Array();
        o = o.childNodes;
        var player = new Object();
        player.playername = o[0].innerHTML;
        player.teamid = parseInt(o[1].innerHTML);
        player.userace = o[2].innerHTML;
        player.apm = o[3].innerHTML;
        player.color = o[4].innerHTML;
        player.action = o[5].innerHTML;
        player.location = o[6].innerHTML;
        for (var j = 7 ; j < o.length ; j ++) {
            var ss = o[j].innerHTML.split(",");
            if (ss[0] == "h")
                hero[hero.length] = ss;
            else if (ss[0] == "s")
                skill[skill.length] = ss;
            else if (ss[0] == "b")
                build[build.length] = ss;
            else if (ss[0] == "u")
                unit[unit.length] = ss;
            else if (ss[0] == "i")
                item[item.length] = ss;
        }
       
        player.hero = hero;
        player.skill = skill;
        player.build = build;
        player.unit = unit;
        player.item = item;
        datalist[i] = player;
    }
    return true;
}
var locationerror = 0;
function insertLocation() {
    var obj = $("replaymapimage");
    var oh = obj.height;
    var ow = obj.width;
    if (locationerror > 5) return;
    if (!oh || !ow || oh < 100 || ow < 100) {
        locationerror ++;
        setTimeout(insertLocation,500);
        return;
    }
    oh = parseInt(oh) / 2;
    ow = parseInt(ow) / 2;
    obj = obj.parentNode;
    for (var i = 1 ; i < 13 ; i ++) {
        var o = datalist[i];
        if (!o) continue;
        var lab = $C("div");
        lab.className = "playerlocation";
        lab.innerHTML = o.playername;
        var l = o.location.split(":");
        if (l.length != 2) continue;
        var ll = parseInt(l[0]);
        var ml = ow + parseInt(l[0]) / 100 * 1.5 - o.playername.length * 3 + 23;
        if (ml < 0) ml = 0;
        if (ml > 168) ml = 168;
        lab.style.marginLeft = ml + "px";
        var mt = oh + 0 - parseInt(l[1]) / 100 * 1.5 - 3;
        if (mt < 0) mt = 0;
        if (mt > 168) mt = 168;
        lab.style.marginTop = mt + "px";
        lab.style.borderColor = o.color;
        setobjopacity(lab.style,70);
        obj.parentNode.insertBefore(lab,obj);
    }
}
function insertPlayerAction() {
    for (var i = 1 ; i < 13 ; i ++) {
        var o = datalist[i];
        if (!o) continue;
        if (ateam == 0) ateam = o.teamid;
        var addteam;
        if (ateam == o.teamid)
            addteam = $("actionteam1");
        else
            addteam = $("actionteam2");
        
        var pd = $C("div");
        //pd.id = "playerdata" + i;
        pd.className = "pd_part";
        addteam.appendChild(pd);
        
        var tdiv = $C("div");
        tdiv.className = "pd_head";
        tdiv.innerHTML = "<span class='headtitle' style='margin:5px 0px 0px 5px;'>" + o.playername + "</span>";
        pd.appendChild(tdiv);
        
        var hdiv = $C("div");
        hdiv.className = "pd_body";
        pd.appendChild(hdiv);
        
        var ss = o.action.split(",");
        var action = parseInt(ss[0]);

        hdiv.appendChild(setactionlist("点击右键：",parseInt(ss[1]),action));
        hdiv.appendChild(setactionlist("基本命令：",parseInt(ss[2]),action));
        hdiv.appendChild(setactionlist("建造/训练：",parseInt(ss[3]),action));
        hdiv.appendChild(setactionlist("选择单位：",parseInt(ss[4]),action));
        hdiv.appendChild(setactionlist("编组编队：",parseInt(ss[7]),action));
        hdiv.appendChild(setactionlist("选择编队：",parseInt(ss[8]),action));
        hdiv.appendChild(setactionlist("攻击：",parseInt(ss[13]),action));
        
        var bdiv = $C("div");
        bdiv.className = "pd_foot";
        pd.appendChild(bdiv);
    }
}
function setactionlist(n,c,a) {
    var barbg = $C("div");
    barbg.className = "actionbg";
    var bar = $C("div");
    bar.className = "actionbar";
    bar.innerHTML = n + c;

    bar.style.backgroundPosition = (c/a-1)*302 + "px 0px";
    bar.onmouseover = function() {
        this.parentNode.style.backgroundPosition = "0px -22px";
        var p = getBackgroundPosition(this.style.backgroundPosition);
        this.style.backgroundPosition = p.x + "px -18px";
        this.style.color = "#835604";
    };
    bar.onmouseout = function() {
        this.parentNode.style.backgroundPosition = "0px 0px";
        var p = getBackgroundPosition(this.style.backgroundPosition);
        this.style.backgroundPosition = p.x + "px 0px";
        this.style.color = "#333333";
    };
    barbg.appendChild(bar);
    return barbg;
}

function insertPlayerData() {
    var cno = $C("div");
    cno.className = "commendshow";
    cno.id = "commendshow";
    cno.innerHTML = CommendNo;
    cno.title = "已经有" + CommendNo + "位玩家评定该录像很强大.";
    cno.onclick = nicegame;
    cno.onmouseover = function(){this.style.backgroundPosition = "0px 87px"};
    cno.onmouseout = function(){this.style.backgroundPosition = "0px 0px"};
    $("pagepart0").getElementsByTagName("div")[2].appendChild(cno);

    for (var i = 1 ; i < 13 ; i ++) {
        var o = datalist[i];
        if (!o) continue;
        if (ateam == 0) ateam = o.teamid;
        var addteam;
        if (ateam == o.teamid)
            addteam = $("playerinfo1");
        else
            addteam = $("playerinfo2");
        var ul = $C("ul");
        ul.className = "playerinfo";
        var ss = o.apm.split(",");
        ul.innerHTML = "<li class='pi_name'><span style='background-color:" + o.color + "'></span>" + o.playername + "</li><li class='raceimage'><img src='" + War3main + o.userace + ".gif' alt='" + o.userace + "' /></li><li>" + o.userace + "</li><li class='apmdata'>Min:" + ss[2] + "</li><li class='apmdata'>Ave:" + ss[1] + "</li><li class='apmdata'>Max:" + ss[0] + "</li>";
        addteam.appendChild(ul);
    }
    insertLocation();
}
function insertPlayerHero() {
    for (var i = 1 ; i < 13 ; i ++) {
        var o = datalist[i];
        if (!o) continue;
        if (ateam == 0) ateam = o.teamid;
        var addteam;
        if (ateam == o.teamid)
            addteam = $("playerteam1");
        else
            addteam = $("playerteam2");
        
        var pd = $C("div");
        pd.id = "playerdata" + i;
        pd.className = "pd_part";
        addteam.appendChild(pd);
        
        var tdiv = $C("div");
        tdiv.className = "pd_head";
        tdiv.innerHTML = "<span class='headtitle' style='margin:5px 0px 0px 5px;'>" + o.playername + "</span>";
        pd.appendChild(tdiv);
        
        var hdiv = $C("div");
        hdiv.className = "pd_body";
        pd.appendChild(hdiv);
        var list = o.hero;
        for (var j = 0 ; j < list.length ; j++ ) {
            var ss = list[j];
            var ul = $C("ul");
            ul.className = "pd_hero";
            ul.onmouseover = function(){this.className = "pd_hero_on";};
            ul.onmouseout = function(){this.className = "pd_hero";};
            ul.id = "hero" + i + ss[1];
            ul.innerHTML = "<li><img class='heroimg' id='herodes" + i + ss[1] + "' onmousemove='heromousemove(event,this)' onmouseout='hidemessagebox()' src='" + Uimage + ss[1] + ".gif' alt='" + ss[2] + "' /></li><li class='pd_name'>" + ss[2] + " (LV:<span id='lv" + i + ss[1] + "'>0</span>)</li>";
            hdiv.appendChild(ul);
            
            var os = new Object();
            os.title = ss[2];
            os.no = 0;
            os.des = "";
            des["herodes" + i + ss[1]] = os;
        }
        var skill = o.skill;
        for (var j = 0 ; j < skill.length ; j ++) {
            var ss = skill[j];
            
            var skl = $("sk" + i + ss[1]);
            var o = des["herodes" + i + ss[2]];

            if (o) {
                o.no++;
                o.des += "<li>[" + ss[4] + "] " + ss[3] + "</li>";
            }
            
            
            if (!skl) {
                var sli = $C("li");
                sli.onmouseover = function(){this.nextSibling.className = "skillshow";if (ie)this.nextSibling.style.backgroundImage="none";};
                sli.onmouseout = function(){this.nextSibling.className = "skillhide";};
                
                sli.innerHTML = "<img class='skillimage' src='" + Simage + ss[1] + ".gif' alt='" + ss[3] + "' />";
                var hb = $("hero" + i + ss[2]);
                if (hb) hb.appendChild(sli);

                sli = $C("li");
                sli.onmouseover = function(){this.className = "skillshow";if (ie)this.style.backgroundImage="none";};
                sli.onmouseout = function(){this.className = "skillhide";};
                sli.className = "skillhide";
                sli.innerHTML = "<span class='skillna'>" + ss[3] + "</span><span class='skilllv' id='sk" + i + ss[1] + "'>1</span>";
                if (hb) hb.appendChild(sli);
            } else {
                if (skl.innerHTML == "3") continue;
                skl.innerHTML = parseInt(skl.innerHTML) + 1;
            }
            var temp = $("lv" + i + ss[2]);
            if (temp) temp.innerHTML = parseInt(temp.innerHTML) + 1;
        }
        
        var bdiv = $C("div");
        bdiv.className = "pd_foot";
        pd.appendChild(bdiv);
    }
}
function heromousemove(event,obj) {
    movemessagebox(event);
    if (msg.style.display == "block") return;
    var o = des[obj.id];
    if (!o) return;
    showmessage(o.title + "(LV:" + o.no + ")","<dl>" + o.des + "</dl>");
}

var apmx,apmwidth;
var apm = new Image();
function setapmwidth() {
    apmwidth = 0;
    var aw = parseInt(apm.width);
    if (aw > 0) {
        apmwidth = aw;
        apm = null;
    }
}
function insertApmImage() {
    $("playerapm").innerHTML = "";
    if (!apm) {
        apm.onload = setapmwidth;
        apm.src = Runpath +"apm.aspx?replayID=" + rid;
    }
    var o = $("playerapm");
    var c = $C("div");
    c.className = "apmimg";
    if (ie)
        c.innerHTML = "<img id='apmimg' src='"+ Runpath +"apm.aspx?replayID=" + rid + "' onmousedown='return false' alt='APM' usemap='#M' />";
    else
        c.innerHTML = "<img id='apmimg' src='"+ Runpath +"apm.aspx?replayID=" + rid + "' onmousedown='return false' alt='APM' />";
    c.onmousedown = function(event){
        var p = getMousePointer(event);
        apmx = p.x;
        apmwidth = 0 - mobj.width + 300;
        _d.onmousemove = function(event){
            //alert(1);
            var p = getMousePointer(event);
            var nx = p.x;
            var mobj = $("apmimg");

            if (apmx != nx) {
                var nl = parseInt(mobj.style.marginLeft) + nx - apmx;
                if (nl < -106 && nl > apmwidth)
                    mobj.style.marginLeft = nl + "px";

                apmx = nx;
            }
        };
        _d.onmouseup = function(){
            _d.onmousemove = null;
        };
    };
    
    o.style.backgroundImage = "url("+ Runpath +"apm.aspx?replayID=" + rid + ")";
    o.appendChild(c);
    var mobj = $("apmimg");
    mobj.style.marginLeft = "-106px";
}
function insertGamedata() {
    var gamedata = $("gamedata");
    for (var i = 1 ; i < 13 ; i ++) {
        if (!datalist[i]) return;
        var player = datalist[i];
        var ul = $C("ul");
        ul.className = "databody";
        gamedata.appendChild(ul);
        var li = $C("li");
        li.className = "userdata";
        li.innerHTML = "<div>" + player.playername + "</div>";
        ul.appendChild(li);
        li = $C("li");
        li.className = "builddata";
        ul.appendChild(li);
        var list = player.build;
        var min = 0;
        var max = 0;
        for (var j = 0 ; j < list.length ; j ++) {
            var item = list[j];
            var id = i + "_build_" + item[1];
            var span = $(id);
            if (!span) {
                var img = $C("img");
                img.src = Uimage + item[1] + ".gif";
                img.id = "des_" + id;
                img.onmouseover = unitmouseover;
                img.onmouseout = unitmouseout;
                img.onmousemove = unitmousemove;
                li.appendChild(img);
                
                span = $C("span");
                span.innerHTML = "1";
                span.id = id;
                li.appendChild(span);
                max++;
                if (max % 4 == 0)
                    li.appendChild($C("br"));
                
                var o = new Object();
                o.title = item[2];
                o.no = 1;
                o.des = "<li>" + item[3] + "</li>";
                des["des_" + id] = o;
            } else {
                des["des_" + id].no++;
                des["des_" + id].des += "<li>" + item[3] + "</li>";
                span.innerHTML = parseInt(span.innerHTML) + 1;
            }

        }
        max = parseInt(max / 4);
        if (max % 4 > 0)
            max++;
        min = max;
        max = 0;
        li = $C("li");
        li.className = "unitdata";
        ul.appendChild(li);
        list = player.unit;
        for (var j = 0 ; j < list.length ; j ++) {
            var item = list[j];
            var id = i + "_unit_" + item[1];
            var span = $(id);
            if (!span) {
                var img = $C("img");
                img.src = Uimage + item[1] + ".gif";
                img.id = "des_" + id;
                img.onmouseover = unitmouseover;
                img.onmouseout = unitmouseout;
                img.onmousemove = unitmousemove;
                li.appendChild(img);

                span = $C("span");
                span.innerHTML = "1";
                span.id = id;
                li.appendChild(span);
                max++;
                if (max % 5 == 0)
                    li.appendChild($C("br"));
                
                var o = new Object();
                o.title = item[2];
                o.no = 1;
                o.des = "<li>" + item[3] + "</li>";
                des["des_" + id] = o;
            } else {
                des["des_" + id].no++;
                des["des_" + id].des += "<li>" + item[3] + "</li>";
                span.innerHTML = parseInt(span.innerHTML) + 1;
            }
        }
        max = parseInt(max / 5);
        if (max % 5 > 0)
            max++;
        if (max > min)
            min = max;
        max = 0;
        li = $C("li");
        li.className = "itemdata";
        ul.appendChild(li);
        list = player.item;
        for (var j = 0 ; j < list.length ; j ++) {
            var item = list[j];
            var id = i + "_item_" + item[1];
            var span = $(id);
            if (!span) {
                var img = $C("img");
                img.src = Iimage + item[1] + ".gif";
                img.id = "des_" + id;
                img.onmouseover = unitmouseover;
                img.onmousemove = unitmousemove;
                img.onmousemove = unitmousemove;
                img.onmouseout = unitmouseout;
                li.appendChild(img);

                span = $C("span");
                span.innerHTML = "1";
                span.id = id;
                li.appendChild(span);
                max++;
                if (max % 5 == 0)
                    li.appendChild($C("br"));
                
                var o = new Object();
                o.title = item[2];
                o.no = 1;
                o.des = "<li>" + item[3] + "</li>";
                des["des_" + id] = o;
            } else {
                des["des_" + id].no++;
                des["des_" + id].des += "<li>" + item[3] + "</li>";
                span.innerHTML = parseInt(span.innerHTML) + 1;
            }
        }
        max = parseInt(max / 5);
        if (max % 5 > 0)
            max++;
        if (max > min)
            min = max;
        li = $C("li");
        li.className = "dataend";
        ul.appendChild(li);
        ul.style.height = min * 45 + 20 + "px";
    }
}
function unitmouseover() {
    var ts = this.style;
    var ss = this.nextSibling.style;
    ss.zIndex = 1001;
    ss.fontWeight = "bold";
    ts.position = "relative";
    if (ie) {
        ts.marginLeft = 0 - this.width / 2 + 1 + "px";
        ts.marginRight = 0 - this.width / 2 + 1 + "px";
        ts.marginTop = 0 - this.height / 2 + 1+ "px";
        ts.marginBottom = 0 - this.height / 2 + 1 + "px";
        ss.marginLeft = 0 - this.width - this.width / 2 - 3 + "px";
        ss.marginTop = 0 - this.height / 2 + 3 + "px";
    } else {
        ts.marginLeft = 0 - this.width / 2 + 2 + "px";
        ts.marginRight = 0 - this.width / 2 + 2 + "px";
        ts.marginTop = 0 - this.height / 2 + 2+ "px";
        ts.marginBottom = 0 - this.height / 2 + 2 + "px";
               
        ss.marginLeft = 0 - this.width - this.width / 2 - 4 + "px";
        ss.marginTop = 0 - this.height / 2 + 4 + "px";
    }

    ts.zIndex = 1000;
    ts.width = this.width * 2 + "px";
    ts.height = this.height * 2 + "px";
}
function unitmouseout() {
    var ts = this.style;
    this.nextSibling.className = "";
    var ss = this.nextSibling.style;
    ss.fontWeight = "normal";
    ss.zIndex = 1;
    ts.marginLeft = "2px";
    ts.marginRight = "2px";
    ts.marginTop = "2px";
    ts.marginBottom = "2px";
    ts.position = "static";
    ts.zIndex = 1;
    
    if (ie || opera) {
        ts.width = this.width / 2 - 3 + "px";
        ts.height = this.height / 2 - 3 + "px";
        ss.marginLeft = 0 - this.width -2 + "px";
        ss.marginTop = "4px";
    } else {
        ts.width = this.width / 2 + "px";
        ts.height = this.height / 2 + "px";
        ss.marginLeft = 0 - this.width -4 + "px";
        ss.marginTop = "4px";
    }
    hidemessagebox();
}
function unitmousemove(event) {
    movemessagebox(event);
    if (msg.style.display == "block") return;
    var o = des[this.id];
    if (!o) return;
    showmessage(o.title + "(" + o.no + ")","<dl>" + o.des + "</dl>");

}
function movemessagebox(event) {
    var p = getMousePointer(event);
    var dp = msg.style;
    dp.left = p.x + 5 + "px";
    dp.top = p.y + 5 + "px";
}
function showmessage(title,content) {
    msg.style.display = "block";
    $("msgtitle").innerHTML = title;
    $("msgcontent").innerHTML = content;
    //msgo = 0;
    //timer = window.setInterval(function(){messageOpacity(10);},10);
}

function messageOpacity(add) {
    msgo += add;
    if (add > 0) {
        if (msgo > 100) msgo = 100;
    } else {
        if (msgo < 0) {
            msgo = 0;
            msg.style.display = "none";
        }
    }
	msg.style.filter = "alpha(opacity=" + msgo + ")";
	msg.style.opacity = msgo / 100;
    if (msgo == 100 || msgo == 0) {
        clearInterval(timer);
    }
}
function hidemessagebox() {
    msg.style.display = "none";
    //msgo = 100;
    //timer = window.setInterval(function(){messageOpacity(-10);},10);
}

function ReplaceData(obj) {
    if (!obj) return;
    var str = obj.innerHTML;
    var re = /(\d{1,10})[楼]/g;
    str = str.replace(re,"<span class=\"clayer\" onmouseover=\"showcomment($1,this,event)\">[$1楼]</span>");
    obj.innerHTML = str;
}
var showlayer;
function showcomment(ladderno,obj,event) {
    var o = $("cladder" + ladderno);

    if (!o) return;
    if (!showlayer) {
        showlayer = $C("div");
        showlayer.id = "showlayer";
        showlayer.className = "leftpart";
        showlayer.onmouseover = function() {showlayer.style.display = "block";}
        showlayer.onmouseout = function() {showlayer.style.display = "none";}
        $("comment").appendChild(showlayer);
    }
    showlayer.innerHTML = o.innerHTML;
    var p = getMousePointer(event);
    showlayer.style.left = p.x - 5 + "px";
    showlayer.style.top = p.y - 5 + "px";
    showlayer.style.display = "block";
    obj.onmouseout = function(){showlayer.style.display = "none";};
}
function UserIsOnline() {
    if (!OnlineUserName) return;
    var ul = $("userlogin");
    if (!ul) return;
    ul.innerHTML = "当前用户:" + OnlineUserName + " <a href='http://bbs.replays.net/logout.aspx' target='_blank'>退出</a>";
}
function getreplaymap(ver,checksum,pass) {
    $("downmap").innerHTML = "检索地图中...";
    httpRequest(Runpath + "Getmap.aspx","replayid=" + rid + "&ver=" + ver + "&checksum=" + checksum + "&pass=" + pass,setreplaymap);
}
function setreplaymap(doc) {
    var os = doc.lastChild.childNodes;
    var r = getValue(os[0]);
    var obj = $("downmap");
    if (r == '0') {
        obj.href = getValue(os[2]);
        obj.innerHTML = "下载 请按地图位置保存[" + getValue(os[3]) + "]";
    } else if (r == '2') {
        obj.href = Runpath + "MapUpload.aspx?ReplayID=" + rid;
        obj.innerHTML = "未收录 我要上传";
    } else {
        obj.innerHTML = getValue(os[1]);;
    }
}