function SceneFaceRecogRegistration(options) {
	this.options = options;
    
    this.MainView=null;
    
    this.SigninTab = null;     	
    this.TitleLabel = null;     	
	this.MsgLabel = null;
	
	this.BoxLabel = null;
	
	this.CalllistLine = null;
	
    this.TakePicBtn = null;
    this.StopBtn = null;	//not use
    this.RetryBtn = null;	//not use
    this.CancelBtn = null;	

    // this.DefaultHelpBar =null;

	//flag	
	this.flagWaiting = false;
	this.flagCameraStarting = false;
	
	this.flagStartRecog = false;
	/*for testing*/
	this.cameraflag = true;
}

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

SceneFaceRecogRegistration.prototype.handleShow = function () {
	alert("SceneFaceRecogRegistration.handleShow()");
	// this function will be called when the scene manager show this scene 
	this.changeBG(true);
	this.initFaceRecogRegistration();
}

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

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

    var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight ==null)
    {
        this.highlight(this.TakePicBtn);
    }
    else
    {
         this.highlight(currentHighlight);
    }
    
    var this_ = sf.scene.get("FaceRecogRegistration");
  	var returnCF =  function(){this_.processReturnKey();};
    WndMgr.SetReturnIconClickCallback(returnCF);
}

SceneFaceRecogRegistration.prototype.handleBlur = function () {
	alert("SceneFaceRecogRegistration.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);
}
 
SceneFaceRecogRegistration.prototype.handleKeyDown = function (keyCode) {
	alert("SceneFaceRecogRegistration.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;	
	}
	
	switch (keyCode) {
		case sf.key.LEFT:
		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;

	}
}

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

SceneFaceRecogRegistration.prototype.create = function(){
    alert("SceneFaceRecogRegistration.create()");
    this.MainView = new View("FaceRecogRegistration");
    
    this.SigninTab = new Label("face_recog_registration_signin_tab",null);
    this.SigninTab.SetBgImage(g_Image.IMAGE_FACERECOGNITION_SIGNIN_TAB);
    
    this.TitleLabel = new Label(null,"face_recog_registration_title");
    this.TitleLabel.SetTextStyle("face_recog_registration_title_style");
    this.TitleLabel.SetText(TV_REGISTER_FACE_BTTN);   
	
    this.MsgLabel = new Label(null,"face_recog_registration_msg_text");    
    this.MsgLabel.SetText(TV_SID_TURN_TOWARDS_THE_TV_FACE_WITHIN_CIRCLE);
    this.MsgLabel.SetTextStyle("face_recog_registration_msg_style");
    
    this.CalllistLine = new Label("face_recog_registration_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" );
	} */
    
    this.BoxLabel = new Label("face_recog_registration_box",null);    
    this.BoxLabel.SetBgImage(g_Image.IMAGE_FACE_RECOG_REGISTRATION_BOX_RED);
	
	var this_ = sf.scene.get("FaceRecogRegistration");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	var overCF =  function(obj){this_.processMouseOverEvent(obj);};
	
	this.TakePicBtn = new Button();
	this.TakePicBtn.SetImageObjId("face_recog_registration_takepic_btn", 30);
	this.TakePicBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMAL);
    this.TakePicBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_SIGNIN_BTN_NORMALFOCUS);
    this.TakePicBtn.SetTextObjId("face_recog_registration_takepic_btn_text");
    this.TakePicBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"face_recog_registration_btn_normal_style");
    this.TakePicBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"face_recog_registration_btn_select_style");
    this.TakePicBtn.SetText(TV_TAKE_PICTURE_BTTN);
    this.TakePicBtn.SetOnClickCallbackFunc(clickCF);
    this.TakePicBtn.SetOnMouseOverCallbackFunc(overCF);
    
    
    this.StopBtn= new Button();
		
    this.RetryBtn= new Button();
	
    this.CancelBtn= new Button();
    this.CancelBtn.SetImageObjId("face_recog_registration_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_registration_cancel_btn_text");
    this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"face_recog_registration_btn_normal_style");
    this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"face_recog_registration_btn_select_style");
    this.CancelBtn.SetText(SID_CANCEL);
    this.CancelBtn.SetOnClickCallbackFunc(clickCF);
    this.CancelBtn.SetOnMouseOverCallbackFunc(overCF);


}


