function SceneAccountManager(options) {
	this.options = options;
    
    this.MainView=null;
	this.MainViewDim=null;
    
    this.TitleBar = null;
    
    this.ChangePwdBtn = null;   
    this.FaceRegiatrationBtn = null;  
	this.FaceInitBtn = null;  
    
    this.HelpBar = null;
	this.CloseTimer = false;
	
	this.flagResetData = false;
	this.isRegisteredFace = false;
}

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

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

	this.MainViewDim.show();
	
	if(this.flagResetData== true)
	{
		this.resetData();
	} 
	
	this.initAccountManager();
	
	this.startTimer();    
}

SceneAccountManager.prototype.handleHide = function () {
	alert("SceneAccountManager.handleHide()");
	// this function will be called when the scene manager hide this scene  
    this.MainViewDim.hide();
	
	if(this.CloseTimer == true)
	{
		this.stopTimer();
	}
}

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

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

SceneAccountManager.prototype.handleKeyDown = function (keyCode) {
	alert("SceneAccountManager.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:

			break;
		case sf.key.UP:
			this.resetTimer();
            this.processUpKey();
			break;
		case sf.key.DOWN:
            this.resetTimer();
			this.processDownKey();
			break;

		case sf.key.ENTER:
             this.processEnterKey();
			break;
            
        case sf.key.RETURN:
        case sf.key.EXIT:
            this.processReturnKey();
            sf.key.block(event);
			break;
            
        
        case 147:  //infolink
        case 261:  //contents
        case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
	}
}

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

SceneAccountManager.prototype.create = function(){
    alert("SceneAccountManager.create()");
    this.MainView = new View("AccountManager");
    this.MainView.SetBgImage(g_Image.IMAGE_ACCOUNT_MANAGER_BG);
	
	this.MainViewDim = new DimBg("AccountManagerDim", "AccountManager");
    
    this.TitleBar = new Label(null,"account_manager_title");
    this.TitleBar.SetTextStyle("account_manager_title_style");
    this.TitleBar.SetText(TV_ACCOUNT_MANAGER);
    
    var this_ = sf.scene.get("AccountManager");
	var clickCF =  function(obj){this_.processClickEvent(obj);};

    this.ChangePwdBtn = new Button();
    this.ChangePwdBtn.SetImageObjId("account_manager_change_pwd_btn");
    this.ChangePwdBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, null);
    this.ChangePwdBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_ACCOUNT_MANAGER_BTN_NORMALFOCUS);
    this.ChangePwdBtn.SetTextObjId("account_manager_change_pwd_btn_text");
    this.ChangePwdBtn.SetText(IDWS_MOIP_CHANGE_PASS);
    this.ChangePwdBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"account_manager_btn_style_nor");
    this.ChangePwdBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"account_manager_btn_style_focus");
    this.ChangePwdBtn.SetOnClickCallbackFunc(clickCF);   
    
    this.FaceRegiatrationBtn = new Button();
    this.FaceRegiatrationBtn.SetImageObjId("account_manager_face_registration_btn");
    this.FaceRegiatrationBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, null);
    this.FaceRegiatrationBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_ACCOUNT_MANAGER_BTN_NORMALFOCUS);
    this.FaceRegiatrationBtn.SetTextObjId("account_manager_face_registration_btn_text");
    this.FaceRegiatrationBtn.SetText(TV_REGISTER_FACE_BTTN);
    this.FaceRegiatrationBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"account_manager_btn_style_nor");
    this.FaceRegiatrationBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"account_manager_btn_style_focus");
    this.FaceRegiatrationBtn.SetOnClickCallbackFunc(clickCF);
    
    this.FaceInitBtn = new Button();
    this.FaceInitBtn.SetImageObjId("account_manager_face_init_btn");
    this.FaceInitBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, null);
    this.FaceInitBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_ACCOUNT_MANAGER_BTN_NORMALFOCUS);
    this.FaceInitBtn.SetTextObjId("account_manager_face_init_btn_text");
    this.FaceInitBtn.SetText(TV_REMOVE_RECOGNIZED_FACE);
    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"account_manager_btn_style_nor");
    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"account_manager_btn_style_focus");
    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"account_manager_btn_style_dim");
    this.FaceInitBtn.SetOnClickCallbackFunc(clickCF); 
    
    /*var CurLangID = ResMgr.GetCurLanguage();    
 	if(CurLangID == ENUM_TV_LANGUAGE.ARA)
 	{
	    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"account_manager_btn_style_nor_s");
	    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"account_manager_btn_style_focus_s");
	    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"account_manager_btn_style_dim_s");
   	}
   	else 
   	{
	    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"account_manager_btn_style_nor");
	    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"account_manager_btn_style_focus");
	    this.FaceInitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"account_manager_btn_style_dim");
   	}*/
   	
      
        
    this.HelpBar = new HelpBar(HelpBarIndex.ACCOUNT_MANAGER, "AccountManager");
    this.HelpBar.SetOnClickCallbackFunc(1, function(){this_.processReturnKey();});
    
    this.MainView.registHelpBar( this.HelpBar);
}

