var displayamount = 8;
var _css = "default";
function CssName(css) {
    _css = css;
}
function DianCMS(address, linkname) {
    linkname = escape(linkname);
    address = address + "_DianCMS_";
    wlink = linkname + "+" + address;
    old_info = getCookie("DianCMS_History");
    var insert = true;
    var include = false;
    if (old_info == null) {
        insert = true;
    }
    else {
        var old_link = old_info.split("_DianCMS_");
        if (old_link.length >= displayamount) {
            insert = false;
            if (old_info.indexOf(address) == -1) {
                for (var j = 0; j < displayamount - 1; j++) {
                    wlink += old_link[j] + "_DianCMS_";
                }
                setCookie("DianCMS_History", wlink);
            }
        }
        else {
            for (var j = 0; j < old_link.length; j++) {
                if (old_link[j].indexOf(linkname) != -1)
                    insert = false;
                if (old_link[j] == "null")
                    break;
            }
        }
    }


    if (insert) {
        wlink += getCookie("DianCMS_History");
        setCookie("DianCMS_History", wlink);
    }

    if (parent.window.frames['Link'] == null) {
        parent.window.frames["mainFrame"].frames['Link'].history_show(_css);
    }
    else {
        parent.window.frames['Link'].history_show(_css);
    }
}

function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

function getCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1) endstr = document.cookie.length;
    return document.cookie.substring(offset, endstr);
}

function setCookie(name, value) {
    var exp = new Date();
    exp.setTime(exp.getTime() + 3600000000);
    document.cookie = name + "=" + value + "; expires=" + exp.toGMTString();
}

function clearCookieVal(name, value) {
    old_info = getCookie("DianCMS_History");
    var wlink = "";
    if (old_info != null) {
        var old_link = old_info.split("_DianCMS_");
        for (var j = 0; j < old_link.length; j++) {
            if (old_link[j] != "" + value + "+" + name + "" && old_link[j] != "null") {
                wlink += old_link[j] + "_DianCMS_";
            }
        }
        setCookie("DianCMS_History", wlink);
        history_show(_css);
    }
}

function ClearAll() {
    setCookie("DianCMS_History", null);
    history_show(_css);
}

function history_show() {
    var history_info = getCookie("DianCMS_History");
    var content = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>";
    if (history_info != null) {
        history_arg = history_info.split("_DianCMS_");

        var factdisplayamount = history_arg.length < displayamount ? history_arg.length : displayamount;

        var i;
        for (i = 0; i < factdisplayamount; i++) {
            if (history_arg[i] != "null" && history_arg[i] != "") {
                var wlink = history_arg[i].split("+");
                content += "<td height=\"21\" valign=\"top\"><img src=\"../css/skin/" + _css + "/images/link_1.gif\" height=\"21\"/></td><td class=\"Link1\"><a href='" + wlink[1] + "' target='InfoFrame'>" + unescape(wlink[0]) + "</a></td><td valign=\"top\"><img src=\"../css/skin/" + _css + "/images/link_2.gif\" style=\"cursor:pointer\" onclick=\"clearCookieVal('" + wlink[1] + "','" + wlink[0] + "')\" /></td><td width=\"5\"></td>";
            }
        }
        content += "</tr></table>";
        document.getElementById("Link").innerHTML = content;
    }
}

function ShowTable(Name, TableName) {
    if (DianCMS_$(TableName).style.display == "none") {
        DianCMS_$(TableName).style.display = "";
        DianCMS_$(Name).className = "lefttd1";
    }
    else {
        DianCMS_$(TableName).style.display = "none";
        DianCMS_$(Name).className = "lefttd2";
    }
}