var saveStatus=false, data1=null, data2=null, data3=null;

function SceneSettingsVideo(options) {
	this.options = options;
	this.sceneId = "SettingsVideo";

	this.SettingsVideoView = null;
	this.SettingsVideoDim = null;
	this.SettingsVideoBG = null;

	this.ReceiveVideoFromLabel = null;
	this.ReceiveVideoFromBtn = null;
	this.ShowHaveVideoToLabel = null;
	this.ShowHaveVideoToBtn = null;

	this.CameraAutoFocusLabel = null;
	this.CameraAutoFocusBtn = null;
	
	this.CameraZoomBtn = null;

	this.SaveBtn = null;
	this.CancelBtn = null;

	this.InitFlag == true;

	this.InitVideoFrom = null;
	this.InitVideoTo = null;
	this.InitAutoFocus = null;
	

	this.IsAutoFocusEnable = false;
	
	this.IsCameraZoomEnable = false;

	this.IsChangeVideoFrom = false;
	this.IsChangeVideoTo = false;
	this.IsChangeAutoFocus = false;


	this.ShownOnOffSubList = false;
	this.ShownSubList = false;
	this.IsEnableSaveBtn = true;
	
	this.BtnList = [];
	this.BtnIndex = 0;
}

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

SceneSettingsVideo.prototype.handleShow = function() {
	alert("SceneSettingsVideo.handleShow()");
	// this function will be called when the scene manager show this scene
	WndMgr.startPopupHideTimer(60000);
	this.InitEnableState();
	this.CreatePopupUI();
	this.InitSettingsVideo();
	this.setSaveBtnEnable(saveStatus);
}

SceneSettingsVideo.prototype.handleHide = function() {
	alert("SceneSettingsVideo.handleHide()");
	// this function will be called when the scene manager hide this scene
	this.SettingsVideoDim.hide();
	if(this.ShownOnOffSubList == true) {
		WndMgr.HideSettingsOnOffSubList();
	}
	if(this.ShownSubList == true) {
		WndMgr.HideSettingsSubList();
	}
	WndMgr.stopPopupHideTimer();
	this.highlight(null);
	this.BtnIndex=0;
}

SceneSettingsVideo.prototype.handleFocus = function() {
	alert("SceneSettingsVideo.handleFocus()");
	// this function will be called when the scene manager focus this scene
	this.SettingsVideoDim.show();
	var obj = this.SettingsVideoView.getCurrentHighlight();
	if(obj != null) {
		this.highlight(obj);
	} else {
		this.highlight(this.BtnList[this.BtnIndex]);
	}
	this.ShownOnOffSubList = false;
	this.ShownSubList = false;

}