SceneAccountManager.prototype.setResetFlag= function(reset_flag){
     this.flagResetData = reset_flag;
}

SceneAccountManager.prototype.resetData = function()
{  
	this.highlight(null);
    this.flagResetData= false;	
}

SceneAccountManager.prototype.initAccountManager = function(){
	
   alert("SceneAccountManager.initOnlineStatus() ");
   
   var faceImagePath = ProcMgr.GetMyFaceImagePath();
   
   if(faceImagePath.length==0)
   {
   		this.isRegisteredFace= false;   		
   		this.FaceInitBtn.SetFlagDim(true);
   }
   else
   {
   	 	this.isRegisteredFace= true;
   	 	this.FaceInitBtn.SetFlagDim(false);
   }
   
}


SceneAccountManager.prototype.highlight=function(obj)
{
    this.MainView.setCurrenHighlight(obj);

}

SceneAccountManager.prototype.processUpKey = function(){
    alert("SceneAccountManager.processUpKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.ChangePwdBtn:
	        if(this.FaceInitBtn.GetFlagDim()==true)
	        {
	        	this.highlight( this.FaceRegiatrationBtn);
	        }
	        else
	        {
	        	this.highlight( this.FaceInitBtn);
	        }
            
            break;
			
       case this.FaceRegiatrationBtn:
            this.highlight(this.ChangePwdBtn);
            break;
            
        case this.FaceInitBtn:
            this.highlight(this.FaceRegiatrationBtn);
            break;            
    }
}

SceneAccountManager.prototype.processDownKey = function(){
    alert("SceneAccountManager.processDownKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.ChangePwdBtn:
            this.highlight( this.FaceRegiatrationBtn);
            break;
			
       case this.FaceRegiatrationBtn:
	        if(this.FaceInitBtn.GetFlagDim()==true)
	        {
	        	this.highlight(this.ChangePwdBtn);
	        }
	        else
	        {
	        	this.highlight(this.FaceInitBtn);
	        }
            
            break;
            
        case this.FaceInitBtn:
            this.highlight(this.ChangePwdBtn);
            break; 
    }
}

SceneAccountManager.prototype.processEnterKey = function(){
    alert("SceneAccountManager.processEnterKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.ChangePwdBtn:
            StateMgr.Start_Change_Password_State();
            break;
			
       case this.FaceRegiatrationBtn:
			if(this.isRegisteredFace== true)
			{
				WndMgr.ReRegistrationStepAccountManager();
			}
			else
			{
				WndMgr.SecurityConfirmStepAccountManager();
			}
			
            break;
            
        case this.FaceInitBtn:
        	WndMgr.inputPwdForInitAccountManager();
            break; 
    }
}

SceneAccountManager.prototype.processReturnKey = function(){
    alert("SceneAccountManager.processReturnKey() ");
    StateMgr.Stop_Account_Manager_State(true);

}

SceneAccountManager.prototype.startTimer = function()
{
    alert("SceneAccountManager.startTimer() ");
	
	this.CloseTimer = true;
	PluginAPIMgr.StartOSDTimer("60000" , function() { sf.scene.get('AccountManager').popupTimerCallback();}, ENUM_TIMER_TYPE.POPUP_WND);
}

SceneAccountManager.prototype.resetTimer = function()
{
    alert("SceneAccountManager.resetTimer() ");

	if(this.CloseTimer == true)
	{
		PluginAPIMgr.RestartOSDTimer("60000" ,ENUM_TIMER_TYPE.POPUP_WND);
	}
}

SceneAccountManager.prototype.stopTimer = function()
{
    alert("SceneAccountManager.stopTimer() ");
	
	this.CloseTimer = false;
	PluginAPIMgr.StopOSDTimer(ENUM_TIMER_TYPE.POPUP_WND);
}

SceneAccountManager.prototype.popupTimerCallback = function()
{
	alert("SceneAccountManager.popupTimerCallback() ");
   if(this.CloseTimer==false)
   {
   	return
   }
   this.CloseTimer = false;
   
	StateMgr.Stop_Account_Manager_State(true);
}

SceneAccountManager.prototype.processClickEvent = function(obj){
	alert("SceneAccountManager.processClickEvent() ");
	
	var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }
	
	this.processEnterKey();
}






