
function SceneSignin(options) {
	this.options = options;
    
    this.InitFlag = true;
    this.destroyFlag = true;
    
    this.MainView=null;
    
    this.TitleLabel = null;     

    this.SkypeNameLabel = null;
    this.PasswordLabel = null;

    this.SkypeNameBtn = null;
    this.PasswordBtn = null;
    
    this.SigninBtn = null;
    
    this.ArrowBtn = null;
    this.QuestionBtn = null;

    this.AutoLoginCheckBox = null;
    this.AutoStartCheckBox = null;
    
    this.DefaultHelpBar =null;
    this.InputHelpBar =null;
    
    //2012 add by minseok
    this.SigninTabBtn = null;
    this.SigninTabFaceRecLabel = null;
    this.LoginMessage = null;
    this.FaceRecogMouseBtn = null;
    this.IDPWMouseBtn = null;
    
    this.FaceRecogEnableFlag = true;
}

SceneSignin.prototype.initialize = function () {
	alert("SceneSignin.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
   
   	// PluginAPIMgr.RecognitionPluginAvailable=false;	//not support
    this.create();
    
}

SceneSignin.prototype.handleShow = function () {
	alert("SceneSignin.handleShow()");
	// this function will be called when the scene manager show this scene 
    if(this.InitFlag == true)
    {
        this.initSignin();
    }
    
    this.ToggleFaceRecogEnable();
}

SceneSignin.prototype.handleHide = function () {
	alert("SceneSignin.handleHide()");
	// this function will be called when the scene manager hide this scene  
    

}

SceneSignin.prototype.handleFocus = function () {
	alert("SceneSignin.handleFocus()");
	// this function will be called when the scene manager focus this scene
    var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight ==null)
    {
        this.highlight(this.SkypeNameBtn);
    }
    else
    {
         this.highlight(currentHighlight);
    }
    
    var this_ = sf.scene.get("Signin");
  	var returnCF =  function(){this_.processReturnKey();};
    WndMgr.SetReturnIconClickCallback(returnCF);
}

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

	WndMgr.SetReturnIconClickCallback(null);
}

SceneSignin.prototype.handleKeyDown = function (keyCode) {
	alert("SceneSignin.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	switch (keyCode) {
		case sf.key.LEFT:
		case sf.key.RIGHT:
            this.processLeftRightKey(keyCode);
			break;
		case sf.key.UP:
            this.processUpKey();
			break;
		case sf.key.DOWN:
            this.processDownKey();
			break;

		case sf.key.ENTER:
            this.processEnterKey();
			break;
        
		case sf.key.TOOLS:
            this.processToolsKey();
			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
            ProcMgr.processInfolinkKey(); 
			break;
			
		default:
            ProcMgr.processBlockKey(keyCode);
            break;

	}
}

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

