function SceneFaceRecogSecureComplete(options) {
	this.options = options;
    
	this.MainView=null;
	
	this.SigninTab = null;     	
    this.TitleLabel = null;   
    
    this.CalllistLine = null;
		
	this.MsgLabel = null;
	
	this.ImageBox = null;
	this.SkypeNameLabel = null;

	this.SecureCheckBox = null;
	
	this.RetryBtn = null;
	this.OkBtn = null;

	this.flagWaiting = false;
	
}

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

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

}

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

    this.enableButton();
    
}

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

}

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

SceneFaceRecogSecureComplete.prototype.handleKeyDown = function (keyCode) {
	alert("SceneFaceRecogSecureComplete.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	if(this.flagWaiting==true)
	{
		return;	
	}
	
	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:
		case sf.key.DOWN:
			this.processUpDownKey(keyCode);
			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;
	}
}

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

SceneFaceRecogSecureComplete.prototype.create = function(){
    alert("SceneFaceRecogSecureComplete.create()");
    this.MainView = new View("FaceRecogSecureComplete");
	
	this.SigninTab = new Label("face_recog_secure_complete_signin_tab",null);
	this.SigninTab.SetBgImage(g_Image.IMAGE_FACERECOGNITION_SIGNIN_TAB);
	
	this.TitleLabel = new Label(null,"face_recog_secure_complete_title");
	this.TitleLabel.SetTextStyle("face_recog_secure_complete_title_style");
    this.TitleLabel.SetText(TV_REGISTER_FACE_BTTN);
    
    this.CalllistLine = new Label("face_recog_secure_complete_callist_line",null);
	this.CalllistLine.SetBgImage(g_Image.IMAGE_FACERECOGNITION_CALLLIST_LINE);
    
    this.MsgLabel = new Label(null,"face_recog_secure_complete_msg");
    this.MsgLabel.SetTextStyle("face_recog_complete_msg_style");
    // this.MsgLabel.SetText(TV_YOUR_FACE_HAS_BEEN_REGISTERED_TO_THE_SELECTED_ACCOUNT_MSG);
    this.MsgLabel.SetText(TV_SID_SELECT_OK_TO_ADD_YOUR_FACE_MSG);
        
    this.ImageBox= new Label("face_recog_secure_complete_image_box", null);
    this.ImageBox.SetBgImage(g_Image.IMAGE_FACE_RECOG_SECURE_COMPLETE_DEFAULT_IMAGE);
    this.ImageBox.AppendFgImage("face_recog_secure_complete_image","0px","0px","250px","250px");
    
    this.SkypeNameLabel = new Label(null,"face_recog_secure_complete_skype_name");
    this.SkypeNameLabel.SetTextStyle("face_recog_secure_complete_skype_name_style");
        
    var this_ = sf.scene.get("FaceRecogSecureComplete");
    var clickCF =  function(obj){this_.processClickEvent(obj);};
    var overCF =  function(obj){this_.processMouseOverEvent(obj);};
    
    this.SecureCheckBox=new CheckBox();
    this.SecureCheckBox.SetImageObjId("face_recog_secure_complete_check_box");
    this.SecureCheckBox.SetBgImage(CBoxImgIndex.CB_NORMAL_IMG,  g_Image.IMAGE_FACE_RECOG_SECURE_COMPLETE_CHECK_BOX_NORMAL);
    this.SecureCheckBox.SetBgImage(CBoxImgIndex.CB_NORMAL_FOCUS_IMG,  g_Image.IMAGE_FACE_RECOG_SECURE_COMPLETE_CHECK_BOX_NORMALFOCUS);
    this.SecureCheckBox.SetTextObjId("face_recog_secure_complete_check_box_text");
    this.SecureCheckBox.SetText(TV_I_WANT_TO_ENTER_PASSWORD_AS_WELL_FOR_INCREASED_SECURITY_MSG);
    this.SecureCheckBox.SetTextStyle("face_recog_secure_complete_check_box_style");
    this.SecureCheckBox.AppendFgImage("face_recog_secure_complete_check_box_selected_icon","0px","0px","29px","29px");
    this.SecureCheckBox.SetFgImage(g_Image.IMAGE_FACE_RECOG_SECURE_COMPLETE_CHECK_BOX_SELECT);
    this.SecureCheckBox.SetOnClickCallbackFunc(clickCF); 
    this.SecureCheckBox.SetOnMouseOverCallbackFunc(overCF);
    
    this.RetryBtn = new Button();
    this.RetryBtn.SetImageObjId("face_recog_secure_complete_retry_btn", 30);
    this.RetryBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMAL);
    this.RetryBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMALFOCUS);		
    this.RetryBtn.SetTextObjId("face_recog_secure_complete_retry_btn_text");
    this.RetryBtn.SetText(SID_RETRY_KR_RETRY);
    this.RetryBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"face_recog_secure_complete_btn_normal_style");
    this.RetryBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"face_recog_secure_complete_btn_select_style");
    this.RetryBtn.SetOnClickCallbackFunc(clickCF); 
    this.RetryBtn.SetOnMouseOverCallbackFunc(overCF);
    
    this.OkBtn = new Button();
    this.OkBtn.SetImageObjId("face_recog_secure_complete_ok_btn", 30);
    this.OkBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMAL);
    this.OkBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMALFOCUS);		
    this.OkBtn.SetTextObjId("face_recog_secure_complete_ok_btn_text");
    this.OkBtn.SetText(SID_OK);
    this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"face_recog_secure_complete_btn_normal_style");
    this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"face_recog_secure_complete_btn_select_style");
    this.OkBtn.SetOnClickCallbackFunc(clickCF);     
    this.OkBtn.SetOnMouseOverCallbackFunc(overCF);
}

