
var ZOOM_POINTER_X_ARRY = [	
//	-10,-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10
	[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],//0
	[ 0, 3, 5, 7, 9,12,14,16,18,20,22,24,26,28,30,32,34,36,38,41,43],//2	x1.6	width:72
	[ 0, 3, 6, 9,12,15,18,21,24,27,32,35,38,41,44,47,50,53,56,59,63],//4	x2.2  
	[ 0, 4, 7,11,14,18,21,25,28,32,38,42,45,49,52,56,59,63,66,70,75],//6	x2.8 
	[ 0, 4, 8,12,16,20,24,28,32,36,41,45,49,53,57,61,65,69,73,77,82],//8	x3.4  
	[ 0, 4, 9,13,18,22,27,31,36,40,44,49,53,58,62,67,71,75,79,83,87],//10	x4.0  
];

var ZOOM_POINTER_Y_ARRY = [	
//	-10,-9,-8,-7,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10
	[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],//0    x1.0 
	[ 0, 1, 2, 4, 5, 6, 7, 8, 9,10,12,13,14,16,17,18,19,20,22,23,24],//2	x1.6	height:40	gap:1.2
	[ 0, 1, 3, 5, 6, 8,10,12,14,16,18,20,22,23,25,27,28,30,32,33,35],//4	x2.2 				gap:1.75
	[ 0, 2, 4, 6, 8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,41],//6	x2.8				gap:2.05
	[ 0, 2, 4, 6, 9,11,13,15,17,20,22,24,26,28,31,33,35,37,40,42,45],//8	x3.4	height:49	gap:2.25
	[ 0, 2, 5, 7, 9,12,14,17,19,21,24,26,29,31,34,36,39,41,44,46,48],//10	x4.0 
];

function SceneCallCameraControl(options) {
	this.options = options;
    
    this.CallCameraControlView =null;

    this.ZoomBtn		= null;
    this.ArrowUpBtn		= null;
    this.ArrowDownBtn	= null;
    this.ArrowLeftBtn	= null;
    this.ArrowRightBtn	= null;
    
    this.slider	= null;
    
    this.PointerBGLabel = null;
    this.PointerLabel	= null;
    
	this.CurrentZoomValue = null;
	this.CurrentPanValue = null;			// left/right
	this.CurrentTiltValue = null;		// up/down
      
	this.currentHighlightObj = null;
	this.flag_press_btn = false;

	this.TooltipTimer = null;
	this.flag_shown_tooltip = false;
	this.flag_shown_arrow = false;
	this.flag_shown_slider = true;
	this.flag_gesture_mode = false;	
	this.flag_mirror = false;
	
}

SceneCallCameraControl.prototype.initialize = function () {
	alert("SceneCallCameraControl.initialize()");

	this.create();
}

SceneCallCameraControl.prototype.handleShow = function () {
	alert("SceneCallCameraControl.handleShow()");

	$('#CallCameraControl_window').css('opacity','0.0');
	$('#CallCameraControl_window').css('display','none');
	
    this.update(); 

    ProcMgr.StartTwoHandGesture();
}

SceneCallCameraControl.prototype.handleHide = function () {
	alert("SceneCallCameraControl.handleHide()");

	PluginAPIMgr.SaveDBZoom(this.CurrentZoomValue);
	PluginAPIMgr.SaveDBPan(this.CurrentPanValue);
	PluginAPIMgr.SaveDBTilt(this.CurrentTiltValue);

	if(this.TooltipTimer)
	{
		clearTimeout(this.TooltipTimer);
		$('#CallCameraControl_zoom_tooltip').sfTooltip('hide');
		//$('#CallCameraControl_helpbar').sfKeyHelp('hide');
		
		this.flag_shown_tooltip = false;		
	}	

	if(ProcMgr.GetIsInCall() == true)
	{
	    ProcMgr.ExchangeVideoRect(false);
	}
	else
	{			
		PluginAPIMgr.StopPreview();

		PluginAPIMgr.SetZoomState(0);
		PluginAPIMgr.SetPanState(0);
		PluginAPIMgr.SetTiltState(0);
		
	}

    this.ChangeGestureMode(false);
	ProcMgr.StopTwoHandGesture();
}