SceneSignin.prototype.create = function(){
    alert("SceneSignin.create()");
    this.MainView = new View("Signin");
    // this.MainView.SetBgImage(g_Image.IMAGE_SIGNIN_BG);
    
    this.SigninTabFaceRecLabel = new Label(null,"signin_tab_facerec_text");
    this.SigninTabFaceRecLabel.SetTextStyle("signin_tab_text_style");
    this.SigninTabFaceRecLabel.SetText(SID_VOICE_FACE_RECOGNITION); 
    
    this.TitleLabel = new Label(null,"signin_title");
    this.TitleLabel.SetTextStyle("signin_title_style");
    // this.TitleLabel.SetText(IDWS_MOIP_WELCOM_TO_SKYPE);    
    this.TitleLabel.SetText(IDWS_MOIP_LOGIN);    

    this.SkypeNameLabel = new Label(null,"signin_skype_name");
    this.SkypeNameLabel.SetTextStyle("signin_text_style");
    this.SkypeNameLabel.SetText(IDWS_MOIP_SKYPE_NAME);

	this.LoginMessage = new Label(null,"signin_login_message");
	this.LoginMessage.SetTextStyle("signin_login_text_style");
    this.LoginMessage.SetText(TV_SID_SKYPE_SIGN_IN_MSG); 

    this.PasswordLabel = new Label(null,"signin_password");
    this.PasswordLabel.SetTextStyle("signin_text_style");
    this.PasswordLabel.SetText(SID_PASSWORD);

    //140227  DF140221-05621
    if(ResMgr.isReverseLanguage()===true){
    	alert("reverse!!!");
    	$("#signin_skype_name").css("text-align","right");
    	$("#signin_password").css("text-align","right");
    }else{
    	$("#signin_skype_name").css("text-align","left");
    	$("#signin_password").css("text-align","left");
    }

	var this_ = sf.scene.get("Signin");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	var overCF =  function(obj){this_.processMouseOverEvent(obj);};
	
	this.SigninTabBtn = new Button();
	this.SigninTabBtn.SetImageObjId("signin_tab");
	this.SigninTabBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_LOGIN_TAB_BG);
	this.SigninTabBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LOGIN_TAB_HIGHLIGHT_BG);
	this.SigninTabBtn.SetTextObjId("signin_tab_text");
	this.SigninTabBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"signin_tab_text_style");
	this.SigninTabBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"signin_tab_text_highlight_style");
	this.SigninTabBtn.SetText(TV_ID_PASSWORD_MENU);
	
    this.SkypeNameBtn= new Button();
    this.SkypeNameBtn.SetImageObjId("signin_skype_name_btn", 30);
    this.SkypeNameBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_INPUT_BTN_NORMAL);
    this.SkypeNameBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_INPUT_BTN_NORMALFOCUS);
    this.SkypeNameBtn.SetTextObjId("signin_skype_name_btn_text");
    this.SkypeNameBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"signin_input_btn_style");
   //2013 add by minseok
    this.SkypeNameBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"signin_input_btn_select_style");
    this.SkypeNameBtn.SetMaxStringLength(32);
    this.SkypeNameBtn.SetMinStringLength(6);
    this.SkypeNameBtn.SetIsPlainText(true);
    this.SkypeNameBtn.SetFlagBlockSpace(true);
	this.SkypeNameBtn.SetFlagIdType(true);
    this.SkypeNameBtn.SetOnTextChangeFunc(function(){ this_.invalidSkypeName();});
    // this.SkypeNameBtn.SetHelpText(IDWS_MOIP_PRESS_ENTER, "signin_input_btn_help_style");
    this.SkypeNameBtn.SetTextEditorInfo(IDWS_MOIP_SKYPE_NAME, SIGN_IN_KEYPAD_HELP_ENTER_SKYPE_NAME);
    this.SkypeNameBtn.SetOnClickCallbackFunc(clickCF);
    this.SkypeNameBtn.SetOnMouseOverCallbackFunc(overCF);

    this.PasswordBtn= new Button();
    this.PasswordBtn.SetImageObjId("signin_password_btn", 30);
    this.PasswordBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_INPUT_BTN_NORMAL);
    this.PasswordBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_INPUT_BTN_NORMALFOCUS);
    this.PasswordBtn.SetTextObjId("signin_password_btn_text", true);
    this.PasswordBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"signin_input_btn_style");
    this.PasswordBtn.SetMaxStringLength(20);//(20);
    this.PasswordBtn.SetMinStringLength(6);
    this.PasswordBtn.SetIsPlainText(true);
    this.PasswordBtn.SetOnTextChangeFunc(function(){ this_.invalidPassword();});
    // this.PasswordBtn.SetHelpText(IDWS_MOIP_PRESS_ENTER, "signin_input_btn_help_style");
    this.PasswordBtn.SetTextEditorInfo(SID_PASSWORD, SIGN_IN_KEYPAD_HELP_ENTER_PASSWORD);
    this.PasswordBtn.SetOnClickCallbackFunc(clickCF);
    this.PasswordBtn.SetOnMouseOverCallbackFunc(overCF);
    
    this.SigninBtn= new Button();
    this.SigninBtn.SetImageObjId("signin_btn", 30);
    this.SigninBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMAL);
    this.SigninBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMALFOCUS);
    this.SigninBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_SIGNIN_BTN_DIM);
    this.SigninBtn.SetTextObjId("signin_btn_text");
    this.SigninBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"signin_btn_normal_style");
	this.SigninBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"signin_btn_select_style");
    this.SigninBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"signin_btn_dim_style");
    this.SigninBtn.SetText(IDWS_MOIP_SKYPE_SIGNIN);
    this.SigninBtn.SetOnClickCallbackFunc(clickCF);
    this.SigninBtn.SetOnMouseOverCallbackFunc(overCF);
    

    this.AutoLoginCheckBox=new CheckBox();
    this.AutoLoginCheckBox.SetImageObjId("signin_auto_login_check_box");
    this.AutoLoginCheckBox.SetBgImage(CBoxImgIndex.CB_NORMAL_IMG,  g_Image.IMAGE_SIGNIN_CHECK_BOX_NORMAL);
    this.AutoLoginCheckBox.SetBgImage(CBoxImgIndex.CB_NORMAL_FOCUS_IMG,  g_Image.IMAGE_SIGNIN_CHECK_BOX_NORMALFOCUS);
    this.AutoLoginCheckBox.SetTextObjId("signin_auto_login_check_box_text");
    this.AutoLoginCheckBox.SetText(IDWS_MOIP_SKYPE_SIGN_ME_IN_WHEN_SKYPE_STARTS);
    this.AutoLoginCheckBox.SetTextStyle("signin_check_box_style");
    this.AutoLoginCheckBox.AppendFgImage("signin_auto_login_check_box_selected_icon","0px","0px","29px","29px");
    this.AutoLoginCheckBox.SetFgImage(g_Image.IMAGE_SIGNIN_CHECK_BOX_SELECTED);
    this.AutoLoginCheckBox.SetOnClickCallbackFunc(clickCF); 
    this.AutoLoginCheckBox.SetOnMouseOverCallbackFunc(overCF);

    this.AutoStartCheckBox=new CheckBox();
    this.AutoStartCheckBox.SetImageObjId("signin_auto_start_check_box");
    this.AutoStartCheckBox.SetBgImage(CBoxImgIndex.CB_NORMAL_IMG,  g_Image.IMAGE_SIGNIN_CHECK_BOX_NORMAL);
    this.AutoStartCheckBox.SetBgImage(CBoxImgIndex.CB_NORMAL_FOCUS_IMG,  g_Image.IMAGE_SIGNIN_CHECK_BOX_NORMALFOCUS);
    this.AutoStartCheckBox.SetBgImage(CBoxImgIndex.CB_DIM_IMG,  g_Image.IMAGE_SIGNIN_CHECK_BOX_DIM);
    this.AutoStartCheckBox.SetTextObjId("signin_auto_start_check_box_text");
    this.AutoStartCheckBox.SetText(TV_SID_SIGN_ME_IN_WHEN_THE_TV_POWER_ON);
    this.AutoStartCheckBox.SetTextStyle("signin_check_box_style"); 
	this.AutoStartCheckBox.SetTextDimStyle("signin_check_box_dim_style");
    this.AutoStartCheckBox.AppendFgImage("signin_auto_start_check_box_selected_icon","0px","0px","29px","29px");
    this.AutoStartCheckBox.SetFgImage(g_Image.IMAGE_SIGNIN_CHECK_BOX_SELECTED);
    this.AutoStartCheckBox.SetFlagSelect(false);
    this.AutoStartCheckBox.SetOnClickCallbackFunc(clickCF); 
    this.AutoStartCheckBox.SetOnMouseOverCallbackFunc(overCF);
    
    this.ArrowBtn= new Button();
    this.ArrowBtn.SetImageObjId("signin_arrow_btn");
    this.ArrowBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_ARROW_BTN_NORMAL);
    this.ArrowBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_ARROW_BTN_NORMALFOCUS);
    this.ArrowBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_SIGNIN_ARROW_BTN_DIM);
    this.ArrowBtn.SetOnClickCallbackFunc(clickCF);
    this.ArrowBtn.SetOnMouseOverCallbackFunc(overCF);
    
    this.QuestionBtn= new Button();
    this.QuestionBtn.SetImageObjId("signin_question_btn");
    this.QuestionBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_QUESTION_BTN_NORMAL);
    this.QuestionBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_QUESTION_BTN_NORMALFOCUS);
    this.QuestionBtn.SetOnClickCallbackFunc(clickCF);
    this.QuestionBtn.SetOnMouseOverCallbackFunc(overCF);


	this.FaceRecogMouseBtn = new Button();
	this.FaceRecogMouseBtn.SetImageObjId("signin_dummy_face_recog_btn");
	this.FaceRecogMouseBtn.SetOnClickCallbackFunc(clickCF);
	this.FaceRecogMouseBtn.SetOnMouseOverCallbackFunc(overCF);
	
	this.IDPWMouseBtn = new Button();
	this.IDPWMouseBtn.SetImageObjId("signin_dummy_id_password_btn");
	this.IDPWMouseBtn.SetOnClickCallbackFunc(clickCF);
	this.IDPWMouseBtn.SetOnMouseOverCallbackFunc(overCF);
}