SceneSettingsVideo.prototype.handleBlur = function() {
	alert("SceneSettingsVideo.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
	var obj = this.SettingsVideoView.getCurrentHighlight();
	if(obj != null) {
		obj.blur();
	}
	/*
	if(this.ShownOnOffSubList || this.ShownSubList)
			this.SaveBtn.SetFlagDim(true);*/
	

}

SceneSettingsVideo.prototype.handleKeyDown = function(keyCode) {
	alert("SceneSettingsVideo.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:
			WndMgr.resetPopupHideTimer();
			this.processLeftKey();
			break;
		case sf.key.RIGHT:
			WndMgr.resetPopupHideTimer();
			this.processRightKey();
			break;
		case sf.key.UP:
			WndMgr.resetPopupHideTimer();
			this.processUpKey();
			break;
		case sf.key.DOWN:
			WndMgr.resetPopupHideTimer();
			this.processDownKey();
			break;

		case sf.key.ENTER:
			this.processEnterKey();
			break;
		case sf.key.RETURN:
		case sf.key.EXIT:
			this.processReturnKey();
			sf.key.preventDefault();
			break;

		case 147:
		//infolink
		case 261:
		//contents
		case 115:
			//wiselink
			ProcMgr.processInfolinkKey();
			break;
	}
}
SceneSettingsVideo.prototype.processReturnKey = function() {
	alert("SceneSettingsVideo.processReturnKey() ");
	saveStatus = false;
 	data1=null, data2=null, data3=null;
	StateMgr.Stop_SettingsVideo_State(true);
}
SceneSettingsVideo.prototype.processMouseOver = function(obj) {
	var currentHighlight = this.SettingsVideoView.getCurrentHighlight();
	if(currentHighlight != obj) {
		this.highlight(obj);
	}
	WndMgr.resetPopupHideTimer();
}
SceneSettingsVideo.prototype.highlight = function(obj) {
	for(var i =0;i<this.BtnList.length;i++){
		if(this.BtnList[i] == obj){
			this.BtnIndex = i;
			break;
		}
	}
	this.SettingsVideoView.setCurrenHighlight(obj);
}

SceneSettingsVideo.prototype.processClickEvent = function(obj) {
	alert("SceneSettingsVideo.processClickEvent() ");

	var currentHighlight = this.SettingsVideoView.getCurrentHighlight();
	if(currentHighlight != obj) {
		this.highlight(obj);
	}
	this.processEnterKey();
}
SceneSettingsVideo.prototype.processUpKey = function() {
	alert("SceneSettingsVideo.processUpKey()");
	var currentHighlight = this.SettingsVideoView.getCurrentHighlight();
	switch(currentHighlight) {
		case this.SaveBtn:
			break;
		case this.CancelBtn:
			if(this.IsEnableSaveBtn)
				this.highlight(this.SaveBtn);
			break;
		default:
			if(this.BtnIndex >0)
				this.highlight(this.BtnList[--this.BtnIndex]);
			break;
	}
}
SceneSettingsVideo.prototype.processDownKey = function() {
	alert("SceneSettingsVideo.processDownKey()");
	var currentHighlight = this.SettingsVideoView.getCurrentHighlight();
	
	switch(currentHighlight) {
		case this.SaveBtn:
			this.highlight(this.CancelBtn);
			break;
		case this.CancelBtn:
			break;
		default:
			if(this.BtnIndex < this.BtnList.length-1)
				if(this.BtnList[this.BtnIndex+1].GetFlagDim() == true)
					return ;
				else
					this.highlight(this.BtnList[++this.BtnIndex]);
			break;
	}
}
SceneSettingsVideo.prototype.processLeftKey = function() {
	alert("SceneSettingsVideo.processLeftKey()");
	var currentHighlight = this.SettingsVideoView.getCurrentHighlight();
	switch(currentHighlight) {
		case this.SaveBtn:
			this.highlight( this.BtnList[this.BtnIndex]);
			break;
		case this.CancelBtn:
			this.highlight( this.BtnList[this.BtnIndex]);
			break;
	}
}

SceneSettingsVideo.prototype.processRightKey = function() {
	alert("SceneSettingsVideo.processRightKey()");
	var currentHighlight = this.SettingsVideoView.getCurrentHighlight();

	switch(currentHighlight) {
		case this.BtnList[this.BtnIndex]:
			if(this.IsEnableSaveBtn)
				this.highlight(this.SaveBtn);
			else
				this.highlight(this.CancelBtn);
			break;
	}
}
SceneSettingsVideo.prototype.processEnterKey = function() {
	alert("SceneSettingsVideo.processEnterKey()");

	var currentHighlight = this.SettingsVideoView.getCurrentHighlight();
	switch(currentHighlight) {
		case this.ReceiveVideoFromBtn:
			this.ShownSubList = true;
			WndMgr.StartSettingsSubList(this.ReceiveVideoFromBtn, this.sceneId, this.SettingsVideoView, this.FromBtnCallBack/*callback*/, this.ReceiveVideoFromBtn.GetText());
			break;
		case this.ShowHaveVideoToBtn:
			this.ShownSubList = true;
			WndMgr.StartSettingsSubList(this.ShowHaveVideoToBtn, this.sceneId, this.SettingsVideoView, this.ToBtnCallBack/*callback*/, this.ShowHaveVideoToBtn.GetText());
			break;
		case this.CameraAutoFocusBtn:
			this.ShownOnOffSubList = true;
			WndMgr.StartSettingsOnOffSubList(this.CameraAutoFocusBtn, this.sceneId, this.SettingsVideoView, this.AutoFocusCallBack/*callback*/, this.CameraAutoFocusBtn.GetText());
			break;
		case this.CameraZoomBtn:
			saveStatus =this.IsEnableSaveBtn;
		 	data1=this.ReceiveVideoFromBtn.GetText();
		 	data2=this.ShowHaveVideoToBtn.GetText();
		 	data3=this.CameraAutoFocusBtn.GetText();
            StateMgr.Start_Call_Camera_Control_State();
			break;
		case this.SaveBtn:
			this.SaveVideoSetting();
			break;
		case this.CancelBtn:
			this.processReturnKey();
			break;
	}
}
SceneSettingsVideo.prototype.SaveSuccess = function() {
	alert("SceneSettingsVideo.SaveSuccess()");
	this.InitVideoFrom = this.ReceiveVideoFromBtn.GetText();
	this.InitVideoTo = this.ShowHaveVideoToBtn.GetText();
	if(this.IsAutoFocusEnable){
		this.InitAutoFocus = this.CameraAutoFocusBtn.GetText();
	}
	data1=null;
	data2=null;
	data3=null;
	saveStatus = false;
	StateMgr.Stop_SettingsVideo_State(true);
	
}
SceneSettingsVideo.prototype.SaveVideoSetting = function() {
	alert("SceneSettingsVideo.SaveVideoSetting()");
		PluginAPIMgr.SetAutoVideoReceive(this.ReceiveVideoFromBtn.GetText());
		PluginAPIMgr.SetVideoAdvert(this.ShowHaveVideoToBtn.GetText());
	if(this.IsAutoFocusEnable) {
		PluginAPIMgr.SetAutoFocusValue(this.CameraAutoFocusBtn.GetText());
	}
		WndMgr.SetCurrentPopupSceneId(this.sceneId);
		WndMgr.HideSettingsVideo();
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.OPTIONS_OK);
}
SceneSettingsVideo.prototype.setSaveBtnEnable = function(flag_enable) {
	alert("SceneSettingsVideo.setSaveBtnEnable() : "+flag_enable);

	if(flag_enable == true) {
		this.SaveBtn.SetFlagDim(false);
		this.IsEnableSaveBtn = true;
	} else if(flag_enable == false) {
		this.SaveBtn.SetFlagDim(true);
		this.IsEnableSaveBtn = false;
	}
}
SceneSettingsVideo.prototype.IsChange = function(caller) {
	alert("SceneSettingsVideo.IsChange()");
	switch(caller) {
		case "TO":
			if(this.IsChangeVideoFrom)
				this.setSaveBtnEnable(true);
			else if(this.IsChangeVideoFrom == false && (this.IsChangeVideoTo || this.IsChangeAutoFocus ))
				this.setSaveBtnEnable(true);
			else
				this.setSaveBtnEnable(false);
			break;
		case "FROM":
			if(this.IsChangeVideoTo)
				this.setSaveBtnEnable(true);
			else if(this.IsChangeVideoTo == false && (this.IsChangeVideoFrom || this.IsChangeAutoFocus ))
				this.setSaveBtnEnable(true);
			else
				this.setSaveBtnEnable(false);
			break;
		case "AUTOFOCUS":
			if(this.IsChangeAutoFocus)
				this.setSaveBtnEnable(true);
			else if(this.IsChangeAutoFocus == false && (this.IsChangeVideoTo || this.IsChangeVideoFrom ))
				this.setSaveBtnEnable(true);
			else
				this.setSaveBtnEnable(false);
			break;
	}
}
SceneSettingsVideo.prototype.InitSettingsVideo = function() {
	alert("SceneSettingsVideo.InitSettingsVideo()");
/*
	data1!=null?	this.InitVideoFrom =data1:this.InitVideoFrom = PluginAPIMgr.GetAutoVideoReceive();
	data2!=null?	this.InitVideoTo=data2: this.InitVideoTo = PluginAPIMgr.GetVideoAdvert();

	if(this.IsAutoFocusEnable) {
		data3!=null?	this.InitAutoFocus = data3:	this.InitAutoFocus = PluginAPIMgr.GetAutoFocusValue();*/

	
	this.InitVideoFrom = PluginAPIMgr.GetAutoVideoReceive();
	this.InitVideoTo = PluginAPIMgr.GetVideoAdvert();
	if(data1&&data1!=this.InitVideoFrom){
		this.IsChangeVideoFrom = true;
		this.ReceiveVideoFromBtn.SetText(data1);
	} else{
		this.IsChangeVideoFrom = false;
	this.ReceiveVideoFromBtn.SetText(this.InitVideoFrom);
	}
		if(data2&&data2!=this.InitVideoTo){
		this.IsChangeVideoTo = true;
		this.ShowHaveVideoToBtn.SetText(data2);
	} else{
		this.IsChangeVideoTo = false;
	this.ShowHaveVideoToBtn.SetText(this.InitVideoTo);
	}
	
	if(this.IsAutoFocusEnable) {
		this.InitAutoFocus = PluginAPIMgr.GetAutoFocusValue();	
		if(data3&&data3!=this.InitAutoFocus){
			this.CameraAutoFocusBtn.SetText(data3);
			this.IsChangeAutoFocus = true;
		}else{
			this.CameraAutoFocusBtn.SetText(this.InitAutoFocus);
	this.IsChangeAutoFocus = false;
		}
	}
}