SceneCallCameraControl.prototype.handleFocus = function () {
	alert("SceneCallCameraControl.handleFocus()");
	
    this.ShowTooltip();
}

SceneCallCameraControl.prototype.handleBlur = function () {
	alert("SceneCallCameraControl.handleBlur()");	
	
}

SceneCallCameraControl.prototype.handleKeyDown = function (keyCode) {
	alert("SceneCallCameraControl.handleKeyDown(" + keyCode + ")");
	
	if(this.flag_press_btn == true)
	{
		alert('flag_press_btn is true!!!!!');
		sf.key.preventDefault();
		return;
	}
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	switch (keyCode) {
		case sf.key.LEFT:
			this.highlight(this.ArrowLeftBtn);
			if(this.flag_mirror == true)
			{
				this.MoveCamera(2);	
			}
			else
			{
				this.MoveCamera(1);
			}
			break;
		
		case sf.key.RIGHT:
			this.highlight(this.ArrowRightBtn);
			if(this.flag_mirror == true)
			{			
				this.MoveCamera(1);
			}
			else
			{
				this.MoveCamera(2);
			}
			break;
		
		case sf.key.UP:
			this.highlight(this.ArrowUpBtn);
			this.MoveCamera(3);			
			break;			
		
		case sf.key.DOWN:
			this.highlight(this.ArrowDownBtn);
			this.MoveCamera(4);			
			break;
		
		case sf.key.ENTER:
			this.highlight(this.ZoomBtn);
			this.Zoom();
			break;
        
        case sf.key.RETURN:
        case sf.key.EXIT:
            this.processReturnKey();
            sf.key.preventDefault();
			break;
            
		case 602:	//INFOLINK
		case 606:	//CONTENTS
		case 608:	//WISELINK
            ProcMgr.processInfolinkKeyInCall();
            sf.key.preventDefault();
			break;
        
        default:
            ProcMgr.processBlockKey(keyCode);
            break;  
	}
}

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

