﻿function getPost(pid, destid) {
    //alert("getting")
    dest = document.getElementById("comment_innerspace_" + destid)
    //alert(dest)
    innerExists = (dest.childNodes.length > 0 && dest.childNodes[0].id && dest.childNodes[0].id.indexOf("comment_innerid_" + destid) == 0)
    if (innerExists) {
        dest.style.display = dest.style.display == "none" ? "" : "none"
        dest.style.innerHTML = "" /// GET RID OF THE INNER POST FOR NOT IS DESCREPANCIES
        return true;
    }

    if (dest.innerHTML == "") {
        postReturn = getAJAXData("/process/posts/getpost.asp", "p=" + pid + "&reqpid=" + destid)
        if (postReturn.indexOf("!") == 0) {
            alert("ERR:" + postReturn)
            return false;
        }

        dest.innerHTML = postReturn
        dest.style.display = ""
    }

    //alert(postReturn)


}

function getReply(pid, destid) {
    locateMsg(pid, true, true)
}

function locateMsg(pid, doFlash, doHL) {
    if (!document.getElementById("comment_id_" + pid))
        return false;
    oid = "comment_id_" + pid
    if (doFlash) {
        isFlashing = true;
        window.setTimeout("flashObjBg('" + oid + "',true,6)", 100)
        document.getElementById("comment_id_" + pid).scrollIntoView(true);

    } else {
        if (!isFlashing)
            flashObjBg(oid, doHL, 1)
    }
    return true

}

var isFlashing = false
function flashObjBg(oid, doFlash, mtimes) {
    if (mtimes <= 0) {
        isFlashing = false
        return;
    }

    if (!document.getElementById(oid))
        return;

    document.getElementById(oid).style.backgroundColor = doFlash ? "#cdffb7" : ""
    window.setTimeout("flashObjBg('" + oid + "'," + !doFlash + "," + (mtimes - 1) + ")", 300)

}