SceneSettingsVideo.prototype.ToBtnCallBack = function(text) {
	alert("SceneSettingsVideo.ToBtnCallBack()");
	var this_ = sf.scene.get("SettingsVideo");
	if(this_.InitVideoTo != text) {
		this_.IsChangeVideoTo = true;
	} else {
		this_.IsChangeVideoTo = false;
	}
	this_.IsChange("TO");
}
SceneSettingsVideo.prototype.FromBtnCallBack = function(text) {
	alert("SceneSettingsVideo.FromBtnCallBack()");
	var this_ = sf.scene.get("SettingsVideo");
	if(this_.InitVideoFrom != text) {
		this_.IsChangeVideoFrom = true;
	} else {
		this_.IsChangeVideoFrom = false;
	}
	this_.IsChange("FROM");
}
SceneSettingsVideo.prototype.AutoFocusCallBack = function(text) {
	alert("SceneSettingsVideo.AutoFocusCallBack()");
	var this_ = sf.scene.get("SettingsVideo");
	if(this_.InitAutoFocus != text) {
		this_.IsChangeAutoFocus = true;
	} else {
		this_.IsChangeAutoFocus = false;
	}
	this_.IsChange("AUTOFOCUS");
}

SceneSettingsVideo.prototype.create = function() {
	alert("SceneSettingsVideo.create()");

	this.SettingsVideoView = new View("SettingsVideo");
	this.SettingsVideoBG = new View("SettingsVideoBG");
	this.SettingsVideoBG.CreatePopupBG(0, "SettingsVideo_popup_BG");
	this.SettingsVideoBG.CreateInnerBox("SettingsVideo_popup_innerbox");
	this.SettingsVideoBG.SetTitleTextofPopupBG(IDWS_MOIP_SKYPE_SETTING_VIDEO_SETTINGS);
	this.SettingsVideoDim = new DimBg("SettingsVideoDim", "SettingsVideoBG");

	var this_ = sf.scene.get("SettingsVideo");
	var clickCF = function(obj) {
		this_.processClickEvent(obj);
	};

	this.ReceiveVideoFromLabel = new TextLayer("settingsvideo_video_from_label");
	this.ReceiveVideoFromLabel.SetTextStyle("settingsvideo_label_style");
	this.ReceiveVideoFromLabel.SetText(TV_SID_AUTOMATICALLY_RECEIVE_VIDEO_FROM + " :");

	this.ShowHaveVideoToLabel = new TextLayer("settingsvideo_video_to_label");
	this.ShowHaveVideoToLabel.SetTextStyle("settingsvideo_label_style");
	this.ShowHaveVideoToLabel.SetText(IDWS_MOIP_SETTING_SHOW_VIDEO + " :");
	
	
	this.CameraAutoFocusLabel = new TextLayer("settingsvideo_camera_focus_label");
	this.CameraAutoFocusLabel.SetTextStyle("settingsvideo_label_style");
	if(ResMgr.isReverseLanguage()){
		this.CameraAutoFocusLabel.SetText(TV_SID_CAMERA_AUTO_FOCUS);
	}else{
		this.CameraAutoFocusLabel.SetText(TV_SID_CAMERA_AUTO_FOCUS + " :");
	}
	
	this.ReceiveVideoFromBtn = new Button();
	this.ReceiveVideoFromBtn.SetImageObjId("settingsvideo_video_from_btn", 29);
	this.ReceiveVideoFromBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_TEXT_INPUT_NORMAL);
	this.ReceiveVideoFromBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_TEXT_INPUT_FOCUS);
	this.ReceiveVideoFromBtn.SetTextObjId("settingsvideo_video_from_btn_text");
	this.ReceiveVideoFromBtn.SetIconObjId("settingsvideo_video_from_btn_arrow");
	this.ReceiveVideoFromBtn.SetBgIcon(0, g_Image.IMAGE_TEXT_INPUT_ARROW);
	this.ReceiveVideoFromBtn.SetBgIcon(1, g_Image.IMAGE_TEXT_INPUT_ARROW);
	this.ReceiveVideoFromBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "image_text_box_normal_style");
	this.ReceiveVideoFromBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "image_text_box_focus_style");
	this.ReceiveVideoFromBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "image_text_box_dim_style");
	this.ReceiveVideoFromBtn.SetOnClickCallbackFunc(clickCF);

	this.ShowHaveVideoToBtn = new Button();
	this.ShowHaveVideoToBtn.SetImageObjId("settingsvideo_video_to_btn", 29);
	this.ShowHaveVideoToBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_TEXT_INPUT_NORMAL);
	this.ShowHaveVideoToBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_TEXT_INPUT_FOCUS);
	this.ShowHaveVideoToBtn.SetTextObjId("settingsvideo_video_to_btn_text");
	this.ShowHaveVideoToBtn.SetIconObjId("settingsvideo_video_to_btn_arrow");
	this.ShowHaveVideoToBtn.SetBgIcon(0, g_Image.IMAGE_TEXT_INPUT_ARROW);
	this.ShowHaveVideoToBtn.SetBgIcon(1, g_Image.IMAGE_TEXT_INPUT_ARROW);
	this.ShowHaveVideoToBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "image_text_box_normal_style");
	this.ShowHaveVideoToBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "image_text_box_focus_style");
	this.ShowHaveVideoToBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "image_text_box_dim_style");
	this.ShowHaveVideoToBtn.SetOnClickCallbackFunc(clickCF);

	this.CameraAutoFocusBtn = new Button();
	this.CameraAutoFocusBtn.SetImageObjId("settingsvideo_camera_focus_btn", 15);
	this.CameraAutoFocusBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_BASIC_BUTTON_NORMAL);
	this.CameraAutoFocusBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_BASIC_BUTTON_FOCUS);
	this.CameraAutoFocusBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_BASIC_BUTTON_DIM);
	this.CameraAutoFocusBtn.SetTextObjId("settingsvideo_camera_focus_btn_text");
	this.CameraAutoFocusBtn.SetIconObjId("settingsvideo_camera_focus_btn_arrow");
	this.CameraAutoFocusBtn.SetBgIcon(0, g_Image.IMAGE_POPUP_BTN_ARROW_DOWN);
	this.CameraAutoFocusBtn.SetBgIcon(1, g_Image.IMAGE_POPUP_BTN_ARROW_DOWN);
	this.CameraAutoFocusBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.CameraAutoFocusBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.CameraAutoFocusBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.CameraAutoFocusBtn.SetOnClickCallbackFunc(clickCF);

	
	this.CameraZoomBtn = new Button();
	this.CameraZoomBtn.SetImageObjId("settingsvideo_camera_zoom_btn", 20);
	this.CameraZoomBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
	this.CameraZoomBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);
	this.CameraZoomBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_POPUP_BTN_DIM);
	this.CameraZoomBtn.SetTextObjId("settingsvideo_camera_zoom_btn_text");
	this.CameraZoomBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.CameraZoomBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.CameraZoomBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.CameraZoomBtn.SetText(IDWS_MOIP_SKYPE_CAMERA_ZOOM);
	this.CameraZoomBtn.SetOnClickCallbackFunc(clickCF);
	
	this.SaveBtn = new Button();
	this.SaveBtn.SetImageObjId("settingsvideo_save_btn", 20);
	this.SaveBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
	this.SaveBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);
	this.SaveBtn.SetTextObjId("settingsvideo_save_btn_text");
	this.SaveBtn.SetText(SID_SAVE);
	this.SaveBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.SaveBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.SaveBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.SaveBtn.SetOnClickCallbackFunc(clickCF);

	this.CancelBtn = new Button();
	this.CancelBtn.SetImageObjId("settingsvideo_cancel_btn", 20);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);

	this.CancelBtn.SetTextObjId("settingsvideo_cancel_btn_text");
	this.CancelBtn.SetText(SID_CANCEL);
	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.CancelBtn.SetOnClickCallbackFunc(clickCF);
	
	this.ReceiveVideoFromBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.ShowHaveVideoToBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.CameraAutoFocusBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.CameraZoomBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.SaveBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.CancelBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	
	
}