SceneCallCameraControl.prototype.create = function(){
    alert("SceneCallCameraControl.create() ");
	
	var this_ = sf.scene.get("CallCameraControl");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	
    this.CallCameraControlView = new View("CallCameraControl");
    
	this.createZoomInfo();
     
    this.ZoomBtn = new Button();
    this.ZoomBtn.SetImageObjId("CallCameraControl_zoom_control_icon");
    this.ZoomBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_CAMERA_ZOOM_INOUT_ICON);
    this.ZoomBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_CAMERA_ZOOM_INOUT_SEL_ICON);//IMAGE_CALL_CAMERA_ZOOM_INOUT_ICON
    //this.ZoomBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_CALL_CAMERA_ZOOM_INOUT_SEL_ICON);
	this.ZoomBtn.SetTextObjId("CallCameraControl_zoom_control_text");
    this.ZoomBtn.SetOnClickCallbackFunc(clickCF);
    
    this.ArrowUpBtn = new Button();
    this.ArrowUpBtn.SetImageObjId("CallCameraControl_move_up");
    this.ArrowUpBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_UP);
    this.ArrowUpBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_SEL_UP); //IMAGE_CALL_CAMERA_MOVE_ARROW_FOCUS_UP
    //this.ArrowUpBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_SEL_UP);
    this.ArrowUpBtn.SetOnClickCallbackFunc(clickCF);

    this.ArrowDownBtn = new Button();
    this.ArrowDownBtn.SetImageObjId("CallCameraControl_move_down");
    this.ArrowDownBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_DOWN);
    this.ArrowDownBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_SEL_DOWN);//IMAGE_CALL_CAMERA_MOVE_ARROW_FOCUS_DOWN
    //this.ArrowDownBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_SEL_DOWN);    
    this.ArrowDownBtn.SetOnClickCallbackFunc(clickCF); 

    this.ArrowLeftBtn = new Button();
    this.ArrowLeftBtn.SetImageObjId("CallCameraControl_move_left");
    this.ArrowLeftBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_LEFT);
    this.ArrowLeftBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_SEL_LEFT);//IMAGE_CALL_CAMERA_MOVE_ARROW_FOCUS_LEFT
    //this.ArrowLeftBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_SEL_LEFT);    
    this.ArrowLeftBtn.SetOnClickCallbackFunc(clickCF);
    
    this.ArrowRightBtn = new Button();
    this.ArrowRightBtn.SetImageObjId("CallCameraControl_move_right");
    this.ArrowRightBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_RIGHT);
    this.ArrowRightBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_SEL_RIGHT);//IMAGE_CALL_CAMERA_MOVE_ARROW_FOCUS_RIGHT
    //this.ArrowRightBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_CALL_CAMERA_MOVE_ARROW_SEL_RIGHT);    
    this.ArrowRightBtn.SetOnClickCallbackFunc(clickCF);

	this.slider = new CompBase();
	this.slider.CreateBG("CallCameraControl_zoom_slider");
	this.slider.AddImageLayer("CallCameraControl_zoom_slider_bg_l");
	this.slider.AddImageLayer("CallCameraControl_zoom_slider_bg_c");
	this.slider.AddImageLayer("CallCameraControl_zoom_slider_bg_r");
	this.slider.AddImageLayer("CallCameraControl_zoom_slider_bar_l");
	this.slider.AddImageLayer("CallCameraControl_zoom_slider_bar_c");
	this.slider.AddImageLayer("CallCameraControl_zoom_slider_bar_r");	

	this.slider.SetImageLayer(1,g_Image.IMAGE_CALL_CAMERA_ZOOM_SLIDER_BG_L);
	this.slider.SetImageLayer(2,g_Image.IMAGE_CALL_CAMERA_ZOOM_SLIDER_BG_C);
	this.slider.SetImageLayer(3,g_Image.IMAGE_CALL_CAMERA_ZOOM_SLIDER_BG_R);
	this.slider.SetImageLayer(4,g_Image.IMAGE_CALL_CAMERA_ZOOM_SLIDER_BAR_L);
	this.slider.SetImageLayer(5,g_Image.IMAGE_CALL_CAMERA_ZOOM_SLIDER_BAR_C);
	this.slider.SetImageLayer(6,g_Image.IMAGE_CALL_CAMERA_ZOOM_SLIDER_BAR_R);


	$('#CallCameraControl_zoom_tooltip').sfTooltip({
		text : TV_SID_SELECT_TO_ZOOM_IN,
		orientation : 'up'
	});	
	this.flag_shown_tooltip = true;
	
	$('#CallCameraControl_helpbar').sfKeyHelp({
		'theme' : 'TRANSPARENT',
		'return' : TV_SID_SAVE_AND_GO_BACK
	});	
	$('#CallCameraControl_helpbar').sfKeyHelp('show');
}

SceneCallCameraControl.prototype.update=function()
{  	
    alert("SceneCallCameraControl.update() ");
 	
 	//disable face traking    <--- from video setting
 	PluginAPIMgr.FaceTracking(false);
	
	if(ProcMgr.GetIsInCall() == true)
	{
		this.flag_mirror = true;
	}
	else
	{
		this.flag_mirror = false;
	}
	
		//sync
		PluginAPIMgr.SyncZoomState();
		PluginAPIMgr.SyncPanState();
		PluginAPIMgr.SyncTiltState();		
	
    this.CurrentZoomValue	= PluginAPIMgr.GetZoomState();
	this.CurrentPanValue	= PluginAPIMgr.GetPanState();
	this.CurrentTiltValue	= PluginAPIMgr.GetTiltState();

	if(parseInt(this.CurrentZoomValue%2)==1)
	{
		this.CurrentZoomValue--;
		PluginAPIMgr.SetZoomState(this.CurrentZoomValue);
	}
    this.setZoomText(this.CurrentZoomValue);
    this.setZoomProcess(this.CurrentZoomValue);

    alert("camera status: zoom="+this.CurrentZoomValue+" pan="+this.CurrentPanValue+" tilt="+this.CurrentTiltValue);
    
    if(this.CurrentZoomValue == 0)
    {
    	this.ArrowUpBtn.hiddenObj();
    	this.ArrowDownBtn.hiddenObj();
    	this.ArrowLeftBtn.hiddenObj();
    	this.ArrowRightBtn.hiddenObj();
    	this.flag_shown_arrow = false;
    }
        
	this.refreshZoomInfo();
								
	PluginAPIMgr.StartOSDTimer(200,
		function() {
						
			if(ProcMgr.GetIsInCall() == true)
			{
			    ProcMgr.ExchangeVideoRect(true);
			}
			else
			{
				PluginAPIMgr.StartPreview(0,0,1920,1080, true);
			}
		
			$('#CallCameraControl_window').css('opacity','1.0');
			$('#CallCameraControl_window').css('display','block');
		},
		ENUM_TIMER_TYPE.OTHER
	);
}

