
function SceneminiSkypeCall(options) {
	this.options = options;
    
    this.VideoCallView = null;
    
	this.VolumeBtn		= null;
	this.CameraOffBtn	= null;
	this.CameraOnBtn	= null;
    this.CallEndBtn		= null;

	this.Btn_arry = new Array(3);
	this.Btn_total_num = 0;

    this.HoldIconLabel = null;

	this.call_tooltip = null;
	this.flag_shown_tooltip = false;
	this.TooltipTimer = null;

	//X12
	this.MyCameraAutoFaceTrackingLabel	= null;	
	this.MyCameraNotSurpportLabel	= null;
	this.NoVolumeMixingTVLabel		= null;
	this.NoVolumeMixingSkypeLabel	= null;
	this.CurSkypeCallVolume	= true;
	
    this.CallDurationTextLabel = null;
    
    this.MyCreditText=null;
           	
	this.flag_enable_camera_btn		= true; 
	 
    this.CallMemberThumbnail = null;
    this.CallMemberDisplayName = null;
    this.CallMemberIdentity = null;      
    this.MyThumbnail = null;
    this.flag_camera_unplugged	= false;
    this.flag_shown_hold_icon	= false;
    this.flag_pstn_call			= false;
    
	this.flag_shown_my_avatar = false;
	this.flag_shown_your_avatar = false;

    this.flag_shown_your_view = false;
	this.flag_shown_my_view = false;

    this.is_receiving_video = false;
    this.is_sending_video = false;

	this.flag_hidden_cam_btn = null;
}

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

	this.create();
}

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

    this.update();
    if(Flag_Hidden_State==false)
        $("#skype_popup_background").show();
	this.ShowKeyHelpbar();
}

SceneminiSkypeCall.prototype.handleHide = function () {
	alert("SceneminiSkypeCall.handleHide()");
	
	this.highlight(null);   
	this.hiddenAllView();
	this.hideAllAvartarInEnd();
	this.flag_hidden_cam_btn = null;
	if(Flag_Hidden_State==false)
	   $("#skype_popup_background").hide();
	
}

SceneminiSkypeCall.prototype.handleFocus = function () {
	alert("SceneminiSkypeCall.handleFocus()");
	
    var currentHighlight = this.VideoCallView.getCurrentHighlight();
    var end_btn_index;
    
    if(currentHighlight == null)
    {
        end_btn_index = this.GetBtnIndex(this.CallEndBtn);
    }
    else
    {
        end_btn_index = this.GetBtnIndex(currentHighlight);
    }
        
    this.highlightBtnWithIndex(end_btn_index);
	this.ShowKeyHelpbar();
}

SceneminiSkypeCall.prototype.handleBlur = function () {
	alert("SceneminiSkypeCall.handleBlur()");	
	
	var currentHighlight = this.VideoCallView.getCurrentHighlight();
     if(currentHighlight != null)
    {
        currentHighlight.blur();
    }
}

SceneminiSkypeCall.prototype.handleKeyDown = function (keyCode) {
	alert("SceneminiSkypeCall.handleKeyDown(" + keyCode + ")");

	//PluginAPIMgr.PlayAudio(keyCode);
		
	switch (keyCode) {
		case $.sfKey.LEFT:
            this.processLeftKey();
			break;
		case $.sfKey.RIGHT:
           this.processRightKey();
			break;
		case $.sfKey.UP:			
		case $.sfKey.DOWN:
			break;
		case $.sfKey.ENTER:
        	this.processEnterKey();
			break;
                
		case $.sfKey.RED:
			break;
		case $.sfKey.BLUE:
			break;	 
		case $.sfKey.YELLOW:
		case $.sfKey.GREEN:
            break;
            
		case $.sfKey.TOOLS:
			break;            
            
		case $.sfKey.RETURN:
			this.processReturnKey();
		    $.sfKey.block(event);
		    break;
		    		
		case $.sfKey.EXIT:		   
		    this.processExitKey();
			$.sfKey.block(event);
			break;
        case	ENUM_CALL_BLOCK_KEY_CODE.DUALVIEW:
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.FUNCTION_ISNT_AVAILABLE);
			break;        
    		//Gesture recognition  >> Scroll
         case 40000002:
         case 40000003:
         case 40000004:
         case 40000005:
			break;

        default:
        	ProcMgr.processBlockKey(keyCode);
		    $.sfKey.block(event);
            break;  
	}
	if(Flag_Hidden_State==false)
	event.stopPropagation();
}

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

