/**
 * ページのプラグインを読み込む為のscript
*/
var _plugin = Class.create();
_plugin.prototype = {
    initialize : function() {} ,

    getNextLive : function(page) {
        if(page.match(/[^0-9]/)) return;

        Element.show($('pluginLoad'));
        Element.hide($('pluginError'));

        var ajax = new Ajax.Updater(
            $("nextlivePlaceholder"),
            "/live/nextlive/?page=" + page,
            {
                method : "post" ,
                onSuccess : function(res) {
                    Element.hide($("pluginLoad"));
                },
                onComplete : function(res) {
                    Element.hide($("pluginLoad"));
                },
                onFailure : function(res) {
                    Element.hide($("pluginLoad"));
                    Element.show($('pluginError'));
                },
                onException : function(res) {
                    Element.hide($("pluginLoad"));
                    Element.show($('pluginError'));
                }
            }
        );
    },

    getcounter : function() {
        Element.show($('pluginLoad'));
        Element.hide($('pluginError'));

        var ajax = new Ajax.Updater(
            $("counterPlaceholder"),
            "/counter/getcount/" ,
            {
                method : "post" ,
                onSuccess : function(res) {
                    Element.hide($("pluginLoad"));
                },
                onComplete : function(res) {
                    Element.hide($("pluginLoad"));
                },
                onFailure : function(res) {
                    Element.hide($("pluginLoad"));
                    Element.show($('pluginError'));
                },
                onException : function(res) {
                    Element.hide($("pluginLoad"));
                    Element.show($('pluginError'));
                }
            }
        );
    },

    /** 読み込み完了時に実行 **/
    pageInit : function() {
        this.getNextLive('1');
        this.getcounter();
    }
}

var plugin = new _plugin();

