if (!ldblogPrivateBody){
    var ldblogPrivateBody = {
        init : function () {
            if (location.hash == '#private-more')
                this.checkLogin(document.getElementById('privatebody-login-link'), 0);
        },
        checkLogin : function (elm, jump) {
            var api_url = elm.href.replace(/login$/, 'status');
            var obj = this;
            this.callJSONP(api_url, function (json) {
                if ( json.login == 1 ){
                    document.getElementById('privatebody-login-nickname').innerHTML = json.nickname;
                    document.getElementById('privatebody-login').style.display = "none";
                    document.getElementById('privatebody-logout').style.display = "";
                    var get_api = api_url.replace(/status$/, 'get');
                    obj.callJSONP(get_api, function(json){
                        if (json.status == 'success')
                            document.getElementById('private-mode-body').innerHTML = json.content;
                        else
                            document.getElementById('private-mode-body').innerHTML = "\u3053\u306E\u8A18\u4E8B\u306F\u8A31\u53EF\u30E6\u30FC\u30B6\u30FC\u3057\u304B\u8AAD\u3080\u4E8B\u304C\u3067\u304D\u307E\u305B\u3093\u3002";
                    });
                }
                else if (jump == 1)
                    location.href = elm.href;
            });
            return false;
        },
        callJSONP : function (api_url, cb_func) {
            var uniq_name = "ldblog_privatebody_cb_" + Math.random().toString(36).slice(2);
            var scr = document.createElement("script");
            scr.type = "text/javascript";
            scr.src = api_url.indexOf('?', 0) > 0 ?
               api_url + '&callback=' + uniq_name :
               api_url + '?callback=' + uniq_name;
            scr.id = uniq_name;
            var obj = this;
            window[uniq_name] = function (json) {
                cb_func(json);
                var u_name = uniq_name;
                setTimeout(function() {
                    obj.head.removeChild(document.getElementById(u_name));
                    try{
                        window[u_name] = null;
                        delete window[u_name];
                    } catch (e) {};
                }, 200);
            };
            obj.head = document.getElementsByTagName("head").item(0);
            setTimeout(function(){ obj.head.appendChild(scr); }, 100);
        }
    };
}
