

function SceneFaceRecogRetryPopup(options) {
	this.options = options;
    
    this.MainView=null;
    this.MainViewBG=null;
	this.MainViewDim=null;
    
    this.PopupMsg = null;
    
    this.RetryBtn = null;
    this.OkBtn = null;
   
    this.CloseTimer = false;

}

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

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

    this.highlight(this.OkBtn);

	WndMgr.startPopupHideTimer(30000,this.popupTimerCallback);
    // this.startTimer();
    
}

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

	this.MainViewDim.hide();
	
	WndMgr.stopPopupHideTimer();
	// if(this.CloseTimer== true)
	// {
		// this.stopTimer();
	// }
}

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

}

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

SceneFaceRecogRetryPopup.prototype.handleKeyDown = function (keyCode) {
	alert("SceneFaceRecogRetryPopup.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:
			WndMgr.resetPopupHideTimer();
        	this.processLeftRightKey(keyCode);
			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();
            //2013 modify by minseok
            sf.key.preventDefault();
			break;
            
         case 147:  //infolink
         case 261:  //contents
         case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
	}
}

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

SceneFaceRecogRetryPopup.prototype.create = function(){
    alert("SceneFaceRecogRetryPopup.create()");
    this.MainView = new View("FaceRecogRetryPopup");
	 
	this.MainViewDim = new DimBg("FaceRecogRetryPopupDim", "FaceRecogRetryPopup");   
    
    this.MainViewBG = new View("FaceRecogRetryPopupBG");
    this.MainViewBG.CreatePopupBG(1,"FaceRecogRetryPopup_popup_BG");
    
    this.PopupMsg = new Label(null,"face_recog_retry_popup_message");
    this.PopupMsg.SetTextStyle("face_recog_retry_popup_message_style");
    this.PopupMsg.SetText(TV_FACE_NOT_REGCOGNIZED); 
    
    var this_ = sf.scene.get("FaceRecogRetryPopup");
    var clickCF =  function(obj){this_.processClickEvent(obj);};

    this.RetryBtn = new Button();
    this.RetryBtn.SetImageObjId("face_recog_retry_popup_retry_btn", 20);
    this.RetryBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
    this.RetryBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);	
    this.RetryBtn.SetTextObjId("face_recog_retry_popup_retry_btn_text");
    this.RetryBtn.SetText(SID_RETRY_KR_RETRY);
    this.RetryBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"cPopup_btn_text");
    this.RetryBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"cPopup_btn_text_high");
	this.RetryBtn.SetOnClickCallbackFunc(clickCF);
    
    this.OkBtn = new Button();
    this.OkBtn.SetImageObjId("face_recog_retry_popup_ok_btn", 20);
    this.OkBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
    this.OkBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);	
    this.OkBtn.SetTextObjId("face_recog_retry_popup_ok_btn_text");
    this.OkBtn.SetText(SID_OK);
    this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"cPopup_btn_text");
    this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"cPopup_btn_text_high");
	this.OkBtn.SetOnClickCallbackFunc(clickCF);
}

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

}

SceneFaceRecogRetryPopup.prototype.popupTimerCallback = function()
{
    alert("SceneFaceRecogRetryPopup.popupTimerCallback() ");
	
		
   ProcMgr.ReturnToFaceRecogRegistrationCaller();
}

SceneFaceRecogRetryPopup.prototype.processLeftRightKey = function(keyCode){
    alert("SceneFaceRecogRetryPopup.processLeftRightKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.RetryBtn:
        	if(keyCode==sf.key.RIGHT)
           		this.highlight(this.OkBtn);
            break;
            
        case this.OkBtn:
        	if(keyCode==sf.key.LEFT)
           		this.highlight(this.RetryBtn);
            break;
    }
}

SceneFaceRecogRetryPopup.prototype.processEnterKey = function(){
    alert("SceneFaceRecogRetryPopup.processEnterKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.RetryBtn:
			ProcMgr.RetryFaceRecogRegistration();
            break;
            
        case this.OkBtn:
		   	ProcMgr.ReturnToFaceRecogRegistrationCaller();
            break;
    }
}

SceneFaceRecogRetryPopup.prototype.processReturnKey = function(){
    alert("SceneFaceRecogRetryPopup.processReturnKey() ");
	
   	ProcMgr.ReturnToFaceRecogRegistrationCaller();
}

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

