
function SceneFaceRecogChooseAccount(options) {
	this.options = options;
    
    this.MainView=null;
    
    this.SigninTab = null;     	
    this.TitleLabel = null;     	
	this.MsgLabel = null;

	this.list = null;	
	
	this.CalllistLine = null;
	
    this.CancelBtn = null;	

    // this.DefaultHelpBar =null;

	this.ScrollBg=null;
    this.ScrollLeft=null;
    this.ScrollMiddle=null;
    this.ScrollRight=null;
    
    this.UpArrow = null;
	this.DownArrow = null; 
	
	//flag	
	this.flagWaiting = false;
	this.flagNoData = false;
	this.flagDataUpdate = false;
	this.isListFocused = true;
	
}

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

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

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

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

     var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight ==null)
    {
    	if(this.flagNoData==true){
    		this.highlight(this.CancelBtn);
    	}else{
	        this.highlight(this.list);
    	}
    }
    else
    {
         this.highlight(currentHighlight);
    }
    
    var this_ = sf.scene.get("FaceRecogChooseAccount");
  	var returnCF =  function(){this_.processReturnKey();};
    WndMgr.SetReturnIconClickCallback(returnCF);
}

SceneFaceRecogChooseAccount.prototype.handleBlur = function () {
	alert("SceneFaceRecogChooseAccount.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 !=null)
    {
    	currentHighlight.blur();
	}

	WndMgr.SetReturnIconClickCallback(null);
}
 
SceneFaceRecogChooseAccount.prototype.handleKeyDown = function (keyCode) {
	alert("SceneFaceRecogChooseAccount.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	if(this.flagWaiting==true)
	{
		return;	
	}
	if(this.isListFocused==true){
		this.list.KeyProcess(keyCode);
		return;
	}
	switch (keyCode) {
		case sf.key.LEFT:
			this.processLeftKey();
			break;
		case sf.key.RIGHT:
		case sf.key.UP:          
		case sf.key.DOWN:

			break;

		case sf.key.ENTER:
            this.processEnterKey();
			break;
		case sf.key.TOOLS:
			break; 
            
        case sf.key.RETURN:
            this.processReturnKey();
            //2013 modify by minseok
            sf.key.preventDefault();
			break;
            
        case sf.key.EXIT:
            this.processExitKey();
            //2013 modify by minseok
            sf.key.preventDefault();
			break;
		
        case 147:  //infolink
        case 261:  //contents
        case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
			
		default:
            ProcMgr.processBlockKey(keyCode);
            break;

	}
}

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

SceneFaceRecogChooseAccount.prototype.create = function(){
    alert("SceneFaceRecogChooseAccount.create()");
    this.MainView = new View("FaceRecogChooseAccount");
    
    this.SigninTab = new Label("face_recog_ChooseAccount_signin_tab",null);
    this.SigninTab.SetBgImage(g_Image.IMAGE_FACERECOGNITION_SIGNIN_TAB);
    
    this.TitleLabel = new Label(null,"face_recog_ChooseAccount_title");
    this.TitleLabel.SetTextStyle("face_recog_choose_account_title_style");
    this.TitleLabel.SetText(TV_REGISTER_FACE_BTTN);   
	
    this.MsgLabel = new Label(null,"face_recog_ChooseAccount_msg_text");    
    this.MsgLabel.SetText(TV_SELECT_YOUR_ACCOUNT_TO_ADD_THE_FACE_TO_IT+"<br/>"+TV_YOU_NEED_TO_CREATE_ACCOUNT_BEFORE_YOU_REGISTER_FACE_MSG);
    this.MsgLabel.SetTextStyle("face_recog_choose_account_msg_style");
    
    this.CalllistLine = new Label("face_recog_ChooseAccount_callist_line",null);
	this.CalllistLine.SetBgImage(g_Image.IMAGE_FACERECOGNITION_CALLLIST_LINE); 
    
	if(ResMgr.GetCurLanguage() == ENUM_TV_LANGUAGE.GRE)
	{
		$("#face_recog_registration_msg_text").css('top', "5px" );
	} 
    
    
	
	var this_ = sf.scene.get("FaceRecogChooseAccount");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	var overCF =  function(obj){this_.processMouseOverEvent(obj);};
	
	this.CancelBtn = new Button();
	this.CancelBtn.SetImageObjId("face_recog_ChooseAccount_cancel_btn", 30);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMAL);
    this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMALFOCUS);
    this.CancelBtn.SetTextObjId("face_recog_ChooseAccount_cancel_btn_text");
    this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"face_recog_choose_account_btn_normal_style");
    this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"face_recog_choose_account_btn_select_style");
    this.CancelBtn.SetText(SID_CANCEL);
    this.CancelBtn.SetOnClickCallbackFunc(clickCF);
    this.CancelBtn.SetOnMouseOverCallbackFunc(overCF);
    
	this.list = new FaceRecogList();
    this.list.Create("FaceRecogChooseAccount","FaceRecogAccountList");
    this.list.SetEventOnRightFunc(this_.leaveList);
    this.list.SetEventOnReturnFunc(this_.processReturnKey);
    this.list.SetEventOnExitFunc(this_.processExitKey);
    this.flagDataUpdate = false;

}
SceneFaceRecogChooseAccount.prototype.updateList = function(){
	alert("SceneFaceRecogChooseAccount.updateList : "+this.flagDataUpdate);
		this.list.InitData();
}
SceneFaceRecogChooseAccount.prototype.showList = function(){
	alert("SceneFaceRecogChooseAccount.showList : "+this.flagNoData);
	if(this.flagNoData==true){
		this.list.Hide();
		
	}else{
		this.list.Show();
	}
} 
SceneFaceRecogChooseAccount.prototype.leaveList = function(){
	alert("SceneFaceRecogChooseAccount.leavlist");
	var this_ = sf.scene.get("FaceRecogChooseAccount");	
	this_.isListFocused = false;
	this_.highlight(this_.CancelBtn);
}