SceneCallCameraControl.prototype.setZoomText = function(zoomState)
{
	
	var magnificationText;
		
    switch(zoomState)
    {
		case 0:
			magnificationText = "X 1.0";
            break;
            
		case 1:
			magnificationText = "X 1.3";
            break;

		case 2:
			magnificationText = "X 1.6";
            break;

		case 3:
			magnificationText = "X 1.9";
            break;

		case 4:
			magnificationText = "X 2.2";
            break;
            
		case 5:
			magnificationText = "X 2.5";
            break;

		case 6:
			magnificationText = "X 2.8";
            break;

		case 7:
			magnificationText = "X 3.1";
            break;
            
		case 8:
			magnificationText = "X 3.4";
            break;

		case 9:
			magnificationText = "X 3.7";
            break;

		case 10:
			magnificationText = "X 4.0";
            break;
        
        default:
        	magnificationText = "X 0.0";
    }
        
    this.ZoomBtn.SetText(magnificationText);
}

SceneCallCameraControl.prototype.highlight=function(obj)
{
	this.currentHighlightObj = obj;

	if(obj)
	{
		obj.highlight();
		this.flag_press_btn = true;
	}

	PluginAPIMgr.StartOSDTimer("500" , function() { sf.scene.get('CallCameraControl').unHighlight();}, ENUM_TIMER_TYPE.POPUP_WND);
}
SceneCallCameraControl.prototype.RemovedCamera = function(){
	alert("SceneCallCameraControl.RemovedCamera() ");
	this.processReturnKey();
}
SceneCallCameraControl.prototype.processReturnKey = function(){
    alert("SceneCallCameraControl.processReturnKey() ");

	//StateMgr.Stop_Call_Camera_Control_State();
	if(ProcMgr.GetIsInCall() == true)
	{
		StateMgr.Start_Video_Call_State();
	}
	else
	{
		StateMgr.Start_Main_State();
		var scene = sf.scene.get("ListMainSetting");
		scene.BtnIdx = 2;
		scene.highlight(scene.SettingsBtn[2]);
		
		StateMgr.Start_SettingsVideo_State("1");
	}
}

SceneCallCameraControl.prototype.processExitKey = function(){
    alert("SceneCallCameraControl.processExitKey() ");
   
	//exit form skype
	if(ProcMgr.GetIsInCall() == true)
	{
		StateMgr.Start_Video_Call_State();
	}
	else
	{
		StateMgr.Start_Main_State();
		var scene = sf.scene.get("ListMainSetting");
		scene.BtnIdx = 2;
		scene.highlight(scene.SettingsBtn[2]);
		StateMgr.Start_SettingsVideo_State("1");
	}
}

