
function SceneminiWelcome(options) {
	this.options = options;
	
    this.destroyFlag = true;
    
    this.MainView=null;
    
    this.TitleLabel = null;
	this.ImageLabel = null;
	this.MsgLabel = null; 
    
    this.SigninBtn = null;
	
    this.DefaultHelpBar =null;
 
}

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

SceneminiWelcome.prototype.handleShow = function () {
	alert("SceneminiWelcome.handleShow()");
	// this function will be called when the scene manager show this scene 
	//$("#miniWelcome").css("display","block");
	if(this.destroyFlag==true)
	{
		//this.highlight(null);
        this.destroyFlag= false;	
	}    
	$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).helpbarType=1;
	this.ShowKeyHelpbar();
	
	$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).LC_setStartPage(true);	
}

SceneminiWelcome.prototype.handleHide = function () {
	alert("SceneminiWelcome.handleHide()");
	// this function will be called when the scene manager hide this scene  
   // $("#miniWelcome").css("display","none");
   this.highlight(null);

   $.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).LC_setEndPage();
}

SceneminiWelcome.prototype.handleFocus = function () {
	alert("SceneminiWelcome.handleFocus()");
	// this function will be called when the scene manager focus this scene
    var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight ==null)
    {
        this.highlight(this.SigninBtn);
    }
    else
    {
         this.highlight(currentHighlight);
    }
   
}

SceneminiWelcome.prototype.handleBlur = function () {
	alert("SceneminiWelcome.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight)
    	currentHighlight.blur();

}
 
SceneminiWelcome.prototype.handleKeyDown = function (keyCode) {
	alert("SceneminiWelcome.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	
	PluginAPIMgr.PlayAudio(keyCode);
	switch (keyCode) {
		case $.sfKey.LEFT:
			/*$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).isFocused = false;
			$.sfScene.get("Home").prevService();*/
			$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processLeftKey();
			break;
		case $.sfKey.RIGHT:
			/*$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).isFocused = false;
			$.sfScene.get("Home").nextService();*/
			$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processRightKey();
			break;
		case $.sfKey.UP:
            //////////////////for socialTV/////////////////////
  			this.processReturnKey();
			break;
		case $.sfKey.DOWN:
           
			break;
		case $.sfKey.RED:
			this.processEnterKey();
			break;
		case $.sfKey.BLUE:
			$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processBlueKey();
			break;
		case $.sfKey.ENTER:
            this.processEnterKey();
			break;
        
		case $.sfKey.TOOLS:
            /*$.sfScene.show("ServiceSetting");
			$.sfScene.focus("ServiceSetting");*/
			$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processToolsKey();
			break; 
            
		case $.sfKey.RETURN:
		case $.sfKey.EXIT:
			$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processExitKey();
			break;
			
        case 147:  //infolink
        case 261:  //contents
        case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
		case	ENUM_CALL_BLOCK_KEY_CODE.DUALVIEW:
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.FUNCTION_ISNT_AVAILABLE);
			break;	
		default:
           // ProcMgr.processBlockKey(keyCode);
            break;
	}
	if(Flag_Hidden_State==false)
		event.stopPropagation();
}

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

SceneminiWelcome.prototype.create = function(){
    alert("SceneminiWelcome.create()");
    this.MainView = new View("miniWelcome");
    // this.MainView.SetBgImage(g_Image.IMAGE_BACKGROUND);
    
    this.TitleLabel = new Label(null,"mini_welcome_title");
    this.TitleLabel.SetTextStyle("mini_welcome_title_style");
    this.TitleLabel.SetText(IDWS_MOIP_LOGIN);    
	
	this.ImageLabel= new Label("mini_welcome_image", null);
    // this.ImageLabel.SetBgImage(g_Image.IMAGE_WELCOME_IMAGE);
    
    /*this.MsgLabel = new Label(null,"mini_welcome_msg");
    this.MsgLabel.SetTextStyle("mini_welcome_msg_style");
    this.MsgLabel.SetText(g_String.SIGNIN_FOR_USING_SKYPE);  */
  
  	var this_ = $.sfScene.get({id:"miniWelcome", scope:WIDGET.id});
  	var clickCF =  function(obj){this_.processClickEvent(obj);};
  	
    this.SigninBtn= new Button();
    this.SigninBtn.SetImageObjId("mini_welcome_signin_btn");
    this.SigninBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_WELCOME_SIGNIN_BG_NORMAL);
    this.SigninBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_WELCOME_SIGNIN_BG_NORMALFOCUS);
    this.SigninBtn.AppendFgImage("welcome_signin_picture_icon", "4px", "4px", "113px", "113px");
	this.SigninBtn.SetFgImage(g_Image.IMAGE_WELCOME_SIGNIN_BG_ICON);
    this.SigninBtn.SetTextObjId("mini_welcome_signin_btn_text");
    this.SigninBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"mini_welcome_btn_normal_style");
	this.SigninBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"mini_welcome_btn_select_style");
    this.SigninBtn.SetText(IDWS_MOIP_SKYPE_SIGNIN);
    this.SigninBtn.SetOnClickCallbackFunc(clickCF);
    this.SigninBtn.SetOnMouseOverCallbackFunc(function(obj){
        this_.processMouseOver(obj);
    });
	this.SigninBtn.setTextKPILog(KPI_LOG_ITEM_ID.LOGIN_BTN);

    /*this.DefaultHelpBar = new HelpBar(HelpBarIndex.WELCOME,"Welcome");
    this.DefaultHelpBar.SetOnClickCallbackFunc(1, function(){this_.processReturnKey();});
    
	this.MainView.registHelpBar(this.DefaultHelpBar);*/

}
SceneminiWelcome.prototype.ShowKeyHelpbar = function(){
	if(WIDGET.mouse==true){
		helpBarHandler.showHelpIcon('red',SID_LOGIN);
		helpBarHandler.hideHelpIcon('green',"");
		helpBarHandler.hideHelpIcon('yellow',"");
		helpBarHandler.showHelpIcon('blue',TV_SID_CHANGE_VIEW);
		helpBarHandler.showHelpIcon('tools',sfLang.SID_TOOLS);
		helpBarHandler.showHelpIcon('return',SID_RETURN);
		helpBarHandler.setHelpIconClickEvent('help_red',function(){
			var Scene = $.sfScene.get({id:"miniWelcome", scope:WIDGET.id});
			Scene.handleKeyDown($.sfKey.RED);
		});


	}else{
		$("#HomeHelp").sfKeyHelp({
			'red' : SID_LOGIN,
			'blue' : TV_SID_CHANGE_VIEW,
			'tools' : sfLang.SID_TOOLS,
			'return' : SID_RETURN
		});	
	}
	

}