SceneFaceRecogChooseAccount.prototype.highlight=function(obj)
{
	alert("SceneFaceRecogChooseAccount.highlight()");
	if(obj == this.list){
		this.isListFocused = true;
	}else{
		this.isListFocused = false;
	}
    this.MainView.setCurrenHighlight(obj);	
}

SceneFaceRecogChooseAccount.prototype.processEnterKey = function(){
    alert("SceneFaceRecogChooseAccount.processEnterKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();

    switch(currentHighlight)
    {
    	case this.CancelBtn:
    		this.processReturnKey();
    		//show one button popup
    		break;
    }
}
SceneFaceRecogChooseAccount.prototype.processLeftKey = function(){
    alert("SceneFaceRecogChooseAccount.processLeftKey() ");
        
    var currentHighlight =  this.MainView.getCurrentHighlight();
    if(this.flagNoData==true){
    	return;
    }
	   switch(currentHighlight)
	   {
	           
	       case this.CancelBtn:
			this.highlight(this.list);
	           break;
	           
	    }
    
}

SceneFaceRecogChooseAccount.prototype.processReturnKey = function(){
    alert("SceneFaceRecogChooseAccount.processReturnKey() ");
	WndMgr.StartOneBottonPopup(OneBtnPopupIndex.FACE_RECOG_CANCELED);
    // ProcMgr.ReturnToFaceRecogRegistrationCaller();
}

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


SceneFaceRecogChooseAccount.prototype.processClickEvent = function(obj){
	alert("SceneFaceRecogChooseAccount.processClickEvent() ");
	
	
	this.processEnterKey();
}
SceneFaceRecogChooseAccount.prototype.processMouseOverEvent = function(obj){
	alert("SceneFaceRecogChooseAccount.processMouseOverEvent() ");
	
	var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	if(obj == this.CancelBtn){
    		this.isListFocused = false;
    	}
    	this.highlight(obj);
    }
	
	// this.processEnterKey();
}

SceneFaceRecogChooseAccount.prototype.processClick = function(index){
	alert("SceneFaceRecogChooseAccount.processClick() index : "+index);
	// this.list.MoveItem(index);
	this.list.KeyProcess(sf.key.ENTER);
}
SceneFaceRecogChooseAccount.prototype.processMouseOver = function(index){
	alert("SceneFaceRecogChooseAccount.processMouseOver() index : "+index);
	this.highlight(this.list);
	this.list.MoveItem(index);
	// this.list.KeyProcess(sf.key.ENTER);
}