SceneSignin.prototype.setInitFlag= function(init_flag){
     this.InitFlag = init_flag;
}

SceneSignin.prototype.setDestroyFlag= function(destroy_flag){
     this.destroyFlag = destroy_flag;
}
SceneSignin.prototype.getDestroyFlag= function(destroy_flag){
     return this.destroyFlag;
}

SceneSignin.prototype.initSignin = function()
{
	alert("SceneSignin.initSignin()")
    var last_id =PluginAPIMgr.GetLastLoginID(0);
    if(last_id.length>0)
    {
        this.SkypeNameBtn.SetText( last_id);
        this.ArrowBtn.SetFlagDim(false);
    }
    else
    {
        this.SkypeNameBtn.SetText( "");
        this.ArrowBtn.SetFlagDim(true);
    }
    
    this.PasswordBtn.SetText("");

     var is_auto_signin = PluginAPIMgr.IsAutoSignInSet();
     this.AutoLoginCheckBox.SetFlagSelect(is_auto_signin);
	  
     if(is_auto_signin == false)
     {
        PluginAPIMgr.SetAutoStart(false); 
        this.AutoStartCheckBox.SetFlagDim(true);
     }
     else
     {
        if( this.AutoStartCheckBox.GetFlagDim() ==true)
        {
            this.AutoStartCheckBox.SetFlagDim(false);
        }
		
		var is_auto_start =PluginAPIMgr.IsAutoStartSet();
		this.AutoStartCheckBox.SetFlagSelect(is_auto_start);
     }
    
	this.highlight(null);
    this.InitFlag = false;
    
    if(this.destroyFlag == true)
    {      
        this.destroyFlag= false;
    }
    //test
    this.SigninBtn.SetFlagDim(true);
    
}