SceneCallCameraControl.prototype.Zoom = function(){
    alert("SceneCallCameraControl.zoom ");
   	
   	//save trev data
	var	tmpZoomValue = this.CurrentZoomValue;
   	
   	if(this.CurrentZoomValue == 0)
   	{
    	this.ArrowUpBtn.visibleObj();
    	this.ArrowDownBtn.visibleObj();
    	this.ArrowLeftBtn.visibleObj();
    	this.ArrowRightBtn.visibleObj();
    	this.flag_shown_arrow = true;
   	}
   	
   	this.CurrentZoomValue += 2;
   	
   	if(this.CurrentZoomValue > 10)
   	{
   		this.CurrentZoomValue = 0;
		this.CurrentPanValue = 0;
		this.CurrentTiltValue = 0;

    	this.ArrowUpBtn.hiddenObj();
    	this.ArrowDownBtn.hiddenObj();
    	this.ArrowLeftBtn.hiddenObj();
    	this.ArrowRightBtn.hiddenObj();
		this.flag_shown_arrow = false;
   	}
   	      	   
   	if(PluginAPIMgr.SetZoomState(this.CurrentZoomValue) == false)
   	{
   		this.CurrentZoomValue = tmpZoomValue;
   		
	   	if(this.CurrentZoomValue == 0 && this.flag_shown_arrow == true)
	   	{
	    	this.ArrowUpBtn.hiddenObj();
	    	this.ArrowDownBtn.hiddenObj();
	    	this.ArrowLeftBtn.hiddenObj();
	    	this.ArrowRightBtn.hiddenObj();
	    	this.flag_shown_arrow = false;
	   	}
	   	else if(this.CurrentZoomValue > 0 && this.flag_shown_arrow == false)
	   	{
	   		this.ArrowUpBtn.visibleObj();
	    	this.ArrowDownBtn.visibleObj();
	    	this.ArrowLeftBtn.visibleObj();
	    	this.ArrowRightBtn.visibleObj();
	    	this.flag_shown_arrow = true;
	   	}
   	}
   	else
   	{
   		this.setZoomText(this.CurrentZoomValue);
		this.setZoomProcess(this.CurrentZoomValue);
   		this.refreshZoomInfo();
   	}
		
}


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

	if(this.flag_press_btn == true)
	{
		alert('flag_press_btn is true!!!!!');
		return;
	}

	this.highlight(obj);
	
	switch(obj)
	{
		case this.ZoomBtn:
			this.Zoom();
			break;
		case this.ArrowUpBtn:
			this.MoveCamera(3);			
			break;				
		case this.ArrowDownBtn:
			this.MoveCamera(4);
			break;		
		case this.ArrowRightBtn:
			if(this.flag_mirror == true)
			{
				this.MoveCamera(2);	
			}
			else
			{
				this.MoveCamera(1);
			}
			break;		
		case this.ArrowLeftBtn:
			if(this.flag_mirror == true)
			{
				this.MoveCamera(1);	
			}
			else
			{
				this.MoveCamera(2);
			}
			break;		
	}
}

SceneCallCameraControl.prototype.unHighlight = function()
{			
	this.currentHighlightObj.blur();
	
	this.currentHighlightObj = null;
	this.flag_press_btn = false;
}

SceneCallCameraControl.prototype.ShowTooltip = function()
{		
	alert("SceneCallCameraControl.ShowTooltip()");

	if(this.flag_shown_tooltip == false)
	{
		$('#CallCameraControl_zoom_tooltip').sfTooltip('show');
		//$('#CallCameraControl_helpbar').sfKeyHelp('show');
		this.flag_shown_tooltip = true;
	}
	
	if(this.TooltipTimer)
	{
		clearTimeout(this.TooltipTimer);
	}
    
	this.TooltipTimer = setTimeout("HideToolTipCallBack()", 5500);
	
	HideToolTipCallBack = function(){
		$('#CallCameraControl_zoom_tooltip').sfTooltip('hide');
		//$('#CallCameraControl_helpbar').sfKeyHelp('hide');
		sf.scene.get('CallCameraControl').flag_shown_tooltip = false;
    }
}

SceneCallCameraControl.prototype.createZoomInfo = function()
{
	alert('SceneCallCameraControl.createZoomInfo');	
	$('#CallCameraControl_zoom_info_bg').css('background-image','url(images/720p/thumbnail/zoom_info_bg.png)');

	$('#CallCameraControl_zoom_info_pointer_tl').css('background-image','url(images/720p/thumbnail/zoom_info_top_left.png)');
	$('#CallCameraControl_zoom_info_pointer_tc').css('background-image','url(images/720p/thumbnail/zoom_info_top_center.png)');
	$('#CallCameraControl_zoom_info_pointer_tr').css('background-image','url(images/720p/thumbnail/zoom_info_top_right.png)');
	$('#CallCameraControl_zoom_info_pointer_cl').css('background-image','url(images/720p/thumbnail/zoom_info_middle_left.png)');	
	$('#CallCameraControl_zoom_info_pointer_cc').css('background-image','url(images/720p/thumbnail/zoom_info_middle_center.png)');
	$('#CallCameraControl_zoom_info_pointer_cr').css('background-image','url(images/720p/thumbnail/zoom_info_middle_right.png)');
	$('#CallCameraControl_zoom_info_pointer_bl').css('background-image','url(images/720p/thumbnail/zoom_info_under_left.png)');
	$('#CallCameraControl_zoom_info_pointer_bc').css('background-image','url(images/720p/thumbnail/zoom_info_under_center.png)');
	$('#CallCameraControl_zoom_info_pointer_br').css('background-image','url(images/720p/thumbnail/zoom_info_under_right.png)');
}