SceneminiSkypeCall.prototype.create = function(){
    alert("SceneminiSkypeCall.create() ");
	var this_ = $.sfScene.get({id:'miniSkypeCall',scope:WIDGET.id});
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	
    this.VideoCallView = new View("VideoCall");
    this.VideoCallView.SetOnClickCallbackFunc(clickCF);
     
	this.CallDurationTextLabel = new Label(null,"video_call_duration_text");	
	this.CallDurationTextLabel.SetText(IDWS_MOIP_SKYPE_CALL_DURATION + " 00:00:00"); 
	
    this.MyCreditText = new Label(null,"video_call_my_credit_text"); 

    this.HoldIconLabel = new Label("video_call_hold_icon", null);
    this.HoldIconLabel.SetBgImage(g_Image.IMAGE_VIDEO_CALL_HOLD_ICON);

	this.CallMemberThumbnail = new CompBase(); 
	this.CallMemberThumbnail.CreateBG("your_thumbnail_video_call");
	this.CallMemberThumbnail.AddJPGImageLayer("your_thumbnail_video_call_avatar");

	this.MyThumbnail = new CompBase(); 
	this.MyThumbnail.CreateBG("my_thumbnail_video_call");
	this.MyThumbnail.AddJPGImageLayer("my_thumbnail_video_call_avatar");
  
    this.VolumeBtn = new Button();
    this.VolumeBtn.SetImageObjId("video_call_volume_hd_btn");
    this.VolumeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_VOLUME_BTN_NORMAL);
    this.VolumeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_VOLUME_BTN_NORMALFOCUS);
    this.VolumeBtn.SetOnClickCallbackFunc(clickCF);
    this.VolumeBtn.setTextKPILog(SID_VOLUME);
    this.VolumeBtn.SetOnMouseOverCallbackFunc(function(obj){
        this_.processMouseOver(obj);
        this_.showTooltip(this_.VolumeBtn);
    });
    
   
    this.CameraOffBtn = new Button();
    this.CameraOffBtn.SetImageObjId("video_call_camera_on_hd_btn");
    this.CameraOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_VIDEO_CALL_CAMERA_BLOCK_BTN_NORMAL);
    this.CameraOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_VIDEO_CALL_CAMERA_BLOCK_BTN_NORMALFOCUS);
    this.CameraOffBtn.SetOnClickCallbackFunc(clickCF);
    this.CameraOffBtn.setTextKPILog(IDWS_MOIP_CAM_OFF);    
    this.CameraOffBtn.SetOnMouseOverCallbackFunc(function(obj){
        this_.processMouseOver(obj);
        this_.showTooltip(this_.CameraOffBtn);
    });

    this.CameraOnBtn = new Button();
    this.CameraOnBtn.SetImageObjId("video_call_camera_off_hd_btn");
    this.CameraOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_VIDEO_CALL_CAMERA_BTN_NORMAL);
    this.CameraOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_VIDEO_CALL_CAMERA_BTN_NORMALFOCUS);	
    this.CameraOnBtn.SetOnClickCallbackFunc(clickCF); 
    this.CameraOnBtn.setTextKPILog(IDWS_MOIP_CAM_ON);
    this.CameraOnBtn.SetOnMouseOverCallbackFunc(function(obj){
        this_.processMouseOver(obj);
        this_.showTooltip(this_.CameraOnBtn);
    });
    
	this.CallEndBtn = new Button();
    this.CallEndBtn.SetImageObjId("video_call_end_hd_btn");
    this.CallEndBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_END_BTN_NORMAL);
    this.CallEndBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_END_BTN_NORMALFOCUS);
    this.CallEndBtn.SetOnClickCallbackFunc(clickCF);
	this.CallEndBtn.setTextKPILog(TV_SID_END_CALL);
    this.CallEndBtn.SetOnMouseOverCallbackFunc(function(obj){
        this_.processMouseOver(obj);
        this_.showTooltip(this_.CallEndBtn);
    });
	this.MyCameraNotSurpportLabel = new Label(null,"video_call_my_video_not_avaiable_label");
		
	this.MyCameraAutoFaceTrackingLabel = new Label(null,"video_call_camera_off_auto_face_tracking");	
	this.MyCameraAutoFaceTrackingLabel.SetText(TV_SID_AUTO_FACE_TRACKING_STOPPED);
		
	this.NoVolumeMixingTVLabel = new Label(null,"video_call_no_volume_mixing_tv");
	this.NoVolumeMixingTVLabel.SetText('TV');
	
	this.NoVolumeMixingSkypeLabel = new Label(null,"video_call_no_volume_mixing_skype");
	this.NoVolumeMixingSkypeLabel.SetText('Skype');	
	   	       
	this.creatTooltip();
	
	if(WndMgr.Is1366x768Panel() == true)
	{
		$('#your_window_video_call').css('width','208px');
	}
}

