var apiRoot = "view.php"

function load_script_to_body(url) {
    var script = document.createElement("script");
    script.type    = "text/javascript";
    script.charset = "utf-8";
    script.src     = url;
    document.body.appendChild(script);
}

window.onload = function() {
    if (location.href.match(/^.+\?username=([^&]+).*$/)) {
        display_progress();
        var username = location.href.replace(/^.+\?username=([a-zA-Z0-9]+)/, "$1");
        $("username").value = username;
        var url = apiRoot + "?username=" + username;
        load_script_to_body(url);
    }
}

function display_progress() {
    $("progress-area").innerHTML = "読み込んでるかも？";
    $("display-area").style.display  = "none";
    $("progress-area").style.display = "block";
}

function hide_progress() {
    $("progress-area").innerHTML = "読み込んでるかも？";
    $("progress-area").style.display = "none";
    $("display-area").style.display  = "block";
}

function display_error() {
    $("progress-area").innerHTML = "。。。え、誰？";
    $("display-area").style.display  = "none";
    $("progress-area").style.display = "block";
}
