/**
 * @copyright Internet Labs
 * @author Bartosz Błaszczyk
 * @version 2008.07.15.18.00
 */


function newPost(textareaAnchorUri, isLoggedIn)
{
    if (!isLoggedIn) {
        window.document.location = textareaAnchorUri + "#login";
    } else {
        window.document.location = textareaAnchorUri + "#form";
        document.getElementById("text").focus();
    }
}


function quotePost(textareaAnchorUri, isLoggedIn, url)
{
    if (!isLoggedIn) {
        window.document.location = textareaAnchorUri + "#login";

    } else {

        var options = {
        data : $("newPostForm"),
            onComplete : function() {
                $("progressBar").setStyle("display", "none");
                $("postTextarea").setStyle("display", "block");
                $("text").focus();
                $("text").value = this.response.text;
                $("text").scrollTop = $("text").scrollHeight;
            },
            onRequest : function() {
                $("postTextarea").setStyle("display", "none");
                $("progressBar").setStyle("display", "block");
                window.document.location = textareaAnchorUri + "#form";
            }
        };

        new Ajax(url, options).request();
    }
}
