(function () {
"use strict";

function request(querytext, func, errorfunc) {
        var req = new XMLHttpRequest();
        req.onreadystatechange = function() {
                if (req.readyState !== 4) {
                        return;
                }
                if (req.status !== 200) {
                        errorfunc();
                        return;
                }
                func(req.responseText);
        };
        req.open("GET",querytext);
        req.send();
}

donewpost.onclick = function(e) {
        var requri=[];
        requri.push("/newpost");
        requri.push(window.location.search);
        requri.push("&h=");
        requri.push(encodeURIComponent(document.getElementById("title").value));
        requri.push("&t=");
        requri.push(encodeURIComponent(document.getElementById("wysihtml5-editor").value));
        request(requri.join(""),function(r) {
                window.location="/posts.html"+window.location.search;},function() {});
};

}());