
function SceneCameraCheckDisconnected(options) {
	this.options = options;
    
    this.MainView=null;
    
    this.TitleLabel = null;     	
	this.MsgLabel = null;
	this.ImageBox1 = null;
	this.ImageBox2 = null;
	this.InfoMsgLabel=null;
	this.InfoCameraMsgLabel=null;
    this.StartSkypeBtn = null;
	this.ExitSkypeBtn = null;

    this.DefaultHelpBar =null;
	this.flagWaiting = false;
 
}

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

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

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

SceneCameraCheckDisconnected.prototype.handleFocus = function () {
	alert("SceneCameraCheckDisconnected.handleFocus()");
	// this function will be called when the scene manager focus this scene
    var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight ==null)
    {
        this.highlight(this.StartSkypeBtn);
    }
    else
    {
         this.highlight(currentHighlight);
    }  
    
    var this_ = sf.scene.get("CameraCheckDisconnected");
  	var returnCF =  function(){this_.processReturnKey();};
    WndMgr.SetReturnIconClickCallback(returnCF);
}

SceneCameraCheckDisconnected.prototype.handleBlur = function () {
	alert("SceneCameraCheckDisconnected.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);
}
 
SceneCameraCheckDisconnected.prototype.handleKeyDown = function (keyCode) {
	alert("SceneCameraCheckDisconnected.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:
			this.processLeftRightKey(keyCode);
			break;
		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();
            //sf.key.block(event);
			break;
            
        case sf.key.EXIT:
            this.processExitKey();
            //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
		
        case 147:  //infolink
        case 261:  //contents
        case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
			
		default:
            ProcMgr.processBlockKey(keyCode);
            break;

	}
}

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

SceneCameraCheckDisconnected.prototype.create = function(){
    alert("SceneCameraCheckDisconnected.create()");
    this.MainView = new View("CameraCheckDisconnected");
    // this.MainView.SetBgImage(g_Image.IMAGE_CAMERA_CHECK_DISCONNECTED_BG);
    
    this.TitleLabel = new Label(null,"camera_check_disconnected_title");
    this.TitleLabel.SetTextStyle("camera_check_disconnected_title_style");
    this.TitleLabel.SetText(TV_DEVICE_CHECK_CHECK_MY_VIDEO );    
	
    this.MsgLabel = new Label(null,"camera_check_disconnected_msg");
    this.MsgLabel.SetTextStyle("camera_check_disconnected_msg_style");
    this.MsgLabel.SetText(TV_YOUR_CAMERA_CANNOT_BE_DETECTED+"</br>"+TV_YOU_CANNOT_MAKE_VIDEO_VOICE_CALL_WITHOUT_CAMERA+"</br>"+TV_PLEASE_CHECK_THE_CAMERA_IN_CONNECTED_TO_THE_TV);  
  
    this.ImageBox1= new Label("camera_check_disconnected_image_box1", null);
    this.ImageBox1.SetBgImage(g_Image.IMAGE_CAMERA_CHECK_DISCONNECTED_IMAGE_BOX);
    this.ImageBox1.AppendFgImage("camera_check_disconnected_image_box1_icon","200px","108px","40px","34px");
   	this.ImageBox1.SetFgImage(g_Image.IMAGE_CAMERA_CHECK_DISCONNECTED_CAMERA_ICON2);
	
	this.ImageBox2= new Label("camera_check_disconnected_image_box2", null);
    this.ImageBox2.SetBgImage(g_Image.IMAGE_CAMERA_CHECK_DISCONNECTED_IMAGE_BOX);
    this.ImageBox2.AppendFgImage("camera_check_disconnected_image_box2_icon","0px","0px","440px","250px");
   	this.ImageBox2.SetFgImage(g_Image.IMAGE_CAMERA_CHECK_DISCONNECTED_CAMERA_ICON);
	
	//2013 modify by minseok
	this.InfoMsgLabel = new Label(null,"camera_check_disconnected_camera_info_msg");
    this.InfoMsgLabel.SetTextStyle("camera_check_disconnected_camera_info_msg_style");
    //if sbb -> support '11 camera
     //140429 add '14 camera for FH6200 
    if(ProcMgr.ProductInfo.model_code == TV_MODEL_CODE.FOX_SBB){
    	this.InfoMsgLabel.SetText(g_Data.CombinateStrings(TV_MIX_CAMERAS_COMPATIBLE_WITH_TV_MSG,"<span class='camera_check_disconnected_camera_info_camera_msg_style'>Samsung CY-STC1100, VG-STC2000, VG-STC3000, VG-STC4000</span>"));
    }else{
	    this.InfoMsgLabel.SetText(g_Data.CombinateStrings(TV_MIX_CAMERAS_COMPATIBLE_WITH_TV_MSG,"<span class='camera_check_disconnected_camera_info_camera_msg_style'>Samsung VG-STC2000, VG-STC3000, VG-STC4000</span>")); 
    }
    
	var this_ = sf.scene.get("CameraCheckDisconnected");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	var overCF =  function(obj){this_.processMouseOverEvent(obj);};
	
	this.StartSkypeBtn= new Button();
    this.StartSkypeBtn.SetImageObjId("camera_check_disconnected_start_skype_btn", 30);
    this.StartSkypeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CAMERA_CHECK_BTN_NORMAL);
    this.StartSkypeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CAMERA_CHECK_BTN_NORMALFOCUS);
    this.StartSkypeBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_CAMERA_CHECK_BTN_DIM);
	this.StartSkypeBtn.SetTextObjId("camera_check_disconnected_start_skype_btn_text");
    this.StartSkypeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"camera_check_disconnected_btn_normal_style");
	this.StartSkypeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"camera_check_disconnected_btn_select_style");
    this.StartSkypeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"camera_check_disconnected_btn_dim_style");
	this.StartSkypeBtn.SetText(TV_SID_CONTINUE_VOICE_KR_CONTINUE);
	this.StartSkypeBtn.SetOnClickCallbackFunc(clickCF); 
	this.StartSkypeBtn.SetOnMouseOverCallbackFunc(overCF);
	
	this.ExitBtn= new Button();
    this.ExitBtn.SetImageObjId("camera_check_disconnected_exit_btn", 30);
    this.ExitBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CAMERA_CHECK_BTN_NORMAL);
    this.ExitBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CAMERA_CHECK_BTN_NORMALFOCUS);
    this.ExitBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_CAMERA_CHECK_BTN_DIM);
	this.ExitBtn.SetTextObjId("camera_check_disconnected_exit_btn_text");
    this.ExitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"camera_check_disconnected_btn_normal_style");
	this.ExitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"camera_check_disconnected_btn_select_style");
	this.ExitBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"camera_check_disconnected_btn_dim_style");
    this.ExitBtn.SetText(SID_EXIT);
    this.ExitBtn.SetOnClickCallbackFunc(clickCF); 
    this.ExitBtn.SetOnMouseOverCallbackFunc(overCF);

}