SceneminiSkypeCall.prototype.update = function()
{  
    alert("SceneminiSkypeCall.update");
    	
    this.CallMemberThumbnail.SetImageLayer(1,ProcMgr.CallInfo.AvataImg);		
    this.MyThumbnail.SetImageLayer(1,g_Data.GetMyAccountAvataImage());
	
	this.CallMemberIdentity = ProcMgr.CallInfo.Identity;
	
	//get call status....
	this.getCameraState();

    this.is_receiving_video = ProcMgr.IsReceivingVideo();
	this.is_sending_video = ProcMgr.CallInfo.IsSendingVideo;
	
	if(ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.INCOMING_PSTN  ||  ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.OUTGOING_PSTN)
	{
		this.flag_pstn_call = true;	
	}	
	else
	{
		this.flag_pstn_call = false;
	}
     
    
    this.CurSkypeCallVolume = true;
    	
    	
    alert("is_receiving_video = " + this.is_receiving_video);
    alert("is_sending_video = " + this.is_sending_video);

	if(this.is_receiving_video == true)
	{
		this.visibleYourView();	
	}
	if(this.is_sending_video == true)
	{
		this.visibleMyView();
	}

	if(ProcMgr.ModelCode == TV_MODEL_CODE.X12)
	{
		if(this.is_sending_video == false)
		{
			this.MyCameraNotSurpportLabel.SetText(TV_SID_YOUR_VIDEO_IS_NOT_BEING_SENT);
		}		
		this.MyCameraNotSurpportLabel.visibleObj();
		//VTP code
		$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog(TV_SID_YOUR_VIDEO_IS_NOT_BEING_SENT);
	}
		
	this.showAvartar();	
	this.showCredit();		
	this.BtnSetting();		
	this.checkHold();

	//VTP code
	$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog(IDWS_MOIP_SKYPE_CALL_DURATION + " 00:00:00");

}

SceneminiSkypeCall.prototype.toggleCameraBtnEnable=function()
{
    alert("SceneminiSkypeCall.toggleCameraBtnEnable()");

	this.flag_hidden_cam_btn = null;

	var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    
    if((this.flag_camera_unplugged == true) || (this.CallMemberIdentity == 'echo123') || (ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.INCOMING_PSTN) || (ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.OUTGOING_PSTN))
    {
        alert("[mini]toggle Camera Btn Disable");
        
        if(currentHighlight ==  this.CameraOffBtn || currentHighlight ==  this.CameraOnBtn)
        {
			this.highlight(this.CallEndBtn);
        }

		this.CameraOffBtn.hiddenObj();
		this.CameraOnBtn.hiddenObj();  
				
		this.flag_enable_camera_btn = false;
    }
    else
    {
        alert("[mini]toggle Camera Btn Enable ");
                
		if(this.is_sending_video == true)
		{
	        if(currentHighlight ==  this.CameraOffBtn)
	        {
				this.highlight(this.CameraOnBtn);			
	        }
	
			this.CameraOffBtn.hiddenObj();
			
			if(TVCOMM_SERVICE_MODE == TVCHAT_MODE_HIDDEN)			
			{			
				this.flag_hidden_cam_btn = this.CameraOnBtn;
				this.CameraOnBtn.hiddenObj();
			}
			else
			{
			
				this.CameraOnBtn.visibleObj();
			}
			
		}
		else{
	        if(currentHighlight ==  this.CameraOnBtn)
	        {
				this.highlight(this.CameraOffBtn);			
	        }
	        
			this.CameraOnBtn.hiddenObj();

			if(TVCOMM_SERVICE_MODE == TVCHAT_MODE_HIDDEN)
			{
				this.flag_hidden_cam_btn = this.CameraOffBtn;
				this.CameraOffBtn.hiddenObj();
			}
			else
			{			
				this.CameraOffBtn.visibleObj();
			}			
			
		}
		this.flag_enable_camera_btn = true;
    }
}

	
//updateCameraState
SceneminiSkypeCall.prototype.getCameraState = function()
{
    var camera_state = PluginAPIMgr.GetCameraState();    
    if(camera_state == ENUM_CAM_STATE.CAM_STATE_DISCONNECTED || camera_state == ENUM_CAM_STATE.CAM_STATE_CONNECTING)
    {
    	this.flag_camera_unplugged = true;
    }
    else{
    	this.flag_camera_unplugged = false;
    }
	
}

SceneminiSkypeCall.prototype.BtnSetting = function()
{
	alert("SceneminiSkypeCall.BtnSetting");	
	
	this.toggleCameraBtnEnable();
	
	this.AdjustBtnPosition();
	this.SetNoVolumeMixingLabel();
}

SceneminiSkypeCall.prototype.toggleYourVideo = function()
{
	alert("SceneminiSkypeCall.toggleYourVideo");
	
    this.is_receiving_video = ProcMgr.IsReceivingVideo();

	if(this.is_receiving_video == true)
	{
		this.visibleYourView();	
	}
	else
	{
		this.hiddenYourView();
	}
		
	this.showAvartar();
	this.BtnSetting();
}