SceneSignin.prototype.ToggleFaceRecogEnable = function(){
	var FaceEnable = true;
	var currentHighlight =  this.MainView.getCurrentHighlight();
	
	var camState = PluginAPIMgr.GetCameraState();
	if(camState ==  ENUM_CAM_STATE.CAM_STATE_READY || camState == ENUM_CAM_STATE.CAM_STATE_PLAYING)
	{
		if(PluginAPIMgr.RecognitionPluginAvailable== false)
		{
			FaceEnable = false;
		}
		else
		{
			FaceEnable = true;
		}
	}
	else
	{
		FaceEnable = false;
	}
	if(ProcMgr.IsDualViewMode()==true){
		FaceEnable = false;
	}
	alert("SceneSignin.ToggleFaceRecogEnable() -> "+ FaceEnable);
	
	if(this.FaceRecogEnableFlag == FaceEnable )
	{
		return;
	}
	else
	{
		if(FaceEnable==false)
		{
			this.SigninTabFaceRecLabel.hiddenObj();
			this.SigninTabBtn.hiddenObj();
			this.FaceRecogMouseBtn.hiddenObj();
			this.IDPWMouseBtn.hiddenObj();
			//reset highlight
			if(currentHighlight===this.SigninTabBtn){
				this.highlight(this.SkypeNameBtn);
			}
			//140121 change text
			this.LoginMessage.SetText(TV_SID_ENTER_SKYPE_INFO_MSG);
			
		}
		else
		{
			this.SigninTabFaceRecLabel.visibleObj();
			this.SigninTabBtn.visibleObj();
			this.FaceRecogMouseBtn.visibleObj();
			this.IDPWMouseBtn.visibleObj();
			//140121 change text
			this.LoginMessage.SetText(TV_SID_SKYPE_SIGN_IN_MSG);
		}
	}
	
	this.FaceRecogEnableFlag = FaceEnable;
}

