﻿function loadcss(rootpath,defaultcss) {
    var css = getcookie("usercss");
    if (css != "") {
        applycss(css, rootpath);
    }
    else {
        css = defaultcss;
        applycss(css, rootpath);
    }
}
function setcss(css, rootpath) {
    setcookie("usercss", css);
    var d = document.getElementById("divstylebox");
    for (var i = 0; i < d.childNodes.length; i++) {
        var cname = d.childNodes[i].className;
        cname = cname.replace(' stylebox_border','');
        document.getElementById(d.childNodes[i].id).className = cname;
    }
    document.getElementById('style_' + css).className = 'stylebox_' + css + ' stylebox_border';
    loadcss(rootpath, css);
}
function applycss(css, rootpath) {
    var lcid = "lc1";
    if (checkObj(lcid)) {
        document.getElementById(lcid).href = rootpath + '/skins/' + css + '/common.css';
    }
    lcid = "lc2";
    if (checkObj(lcid)) {
        document.getElementById(lcid).href = rootpath + '/skins/' + css + '/default.css';
    }
    lcid = "lc3";
    if (checkObj(lcid)) {
        document.getElementById(lcid).href = rootpath + '/skins/' + css + '/board.css';
    }
    lcid = "lc4";
    if (checkObj(lcid)) {
        document.getElementById(lcid).href = rootpath + '/skins/' + css + '/topic.css';
    }
    lcid = "lc5";
    if (checkObj(lcid)) {
        document.getElementById(lcid).href = rootpath + '/skins/' + css + '/user.css';
    }
    lcid = "lc6";
    if (checkObj(lcid)) {
        document.getElementById(lcid).href = rootpath + '/skins/' + css + '/post.css';
    }
    lcid = "lc7";
    if (checkObj(lcid)) {
        document.getElementById(lcid).href = rootpath + '/skins/' + css + '/misc.css';
    }
}