SceneminiSkypeCall.prototype.toggleMyVideo = function()
{
	alert("SceneminiSkypeCall.toggleMyVideo");
	
    if(PluginAPIMgr.IsSendingVideo() == 0)
    {
    	this.is_sending_video = false;	
    	this.hiddenMyView();
    }
    else
    {
    	this.is_sending_video = true;
    	this.visibleMyView();
    }

	this.showAvartar();
	this.BtnSetting();

}

SceneminiSkypeCall.prototype.highlight = function(obj)
{
    this.VideoCallView.setCurrenHighlight(obj);
}

SceneminiSkypeCall.prototype.highlightBtnWithIndex = function(cur_index)
{
	var cur_name = this.Btn_arry[cur_index];
	alert('highlightBtnWithIndex  = ' + cur_name);
	
    switch(cur_name)
    {
        case 'endcall':
        	this.highlight(this.CallEndBtn);
        	this.showTooltip(this.CallEndBtn);
            break;
        case 'camera':
			if( this.CameraOnBtn.GetFlagVisible() == true)
			{
				this.highlight(this.CameraOnBtn);
				this.showTooltip(this.CameraOnBtn);
			}
			else
			{
				this.highlight(this.CameraOffBtn);
				this.showTooltip(this.CameraOffBtn);
			}
            break;            
        case 'volume':
			this.highlight(this.VolumeBtn);
			this.showTooltip(this.VolumeBtn);
            break;
        default:
        	alert('error!!!!!')
        	this.highlight(null);
        	break;
           
    }	
}

SceneminiSkypeCall.prototype.GetBtnIndex = function(cur_obj)
{
	var btn_name;
    switch(cur_obj)
    {
        case this.CallEndBtn:
        	btn_name = 'endcall';
            break;
		case this.CameraOffBtn:            
		case this.CameraOnBtn:
			btn_name = 'camera';
            break;
        case this.VolumeBtn:		
			btn_name = 'volume';
            break;
    }

	for (var i=0; i < 3; i++) 
	{		
		if((this.Btn_arry[i] != null) && (btn_name == this.Btn_arry[i]))
		{
			return i;
		}
	}
	return -1;
}


SceneminiSkypeCall.prototype.processLeftKey=function()
{
    alert("SceneminiSkypeCall.processLeftKey() ");
    var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    //check flag keypad or btn...
    
    var cur_index = this.GetBtnIndex(currentHighlight);
    
    cur_index--;
    
    if(cur_index < 0)
    {
    	alert('no more btn!!!');
    	return;
    }
    
    this.highlightBtnWithIndex(cur_index);
}

SceneminiSkypeCall.prototype.processRightKey = function()
{
    alert("SceneminiSkypeCall.processRightKey() ");
    var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    
    //check flag keypad or btn...
    
    var cur_index = this.GetBtnIndex(currentHighlight);
    
    cur_index++;
    
    if(cur_index > (this.Btn_total_num - 1))    
    {
    	alert('no more btn!!!');
    	return;
    }
    
    this.highlightBtnWithIndex(cur_index);
}

SceneminiSkypeCall.prototype.processEnterKey=function()
{
    alert("SceneminiSkypeCall.processEnterKey() ");
    var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {    	
        case this.CallEndBtn:
        	this.hiddenAllView();
        	this.showAllAvartarInEnd();
            ProcMgr.DisconnectCall();
            break;
		
		case this.CameraOffBtn:			
		case this.CameraOnBtn:
			this.changeCameraBtn();
			break;
		
		case this.VolumeBtn:	
			this.processVolumeKey();
			break;                
    }
}


SceneminiSkypeCall.prototype.processReturnKey = function(){
    alert("SceneminiSkypeCall.processReturnKey() ");

	WndMgr.StartCallConfirmPopup(MINI_CALL_CONFIRM_POPUP.WANT_TO_END_CALL);
}

SceneminiSkypeCall.prototype.processVolumeKey=function()
{
    alert("SceneminiSkypeCall.processVolumeKey() ");

	if(ProcMgr.ModelCode == TV_MODEL_CODE.X12 || ProcMgr.ModelCode == TV_MODEL_CODE.FOX_SBB)
	{
		if(ProcMgr.CurOutputMixVolume == 0)
		{			
			PluginAPIMgr.MuteMic(true);
			PluginAPIMgr.SetCallMixVolume(0);			
			PluginAPIMgr.SetTVMixVolume(100);
			ProcMgr.CurOutputMixVolume = 1;
			
			$("#video_call_no_volume_mixing_tv").css('color','#000000');
			$("#video_call_no_volume_mixing_skype").css('color','#FFFFFF');
		}
		else
		{
			PluginAPIMgr.MuteMic(false);
			PluginAPIMgr.SetTVMixVolume(0);
			PluginAPIMgr.SetCallMixVolume(100);
			ProcMgr.CurOutputMixVolume = 0;

			$("#video_call_no_volume_mixing_tv").css('color','#FFFFFF');
			$("#video_call_no_volume_mixing_skype").css('color','#000000');
		}		
	}
	else
	{
		StateMgr.Start_Volume_Speaker_State();	
	}
}

