﻿var LoadingPanel = "";
$addHandler(window, 'load', function(){
    LoadingPanel = $create(CodeSample.LoadingPanel, {}, null, null, null);
});

Type.registerNamespace("CodeSample");

CodeSample.LoadingPanel = function(){
    CodeSample.LoadingPanel.initializeBase(this);
    this._textElm = "";                 //表示テキスト部のエレメント
    this._panelbehavior ="";            //ModalPopupExtender
}

CodeSample.LoadingPanel.prototype ={
    initialize:function() {
        CodeSample.LoadingPanel.callBaseMethod(this,'initialize');
        this._panelbehavior=$find("LoadingPanelBehaviour");
        this._textElm=$get("LoadingPanelText");
        this.setText("Loading Now...");//Default Text
        
    },
    //パネルの表示テキストの設定
    setText:function(txt){
        this._textElm.innerText=txt;
    },
    //パネルの表示処理
    openPanel :function(){
        this._getPanelBehavior().show();
    },
    //パネルのClose処理
    closePanel :function(){
        this._getPanelBehavior().hide();
    },
    _getPanelBehavior : function(){
        if(this._panelbehavior==null){
            this._panelbehavior=$find("LoadingPanelBehaviour");
        }
        return this._panelbehavior;
    },
    //３秒間パネルを開いて、その後閉じる。
    openThreeSecond : function(){
        this.openPanel();
        var handler = Function.createDelegate(this, this.closePanel);
        this._wait(handler,3000);
    },
    _wait:function(func,waitTime){
        var f = function(){
            func();
        };
        setTimeout(f,waitTime);
    },
    dispose: function() {
        CodeSample.LoadingPanel.callBaseMethod(this, 'dispose');
    }
}


CodeSample.LoadingPanel.registerClass('CodeSample.LoadingPanel', Sys.Component);


if (typeof(Sys) !== 'undefined')
   Sys.Application.notifyScriptLoaded(); 

