var comment_id;
var comment_container_id;

function toggle_me2comment(postid, divid) {
    var area = document.getElementById(divid);
    if (area.style.display) {
        comment_container_id = divid;
        comment_id = postid;
        area.style.display = '';
        comment_loadXMLDoc('http://openlook.org/blog/extfeed/' + postid + '/', '');
    }
    else
        area.style.display = 'none';
}

function comment_loadXMLDoc(url, data) {
    if(window.XMLHttpRequest) {
        comment_req = new XMLHttpRequest();
        comment_req.onreadystatechange = comment_processReqChange;
    }
    else if(window.ActiveXObject) {
        comment_req = new ActiveXObject("Microsoft.XMLHTTP");
        if (comment_req) {
            comment_req.onreadystatechange = comment_processReqChange;
        }
    }
    comment_req.open("POST", url, true);
    comment_req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    comment_req.send(data);
}

function comment_processReqChange() {
    var result = "";
    if (comment_req.readyState == 4) {
        if (comment_req.status == 200) {
            var area = document.getElementById(comment_container_id);
            area.innerHTML = comment_req.responseText;
            area.style.display = '';
            return;
            google.friendconnect.container.renderWallGadget({
                'id': comment_container_id + '_gf',
                'site': '17686521191182239334',
                'view-params': {"scope":"ID","allowAnonymousPost":"true","features":"video,comment","docId":"extfeed-" + comment_id} }, gf_skin_white);
        }
        else
            alert("Un" + comment_req.status);
    }
}

function fold_comment(id) {
    var area = getFoldedCommentArea(id);
    if (area.style.display) {
        comment_recentid = id;
        comment_loadXMLDoc(id + "/comment_supplemental_html", '');
    }
    else {
        area.style.display = 'none';
    }
}

function folded_update(frm, id) {
    var r = new Array();
    for(var i=frm.elements.length;i--;) {
        var el = frm.elements[i];
        if(el.name && el.name != 'forgetPersonalInfo:method') {
            r[i] = escape(el.name) + '=' + escape(el.value);
        }
    }
    comment_recentid = id;
    postdata = r.join('&');
    //postdata = 'folded=1&author=FFF&url=&email=&title=Re%3A+%ED%81%AC%EB%A1%9C%EC%8A%A4%EC%BB%B4%ED%8C%8C%EC%9D%BC+%ED%88%B4%ED%82%B7+scratchbox&body=FFF&addComment%3Amethod=%uAE00%20%uC4F0%uAE30';
    comment_loadXMLDoc(id+'/', postdata);
    return false;
}

function getFoldedCommentArea(id) {
    return document.getElementById("folded_comment_" + id);
}

function reveal_identity_form(id, id_email) {
    var area = document.getElementById("comment_cpart_" + id);
    area.style.display = '';
    var editform = document.getElementById(id_email);
    editform.focus();
    var revealbut = document.getElementById("comment_form_reveal_button_" + id);
    revealbut.style.display = 'none';
}

// vim: syntax=javascript ts=8 sts=4 sw=4 et