SceneSignin.prototype.requestSignin = function(){
    alert("SceneSignin.requestSignin() ");
    if(this.invalidEmainID()==true){
	ProcMgr.Signin(this.SkypeNameBtn.GetText(), this.PasswordBtn.GetText(), this.AutoLoginCheckBox.GetFlagSelect());
    PluginAPIMgr.SetAutoStart(this.AutoStartCheckBox.GetFlagSelect());    
    }else{
    	//prevent msa login
    	StateMgr.Start_Guide_Page_State(GUIDEPAGE_TYPE.SIGNIN_WITH_EMAIL);
    }
}

SceneSignin.prototype.invalidEmainID = function(){
	alert("SceneSignin.invalidEmainID() ");
	var skypeName = this.SkypeNameBtn.GetText();
	if(PluginAPIMgr.IsValidEmail(skypeName)==true){
		return false;
	}else{
		return true;
	}
}

SceneSignin.prototype.startTextInput = function(){
    alert("SceneSignin.startTextInput() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.SkypeNameBtn:
        case this.PasswordBtn:
        
             WndMgr.StartTextEditor(currentHighlight, "Signin", null);
            break;            
    }    
}

SceneSignin.prototype.toggleAutoLoginCheckBox = function(){
    alert("SceneSignin.toggleAutoLoginCheckBox() ");
    
	PluginAPIMgr.SetAutoSignIn(this.AutoLoginCheckBox.GetFlagSelect());
	
	var auto_login_set =  this.AutoLoginCheckBox.GetFlagSelect();
	 
	if(auto_login_set == false)
	{
	    PluginAPIMgr.SetAutoStart(false); 
	    this.AutoStartCheckBox.SetFlagDim(true);
	}
	else
	{
	    if( this.AutoStartCheckBox.GetFlagDim() ==true)
	    {
	        this.AutoStartCheckBox.SetFlagDim(false);
	 	}             
	}  
}

SceneSignin.prototype.toggleAutoStartCheckBox = function(){
    alert("SceneSignin.toggleAutoStartCheckBox() ");
    
    PluginAPIMgr.SetAutoStart(this.AutoStartCheckBox.GetFlagSelect()); 
}


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

SceneSignin.prototype.select=function(obj)
{
     this.MainView.setCurrentSelect(obj);
}

SceneSignin.prototype.processLeftRightKey = function(keyCode){
    alert("SceneSignin.processLeftRightKey() ");
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {  
    	case this.SigninTabBtn:
    		if(keyCode == sf.key.RIGHT){		//start face recognition
    			if(this.FaceRecogEnableFlag == true)
    			{
    				ProcMgr.StartFaceRecogSignin();
    			}			
			}
    		break;
        case this.SkypeNameBtn:
			if(keyCode == sf.key.RIGHT && this.ArrowBtn.GetFlagDim() ==false)
			{
				this.highlight(this.ArrowBtn);
			}
            break;
            
        case this.PasswordBtn:
			if(keyCode == sf.key.RIGHT){
				this.highlight(this.QuestionBtn);
			}
            break;
            
        case this.ArrowBtn:
			if(keyCode == sf.key.LEFT){
				this.highlight(this.SkypeNameBtn);
			}
            break;
            
        case this.QuestionBtn:
			if(keyCode == sf.key.LEFT){
				this.highlight(this.PasswordBtn);
			}
            break;
            
    }
}

SceneSignin.prototype.processDownKey = function(){
    alert("SceneSignin.processDownKey() ");
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
    	case this.SigninTabBtn:
    		var input_text = this.SkypeNameBtn.GetText();
    		if(input_text.length>0){
    			this.highlight(this.PasswordBtn);
    		}else{
				this.highlight(this.SkypeNameBtn);            
    		}
            break;
        case this.SkypeNameBtn:
            this.processDownAtSkypeNameBtn();
            break;
            
        case this.PasswordBtn:
             if( this.SigninBtn.GetFlagDim() == false)
            {
                this.highlight(this.SigninBtn);
            }
            else
            {
            	this.highlight(this.AutoLoginCheckBox);
            }
            
            break;
            
        case this.ArrowBtn:
            this.highlight(this.PasswordBtn);
            break;
            
        case this.QuestionBtn:
             if( this.SigninBtn.GetFlagDim() == false)
            {
                this.highlight(this.SigninBtn);
            }
            else
            {
            	this.highlight(this.AutoLoginCheckBox);
                 
            }
            
            break;

        case this.SigninBtn:
            this.highlight(this.AutoLoginCheckBox);
            break;
            
            
        case this.AutoLoginCheckBox:
           if( this.AutoStartCheckBox.GetFlagDim() == false)
           {
                this.highlight(this.AutoStartCheckBox);
           }
            break;
            
        case this.AutoStartCheckBox:
            //this.highlight(this.SkypeNameBtn);
            break;
    }

}