SceneminiWelcome.prototype.setDestroyFlag= function(destroy_flag){
     this.destroyFlag = destroy_flag;
}

SceneminiWelcome.prototype.highlight=function(obj)
{
	alert("SceneminiWelcome.highlight()");
	
    this.MainView.setCurrenHighlight(obj);
	
}

SceneminiWelcome.prototype.processLeftRightKey = function(){
    alert("SceneminiWelcome.processLeftRightKey() ");
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {       
        case this.SigninBtn:
            break;
            
    }
}

SceneminiWelcome.prototype.processEnterKey = function(){
    alert("SceneminiWelcome.processEnterKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
	//////////////////for socialTV/////////////////////
	
	$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).LC_addEvent("EV012", "SKYPELOGIN");

	var widgetAPI = new Common.API.Widget();
    widgetAPI.runSearchWidget(WIDGET.id, "jumpFromMini");
	
}

SceneminiWelcome.prototype.processReturnKey = function(){
    alert("SceneminiWelcome.processReturnKey() ");
   // //////////////////for socialTV/////////////////////
   /*$.sfScene.focus("Home");
   $.sfScene.get('Home').setCurrentServiceFocused();*/
   //$.sfScene.focus({id:"miniWidgetLoading", scope:WIDGET.id});
   //$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).isFocused = false;
   // ProcMgr.CloseWithSignIn();
   ProcMgr.returnTab();
}

SceneminiWelcome.prototype.processExitKey = function(){
    alert("SceneminiWelcome.processExitKey() ");
   // //////////////////for socialTV/////////////////////
   SocialTV.rtnCategory();
   // ProcMgr.ExitWithSignIn();
}


///////// Processing Click evnet  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////

SceneminiWelcome.prototype.processMouseOver = function(obj){
    alert("SceneminiWelcome.processMouseOver() ");
    
	var SNS_Scene = $.sfScene.get({id:WIDGET.name, scope:WIDGET.id});
	alert("tabFocus : "+SNS_Scene.tabFocus);
	if(SNS_Scene.tabFocus==true){
       // SNS_Scene.tabFocus = false;
      //  utilitySet.changeTabBGStatus(WIDGET.id, 'focus', true);
        StateMgr.Focus_Current_State();
	}
    var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
        this.highlight(obj);
    }
    
}
SceneminiWelcome.prototype.processClickEvent = function(obj){
	alert("SceneminiWelcome.processClickEvent() ");
	//add by minseok : mouse click
	var SNS_Scene = $.sfScene.get({id:WIDGET.name, scope:WIDGET.id});
	//if(SNS_Scene.moveFocusToSkype==false)	SNS_Scene.moveFocusToSkype=true;
	if(SNS_Scene.tabFocus==true){
		SNS_Scene.tabFocus=false;
		utilitySet.changeTabBGStatus(WIDGET.id,'focus',true);
	}
	
	var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }
	
	this.processEnterKey();
}