SceneminiSkypeCall.prototype.processMouseOver = function(obj){
    alert("SceneminiSkypeCall.processMouseOver() ");

    var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
        this.highlight(obj);
    }
    

}
SceneminiSkypeCall.prototype.processClickEvent = function(obj){
	alert("SceneminiSkypeCall.processClickEvent() ");
	
	var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }
	
	this.processEnterKey();

}

SceneminiSkypeCall.prototype.visibleYourView = function()
{
	alert("SceneminiSkypeCall.visibleYourView");
	if(this.flag_shown_your_view == false)
	{
		$('#your_window_video_call').css('opacity','1.0');
		$('#your_window_video_call').css('display','block');
		this.flag_shown_your_view = true;
	}
}

SceneminiSkypeCall.prototype.visibleMyView = function()
{
	alert("SceneminiSkypeCall.visibleMyView");
	if(this.flag_shown_my_view == false)
	{
		if(ProcMgr.ModelCode == TV_MODEL_CODE.X12)
		{
			this.MyCameraNotSurpportLabel.SetText(TV_SID_YOUR_VIDEO_IS_BEING_SENT);
			if(PluginAPIMgr.GetDBAutoTracking() == 1)
			{
				PluginAPIMgr.FaceTracking(false);
				this.MyCameraAutoFaceTrackingLabel.visibleObj();
				
				//VTP code
				$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog(TV_SID_YOUR_VIDEO_IS_BEING_SENT);
				$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog(TV_SID_AUTO_FACE_TRACKING_STOPPED);
			}
		}
		else
		{
			$('#my_window_video_call').css('opacity','1.0');
			$('#my_window_video_call').css('display','block');			
		}

		this.flag_shown_my_view = true;
	}
}

SceneminiSkypeCall.prototype.hiddenYourView = function()
{
	alert("SceneminiSkypeCall.hiddenYourView");
	if(this.flag_shown_your_view == true)
	{	
		$('#your_window_video_call').css('opacity','0.0');
		$('#your_window_video_call').css('display','none');				
		
		this.flag_shown_your_view = false;
	}
}

SceneminiSkypeCall.prototype.hiddenMyView = function()
{
	alert("SceneminiSkypeCall.hiddenMyView");
	if(this.flag_shown_my_view == true)
	{
		if(ProcMgr.ModelCode == TV_MODEL_CODE.X12)
		{
			this.MyCameraNotSurpportLabel.SetText(TV_SID_YOUR_VIDEO_IS_NOT_BEING_SENT);
			this.MyCameraAutoFaceTrackingLabel.hiddenObj();

			//VTP code
			$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog(TV_SID_YOUR_VIDEO_IS_NOT_BEING_SENT);
			
		}
		else
		{
			$('#my_window_video_call').css('opacity','0.0');
			$('#my_window_video_call').css('display','none');
		}
		this.flag_shown_my_view = false;
	}
}

SceneminiSkypeCall.prototype.hiddenAllView = function()
{
	alert("SceneminiSkypeCall.hiddenView");
	this.hiddenYourView();
	this.hiddenMyView();
	
	if(ProcMgr.ModelCode == TV_MODEL_CODE.X12)
	{
		this.MyCameraNotSurpportLabel.hiddenObj();
		this.MyCameraAutoFaceTrackingLabel.hiddenObj();
	}
}

SceneminiSkypeCall.prototype.showAvartar = function(){
	alert("SceneminiSkypeCall.showAvartar() ");

	//check avatar show..
	if(this.is_receiving_video == false)
	{
		if(this.flag_shown_your_avatar == false)
		{
			alert("CallMemberThumbnail.Show");
			this.CallMemberThumbnail.Show();
			this.flag_shown_your_avatar = true;
		}		
	}
	else
	{
		if(this.flag_shown_your_avatar == true)
		{
			alert("CallMemberThumbnail.Hide");		
			this.CallMemberThumbnail.Hide();
			this.flag_shown_your_avatar = false;
		}		
	}
	
	if(this.is_sending_video == false)
	{
		if(ProcMgr.ModelCode != TV_MODEL_CODE.X12)
		{
			if(this.flag_shown_my_avatar == false)
			{		
				alert("MyThumbnail.Show");
				this.MyThumbnail.Show();
				this.flag_shown_my_avatar = true;
			}
		}
	}
	else
	{
		if(this.flag_shown_my_avatar == true)
		{		
			alert("MyThumbnail.Hide");		
			this.MyThumbnail.Hide();
			this.flag_shown_my_avatar = false;
		}				
	}
}