SceneCameraCheckDisconnected.prototype.highlight=function(obj)
{
	alert("SceneCameraCheckDisconnected.highlight()");
	
    this.MainView.setCurrenHighlight(obj);
	
}

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


SceneCameraCheckDisconnected.prototype.processEnterKey = function(){
    alert("SceneCameraCheckDisconnected.processEnterKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
	
    switch(currentHighlight)
    {            
        case this.StartSkypeBtn:
        	
			this.disableButton();
			StateMgr.Start_Main_State();
            break;
			
		case this.ExitBtn:
			StateMgr.Start_Exit_State(false);
            break; 
    }
}

SceneCameraCheckDisconnected.prototype.processReturnKey = function(){
    alert("SceneCameraCheckDisconnected.processReturnKey() ");
   
   //ProcMgr.CloseWithSignIn();
   StateMgr.Start_Exit_State(true);
}

SceneCameraCheckDisconnected.prototype.processExitKey = function(){
    alert("SceneCameraCheckDisconnected.processExitKey() ");
   
   StateMgr.Start_Exit_State(false);
}

SceneCameraCheckDisconnected.prototype.enableButton = function(){
    alert("SceneCameraCheckDisconnected.enableButton() ");
    
    this.StartSkypeBtn.SetFlagDim(false);
    this.ExitBtn.SetFlagDim(false);
	
    this.flagWaiting = false;
}

SceneCameraCheckDisconnected.prototype.disableButton = function(){
    alert("SceneCameraCheckDisconnected.disableButton() ");
	
     this.flagWaiting = true;
     
    this.StartSkypeBtn.blur();
    
    this.StartSkypeBtn.SetFlagDim(true);
	this.ExitBtn.SetFlagDim(true);
}

SceneCameraCheckDisconnected.prototype.refreshCheckWnd = function(){
    alert("SceneCameraCheckDisconnected.refreshCheckWnd() ");

	var camState = PluginAPIMgr.GetCameraState();

	if(camState ==  ENUM_CAM_STATE.CAM_STATE_READY || camState == ENUM_CAM_STATE.CAM_STATE_PLAYING)
	{
		//StateMgr.Start_Camera_Check_Connected_State();
		var camera_check_disable = PluginAPIMgr.GetCameraCheckDisable();
	
		if(camera_check_disable==false)
		{	
			StateMgr.Start_Camera_Check_Connected_State();
		}
		else
		{
			StateMgr.Start_Main_State();
		}
	}	

}

SceneCameraCheckDisconnected.prototype.processClickEvent = function(obj){
	alert("SceneCameraCheckDisconnected.processClickEvent() ");
	
	if(this.flagWaiting==true)
	{
		return;	
	}
	
	
	this.processEnterKey();
}

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

