
function SceneCameraLightAdjControl(options) {
	this.options = options;
    
    this.BgView			= null;
	this.PanelView		= null;
    this.SublistView	= null;

	this.flag_cur_value		= -1;
	this.flag_prev_value	= -1;
}

SceneCameraLightAdjControl.prototype.initialize = function () {
	alert("CameraLightAdjControl.initialize()");

   this.create();
}

SceneCameraLightAdjControl.prototype.handleShow = function () {
	alert("CameraLightAdjControl.handleShow()");

    this.update();
    
	var callbackFunction = function() {
		sf.scene.get('CameraLightAdjControl').processReturnKey();
	};

	WndMgr.startPopupHideTimer(30000, callbackFunction);
}

SceneCameraLightAdjControl.prototype.handleHide = function () {
	alert("CameraLightAdjControl.handleHide()");

	//$('#CameraLightAdjControl_sublist').sfList('hide');

	WndMgr.stopPopupHideTimer();
}

SceneCameraLightAdjControl.prototype.handleFocus = function () {
	alert("CameraLightAdjControl.handleFocus()");

	$('#CameraLightAdjControl_sublist').sfList('focus');
}

SceneCameraLightAdjControl.prototype.handleBlur = function () {
	alert("CameraLightAdjControl.handleBlur()");

	$('#CameraLightAdjControl_sublist').sfList('blur');
}


SceneCameraLightAdjControl.prototype.handleKeyDown = function (keyCode) {
	alert("CameraLightAdjControl.handleKeyDown(" + keyCode + ")");
	
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	
	switch (keyCode) 
	{
		case sf.key.UP:
			this.processUpKey();
			WndMgr.resetPopupHideTimer(); 
			break;
			
		case sf.key.DOWN:
            this.processDownKey();
			WndMgr.resetPopupHideTimer();
			break;

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

		case 602:	//INFOLINK
		case 606:	//CONTENTS
		case 608:	//WISELINK
            sf.key.preventDefault();
			break;
	}
}

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

SceneCameraLightAdjControl.prototype.create = function(){
    alert("CameraLightAdjControl.create()");
    
    this.BgView = new View("CameraLightAdjControl");
 
 	this.PanelView = new View("CameraLightAdjControl_panel_bg");
	this.PanelView.CreatePopupBG(3,'CameraLightAdjControl_panel_style');

	$('#CameraLightAdjControl_panel_title').sfLabel({text:TV_CAMERA_LIGHT_ADJUSTMENT});

	this.SublistView = new View("CameraLightAdjControl_sublist_bg");
	this.SublistView.CreatePopupBG(2,'CameraLightAdjControl_sublist_style');
	
	$('#CameraLightAdjControl_sublist').sfList({
		data : [SID_OFF_KR_DEACT,SID_LOW_KR_VOL,COM_SID_MEDIUM,SID_HIGH_KR_VOL], 
		itemsPerPage : 4
	});

	var this_ = sf.scene.get("CameraLightAdjControl");		
	$('#CameraLightAdjControl_sublist_item_1').bind('click',function(){this_.processItemClick(0);});
	$('#CameraLightAdjControl_sublist_item_2').bind('click',function(){this_.processItemClick(1);});
	$('#CameraLightAdjControl_sublist_item_3').bind('click',function(){this_.processItemClick(2);});
	$('#CameraLightAdjControl_sublist_item_4').bind('click',function(){this_.processItemClick(3);});

	$('#CameraLightAdjControl_sublist_item_1').bind('mouseover',function(){this_.processItemOver(0);});		
	$('#CameraLightAdjControl_sublist_item_2').bind('mouseover',function(){this_.processItemOver(1);});
	$('#CameraLightAdjControl_sublist_item_3').bind('mouseover',function(){this_.processItemOver(2);});
	$('#CameraLightAdjControl_sublist_item_4').bind('mouseover',function(){this_.processItemOver(3);});
		
	$('#CameraLightAdjControl_sublist').sfList('show');	
}

SceneCameraLightAdjControl.prototype.update = function(){
    alert("CameraLightAdjControl.update()");

	this.flag_cur_value = PluginAPIMgr.GetCameraLightMode();
	this.flag_prev_value = this.flag_cur_value;

	$('#CameraLightAdjControl_sublist').sfList('move',this.flag_cur_value);	
}


SceneCameraLightAdjControl.prototype.processUpKey = function()
{  
	$('#CameraLightAdjControl_sublist').sfList('prev');
	this.flag_cur_value = $('#CameraLightAdjControl_sublist').sfList('getIndex');
	PluginAPIMgr.SaveCameraLightMode(this.flag_cur_value);
	PluginAPIMgr.SetCameraLightMode();	
}

SceneCameraLightAdjControl.prototype.processDownKey = function()
{  
	$('#CameraLightAdjControl_sublist').sfList('next');
	this.flag_cur_value = $('#CameraLightAdjControl_sublist').sfList('getIndex');
	PluginAPIMgr.SaveCameraLightMode(this.flag_cur_value);
	PluginAPIMgr.SetCameraLightMode();
}

SceneCameraLightAdjControl.prototype.processReturnKey = function()
{  
    alert("SceneCameraLightAdjControl.processReturnKey() ");
	
	PluginAPIMgr.SaveCameraLightMode(this.flag_prev_value);	
	PluginAPIMgr.SetCameraLightMode();	
	
	StateMgr.Start_Call_Setting_State();
}

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

	StateMgr.Start_Call_Setting_State();
}

SceneCameraLightAdjControl.prototype.processExitKey = function()
{
    alert("SceneCameraLightAdjControl.processExitKey() ");

	StateMgr.Stop_Camera_Adjust_State(true);
	PluginAPIMgr.SaveCameraLightMode(this.flag_prev_value);
	PluginAPIMgr.SetCameraLightMode();
}

SceneCameraLightAdjControl.prototype.processItemOver = function(itemIndex)
{
	$('#CameraLightAdjControl_sublist').sfList('move',itemIndex);
	PluginAPIMgr.SaveCameraLightMode(itemIndex);
	PluginAPIMgr.SetCameraLightMode();
	WndMgr.resetPopupHideTimer(); 
}

SceneCameraLightAdjControl.prototype.processItemClick = function(itemIndex)
{
	StateMgr.Start_Call_Setting_State();
}