SceneSettingsVideo.prototype.backtoCameraZoom = function() {
	alert("SceneSettingsVideo.backtoCameraZoom ");
	for(this.BtnIndex =0;this.BtnIndex< this.BtnList.length;this.BtnIndex++){
		if(this.BtnList[this.BtnIndex] == this.CameraZoomBtn)
			break;
	}
	
	if(this.IsCameraZoomEnable ==true && this.BtnList[this.BtnIndex].GetFlagDim()==false){
		this.highlight(this.BtnList[this.BtnIndex]);
	}else{
		this.BtnIndex=0;
		this.highlight(this.BtnList[this.BtnIndex]);
	}
}
SceneSettingsVideo.prototype.updatePopup = function() {
	alert("SceneSettingsVideo.updatePopup ");
	this.InitEnableState();
	this.CreatePopupUI();
	this.InitSettingsVideo();
	WndMgr.resetPopupHideTimer();
	
}


SceneSettingsVideo.prototype.InitEnableState = function() {
	this.IsAutoFocusEnable = true;
	this.IsCameraZoomEnable = true;
	this.IsAutoFocusEnable = ProcMgr.isAutoFocusEnable();
	
	var CamState = PluginAPIMgr.GetCameraState();
	if(CamState == ENUM_CAM_STATE.CAM_STATE_DISCONNECTED || CamState == ENUM_CAM_STATE.CAM_STATE_CONNECTING)
	{
		this.IsFaceTrackingEnable = false;
		this.IsCameraZoomEnable = false;
		this.IsAutoFocusEnable  = false;
	}
	if(!(PluginAPIMgr.GetCamCapability(ENUM_CAM_CAPABILITY.CAM_CAPABILITY_ZOOM) == 1 && 
		PluginAPIMgr.GetCamCapability(ENUM_CAM_CAPABILITY.CAM_CAPABILITY_SIGNAL_TYPE) == 1))
	{
		this.IsCameraZoomEnable = false;
	}
	if(!PluginAPIMgr.GetCamCapability(ENUM_CAM_CAPABILITY.CAM_CAPABILITY_FACE_TRACKING) == 1)
		this.IsFaceTrackingEnable = false;
	
	
	
	
}