SceneSignin.prototype.processUpKey = function(){
    alert("SceneSignin.processUpKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
       	case this.ArrowBtn:
        case this.SkypeNameBtn:
        	if(this.SigninTabBtn.GetFlagVisible()){
				this.highlight(this.SigninTabBtn);            
        	}
            break;
            
        case this.PasswordBtn:
            this.highlight(this.SkypeNameBtn);
            break;
            
            
        case this.QuestionBtn:
            this.highlight(this.SkypeNameBtn);
            break;

        case this.SigninBtn:
            this.highlight(this.PasswordBtn);
            break;
		
            
        case this.AutoLoginCheckBox:
            if( this.SigninBtn.GetFlagDim() == false)
            {
                this.highlight(this.SigninBtn);
            }
            else
            {
            	this.highlight(this.PasswordBtn);
                 
            }
            
            break;
            
        case this.AutoStartCheckBox:
            this.highlight(this.AutoLoginCheckBox);
            break;
    }
}

SceneSignin.prototype.processEnterKey = function(){
    alert("SceneSignin.processEnterKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    this.select(currentHighlight);
     
    switch(currentHighlight)
    {
    	case this.SigninTabBtn:
			this.processDownKey();            
            break;
        case this.SkypeNameBtn:
        case this.PasswordBtn:
        	this.startTextInput();
            break;
            
        case this.ArrowBtn:
            this.ToggleLastLoginIdList();
            break;
            
        case this.QuestionBtn:
            StateMgr.Start_Forgot_Pwd_State();
            break;

        case this.SigninBtn:
			this.requestSignin();			
            break;
                 
        case this.AutoLoginCheckBox:
			this.toggleAutoLoginCheckBox();			 
            break;
            
       case this.AutoStartCheckBox:
	   		this.toggleAutoStartCheckBox();	            
            break;
    }
}


SceneSignin.prototype.processReturnKey = function(){
    alert("SceneSignin.processReturnKey() ");
   
    StateMgr.Start_Welcome_State();
}

SceneSignin.prototype.processExitKey = function(){
    alert("SceneSignin.processExitKey() ");
   
   ProcMgr.ExitWithSignIn();
}

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

SceneSignin.prototype.invalidSkypeName = function(){
    alert("SceneSignin.invalidSkypeName() ");
    if(this.InitFlag ==true)
    {
        return;
    }

    this.checkSigninBtnEnable();
    
    var inputText = this.SkypeNameBtn.GetText();
    
    if(inputText.length > 0)
    {
        this.highlight(this.PasswordBtn);
    } 

}

SceneSignin.prototype.invalidPassword = function(){
    alert("SceneSignin.invalidPassword() ");
     if(this.InitFlag ==true)
    {
        return;
    }
    
     this.checkSigninBtnEnable();
    
    var PWDInputText = this.PasswordBtn.GetText();
    
     if(PWDInputText.length > 0)
    {
        var inputText = this.SkypeNameBtn.GetText();
        if( inputText.length > 0)
        {
            this.highlight(this.SigninBtn);
        }
        else
        {
            this.highlight(this.SkypeNameBtn);
        }
    }
}

SceneSignin.prototype.checkSigninBtnEnable = function(){
    var SkypeNameInputText = this.SkypeNameBtn.GetText();
    var PWDInputText = this.PasswordBtn.GetText();
    
    if(SkypeNameInputText.length > 0 && PWDInputText.length >0)
    {
         alert("SceneSignin.checkSigninBtnEnable()  : false");
        this.SigninBtn.SetFlagDim(false);
    }
    else
    {
        alert("SceneSignin.checkSigninBtnEnable()  : true");
        this.SigninBtn.SetFlagDim(true);
        
    }

}

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

SceneSignin.prototype.InputPWDAgain = function()
{
    alert("SceneSignin.InputPWDAgain() ");
   
    this.highlight(this.PasswordBtn);
    this.PasswordBtn.SetText("");
   	//sf.scene.focus('Signin');
}

SceneSignin.prototype.processToolsKey = function()
{

}

SceneSignin.prototype.ToggleLastLoginIdList = function()
{
	var scene = sf.scene.get("LastLoginIdList");	

	if(scene.ShowState()){
		sf.scene.hide('LastLoginIdList');
	}
	else {	
		sf.scene.get('LastLoginIdList').setCallerScene("Signin");	
		sf.scene.show('LastLoginIdList');		
		sf.scene.focus('LastLoginIdList');
	}	
}

SceneSignin.prototype.processDownAtSkypeNameBtn = function(){

	var scene = sf.scene.get("LastLoginIdList");
	if(scene.ShowState()){
		sf.scene.focus('LastLoginIdList');
	}
	else {
		this.highlight(this.PasswordBtn);
	}
}


SceneSignin.prototype.SetSkypeNameFromLoginIdList = function(s_skype_name)
{
    alert("SceneSignin.SetSkypeNameFromLoginIdList() ");
   
   //2013 add by minseok
    // this.PasswordBtn.SetText("");
    this.SkypeNameBtn.SetText(s_skype_name);
   	sf.scene.focus('Signin');
}

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


SceneSignin.prototype.processClickEvent = function(obj){
	alert("SceneSignin.processClickEvent() ");
	
	var currentHighlight =  this.MainView.getCurrentHighlight();
	if(obj==this.FaceRecogMouseBtn || obj==this.IDPWMouseBtn){
		this.highlight(this.SigninTabBtn);
		if(obj==this.FaceRecogMouseBtn){
			this.processLeftRightKey(sf.key.RIGHT);
		}
		return;
	}
    /*if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }*/
    
	var scene = sf.scene.get("LastLoginIdList");	

	if(scene.ShowState()){
		sf.scene.hide('LastLoginIdList');
	}
	
	this.processEnterKey();
}
SceneSignin.prototype.processMouseOverEvent = function(obj){
	alert("SceneSignin.processMouseOverEvent() ");
	var currentHighlight =  this.MainView.getCurrentHighlight();
   	if(obj==this.IDPWMouseBtn){
   		if(this.SigninTabBtn.GetFlagVisible()){
			this.highlight(this.SigninTabBtn);
			return;            
       	}
   	}else if(obj==this.FaceRecogMouseBtn){
   		if(this.SigninTabBtn.GetFlagVisible()){
   			var image_layer = this.SigninTabBtn.GetBGLayer();
   			if(currentHighlight==this.SigninTabBtn){
   				image_layer.SetBgImage(g_Image.IMAGE_LOGIN_TAB_HIGHLIGHT_OVER_BG);
   			}else{
    			image_layer.SetBgImage(g_Image.IMAGE_LOGIN_TAB_OVER_BG);
   			}
			return;            
       	}
   	}else{
   		if(this.SigninTabBtn.GetFlagVisible()){
   			this.SigninTabBtn.GetBGLayer().SetBgImage(g_Image.IMAGE_LOGIN_TAB_BG);
       	}
   	}
    if(currentHighlight != obj)
    {
    	if(obj.GetFlagDim()==true){
    		return;
    	}
    	this.highlight(obj);
    }
    
}
SceneSignin.prototype.hideTabOverImage = function(){
	alert("SceneSignin.hideTabOverImage() ");
	var currentHighlight =  this.MainView.getCurrentHighlight();
	switch(currentHighlight){
		case this.SigninTabBtn:
			this.highlight(this.SigninTabBtn);
			break;
		default:
			if(this.SigninTabBtn.GetFlagVisible()){
   				this.SigninTabBtn.GetBGLayer().SetBgImage(g_Image.IMAGE_LOGIN_TAB_BG);
       		}
			break;
	}
}


