
function SceneCameraCheckConnected(options) {
	this.options = options;
    
    this.MainView=null;
    
    this.TitleLabel = null;     	
	this.MsgLabel1 = null;
	this.MsgLabel2 = null;
    this.AgainCheckBox=null;
    this.StartSkypeBtn = null;

    this.DefaultHelpBar =null;
	
	//flag	
	this.flagWaiting = false;
	this.flagCameraStarting = false;
	
	//for testing
	// this.flag = false;
}

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

SceneCameraCheckConnected.prototype.handleShow = function () {
	alert("SceneCameraCheckConnected.handleShow()");
	// this function will be called when the scene manager show this scene 
	this.changeBG(true);
	this.enableButton();
	this.AgainCheckBox.SetFlagSelect(true);

	
	ProcMgr.StartPreviewOfCameraCheckConnected();

}

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

SceneCameraCheckConnected.prototype.handleFocus = function () {
	alert("SceneCameraCheckConnected.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("CameraCheckConnected");
  	var returnCF =  function(){this_.processReturnKey();};
    WndMgr.SetReturnIconClickCallback(returnCF);
}

SceneCameraCheckConnected.prototype.handleBlur = function () {
	alert("SceneCameraCheckConnected.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);
}
 
SceneCameraCheckConnected.prototype.handleKeyDown = function (keyCode) {
	alert("SceneCameraCheckConnected.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:

			break;
		case sf.key.UP:          
		case sf.key.DOWN:
           this.processUpDownKey(keyCode);
			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;

	}
}

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

SceneCameraCheckConnected.prototype.create = function(){
    alert("SceneCameraCheckConnected.create()");
    this.MainView = new View("CameraCheckConnected");
     // this.MainView.SetBgImage(g_Image.IMAGE_CAMERA_CHECK_CONNECTED_BG);
    
    this.TitleLabel = new Label(null,"camera_check_connected_title");
    this.TitleLabel.SetTextStyle("camera_check_connected_title_style");
    this.TitleLabel.SetText(TV_DEVICE_CHECK_CHECK_MY_VIDEO );    
	
    this.MsgLabel1 = new Label(null,"camera_check_connected_msg1");
    this.MsgLabel1.SetTextStyle("camera_check_connected_msg1_style");
    this.MsgLabel1.SetText(TV_THIS_IS_YOUR_CAMERAS_VIDEO);  
    
    this.MsgLabel2 = new Label(null,"camera_check_connected_msg2");
    this.MsgLabel2.SetTextStyle("camera_check_connected_msg2_style");
    this.MsgLabel2.SetText(TV_WHAT_FRIENDS_VIDEO_CALL_MSG);
	
	var this_ = sf.scene.get("CameraCheckConnected");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	var overCF =  function(obj){this_.processMouseOverEvent(obj);};
	
	this.AgainCheckBox=new CheckBox();
    this.AgainCheckBox.SetImageObjId("camera_check_connected_check_box");
    this.AgainCheckBox.SetBgImage(CBoxImgIndex.CB_NORMAL_IMG,  g_Image.IMAGE_CAMERA_CHECK_CHECK_BOX_NORMAL);
    this.AgainCheckBox.SetBgImage(CBoxImgIndex.CB_NORMAL_FOCUS_IMG,  g_Image.IMAGE_CAMERA_CHECK_CHECK_BOX_NORMALFOCUS);
    this.AgainCheckBox.SetTextObjId("camera_check_connected_check_box_text");
    this.AgainCheckBox.SetText(TV_DONT_SHOW_THIS_MESSAGE_AGAIN);
    this.AgainCheckBox.SetTextStyle("camera_check_connected_check_box_style");
    this.AgainCheckBox.AppendFgImage("camera_check_connected_check_box_selected_icon","0px","0px","29px","29px");
    this.AgainCheckBox.SetFgImage(g_Image.IMAGE_CAMERA_CHECK_CHECK_BOX_SELECTED);
	this.AgainCheckBox.SetFlagSelect(true);
	this.AgainCheckBox.SetOnClickCallbackFunc(clickCF); 
	this.AgainCheckBox.SetOnMouseOverCallbackFunc(overCF);
  
    this.StartSkypeBtn= new Button();
    this.StartSkypeBtn.SetImageObjId("camera_check_connected_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_connected_start_skype_btn_text");
    this.StartSkypeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"camera_check_connected_btn_normal_style");
	this.StartSkypeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"camera_check_connected_btn_select_style");
    this.StartSkypeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"camera_check_connected_btn_dim_style");
	this.StartSkypeBtn.SetText(TV_SID_CONTINUE_VOICE_KR_CONTINUE);
	this.StartSkypeBtn.SetOnClickCallbackFunc(clickCF);
	this.StartSkypeBtn.SetOnMouseOverCallbackFunc(overCF);

}

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

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

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


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

    switch(currentHighlight)
    {
        case this.AgainCheckBox:

            break;
            
        case this.StartSkypeBtn:
			this.requestStartMain();
            break;
    }
}


SceneCameraCheckConnected.prototype.processReturnKey = function(){
    alert("SceneCameraCheckConnected.processReturnKey() ");
	
   StateMgr.Start_Exit_State(true);
}

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

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

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

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

	var camState = PluginAPIMgr.GetCameraState();

	if(camState ==  ENUM_CAM_STATE.CAM_STATE_DISCONNECTED);
	{
		StateMgr.Start_Camera_Check_Disconnected_State();
	}	
}

SceneCameraCheckConnected.prototype.requestStartMain = function(){
    alert("SceneCameraCheckConnected.requestStartMain() ");
	
	PluginAPIMgr.SetCameraCheckDisable(this.AgainCheckBox.GetFlagSelect());
	this.disableButton();
	StateMgr.Start_Main_State();
}
SceneCameraCheckConnected.prototype.changeBG = function(flag){
	if(flag){
		$("#skype_main_bg").css('background-image','url('+g_Image.IMAGE_CAMERA_CHECK_CONNECTED_BG+')');
	}else{
		$("#skype_main_bg").css('background-image','url('+g_Image.IMAGE_SKYPE_BG+')');
	}
}


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