SceneminiSkypeCall.prototype.showAllAvartarInEnd = function(){
	alert("SceneminiSkypeCall.showAllAvartarInEnd() ");

	if(this.flag_shown_your_avatar == false)
	{
		this.CallMemberThumbnail.Show();
		this.flag_shown_your_avatar = true;
	}
	
	if(this.flag_shown_my_avatar == false)
	{		
		this.MyThumbnail.Show();
		this.flag_shown_my_avatar = true;
	}
}

SceneminiSkypeCall.prototype.hideAllAvartarInEnd = function(){
	alert("SceneminiSkypeCall.hideAllAvartarInEnd() ");

	if(this.flag_shown_your_avatar == true)
	{
		this.CallMemberThumbnail.Hide();
		this.flag_shown_your_avatar = false;
	}	
	
	if(this.flag_shown_my_avatar == true)
	{
		this.MyThumbnail.Hide();
		this.flag_shown_my_avatar = false;
	}
}

SceneminiSkypeCall.prototype.changeCameraBtn= function()
{
	if( this.CameraOnBtn.GetFlagVisible() == true)
	{
		this.CameraOnBtn.hiddenObj();
		//this.CameraOnBtn.blur();		
		this.highlight(this.CameraOffBtn);	
		this.CameraOffBtn.visibleObj();
		this.showTooltip(this.CameraOffBtn);
		
		ProcMgr.StopSendVideo();
	}
	else
	{
		this.CameraOffBtn.hiddenObj();
		//this.CameraOffBtn.blur();		
		this.highlight(this.CameraOnBtn);			
		this.CameraOnBtn.visibleObj();
		this.showTooltip(this.CameraOnBtn);
		
		ProcMgr.StartSendVideo();
	}
}

//1. camera  2.volume  3.end call
SceneminiSkypeCall.prototype.AdjustBtnPosition = function(){
	alert("SceneminiSkypeCall.AdjustBtnPosition() ");

	var btn_count = 2;
	var btn_cur_index = 0;
	
	//reset
	for(var i=0; i < 3; i++)
	{
		this.Btn_arry[i] = null;
	}
	
	//Step 1. count button number
	//tv & end call btn
	if(this.flag_enable_camera_btn == true)
	{	
		btn_count++;
		this.Btn_arry[btn_cur_index++] = 'camera';
	}
	this.Btn_arry[btn_cur_index++] = 'volume';
	this.Btn_arry[btn_cur_index++] = 'endcall';

	this.Btn_total_num = btn_count;

	//Setp 2. set position
	for (var i=0; i < btn_count; i++) {
		this.SetBtnPosition(this.Btn_arry[i],btn_count,i);
	}
	
}


SceneminiSkypeCall.prototype.SetBtnPosition = function(BtnName,totalNum,index)
{
	alert('SetBtnPosition >> BtnName = ' + BtnName + '>> totalNum = ' + totalNum + '>> index = ' + index );

	var BtnPositionArry = [
		['128px','0px','0px'],//2 btn
		['83px','173px','0px'],
		['55px','128px','201px']
	];

	var OnBtnEID = null;
	var OffBtnEID = null;

	if(BtnName == 'camera')
	{
		OnBtnEID = '#video_call_camera_on_hd_btn';
		OffBtnEID = '#video_call_camera_off_hd_btn';
	}	
	else if(BtnName == 'volume')
	{	
		OnBtnEID = '#video_call_volume_hd_btn';
	}	
	else if(BtnName == 'endcall')
	{
		OnBtnEID = '#video_call_end_hd_btn';
	}
	
	//set on btn position
	$(OnBtnEID).css('left',BtnPositionArry[totalNum-1][index]);
	
	//set off btn position
	if(OffBtnEID != null)
	{
		$(OffBtnEID).css('left',BtnPositionArry[totalNum-1][index]);
	}	
}

SceneminiSkypeCall.prototype.checkHold = function()
{
	alert("SceneminiSkypeCall.checkHold() ");

	if(g_Data.GetCallRemoteHold() == true)
	{
		this.setHold(true);
	}
	else
	{
		this.setHold(false);
	}
}

SceneminiSkypeCall.prototype.setHold = function(showFlag)
{
	alert("SceneminiSkypeCall.setHold()"+showFlag);
	if(showFlag == true)
	{
		if(this.flag_shown_hold_icon == false)
		{
			$('#video_call_hold_area').css("display","block");
			this.highlight(null);
			this.call_tooltip.Hide();
			this.flag_shown_tooltip = false;			
						
			this.flag_shown_hold_icon = true;
		}
	}
	else
	{
		if(this.flag_shown_hold_icon == true)
		{
			$('#video_call_hold_area').css("display","none");
			var currentHighlight =  this.VideoCallView.getCurrentHighlight();			
	        if(currentHighlight ==  null)
	        {
				currentHighlight = this.CallEndBtn;
	        }
			var cur_index = this.GetBtnIndex(currentHighlight);
			this.highlightBtnWithIndex(cur_index);
			
			this.flag_shown_hold_icon = false;
		}
	}
}