SceneFaceRecogRegistration.prototype.initFaceRecogRegistration = function(){
    alert("SceneFaceRecogRegistration.initFaceRecogRegistration() ");
    
    this.showStartRecogPage();
    this.BoxLabel.SetBgImage(g_Image.IMAGE_FACE_RECOG_REGISTRATION_BOX_RED);
    //init previous data
    RecogMgr.trainResult = null;
}

SceneFaceRecogRegistration.prototype.showStartRecogPage = function(){
    alert("SceneFaceRecogRegistration.showStartRecogPage() ");
	this.flagStartRecog = true;
	this.TakePicBtn.visibleObj();
	this.CancelBtn.hiddenObj();
    
    this.highlight(this.TakePicBtn);
}


SceneFaceRecogRegistration.prototype.updateBoxColor = function(image){
    alert("SceneFaceRecogRegistration.updateBoxColor() ");
    
    this.BoxLabel.SetBgImage(image);
}
SceneFaceRecogRegistration.prototype.startFaceRecogDetect=function(){
	alert("SceneFaceRecogRegistration.startFaceRecogDetect() ");
	ProcMgr.FaceDetectTimer = true;
	PluginAPIMgr.StartOSDTimer("1000" , 
				function() { 
					ProcMgr.FaceDetectTimer=false;
					PluginAPIMgr.SubscribeFaceRecogEvent(); 
					ProcMgr.StartFaceDetect();
				}, 
				ENUM_TIMER_TYPE.POPUP_WND);
	this.CancelBtn.visibleObj();
	this.TakePicBtn.hiddenObj();
    
    this.highlight(this.CancelBtn);
}
SceneFaceRecogRegistration.prototype.stopFaceRecogDetect=function(){
	ProcMgr.PauseFaceDetect(true);
	this.TakePicBtn.visibleObj();
	this.CancelBtn.hiddenObj();
    
    this.highlight(this.TakePicBtn);
}
SceneFaceRecogRegistration.prototype.highlight=function(obj)
{
	alert("SceneFaceRecogRegistration.highlight()");
	
    this.MainView.setCurrenHighlight(obj);	
}

SceneFaceRecogRegistration.prototype.processNextRegisteration = function(){
    alert("SceneFaceRecogRegistration.processNextRegisteration() ");
    // ProcMgr.StartFaceDetect();
    		
	WndMgr.NextStepFaceRecogRegistration();
}

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

    switch(currentHighlight)
    {
    	case this.TakePicBtn:
    		/*2012 scenario
    		if(RecogMgr.isSuccessTraining==true){
	    		this.processNextRegisteration();
    		}*/
    		this.startFaceRecogDetect();
    		break;
      /*  case this.StopBtn:
			ProcMgr.PauseFaceDetect(true);
			this.showStopRecogPage();
            break;
            
        case this.RetryBtn:
			ProcMgr.RetryFaceDetect();
			this.showStartRecogPage();
            break;
        */    
        case this.CancelBtn:
        	/*2012 scenario
        	ProcMgr.ReturnToFaceRecogRegistrationCaller();*/
        	this.stopFaceRecogDetect();
            break;
    }
}


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

SceneFaceRecogRegistration.prototype.processExitKey = function(){
    alert("SceneFaceRecogRegistration.processExitKey() ");
	  ProcMgr.ReturnToFaceRecogRegistrationCaller();
   // ProcMgr.ExitWithSignIn();
}


SceneFaceRecogRegistration.prototype.processClickEvent = function(obj){
	alert("SceneFaceRecogRegistration.processClickEvent() ");
	
	/*var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }*/
	
	this.processEnterKey();
}
SceneFaceRecogRegistration.prototype.processMouseOverEvent = function(obj){
	alert("SceneFaceRecogRegistration.processMouseOverEvent() ");
	
	var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }
	
	// this.processEnterKey();
}
SceneFaceRecogRegistration.prototype.changeBG = function(flag){
	alert("SceneFaceRecogRegistration.changeBG() : "+flag);
	if(flag){
		$("#skype_main_bg").css('background-image','url('+g_Image.IMAGE_FACERECOGNITION_CAMERA_BG+')');
	}else{
		$("#skype_main_bg").css('background-image','url('+g_Image.IMAGE_SKYPE_BG+')');
	}
	
}