SceneFaceRecogSecureComplete.prototype.setImagePath = function(){
	alert("SceneFaceRecogSecureComplete.setImagePath() ");
	var path = RecogMgr.trainResult.imageFilePath;
    var id = RecogMgr.trainResult.detectResult;
    alert("path : "+path+", id : "+id);
    ProcMgr.SetMyFaceImagePath(path, id); 
}
SceneFaceRecogSecureComplete.prototype.updateData = function(){
    alert("SceneFaceRecogSecureComplete.updateData() ");
    this.SkypeNameLabel.SetText(PluginAPIMgr.GetMySkyeName());
	var path = RecogMgr.trainResult.imageFilePath;
    // this.ImageBox.SetFgImage("");
    this.ImageBox.SetFgImage(path+g_Data.GetImgSuffixPath());
    
    this.SecureCheckBox.SetFlagSelect(false);
}

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

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


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

SceneFaceRecogSecureComplete.prototype.processUpDownKey = function(keyCode){
    alert("SceneFaceRecogSecureComplete.processUpDownKey() ");
    var currentHighlight =  this.MainView.getCurrentHighlight();
    switch(currentHighlight)
    {
    	
    		
        case this.RetryBtn:
        	if(keyCode==sf.key.DOWN){
	           this.highlight(this.OkBtn);
        	}
           break;
            
        case this.OkBtn:
        	if(keyCode==sf.key.UP){
	           this.highlight(this.RetryBtn);
        	}
           break;         
    }
}

SceneFaceRecogSecureComplete.prototype.processEnterKey = function(){
    alert("SceneFaceRecogSecureComplete.processEnterKey() ");

    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    this.select(currentHighlight);
  
    switch(currentHighlight)
    {
    	case this.RetryBtn:
    		this.disableButton();
    		ProcMgr.RetryFaceRecogRegistration();
    		break;
        case this.OkBtn:
        	this.disableButton();
        	this.setImagePath();
        	ProcMgr.StopFaceRecogRegistration();
			ProcMgr.CompliteFaceRecogRegistration(this.SecureCheckBox.GetFlagSelect());
            break;

    }
}
//140124 update for multi tasking scenario DF140123-01771
SceneFaceRecogSecureComplete.prototype.updateButton = function(){
    alert("SceneFaceRecogSecureComplete.updateButton() ");
    var FaceEnable = true;
    var camState = PluginAPIMgr.GetCameraState();
    var currentHighlight =  this.MainView.getCurrentHighlight();
	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;
	}
	alert("SceneFaceRecogSecureComplete.updateButton():FaceEnable -> "+ FaceEnable);
	if(this.flagEnableFace===FaceEnable){
		return;		//not changed status
	}else{
		this.flagEnableFace = FaceEnable;
	}
	//if face recog is not available -> dim retry button
	if(FaceEnable===true){
		this.RetryBtn.SetFlagDim(false);
	}else{
		if(currentHighlight===this.RetryBtn){
			this.highlight(this.OkBtn);
		}
		this.RetryBtn.SetFlagDim(true);
	}
    
    
}
SceneFaceRecogSecureComplete.prototype.enableButton = function(){
    alert("SceneFaceRecogSecureComplete.enableButton() ");
	
    this.RetryBtn.SetFlagDim(false);
    this.OkBtn.SetFlagDim(false);

    this.flagWaiting = false;
}

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

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

SceneFaceRecogSecureComplete.prototype.processReturnKey = function(){
    alert("SceneFaceRecogSecureComplete.processReturnKey() ");
 	if(this.flagWaiting ==true)
    {
        return;
    }
  
    //ProcMgr.CompliteFaceRecogRegistration();
    // ProcMgr.CompliteFaceRecogRegistration(this.SecureCheckBox.GetFlagSelect());
    ProcMgr.StopFaceRecogRegistration();
    ProcMgr.ReturnToFaceRecogRegistrationCaller();
}

SceneFaceRecogSecureComplete.prototype.processClickEvent = function(obj){
	alert("SceneFaceRecogSecureComplete.processClickEvent() ");
	
	if(this.flagWaiting==true)
	{
		return;	
	}
	
	/*var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }*/
	
	this.processEnterKey();
}
SceneFaceRecogSecureComplete.prototype.processMouseOverEvent = function(obj){
	alert("SceneFaceRecogSecureComplete.processMouseOverEvent() ");
	
	if(this.flagWaiting==true)
	{
		return;	
	}
	
	var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }
	
	// this.processEnterKey();
}

