// To set the link options
function setlink() {
    var i = 0;
    var f = g('comment');
    if (f.email.value != "") {i += 1;}
    if (f.www.value != "") {i += 2;}
    f.link[i].checked = true;
    return true;
}

function choosecolor(c) {
    switch(c) {
        case "green":
            var bg = '#d9ffec';
            var fg = '#141';
            break;
        case "blue":
            var bg = '#bfe0f2';
            var fg = '#336';
            break;
        case "purple":
            var bg = '#d6d6ff';
            var fg = '#434';
            break;
        case "pink":
            var bg = '#ffe4f3';
            var fg = '#891554';
            break;
    }
    g('commenttext').style.background
        = g('authorid').style.background
        = g('emailid').style.background
        = g('wwwid').style.background
        = g('titleid').style.background
        = bg;

    g('commenttext').style.color
        = g('authorid').style.color
        = g('emailid').style.color
        = g('wwwid').style.color
        = g('titleid').style.color
        = fg;

    g('commenttext').style.backgroundImage  = 'url(/_images/stars_background_05.png)';
    g('commenttext').style.backgroundRepeat = "repeat";

    return true;
}

function changeIndent() {
    var marg = null;
    var button = g('toggle');
    var choice = button.value;
    if (choice == 'flatten replies') {
        marg = '0px';
        button.value = 'nest replies';
    }
    else if (choice == 'nest replies') {
        marg = '20px';
        button.value = 'flatten replies';
    }
    var divs = document.getElementsByTagName("div");
    for (var i = 0; i < divs.length; i++) {
        var div = divs[i];
        if (div.getAttribute("class") == "commentchild") {
            div.style.marginLeft = marg;
        }
    }
    return true;
}
