function SceneminiWidgetLoading(options) {
	this.options = options;
    
    this.miniWidgetLoadingView=null;
    
	//this.DimBg = null;
    // this.LoadingBg = null;
    this.LoadingAni = null;
    this.LoadingMsg = null;
    
    this.FlagAnimation = false;
    this.LoadingAniImage = new Array(18);
    this.iCurrAniImage =0;
    
    this.WidgetLoadingTimer = null;
}

SceneminiWidgetLoading.prototype.initialize = function () {
	alert("SceneminiWidgetLoading.initialize()");
	// this function will be called only once when the scene manager show this scene first time
	// initialize the scene controls and styles, and initialize your variables here 
	// scene HTML and CSS will be loaded before this function is called
    
   this.create();
}

SceneminiWidgetLoading.prototype.handleShow = function () {
	alert("SceneminiWidgetLoading.handleShow()");
	// this function will be called when the scene manager show this scene 

    this.FlagAnimation=true;
    this.startTimer();
    this.ShowKeyHelpbar();
    $.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).helpbarType=0;
}

SceneminiWidgetLoading.prototype.handleHide = function () {
	alert("SceneminiWidgetLoading.handleHide()");
	// this function will be called when the scene manager hide this scene  
    
    this.FlagAnimation=false;
	//if(this.WidgetLoadingTimer != null)
	//{
		this.stopTimer();
	//}
}

SceneminiWidgetLoading.prototype.handleFocus = function () {
	alert("SceneminiWidgetLoading.handleFocus()");
	// this function will be called when the scene manager focus this scene

}

SceneminiWidgetLoading.prototype.handleBlur = function () {
	alert("SceneminiWidgetLoading.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
}

SceneminiWidgetLoading.prototype.handleKeyDown = function (keyCode) {
	alert("SceneminiWidgetLoading.handleKeyDown(" + keyCode + ")");
	PluginAPIMgr.PlayAudio(keyCode);
	// TODO : write an key event handler when this scene get focued
	switch (keyCode) {
		case $.sfKey.LEFT:
			/*$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).isFocused = false;
			$.sfScene.get("Home").prevService();*/
			break;
		case $.sfKey.RIGHT:
			/*$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).isFocused = false;
			$.sfScene.get("Home").nextService();*/
			break;
		case $.sfKey.UP:

			break;
		case $.sfKey.DOWN:

			break;

		case $.sfKey.ENTER:
			break;
            
        case $.sfKey.RETURN:
            /*this.processReturnKey();*/
            $.sfKey.block(event);
			break;
            
         case $.sfKey.EXIT:
          /* this.processExitKey();*/
            $.sfKey.block(event);
			break;
            
         case 147:  //infolink
         case 261:  //contents
         case 115:  //wiselink
            $.sfKey.block(event);
			break;
		case $.sfKey.BLUE:
			/*StateMgr.Start_Current_State(MAIN_STATE.MAIN);
			StateMgr.Focus_Current_State();*/
			break;
	}
	if(Flag_Hidden_State==false)
		event.stopPropagation();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

SceneminiWidgetLoading.prototype.create = function(){
    alert("SceneminiWidgetLoading.create()");
    this.miniWidgetLoadingView = new View("miniWidgetLoading");
    // this.WidgetLoadingView.SetBgImage(g_Image.IMAGE_WIDGET_LOADING_BG);

    // this.LoadingBg= new Label("widget_loading_bg", null);
    // this.LoadingBg.SetBgImage(g_Image.IMAGE_WIDGET_LOADING_BOX_BG);
    
    var a=0;
    for (a=0; a < this.LoadingAniImage.length; a++)
    {
        var b = (a+1);
        if(b<10)
        {
            this.LoadingAniImage[a] = g_Image.base_widget_loading_image_path +"loading_66x66_"+"0"+b+".png";
        }
        else
        {
            this.LoadingAniImage[a] = g_Image.base_widget_loading_image_path +"loading_66x66_"+b+".png";
        }
    }
    
    this.LoadingAni= new Label("mini_widget_loading_animation", null);
    this.LoadingAni.SetBgImage(this.LoadingAniImage[this.iCurrAniImage]);
    
    this.LoadingMsg = new Label(null,"mini_widget_loading_message");
    this.LoadingMsg.SetTextStyle("mini_widget_loading_message_style");
    this.LoadingMsg.SetText(SID_LOADING_3DOT_KR_DIF);
     
}

SceneminiWidgetLoading.prototype.highlight=function(obj)
{
    this.miniWidgetLoadingView.setCurrenHighlight(obj);

}
SceneminiWidgetLoading.prototype.ShowKeyHelpbar = function(){
	if(WIDGET.mouse==true){
		helpBarHandler.hideHelpIcon('red',"");
		helpBarHandler.hideHelpIcon('green',"");
		helpBarHandler.hideHelpIcon('yellow',"");
		helpBarHandler.showHelpIcon('blue',TV_SID_CHANGE_VIEW);
		helpBarHandler.showHelpIcon('tools',sfLang.SID_TOOLS);
		helpBarHandler.showHelpIcon('return',SID_RETURN);
	}else{
		$("#HomeHelp").sfKeyHelp({
			'blue' : TV_SID_CHANGE_VIEW,
			'tools' : sfLang.SID_TOOLS,
			'return' : SID_RETURN
		});
	}
}
SceneminiWidgetLoading.prototype.startTimer = function()
{   
	var scene = $.sfScene.get({id:"miniWidgetLoading", scope:WIDGET.id});
    this.WidgetLoadingTimer=setInterval("timerCF()", 100);
    timerCF = function() {  scene.loadingTimerCallback();}
}

SceneminiWidgetLoading.prototype.stopTimer = function()
{
    alert("SceneLoading.stopTimer() ");
    
	clearTimeout(this.WidgetLoadingTimer);
    this.WidgetLoadingTimer=null;
    this.iCurrAniImage =0;
}

SceneminiWidgetLoading.prototype.loadingTimerCallback = function()
{
    this.iCurrAniImage++;
    
    if(this.iCurrAniImage >= this.LoadingAniImage.length)
    {
        this.iCurrAniImage = 0;
    }   
    this.LoadingAni.SetBgImage(this.LoadingAniImage[this.iCurrAniImage]);
	
}


SceneminiWidgetLoading.prototype.processReturnKey = function(){
    alert("SceneminiWidgetLoading.processReturnKey() ");   
  // ProcMgr.CloseWidget(); 
	ProcMgr.returnTab();
}


SceneminiWidgetLoading.prototype.processExitKey = function(){
    alert("SceneminiWidgetLoading.processExitKey() ");   
   ProcMgr.ExitWidget();
}