SceneminiSkypeCall.prototype.updateCallDuration = function(time)
{
     this.CallDurationTextLabel.SetText(IDWS_MOIP_SKYPE_CALL_DURATION + "  "  + time);
}

SceneminiSkypeCall.prototype.showCredit = function()
{	
	if(this.flag_pstn_call == true)
	{
		//show
		this.updateCredit();
		this.MyCreditText.visibleObj();
	}
	else
	{
		//hide
		this.MyCreditText.hiddenObj();
	}
}

SceneminiSkypeCall.prototype.updateCredit = function()
{
	var credit_text = PluginAPIMgr.GetMyCredit();
	this.MyCreditText.SetText(credit_text);
	//VTP code
	$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog(credit_text);
}

//volume btn is first!!
SceneminiSkypeCall.prototype.SetNoVolumeMixingLabel = function()
{	
	if(ProcMgr.ModelCode != TV_MODEL_CODE.X12 && ProcMgr.ModelCode != TV_MODEL_CODE.FOX_SBB)
	{
		return;
	}

	this.NoVolumeMixingTVLabel.visibleObj();
	this.NoVolumeMixingSkypeLabel.visibleObj();

	$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog('TV');
	$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog('Skype');
	
	var tv_label_left = '133px';
	var skype_label_left = '158px';

	if(this.Btn_total_num == 2)
	{
		tv_label_left = '90px';
		skype_label_left = '115px';		
	}
	
	$("#video_call_no_volume_mixing_tv").css('left',tv_label_left);
	$('#video_call_no_volume_mixing_skype').css('left',skype_label_left);

	if(ProcMgr.CurOutputMixVolume == 0)
	{
		$("#video_call_no_volume_mixing_tv").css('color','#FFFFFF');
		$("#video_call_no_volume_mixing_skype").css('color','#000000');
	}
	else
	{
		$("#video_call_no_volume_mixing_skype").css('color','#FFFFFF');
		$("#video_call_no_volume_mixing_tv").css('color','#000000');
	}
}

SceneminiSkypeCall.prototype.creatTooltip = function()
{	
	this.call_tooltip = new CompBase(); 
	this.call_tooltip.CreateBG("video_call_tooltip_bg");
	this.call_tooltip.AddImageLayer("video_call_tooltip_left_corner");
	this.call_tooltip.AddImageLayer("video_call_tooltip_left_px");
	this.call_tooltip.AddImageLayer("video_call_tooltip_center");
	this.call_tooltip.AddImageLayer("video_call_tooltip_right_px");
	this.call_tooltip.AddImageLayer("video_call_tooltip_right_corner");
	this.call_tooltip.AddTextLayer("video_call_tooltip_text");	
	
	this.call_tooltip.SetImageLayer(1,g_Image.IMAGE_TOOLTIP_LEFT);
	this.call_tooltip.SetImageLayer(2,g_Image.IMAGE_TOOLTIP_PX);
	this.call_tooltip.SetImageLayer(3,g_Image.IMAGE_TOOLTIP_CENTER);
	this.call_tooltip.SetImageLayer(4,g_Image.IMAGE_TOOLTIP_PX);
	this.call_tooltip.SetImageLayer(5,g_Image.IMAGE_TOOLTIP_RIGHT);	
	
	this.flag_shown_tooltip = false;
}

