function SceneWidgetLoading(options) {
	this.options = options;
    
    this.WidgetLoadingView=null;
    
    this.testpopup = null;
	//this.DimBg = null;
    this.LoadingBg = null;
    this.LoadingAni = null;
    this.LoadingMsg = null;
    
    this.FlagAnimation = false;
    this.LoadingAniImage = new Array(18);
    this.iCurrAniImage =0;
    
    //2013 add by minseok
    this.LoadingAniImagePath = null;
    
    this.WidgetLoadingTimer = null;
}

SceneWidgetLoading.prototype.initialize = function () {
	alert("SceneWidgetLoading.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();
}

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

    this.FlagAnimation=true;
    this.startTimer();
    
}

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

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

}

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

SceneWidgetLoading.prototype.handleKeyDown = function (keyCode) {
	alert("SceneWidgetLoading.handleKeyDown(" + keyCode + ")");
	PluginAPIMgr.PlayAudio(keyCode);
	// TODO : write an key event handler when this scene get focued
	switch (keyCode) {
		case sf.key.LEFT:
		case sf.key.RIGHT:
			break;
		case sf.key.UP:

			break;
		case sf.key.DOWN:

			break;

		case sf.key.ENTER:
			break;
            
        case sf.key.RETURN:
            this.processReturnKey();
            //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
            
         case sf.key.EXIT:
           this.processExitKey();
            //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
            
         case 147:  //infolink
         case 261:  //contents
         case 115:  //wiselink
            //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
	}
}

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

SceneWidgetLoading.prototype.create = function(){
    alert("SceneWidgetLoading.create()");
    this.WidgetLoadingView = new View("WidgetLoading");
    
    //Because sf.core.loadJS func is asynchronous
    var ResStr = sf.env.getResolution();
   	this.LoadingAniImagePath = "images/"+ResStr+"/loading/loading_96/";
   	alert("SceneWidgetLoading.create() : loadinganiImagePath"+this.LoadingAniImagePath);
    
    
    var a=0;
    for (a=0; a < this.LoadingAniImage.length; a++)
    {
        var b = (a+1);
        if(b<10)
        {
            this.LoadingAniImage[a] = this.LoadingAniImagePath +"loading_96_"+"0"+b+".png";
        }
        else
        {
            this.LoadingAniImage[a] = this.LoadingAniImagePath +"loading_96_"+b+".png";
        }
    }
    
    this.LoadingAni= new Label("widget_loading_animation", null);
    this.LoadingAni.SetBgImage(this.LoadingAniImage[this.iCurrAniImage]);
    // this.WidgetLoadingView.popup.SetLoadingBG(this.LoadingAniImage[this.iCurrAniImage]);
    
    this.LoadingMsg = new Label(null,"widget_loading_message");
    this.LoadingMsg.SetTextStyle("widget_loading_message_style");
    this.LoadingMsg.SetText(SID_LOADING_3DOT_KR_DIF);
     
}

SceneWidgetLoading.prototype.highlight=function(obj)
{
    this.WidgetLoadingView.setCurrenHighlight(obj);

}

SceneWidgetLoading.prototype.startTimer = function()
{   
	var scene = sf.scene.get('WidgetLoading');
    this.WidgetLoadingTimer=setInterval("timerCF()", 100);
    timerCF = function() {  scene.loadingTimerCallback();}
}

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

SceneWidgetLoading.prototype.loadingTimerCallback = function()
{
     this.iCurrAniImage++;
     
    if(this.iCurrAniImage >= this.LoadingAniImage.length)
    {
        this.iCurrAniImage = 0;
    }   
    
    this.LoadingAni.SetBgImage(this.LoadingAniImage[this.iCurrAniImage]);
    // this.WidgetLoadingView.popup.SetLoadingBG(this.LoadingAniImage[this.iCurrAniImage]);
	
}


SceneWidgetLoading.prototype.processReturnKey = function(){
    alert("SceneWidgetLoading.processReturnKey() ");   
   ProcMgr.CloseWidget(); 
}


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



