if (!themeblogRecentPlugin){
    var themeblogRecentPlugin;
    (function () {
        var tb_recent_plugin = function () {};
        tb_recent_plugin.prototype = {
            write : function (cfg) {
                this.cfg = cfg;
                if (this.cfg.max < 1)
                    this.cfg.max = 10;
                this.base_url = 'http://blog.livedoor.com/themeblog/';
                this.elm_id = "themeblog_recent_plugin_" + Math.random().toString(36).slice(2);
                document.write('<div id="'+this.elm_id+'" class="side"></div>');
                var obj = this;
                setTimeout(function () { obj.loadData(); }, 100);
            },
            loadData : function () {
                var api_url = this.base_url+this.cfg.theme+"/index.js";
                var obj = this;
                this.callJSONP(api_url, function (json) {
                    try {
                        obj.elm = document.getElementById(obj.elm_id);
                        if ( json.link.length ) {
                            var cfg = obj.cfg;
                            var html = '';
                            for (var i=0;i<json.articles.length&&i<cfg.max; i++) {
                                var article = json.articles[i];
                                html = html+'<div class="sidebody"><a href="'+article.link+'"';
                                if (cfg.target_blank)
                                    html = html+' target="_blank"';
                                html = html+'>'+article.title+' - '+article.blog.title+'</a></div>';
                            }
                            html = html+'<div style="padding-top: 20px;text-align:right;"><a href="'+json.link;
                            if (cfg.target_blank)
                                html = html+' target="_blank"';
                            html = html+'>'+json.title+'</a></div>';
                            obj.elm.innerHTML = html;
                        }
                        else
                            obj.elm.innerHTML = "¼èÆÀ¼ºÇÔ";
                    } catch (e) {}
                });
            },
            callJSONP : function (api_url, cb_func) {
                var uniq_name = 'cb_'+this.elm_id;
                var scr = document.createElement("script");
                scr.type = "text/javascript";
                scr.src = 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;
                    var obj2 = obj;
                    setTimeout(function() {
                        obj2.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);
            }
        };
        themeblogRecentPlugin = new tb_recent_plugin();
    })();
}