SceneSettingsVideo.prototype.CreatePopupUI = function() {
	alert("SceneSettingsVideo.prototype.CreatePopupUI ");
	var obj = this.SettingsVideoView.getCurrentHighlight();
	
	var i = 0;
    if (this.IsAutoFocusEnable) {
        if (this.IsCameraZoomEnable == true) {
			i=1;
			$("#settingsvideo_camera_focus_label").css("top","371px");
			$("#settingsvideo_camera_focus_btn").css("top","357px");
			$("#settingsvideo_camera_zoom_btn").css("top","431px");
			this.CameraAutoFocusLabel.visibleObj();
			this.CameraAutoFocusBtn.visibleObj();
			this.CameraZoomBtn.visibleObj();
			this.BtnList = new Array(4);
			this.BtnList[0] = this.ReceiveVideoFromBtn;
			this.BtnList[1] = this.ShowHaveVideoToBtn;
			this.BtnList[2] = this.CameraAutoFocusBtn;
			this.BtnList[3] = this.CameraZoomBtn;
        } else {
   
			i=2;
			$("#settingsvideo_camera_focus_label").css("top","371px");
   
			$("#settingsvideo_camera_focus_btn").css("top","357px");
			this.CameraAutoFocusLabel.visibleObj();
			this.CameraAutoFocusBtn.visibleObj();
			this.CameraZoomBtn.hiddenObj();
			this.BtnList = new Array(3);
			this.BtnList[0] = this.ReceiveVideoFromBtn;
			this.BtnList[1] = this.ShowHaveVideoToBtn;
			this.BtnList[2] = this.CameraAutoFocusBtn;
            if (obj == this.CameraZoomBtn) {
				this.BtnIndex=2;
				this.highlight(this.BtnList[2]);
			}
		}
			}
    else {

    if (this.IsCameraZoomEnable == true) {
			i=2;
			$("#settingsvideo_camera_zoom_btn").css("top","371px");
			this.CameraAutoFocusLabel.hiddenObj();
			this.CameraAutoFocusBtn.hiddenObj();
			this.CameraZoomBtn.visibleObj();
			this.BtnList = new Array(3);
			this.BtnList[0] = this.ReceiveVideoFromBtn;
			this.BtnList[1] = this.ShowHaveVideoToBtn;
			this.BtnList[2] = this.CameraZoomBtn;
    } else {
			i=3;
			this.CameraAutoFocusLabel.hiddenObj();
			this.CameraAutoFocusBtn.hiddenObj();
			this.CameraZoomBtn.hiddenObj();
			this.BtnList = new Array(2);
			this.BtnList[0] = this.ReceiveVideoFromBtn;
			this.BtnList[1] = this.ShowHaveVideoToBtn;
        if (obj == this.CameraAutoFocusBtn || obj == this.CameraZoomBtn ) {
				this.BtnIndex=1;
				this.highlight(this.BtnList[1]);
			}
    
		}
    }



	var bgL = 265;
	var bgT = [49, 79,109,149];
	var bgW = 848;
	var bgH = [626,	566,506,456];
	var innerL = 29;
	var innerT = 81;
	var innerW = 638;
	var innerH = [469,415,361,307];
	var saveBtnTop = [256,235,214,193];
	
	$("#SettingsVideo").css("top",bgT[i]+"px");
	$("#SettingsVideo").css("height",bgH[i]-55+"px");
	this.SettingsVideoBG.ChangePopupBGSize(null,bgL,bgT[i],bgW,bgH[i]);
	this.SettingsVideoBG.ChangeInnerBox(innerL, innerT, innerW, innerH[i]);
	$("#settingsvideo_save_btn").css("top",saveBtnTop[i]+'px');
	$("#settingsvideo_cancel_btn").css("top",saveBtnTop[i]+60+'px');
}