SceneCallCameraControl.prototype.refreshZoomInfo = function()
{
	alert('SceneCallCameraControl.moveZoomInfo');
	
	this.resizeZoomInfo();
	this.moveZoomInfo();

}

SceneCallCameraControl.prototype.moveZoomInfo = function()
{
    alert("moveZoomInfo: zoom="+this.CurrentZoomValue+" pan="+this.CurrentPanValue+" tilt="+this.CurrentTiltValue);

	var arrayIndex = parseInt(this.CurrentZoomValue/2);		
	var pointer_left = ZOOM_POINTER_X_ARRY[arrayIndex][this.CurrentPanValue+10] + 'px';
	var pointer_top = ZOOM_POINTER_Y_ARRY[arrayIndex][this.CurrentTiltValue+10] + 'px';
	
	$('#CallCameraControl_zoom_info_pointer').css('top',pointer_top);
	$('#CallCameraControl_zoom_info_pointer').css('left',pointer_left);
}

SceneCallCameraControl.prototype.resizeZoomInfo = function()
{
	alert('resizeZoomInfo zoom='+this.CurrentZoomValue);

	var time_value = 10/(10+(3*(this.CurrentZoomValue)));
	alert('time_value=' + time_value);
	
    var pointer_width = parseInt(114*time_value);
    var pointer_height = parseInt(64*time_value);
	
	alert('pointer_width=' + pointer_width + '   pointer_height=' + pointer_height);
	
	$('#CallCameraControl_zoom_info_pointer').css('width',pointer_width + 'px');
	$('#CallCameraControl_zoom_info_pointer').css('height',pointer_height + 'px');

	var c_width = (pointer_width-8) + 'px';
	var f_left = (pointer_width-4) + 'px';
	var c_height = (pointer_height-8) + 'px';
	var b_top = (pointer_height-4) + 'px';

	$('#CallCameraControl_zoom_info_pointer_tc').css('width',c_width);
	$('#CallCameraControl_zoom_info_pointer_tr').css('left',f_left);
	
	$('#CallCameraControl_zoom_info_pointer_cl').css('height',c_height)
	$('#CallCameraControl_zoom_info_pointer_cc').css('width',c_width);
	$('#CallCameraControl_zoom_info_pointer_cc').css('height',c_height)	
	$('#CallCameraControl_zoom_info_pointer_cr').css('left',f_left);
	$('#CallCameraControl_zoom_info_pointer_cr').css('height',c_height)		
	
	$('#CallCameraControl_zoom_info_pointer_bl').css('top',b_top);
	$('#CallCameraControl_zoom_info_pointer_bc').css('top',b_top);
	$('#CallCameraControl_zoom_info_pointer_bc').css('width',c_width);
	$('#CallCameraControl_zoom_info_pointer_br').css('top',b_top);
	$('#CallCameraControl_zoom_info_pointer_br').css('left',f_left);
}

