                         Event.observe(window, "load", function() {  ajaxEngine.registerRequest("ajaxComments", "/ajaxComments.dos");  ajaxEngine.registerRequest("ajaxCommentEdit", "/comment/edit.dos");  ajaxEngine.registerRequest("ajaxCommentDelete", "/comment/delete.dos");  ajaxEngine.registerRequest("ajaxCommentBlock", "/comment/block.dos");
    ajaxEngine.registerAjaxElement("ajaxComments");
    ajaxEngine.registerAjaxObject("ajaxCommentsScrollTo", new AjaxScrollTo());
});

function AjaxScrollTo() {
    this.ajaxUpdate = function(ajaxResponse) {
        var anchor = ajaxResponse.firstChild.nodeValue;
        if (anchor) {
            location.hash = anchor;
        }
    }
}

// this is separate to allow pages to override
function submitForm(formEl) {
    var req = formEl.id == "ajaxCommentDelete" ? 
        "ajaxCommentDelete" : "ajaxCommentEdit";
    ajaxEngine.sendRequest(req, {
        method: 'post',
        parameters: formEl.serialize(true)
    });
}

post.page = function(topicId, pageNum) {
    ajaxEngine.sendRequest("ajaxComments", {
        method: 'get',
        parameters: {
            "topicId" : topicId,
            "page" : pageNum
        }
    });
    return false;
};

post.select = function(topicId, postId) {
    if (postId.length < 1) {
        return post.page(topicId, 1);
    }
    ajaxEngine.sendRequest("ajaxComments", {
        method: 'get',
        parameters: {
            "topicId" : topicId,
            "selectedPost" : postId
        }
    });
    return false;
};

post.save = function(formEl) {
    //go through form and disabled form input submit and buttons
    Form.getElements(formEl).each(function(elem) {
        type = elem.type.toLowerCase();
        if (elem.tagName.toLowerCase() == "input" && (type == "submit" || type == "button")) {
           elem.disabled = true;
        }
    });
    ajaxEngine.sendRequest("ajaxCommentEdit", {
        method: 'post',
        parameters: formEl.serialize(true)
    });
    return false;
};

// 'delete' is a JS keyword
post.delete0 = function(postId) {
    ajaxEngine.sendRequest("ajaxCommentDelete", {
        method: 'post',
        parameters: $("postDeleteForm" + postId).serialize(true)
    });
};

post.block = function(postId) {
    ajaxEngine.sendRequest("ajaxCommentBlock", {
        method: 'post',
        parameters: $("postBlockForm" + postId).serialize(true)
    });
};
