function SceneFaceRecogComplete(options) {
	this.options = options;
    
	this.MainView=null;
	this.MainViewDim=null;
	
	this.MsgLabel1 = null;
	this.MsgLabel2 = null;
	
	this.ImageBox = null;

	this.StartSkypeBtn = null;

	this.flagWaiting = false;
	
	this.CloseTimer = false;
}

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

SceneFaceRecogComplete.prototype.handleShow = function () {
	alert("SceneFaceRecogComplete.handleShow()");
	// this function will be called when the scene manager show this scene 
	this.MainViewDim.show();
	this.updateData();
    this.highlight(this.StartSkypeBtn);

    this.startTimer();
}

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

    this.enableButton();
    
	if(this.CloseTimer == true)
	{
		this.stopTimer();
	}
}

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

}

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

SceneFaceRecogComplete.prototype.handleKeyDown = function (keyCode) {
	alert("SceneFaceRecogComplete.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:
			break;
		case sf.key.RIGHT:
			break;
		case sf.key.UP:

			break;
		case sf.key.DOWN:

			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;
	}
}

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

SceneFaceRecogComplete.prototype.create = function(){
    alert("SceneFaceRecogComplete.create()");
    this.MainView = new View("FaceRecogComplete");
    this.MainView.SetBgImage(g_Image.IMAGE_FACE_RECOG_COMPLETE_BG);
	
	this.MainViewDim = new DimBg("FaceRecogCompleteDim", "FaceRecogComplete");
    
    this.MsgLabel1 = new Label(null,"face_recog_complete_msg_1");
    this.MsgLabel1.SetTextStyle("face_recog_complete_msg_style");
    
    this.MsgLabel2 = new Label(null,"face_recog_complete_msg_2");
    this.MsgLabel2.SetTextStyle("face_recog_complete_msg_style");
    this.MsgLabel2.SetText(TV_GO_TO_SETTINGS_ACCOUNT_MANAGER_FACE_MSG);
    
    this.ImageBox= new Label("face_recog_complete_image_box", null);
    this.ImageBox.SetBgImage(g_Image.IMAGE_FACE_RECOG_COMPLETE_IMAGE);
    this.ImageBox.AppendFgImage("face_recog_complete_image","7px","7px","60px","60px");
    
    var this_ = sf.scene.get("FaceRecogComplete");
    var clickCF =  function(obj){this_.processClickEvent(obj);};
    
    this.StartSkypeBtn = new Button();
    this.StartSkypeBtn.SetImageObjId("face_recog_complete_start_skype_btn");
    this.StartSkypeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_FACE_RECOG_COMPLETE_BTN_NORMAL);
    this.StartSkypeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_FACE_RECOG_COMPLETE_BTN_NORMALFOCUS);		
    this.StartSkypeBtn.SetTextObjId("face_recog_complete_start_skype_btn_text");
    this.StartSkypeBtn.SetText(TV_SID_CONTINUE_VOICE_KR_CONTINUE);
    this.StartSkypeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"face_recog_complete_msg_style");
    this.StartSkypeBtn.SetOnClickCallbackFunc(clickCF);     
}

SceneFaceRecogComplete.prototype.updateData = function(){
    alert("SceneFaceRecogComplete.updateData() ");
    this.MsgLabel1.SetText(g_Data.CombinateStrings(TV_MIX_THE_FACE_REGISTERED_TO_ACCOUNT, g_Data.GetFaceRecogCompleteSkypeName()));

    this.ImageBox.SetFgImage("");
    this.ImageBox.SetFgImage(ProcMgr.GetMyFaceImagePath()+g_Data.GetImgSuffixPath());
}

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

SceneFaceRecogComplete.prototype.processEnterKey = function(){
    alert("SceneFaceRecogComplete.processEnterKey() ");
    if(this.flagWaiting ==true)
    {
        return;
    }
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
  
    switch(currentHighlight)
    {
        case this.StartSkypeBtn:
        	this.disableButton();
			ProcMgr.CompliteFaceRecogRegistration();
            break;

    }
}

SceneFaceRecogComplete.prototype.enableButton = function(){
    alert("SceneFaceRecogComplete.enableButton() ");
	
    this.StartSkypeBtn.SetFlagDim(false);

    this.flagWaiting = false;
}

SceneFaceRecogComplete.prototype.disableButton = function(){
    alert("SceneFaceRecogComplete.disableButton() ");
	if(this.CloseTimer == true)
	{
		this.stopTimer();
	}
	
    this.flagWaiting = true;

    var currentHighlight =  this.MainView.getCurrentHighlight();
    currentHighlight.blur();
    
    this.StartSkypeBtn.SetFlagDim(true); 
}

SceneFaceRecogComplete.prototype.processReturnKey = function(){
    alert("SceneFaceRecogComplete.processReturnKey() ");
 	if(this.flagWaiting ==true)
    {
        return;
    }
  
    ProcMgr.CompliteFaceRecogRegistration();
}

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

SceneFaceRecogComplete.prototype.resetTimer = function()
{
    alert("SceneFaceRecogComplete.resetTimer() ");
	
	if(this.CloseTimer == true)
	{
		PluginAPIMgr.RestartOSDTimer("10000" ,ENUM_TIMER_TYPE.POPUP_WND);
	}
}

SceneFaceRecogComplete.prototype.stopTimer = function()
{
    alert("SceneFaceRecogComplete.stopTimer() ");

	this.CloseTimer = false;
	PluginAPIMgr.StopOSDTimer(ENUM_TIMER_TYPE.POPUP_WND); 
}

SceneFaceRecogComplete.prototype.popupTimerCallback = function()
{
    alert("SceneFaceRecogComplete.popupTimerCallback() ");
	
	if (this.CloseTimer == false)
	{
		return;
	}
	this.CloseTimer = false;	
		
	ProcMgr.CompliteFaceRecogRegistration();
}

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