SceneCallCameraControl.prototype.MoveCamera = function(direction)
{
	alert('SceneCallCameraControl.MoveCamera');

	if(direction == 1 || direction == 2)
	{
		
		var prevPanValue = this.CurrentPanValue;
		
		if(direction == 1)
		{
			//up
			this.CurrentPanValue--;
			if(this.CurrentPanValue < -10)
			{
				this.CurrentPanValue = -10;
				return;
			}
		}
		else
		{
			//down
			this.CurrentPanValue++;
			if(this.CurrentPanValue > 10)
			{
				this.CurrentPanValue = 10;
				return;
			}
		}
		PluginAPIMgr.SetPanState(this.CurrentPanValue);
	}
	else if(direction == 3 || direction == 4)
	{
		var prevTiltValue = this.CurrentTiltValue;
		
		if(direction == 3)
		{
			//up
			this.CurrentTiltValue--;
			if(this.CurrentTiltValue < -10)
			{
				this.CurrentTiltValue = -10;
				return;
			}			
		}
		else
		{
			//down
			this.CurrentTiltValue++;
			if(this.CurrentTiltValue > 10)
			{
				this.CurrentTiltValue = 10;
				return;
			}			
		}
		PluginAPIMgr.SetTiltState(this.CurrentTiltValue);
	}
	this.moveZoomInfo();
}

SceneCallCameraControl.prototype.ChangeGestureMode = function(bGestureMode)
{
	alert('SceneCallCameraControl.ChangeGestureMode');	
	
	if(bGestureMode == true)
	{
		if(this.flag_gesture_mode == false)
		{
			$('#CallCameraControl_bg').css('visibility','hidden');

		   	if(this.CurrentZoomValue == 0 && this.flag_shown_arrow == true)
		   	{
		    	this.ArrowUpBtn.hiddenObj();
		    	this.ArrowDownBtn.hiddenObj();
		    	this.ArrowLeftBtn.hiddenObj();
		    	this.ArrowRightBtn.hiddenObj();
		    	this.flag_shown_arrow = false;
		   	}
			
			this.flag_gesture_mode = true;
		}
	}
	else
	{
		if(this.flag_gesture_mode == true)
		{
			$('#CallCameraControl_bg').css('visibility','visible');
			
		   	if(this.CurrentZoomValue > 0 && this.flag_shown_arrow == false)
		   	{
		    	this.ArrowUpBtn.visibleObj();
		    	this.ArrowDownBtn.visibleObj();
		    	this.ArrowLeftBtn.visibleObj();
		    	this.ArrowRightBtn.visibleObj();
		    	this.flag_shown_arrow = true;
		   	}
			
			this.flag_gesture_mode = false;
		}
	}
	
}

//for Gesture zoom in&out
SceneCallCameraControl.prototype.ZoomIn = function()
{ 
	if(this.CurrentZoomValue > 8)
	{
		return;
	}
	var tmpZoomValue = this.CurrentZoomValue; 
   	this.CurrentZoomValue += 2;
   
   	if(PluginAPIMgr.SetZoomState(this.CurrentZoomValue) == false)
   	{
   		this.CurrentZoomValue = tmpZoomValue;
   	}
   	else{
   		this.setZoomText(this.CurrentZoomValue);
   		this.setZoomProcess(this.CurrentZoomValue);
   		this.refreshZoomInfo();   		
   	}
}

SceneCallCameraControl.prototype.ZoomOut = function()
{
   	if(this.CurrentZoomValue == 0)
   	{
		return;
   	}
   	
	var tmpZoomValue = this.CurrentZoomValue;    	
   	this.CurrentZoomValue -= 2;
   	
   	if(PluginAPIMgr.SetZoomState(this.CurrentZoomValue) == false)
   	{
   		this.CurrentZoomValue = tmpZoomValue;
   	}
   	else
   	{
   		this.setZoomText(this.CurrentZoomValue);
   		this.setZoomProcess(this.CurrentZoomValue);
   		this.refreshZoomInfo();
   	}
}

SceneCallCameraControl.prototype.setZoomProcess = function(zoomState)
{
	if(zoomState == 0)
	{
		this.slider.Hide();
		this.flag_shown_slider = false;
	}
	else
	{
		if(this.flag_shown_slider == false)
		{
			this.slider.Show();
		}
		
		var bar_width = parseInt(185*zoomState/10);
		var center_width = (bar_width - 12) + 'px';
		var left_width = (bar_width - 6) + 'px';
		
		$('#CallCameraControl_zoom_slider_bar_c').css('width',center_width);
		$('#CallCameraControl_zoom_slider_bar_r').css('left',left_width);
	}
}