SceneminiSkypeCall.prototype.showTooltip = function(cur_button)
{
	alert('SceneminiSkypeCall.showTooltip');	
	var center_pos;
	var text_width_st;
	var tooltip_text;
	//check left position
	if(this.Btn_total_num == 3)
	{
		if(cur_button == this.VolumeBtn)
		{
			tooltip_text = SID_VOLUME;
			$('#video_call_tooltip_text_checker').html(SID_VOLUME);
			text_width_st = $('#video_call_tooltip_text_checker').css('width');			
			center_pos = 163;
		}
		else if(cur_button == this.CameraOffBtn || cur_button == this.CameraOnBtn)
		{
			if(cur_button == this.CameraOnBtn)
			{
				tooltip_text = IDWS_MOIP_CAM_OFF;
			}
			else
			{
				tooltip_text = IDWS_MOIP_CAM_ON;
			}
			$('#video_call_tooltip_text_checker').html(tooltip_text);
			text_width_st = $('#video_call_tooltip_text_checker').css('width');
			center_pos = 90;
		}
		else if(cur_button == this.CallEndBtn)
		{
			tooltip_text = TV_SID_END_CALL;
			$('#video_call_tooltip_text_checker').html(TV_SID_END_CALL);
			text_width_st = $('#video_call_tooltip_text_checker').css('width');			
			center_pos = 236;
		}
		else
		{
			alert('error::cur_button_3');
			return;
		}
	}
	//Btn_total_num == 2
	else if(this.Btn_total_num == 2)
	{
		if(cur_button == this.VolumeBtn)
		{
			tooltip_text = SID_VOLUME;
			$('#video_call_tooltip_text_checker').html(SID_VOLUME);
			text_width_st = $('#video_call_tooltip_text_checker').css('width');			
			center_pos = 120;
		}
		else if(cur_button == this.CallEndBtn)
		{
			tooltip_text = TV_SID_END_CALL;
			$('#video_call_tooltip_text_checker').html(TV_SID_END_CALL);
			text_width_st = $('#video_call_tooltip_text_checker').css('width');			
			center_pos = 191;
		}
		else
		{
			alert('error::cur_button_2');
			return;
		}		
	}
	else
	{
		alert('error::Btn_total_num');
		return;
	}
	
	alert('center_pos='+center_pos);
	
	var PXWordLen = text_width_st.indexOf("px");
	var text_width = parseInt(text_width_st.substring(0, PXWordLen));	
	alert('text_width='+text_width);
		
	var text_width_half = parseInt(text_width/2);
			
	//setting bg position
	var bg_width = (40+text_width) +'px';
	var bg_left = (center_pos-text_width_half-20) + 'px';
	$('#video_call_tooltip_bg').css('left',bg_left);	
	$('#video_call_tooltip_bg').css('width',bg_width);
	
	if(ProcMgr.ModelCode == TV_MODEL_CODE.X12 || ProcMgr.ModelCode == TV_MODEL_CODE.FOX_SBB)
	{
		if(cur_button == this.VolumeBtn)
		{
			$('#video_call_tooltip_bg').css('top','345px');
		}
		else
		{
			$('#video_call_tooltip_bg').css('top','353px');
		}
	}
	
	//setting left px position
	var left_px_width_pos = (text_width_half-10)+'px';
	$('#video_call_tooltip_left_px').css('width',left_px_width_pos);
	
	//setting center position
	var center_left_pos = (text_width_half+10)+'px';	
	$('#video_call_tooltip_center').css('left',center_left_pos);
	
	//setting right px position
	var right_px_left_pos = (text_width_half+30)+'px';
	$('#video_call_tooltip_right_px').css('left',right_px_left_pos);
	$('#video_call_tooltip_right_px').css('width',left_px_width_pos);//same width left_px_width
		
	//setting right corner position	
	var right_corner_left_pos = (text_width+20)+'px';
	if(text_width%2 > 0)
	{
		right_corner_left_pos = (text_width+19)+'px';
	}
	
	$('#video_call_tooltip_right_corner').css('left',right_corner_left_pos);
	
	//setting right corner position
	var text_width_pos = text_width+'px';
	$('#video_call_tooltip_text').css('width',text_width_pos);	
	
	if(this.flag_shown_tooltip == false)
	{
		this.call_tooltip.Show();
		this.flag_shown_tooltip = true;
	}

	this.call_tooltip.SetTextLayer(6,tooltip_text);

	//start & reset tooltip timer
	this.StartTimerTooltip();
}

SceneminiSkypeCall.prototype.StartTimerTooltip = function()
{
	if(this.TooltipTimer)
	{
		clearTimeout(this.TooltipTimer);
	}
    
	this.TooltipTimer = setTimeout("HideToolTipCallBack()", 6000);
	
	HideToolTipCallBack = function(){
		var this_ = $.sfScene.get({id:'miniSkypeCall',scope:WIDGET.id});
		this_.call_tooltip.Hide();
		this_.flag_shown_tooltip = false;
    }	
}

SceneminiSkypeCall.prototype.ShowKeyHelpbar = function(){
	if(WIDGET.mouse==true){
		helpBarHandler.hideHelpIcon('red',"");
		helpBarHandler.hideHelpIcon('green',"");
		helpBarHandler.hideHelpIcon('yellow',"");
		helpBarHandler.hideHelpIcon('blue',"");
		helpBarHandler.hideHelpIcon('tools',"");
		helpBarHandler.showHelpIcon('return',SID_RETURN);
		helpBarHandler.setHelpIconClickEvent('help_return',function(){
                $.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processExitKey();
        });
	}else{
		$("#HomeHelp").sfKeyHelp({
			'return' : SID_RETURN
		});	
	}
}

SceneminiSkypeCall.prototype.RecoveryCamBtn = function()
{
	if(this.flag_hidden_cam_btn)
	{
		this.flag_hidden_cam_btn.visibleObj();
	}
}

SceneminiSkypeCall.prototype.processExitKey = function()
{
	if(ProcMgr.isUDmodel == false)
	{
		$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processExitKey();
	}
	//ud model
	else
	{
		this.processReturnKey();
	}
}

		    
