/*
 * name : VideoCall.js 
 * author : Lee Dong Hee
 * brief : control Video/Voice/Tv call
 * 
 * 
 * button
 * window(hole)
 *  
 */

var SKYPE_CALL_VIEW_TYPE = {
 	INIT				: 0,	//voice call mode
	ONLY_YOUR			: 1,	//only your view in video call mode
	ONLY_MY				: 2,	//only my view in video call mode
	YOUR_AND_MY			: 3,	//your & my view in video call mode
	ONLY_TV				: 4,	//only tv view in tv mode
	TV_AND_YOUR			: 5,	//tv & your view in tv mode
	TV_AND_MY			: 6,	//tv & my view in tv mode
	TV_AND_MY_IN_X12	: 7,	//only tv in tv mode with X12 
	TV_YOUR_MY			: 8,	//tv & your & my view in tv mode
	TV_YOUR_MY_IN_X12	: 9		//tv & your in tv mode with X12
}

var SKYPE_CALL_BTN_POS_ARRY = [  //BtnPositionArry
	['608px','0px','0px','0px','0px','0px','0px'],				//1 btn
	['551px','665px','0px','0px','0px','0px','0px'],			//2 btn
	['491px','608px','725px','0px','0px','0px','0px'],			//3 btn
	['437px','551px','665px','779px','0px','0px','0px'],		//4 btn
	['380px','494px','608px','722px','836px','0px','0px'],		//5 btn
	['323px','437px','551px','665px','779px','893px','0px'],		//6 btn
	['266px','380px','494px','608px','722px','836px','950px']	//7 btn
];

function SceneVideoCall(options) {
	this.options = options;
    
    this.VideoCallView =null;

    this.LogoLabel =null;
    
    this.VolumeBtn			= null;
    this.SettingBtn			= null;
    this.TVModeOnBtn		= null;
    this.TVModeOffBtn		= null;
    this.MicMuteOnBtn		= null;
	this.MicMuteOffBtn		= null;    
	this.CameraOffBtn		= null;
	this.CameraOnBtn		= null;
    this.CallEndBtn			= null;
	this.FaceTrackingOnBtn	= null;
	this.FaceTrackingOffBtn	= null;

	this.Btn_arry = new Array(7);
	this.Btn_total_num = 0;
	
    this.HoldIconLabel = null;

    this.CallDurationBgLabel	= null;
    this.CallDurationTextLabel	= null;
    this.CallDurationTimeLabel	= null;

    this.MyCreditBgLabel=null;
    this.MyCreditIcon=null;
    this.MyCreditText=null;

	//for X12
	this.MyCameraNotSurpportLabel		= null;
	this.MyCameraAutoFaceTrackingLabel	= null;
	this.NoVolumeMixingTVLabel			= null;
	this.NoVolumeMixingSkypeLabel		= null;

	this.flag_enable_setting_btn	= true;
	this.flag_enable_mute_btn		= true;
	this.flag_enable_camera_btn		= true; 
	this.flag_enable_voume_btn		= false;
	this.flag_enable_tv_btn			= false;
	this.flag_enable_face_tracking_btn = false;
          
    this.CallMemberThumbnail = null;
    this.CallMemberDisplayName = null;
    this.CallMemberIdentity = null;    
    this.MyThumbnail = null;
    this.MyName = null;	
	this.YourNameTextLabel = null;		
	this.MyNameTextLabel = null;
	    
    this.InfoArea = null;
    this.HideTimer = false;
    this.InfoAreaShowState = true;
        
    this.flag_camera_unplugged	= false; 
    this.flag_voice_call		= false;     
    this.flag_tv_mode			= false;
    this.flag_shown_hold_icon	= false;
    this.flag_pstn_call			= false;
    this.flag_shown_loading_ani = false;
    
    
    //////////////////////////////////////////////
    //do not initialize when hide!!!!!
    //////////////////////////////////////////////
    this.flag_skype_call_view_type		= SKYPE_CALL_VIEW_TYPE.INIT;
    this.flag_cur_skype_call_bg_type	= 0;
    	
	this.flag_close_all = false;

	this.flag_shown_my_avatar = false;
	this.flag_shown_your_avatar = false;

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

	this.TooltipTimer = null;
	this.flag_shown_tooltip = false;
	
	this.LoadingAniImagePath	= null;
    this.LoadingAniArray		= new Array(18);
    this.LoadingAniLabel		= null;    
    this.LoadingTimer			= null;
    this.iCurrAniImage 			= 0;
    
    this.flag_shown_initialize 	= false;
    
    //1. It takes some time when turn on/off face tacking mode
    //2. so must be prevented to press button
    this.flag_tracking_face = false;		
}

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

	this.create();
}

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

    this.update();
}

SceneVideoCall.prototype.handleHide = function () {
	alert("SceneVideoCall.handleHide()");
	
	this.highlight(null);   
	
	this.updateCallDuration(' ');
	this.hiddenView();
	this.flag_skype_call_view_type	= SKYPE_CALL_VIEW_TYPE.INIT;

	this.hiddenAvartar();
	
	if(this.TooltipTimer)
	{
		clearTimeout(this.TooltipTimer);
		$('#video_call_btn_tooltip').sfTooltip('hide');
		this.flag_shown_tooltip = false;		
	}
	
	this.flag_shown_initialize = false;
	this.flag_close_all = false;
	this.flag_tracking_face = false;
	
}

SceneVideoCall.prototype.handleFocus = function () {
	alert("SceneVideoCall.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);
    
	var this_ = sf.scene.get("VideoCall");
	var returnCF =  function(){this_.processReturnKey();};
	WndMgr.SetReturnIconClickCallback(returnCF);       
    
}

SceneVideoCall.prototype.handleBlur = function () {
	alert("SceneVideoCall.handleBlur()");	
	
	var currentHighlight =  this.VideoCallView.getCurrentHighlight();
     if(currentHighlight !=null)
    {
        currentHighlight.blur();
    }
        
    if(this.HideTimer == true)
	{
		this.stopTimer();
	}
	
	WndMgr.SetReturnIconClickCallback(null);
}

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

	//PluginAPIMgr.PlayAudio(keyCode);
	
    if(keyCode > 50100000 && keyCode < 50500000)
    {
		return;
    }    
	
	if(ProcMgr.checkWidgetHighlight()==false)
	{
		return;
	}
	if(this.ShowInfoArea())
	{
		return;
	}
	
	switch (keyCode) {
		case sf.key.LEFT:
            this.processLeftKey();
			break;
		case sf.key.RIGHT:
           this.processRightKey();
			break;
		case sf.key.UP:
			break;
		case sf.key.DOWN:
			break;

		case sf.key.ENTER:
        	this.processEnterKey();
			break;
        case sf.key.GREEN:
            break;
        
        case sf.key.VOL_DOWN:
        case sf.key.PANEL_VOL_DOWN:
		case sf.key.VOL_UP:
        case sf.key.PANEL_VOL_UP:
             this.processVolumeKey(false);
			break;
        
		case sf.key.TOOLS:
			break;            
            
		case sf.key.RETURN:
			this.processReturnKey();
		    sf.key.preventDefault();
			break;
					
		case sf.key.EXIT:        
			this.processExitKey();
		    sf.key.preventDefault();
			break;
                
    		//Gesture recognition  >> Scroll
         case 40000002:
         case 40000003:
         case 40000004:
         case 40000005:
			break;

        case sf.key.N1:
            ProcMgr.SendDTMF(0);
            break;        
        case sf.key.N2:
            ProcMgr.SendDTMF(1);
            break;        
        case sf.key.N3:
            ProcMgr.SendDTMF(2);
            break;        
        case sf.key.N4:
            ProcMgr.SendDTMF(3);        
            break;        
        case sf.key.N5:
            ProcMgr.SendDTMF(4);        
            break;        
        case sf.key.N6:
            ProcMgr.SendDTMF(5);        
            break;        
        case sf.key.N7:
            ProcMgr.SendDTMF(6);        
            break;        
        case sf.key.N8:
            ProcMgr.SendDTMF(7);        
            break;        
        case sf.key.N9:
            ProcMgr.SendDTMF(8);
            break;        
        case sf.key.N0:
            ProcMgr.SendDTMF(10);
            break;
            
        case 35:
		case 650:			//ttx
            ProcMgr.SendDTMF(9);        
            break;
            
        case 259:			//pre
            ProcMgr.SendDTMF(11);        
            break;
        
        case sf.key.MUTE:
        	this.processMuteKey();
            break;

		case 602:	//INFOLINK
		case 606:	//CONTENTS
		case 608:	//WISELINK
            ProcMgr.processInfolinkKeyInCall();
            sf.key.preventDefault();
			break;
			
        default:
            ProcMgr.processBlockKey(keyCode);
            break;  
	}
}

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

SceneVideoCall.prototype.create = function(){
    alert("SceneVideoCall.create() ");
			
	var this_ = sf.scene.get("VideoCall");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	
    this.VideoCallView = new View("VideoCall");
    this.VideoCallView.SetOnClickCallbackFunc(clickCF);
     
 	//this.InfoArea = new View("video_call_info_area");

    this.LogoLabel= new Label("video_call_skype_logo", null);
    this.LogoLabel.SetBgImage(g_Image.IMAGE_CALL_SKYPE_LOGO);
   
    this.CallDurationBgLabel = new Label("video_call_duration_bg",null);
	this.CallDurationBgLabel.SetBgImage(g_Image.IMAGE_CALL_DURATION_BG);
	
	this.CallDurationTextLabel = new Label(null,"video_call_duration_text");	
	this.CallDurationTextLabel.SetText(IDWS_MOIP_SKYPE_CALL_DURATION); 
	
    this.CallDurationTimeLabel = new Label(null,"video_call_duration_time");
    this.CallDurationTimeLabel.SetText("00:00:00");

	var CurLangID = ResMgr.GetCurLanguage();
	if(CurLangID == ENUM_TV_LANGUAGE.VIE || CurLangID == ENUM_TV_LANGUAGE.IND || CurLangID == ENUM_TV_LANGUAGE.KAZ || CurLangID == ENUM_TV_LANGUAGE.LIT ||
		CurLangID == ENUM_TV_LANGUAGE.MKD || CurLangID == ENUM_TV_LANGUAGE.MAY || CurLangID == ENUM_TV_LANGUAGE.POL || CurLangID == ENUM_TV_LANGUAGE.ALB ||
		CurLangID == ENUM_TV_LANGUAGE.TAM || CurLangID == ENUM_TV_LANGUAGE.XHO || CurLangID == ENUM_TV_LANGUAGE.ZUL)
	{
		$('#video_call_duration_text').css('left','18px');
		$('#video_call_duration_text').css('width','220px');
		
		$('#video_call_duration_time').css('left','210px');
	}

    this.MyCreditBgLabel = new Label("video_call_my_credit",null);
	this.MyCreditBgLabel.SetBgImage(g_Image.IMAGE_SKYPE_CREDIT_BG);
    
    this.MyCreditIcon = new Label("video_call_my_credit_icon",null);    
    this.MyCreditIcon.SetBgImage(g_Image.IMAGE_SKYPE_CREDIT_ICON);
    
    this.MyCreditText = new Label(null,"video_call_my_credit_text"); 
    this.MyCreditText.SetReverseDisable(true);

   
    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_hd");
	this.CallMemberThumbnail.AddJPGImageLayer("your_thumbnail_hd_avatar");

	this.MyThumbnail = new CompBase(); 
	this.MyThumbnail.CreateBG("my_thumbnail_hd");
	this.MyThumbnail.AddJPGImageLayer("my_thumbnail_hd_avatar");

    //this.MyCameraOffThumnail = new Label("my_thumbnail_hd_camera_off",null);
	//this.MyCameraOffThumnail.SetBgImage(g_Image.IMAGE_VIDEO_CALL_CAMERA_OFF_THUMB_BG);
	    
	this.YourNameTextLabel = new Label(null,"video_call_your_name");
	this.YourNameTextLabel.SetIsPlainText(true);	
	
	this.MyNameTextLabel = new Label(null,"video_call_my_name");
	this.MyNameTextLabel.SetIsPlainText(true);		

    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);
    $('#video_call_volume_hd_btn').bind('mouseover',function(){this_.processVolumeBtnOver();});
        
    this.SettingBtn = new Button();
    this.SettingBtn.SetImageObjId("video_call_setting_hd_btn");
    this.SettingBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_SETTING_BTN_NORMAL);
    this.SettingBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_SETTING_BTN_NORMALFOCUS);    
    this.SettingBtn.SetOnClickCallbackFunc(clickCF);
    $('#video_call_setting_hd_btn').bind('mouseover',function(){this_.processSettingBtnOver();});
    
    this.TVModeOnBtn = new Button();
    this.TVModeOnBtn.SetImageObjId("video_call_tv_mode_on_btn");
    this.TVModeOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_TV_MODE_BTN_NORMAL);
    this.TVModeOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_TV_MODE_BTN_NORMALFOCUS);
    this.TVModeOnBtn.SetOnClickCallbackFunc(clickCF); 
    $('#video_call_tv_mode_on_btn').bind('mouseover',function(){this_.processTVModeOnBtnOver();});
    
    this.TVModeOffBtn = new Button();
    this.TVModeOffBtn.SetImageObjId("video_call_tv_mode_off_btn");
    this.TVModeOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_TV_MODE_BLOCK_BTN_NORMAL);
    this.TVModeOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_TV_MODE_BLOCK_BTN_NORMALFOCUS);
    this.TVModeOffBtn.SetOnClickCallbackFunc(clickCF);     
    $('#video_call_tv_mode_off_btn').bind('mouseover',function(){this_.processTVModeOffBtnOver();});
    
    this.MicMuteOnBtn = new Button();
    this.MicMuteOnBtn.SetImageObjId("video_call_mute_on_hd_btn");
    this.MicMuteOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_MIC_BTN_NORMAL);
    this.MicMuteOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_MIC_BTN_NORMALFOCUS);
    this.MicMuteOnBtn.SetOnClickCallbackFunc(clickCF);
    $('#video_call_mute_on_hd_btn').bind('mouseover',function(){this_.processMicMuteOnBtnOver();});
        
    this.MicMuteOffBtn = new Button();
    this.MicMuteOffBtn.SetImageObjId("video_call_mute_off_hd_btn");
    this.MicMuteOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_MIC_BLCOK_BTN_NORMAL);
    this.MicMuteOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_MIC_BLCOK_BTN_NORMALFOCUS);
    this.MicMuteOffBtn.SetOnClickCallbackFunc(clickCF);    
    $('#video_call_mute_off_hd_btn').bind('mouseover',function(){this_.processMicMuteOffBtnOver();});
    
    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); 
    $('#video_call_camera_on_hd_btn').bind('mouseover',function(){this_.processCameraOffBtnOver();});
    
    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); 
    $('#video_call_camera_off_hd_btn').bind('mouseover',function(){this_.processCameraOnBtnOver();});
    
	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);
    $('#video_call_end_hd_btn').bind('mouseover',function(){this_.processCallEndBtnOver();});

    this.FaceTrackingOnBtn = new Button();
    this.FaceTrackingOnBtn.SetImageObjId("video_call_face_tracking_on_hd_btn");
    this.FaceTrackingOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_FACE_TRACKING_ON_BTN_NORMAL);
    this.FaceTrackingOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_FACE_TRACKING_ON_BTN_NORMALFOCUS);    
    this.FaceTrackingOnBtn.SetOnClickCallbackFunc(clickCF);
    $('#video_call_face_tracking_on_hd_btn').bind('mouseover',function(){this_.processFaceTrackingOnBtnOver();});

    this.FaceTrackingOffBtn = new Button();
    this.FaceTrackingOffBtn.SetImageObjId("video_call_face_tracking_off_hd_btn");
    this.FaceTrackingOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_FACE_TRACKING_OFF_BTN_NORMAL);
    this.FaceTrackingOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_FACE_TRACKING_OFF_BTN_NORMALFOCUS);
    this.FaceTrackingOffBtn.SetOnClickCallbackFunc(clickCF);
    $('#video_call_face_tracking_off_hd_btn').bind('mouseover',function(){this_.processFaceTrackingOffBtnOver();});
    
    
	this.MyCameraNotSurpportLabel = new Label(null,"my_thumbnail_hd_camera_off");
	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');

	$('#video_call_btn_tooltip').sfTooltip({
		text : TV_SID_END_CALL,
		orientation : 'down'
	});
	this.flag_shown_tooltip = true;

	this.createLoading();
}

SceneVideoCall.prototype.update=function()
{  
    alert("SceneVideoCall.update");
    	
	//set all property!!! 
    $('#video_call_info_area').css("display","block");
	
	this.CallMemberDisplayName = ProcMgr.CallInfo.DisplayName;
	this.CallMemberIdentity = ProcMgr.CallInfo.Identity;
	
    this.CallMemberThumbnail.SetImageLayer(1,ProcMgr.CallInfo.AvataImg);		
    this.MyThumbnail.SetImageLayer(1,g_Data.GetMyAccountAvataImage());
	
    this.YourNameTextLabel.SetText(this.CallMemberDisplayName);    	
	this.MyNameTextLabel.SetText(g_Data.GetMyAccountDisplayName());
	
	this.VideoCallView.DisableOnClick();
	
	this.InfoAreaShowState = true;	
	this.flag_tv_mode = ProcMgr.CallInfo.IsTvMode;
     
	//get call status....
	this.getCameraState();
    this.is_receiving_video = ProcMgr.IsReceivingVideo();
	this.is_sending_video = ProcMgr.CallInfo.IsSendingVideo;
    	
    alert("is_receiving_video = " + this.is_receiving_video);
    alert("is_sending_video = " + this.is_sending_video);
       
    if(this.is_receiving_video == true || this.is_sending_video == true)
    {
		this.flag_voice_call = false;
    }
    else
    {
    	this.flag_voice_call = true;
    }
            
    this.showWindowView();

	this.showAvartar();	
	this.showCredit();	
	this.BtnSetting();
	this.ShowInfoArea();			
	this.checkHold();

	this.flag_shown_initialize = true;
}

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

	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("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("toggle Camera Btn Enable ");

		if(this.is_sending_video == true)
		{
	        if(currentHighlight ==  this.CameraOffBtn)
	        {
				this.highlight(this.CameraOnBtn);			
	        }
			
			this.CameraOffBtn.hiddenObj();
			this.CameraOnBtn.visibleObj();
		}
		else{
	        
	        if(currentHighlight ==  this.CameraOnBtn)
	        {
				this.highlight(this.CameraOffBtn);			
	        }
	        			
			this.CameraOnBtn.hiddenObj();
			this.CameraOffBtn.visibleObj();
		}
		this.flag_enable_camera_btn = true;
    }
        
}

SceneVideoCall.prototype.toggleSettingBtnEnable=function()
{
    alert("SceneVideoCall.toggleSettingBtnEnable() ");

	//check Setting btn
	
	if(this.is_sending_video == true && this.flag_tv_mode == false)
	{	 	
		//check camera adjustment || zoom
		if((ProcMgr.ProductInfo.support_cam_adjustment == true && this.is_receiving_video == true) || (ProcMgr.ProductInfo.capability_eptz == true && PluginAPIMgr.GetFaceTracking() == false))
		{
			this.flag_enable_setting_btn = true;
		}
		else
		{
			this.flag_enable_setting_btn = false;
		}
	}
	else
	{
		this.flag_enable_setting_btn = false;
	}
    
    //show/hide btn
    if(this.flag_enable_setting_btn == true )
    {
    	this.SettingBtn.visibleObj();
    }
    else
    {
		var currentHighlight =  this.VideoCallView.getCurrentHighlight();

        if(currentHighlight ==  this.SettingBtn)
        {
			this.highlight(this.CallEndBtn);
        }
        
		this.SettingBtn.hiddenObj();
    }
}

SceneVideoCall.prototype.toggleFaceTrackincBtnEnable=function()
{
    alert("SceneVideoCall.toggleFaceTrackincBtnEnable()");
	
	//check face btn
	//connectioned camera
	//current state.... 
	if(ProcMgr.ProductInfo.capability_face_tracking == true && this.is_sending_video == true && (this.flag_tv_mode == false || ProcMgr.ProductInfo.support_mixing_video == true))
	{
		this.flag_enable_face_tracking_btn = true;
	}
	else
	{
		this.flag_enable_face_tracking_btn = false;
	}
	
    //show/hide btn
    if(this.flag_enable_face_tracking_btn == true)
    {
    	if(PluginAPIMgr.GetFaceTracking() == true)
    	{
	        if(currentHighlight ==  this.FaceTrackingOffBtn)
	        {
				this.highlight(this.FaceTrackingOffBtn);
	        }
    		
			this.FaceTrackingOffBtn.hiddenObj();
			this.FaceTrackingOnBtn.visibleObj();
    	}
    	else
    	{
	        if(currentHighlight ==  this.FaceTrackingOnBtn)
	        {
				this.highlight(this.FaceTrackingOnBtn);
	        }

			this.FaceTrackingOnBtn.hiddenObj();    		
			this.FaceTrackingOffBtn.visibleObj();			
    	}
    }
    else
    {
		var currentHighlight =  this.VideoCallView.getCurrentHighlight();

        if(currentHighlight == this.FaceTrackingOnBtn || currentHighlight == this.FaceTrackingOffBtn)
        {
			this.highlight(this.CallEndBtn);
        }
        
		this.FaceTrackingOnBtn.hiddenObj();
		this.FaceTrackingOffBtn.hiddenObj();
    }	
}


SceneVideoCall.prototype.toggleMuteBtnEnable=function()
{
    alert("SceneVideoCall.toggleMuteBtnEnable() ");
    
    //get mute state 
    this.is_mic_mute = ProcMgr.CallInfo.IsMicMute;
	
	var currentHighlight =  this.VideoCallView.getCurrentHighlight();

	//Set Mute Btn
    if((ProcMgr.ProductInfo.support_mixing_video == false && this.flag_tv_mode == true) || this.flag_camera_unplugged == true)
    {	
        if(currentHighlight ==  this.MicMuteOnBtn || currentHighlight ==  this.MicMuteOffBtn)
        {
			this.highlight(this.CallEndBtn);			
        }		
		
		this.MicMuteOnBtn.hiddenObj();
		this.MicMuteOffBtn.hiddenObj();
		
		this.flag_enable_mute_btn = false;
	}
	else{

		if(this.is_mic_mute == true)
		{
	        if(currentHighlight ==  this.MicMuteOnBtn)
	        {
				this.highlight(this.MicMuteOffBtn);			
	        }
	        			
			this.MicMuteOffBtn.visibleObj();
			this.MicMuteOnBtn.hiddenObj();
		}
		else{
			
	        if(currentHighlight ==  this.MicMuteOffBtn)
	        {
				this.highlight(this.MicMuteOnBtn);			
	        }
	        
			this.MicMuteOffBtn.hiddenObj();
			this.MicMuteOnBtn.visibleObj();
					
		}
		
		this.flag_enable_mute_btn = true;
	}
}

SceneVideoCall.prototype.toggleTVModeBtn=function()
{
    alert("SceneVideoCall.toggleTVModeBtn() ");
	
	var currentHighlight =  this.VideoCallView.getCurrentHighlight();


	if(this.CallMemberIdentity == 'echo123' || PluginAPIMgr.IsPrevISPSource() == true)
	{
		this.TVModeOffBtn.hiddenObj();	
		this.TVModeOnBtn.hiddenObj();
		this.flag_enable_tv_btn = false;
		return;
	}

	if(this.flag_tv_mode)
	{
		if(currentHighlight == this.TVModeOnBtn)
        {
			this.highlight(this.TVModeOffBtn);			
        }
        			
		this.TVModeOffBtn.visibleObj();
		this.TVModeOnBtn.hiddenObj();
	}
	else
	{
		if(currentHighlight == this.TVModeOffBtn)
        {
			this.highlight(this.TVModeOnBtn);			
        }
        			
		this.TVModeOnBtn.visibleObj();
		this.TVModeOffBtn.hiddenObj();		
	}
	
	this.flag_enable_tv_btn = true;
}

	
//updateCameraState
SceneVideoCall.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;
    }
	
}

SceneVideoCall.prototype.BtnSetting = function()
{
	alert("SceneVideoCall.BtnSetting");	
		
	this.toggleVoumeBtn();
	this.toggleSettingBtnEnable();	
	this.toggleTVModeBtn();
	this.toggleCameraBtnEnable();	
	this.toggleMuteBtnEnable();	
	this.toggleFaceTrackincBtnEnable();
	
	this.AdjustBtnPosition();	
	//after adjustBtnPosition	
	this.ResetTooltip();
	this.SetNoVolumeMixingLabel();
}


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

    if(this.is_receiving_video == true || this.is_sending_video == true)
    {
		this.flag_voice_call = false;
    }
    else
    {
    	this.flag_voice_call = true;
    }
    
	//Get Current tv movde
	this.flag_tv_mode = ProcMgr.CallInfo.IsTvMode;
	
	this.showWindowView();

	this.showAvartar();
	this.BtnSetting();
	this.stopTimer();
	this.ShowInfoArea();
}

SceneVideoCall.prototype.toggleMyVideo = function()
{
	alert("SceneVideoCall.toggleMyVideo");

	this.getCameraState();
	
    if(PluginAPIMgr.IsSendingVideo() == 0)
    {
    	this.is_sending_video = false;	
    }
    else
    {
    	this.is_sending_video = true;
    }

    if(this.is_receiving_video == true || this.is_sending_video == true)
    {
		this.flag_voice_call = false;
    }
    else
    {
    	this.flag_voice_call = true;
    }

	//Get Current tv movde
	this.flag_tv_mode = ProcMgr.CallInfo.IsTvMode;
	
	this.showWindowView();

	this.showAvartar();
	this.BtnSetting();
	this.stopTimer();
	this.ShowInfoArea();
}

SceneVideoCall.prototype.openVideoRect = function()
{
    //$("#SceneVideoCall").css('background-color' , 'transparent');
}

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

SceneVideoCall.prototype.highlightBtnWithIndex = function(cur_index)
{
	var cur_name = this.Btn_arry[cur_index];
	var tooltip_text;
	alert('highlightBtnWithIndex  = ' + cur_name);
	
    switch(cur_name)
    {
        case 'endcall':
        	tooltip_text = TV_SID_END_CALL;
        	this.highlight(this.CallEndBtn);
            break;
        case 'camera':
			if( this.CameraOnBtn.GetFlagVisible() == true)
			{
				tooltip_text = IDWS_MOIP_CAM_OFF;
				this.highlight(this.CameraOnBtn);
			}
			else
			{
				tooltip_text = IDWS_MOIP_CAM_ON;
				this.highlight(this.CameraOffBtn);
			}
            break;            
        case 'mute':
			if( this.MicMuteOnBtn.GetFlagVisible() == true)
			{
				tooltip_text = IDWS_MOIP_SKYPE_MUTE_MIC;
				this.highlight(this.MicMuteOnBtn);
			}
			else
			{
				tooltip_text = IDWS_MOIP_SKYPE_UNMUTE_MIC;
				this.highlight(this.MicMuteOffBtn);
			}				
            break; 
        case 'tv':
			if( this.TVModeOnBtn.GetFlagVisible() == true)
			{
				if(ProcMgr.IsDualViewMode() == true)
				{
					tooltip_text = "<font color='#005EA2'>" + TV_SID_SHOW_TV + "</font><br>" + TV_SID_FUNCTION_UNAVAILABEL_WHILE_SAMSUNG_MULTI_VIEW + "<br>" + TV_SID_TO_USE_FUNCTION_MUST_STOP_SAMSUNG_MULTI_VIEW;
				}
				else
				{
					tooltip_text = TV_SID_SHOW_TV;
				}
				this.highlight(this.TVModeOnBtn);
			}
			else
			{
				tooltip_text = TV_SID_HIDE_TV;
				this.highlight(this.TVModeOffBtn);
			}  
            break;
        case 'setting':
        	tooltip_text = TV_SID_VIDEO_CALL_SETTINGS;
            this.highlight(this.SettingBtn);
            break;
        case 'volume':
        	tooltip_text = SID_VOLUME;
        	this.highlight(this.VolumeBtn);
            break;
        case 'faceTracking':
			if( this.FaceTrackingOnBtn.GetFlagVisible() == true)
			{
				tooltip_text = TV_SID_AUTO_FACE_TRACKING_OF;
				this.highlight(this.FaceTrackingOnBtn);
			}
			else
			{
				tooltip_text = TV_SID_AUTO_FACE_TRACKING_ON;
				this.highlight(this.FaceTrackingOffBtn);
			}
            break;
        default:
        	alert('error!!!!!')
        	this.highlight(null);
        	break;
           
    }	
    
	this.ShowTooltip(tooltip_text,cur_index);
}

SceneVideoCall.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.MicMuteOnBtn:
		case this.MicMuteOffBtn:     
			btn_name = 'mute';
            break; 
         case this.TVModeOnBtn:
         case this.TVModeOffBtn:                  			
			btn_name = 'tv';
            break;
         case this.SettingBtn:
			btn_name = 'setting';
            break;
         case this.VolumeBtn:
            btn_name = 'volume';
            break;
         case this.FaceTrackingOnBtn:
         case this.FaceTrackingOffBtn:
            btn_name = 'faceTracking';
            break;
           
    }

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


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

//ceck..
//1. setting 2. camera  3.mute  4.tv  5. end call
SceneVideoCall.prototype.processRightKey=function()
{
    alert("SceneVideoCall.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);
}

SceneVideoCall.prototype.processEnterKey=function()
{
    alert("SceneVideoCall.processEnterKey() ");
    
    if(this.flag_tracking_face == true)
    {
    	alert("flag_tracking_face == true, return");
    	return;
    }
    
    var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {    	
        case this.VolumeBtn:
            this.processVolumeKey(true);
            break;  
                	
        case this.SettingBtn:
            StateMgr.Start_Call_Setting_State();
            break;    
            	
         case this.TVModeOnBtn:
         case this.TVModeOffBtn:      	
    		this.changeTVBtn();
    		break;
    	
        case this.CallEndBtn:
            this.processCallEndBtn();
            break;
		
		case this.CameraOffBtn:			
		case this.CameraOnBtn:
			this.changeCameraBtn();
			break;
		
		case this.MicMuteOnBtn:	
        case this.MicMuteOffBtn:
			this.changeMuteBtn();
			break;
			
		case this.FaceTrackingOnBtn:	
        case this.FaceTrackingOffBtn:
			this.changeFaceTrackingBtn();
			break;   			
    }
}


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

	if(ProcMgr.ProductInfo.support_multitasking == false)
	{
		StateMgr.Start_Call_Confirm_State(2);
	}
	else
	{
		//FoxP
		//external entering
		if(g_Data.WIDGET_PARAM.start == true)
		{
			if(this.flag_tv_mode == true)
			{
				PluginAPIMgr.SetSourceMode(false); 
				sf.service.setChannelControl(false);
				ProcMgr.GoOutWithSignIn(true);
			}
			else
			{
				ProcMgr.GoOutWithSignIn(false);
			}
		}
		//normal entering
		else
		{
			if(this.flag_tv_mode == true)
			{
				StateMgr.Start_Call_Confirm_State(3);
			}
			else
			{
				StateMgr.Start_Main_State();
			}
		}
	}
}

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

SceneVideoCall.prototype.processCallEndBtn = function()
{
    alert("SceneVideoCall.processCallEndBtn()");
	
	this.closingProcess();
	ProcMgr.DisconnectCall();
}

SceneVideoCall.prototype.processVolumeKey = function(is_source)
{
    alert("SceneVideoCall.processVolumeKey() ");
    
	if(ProcMgr.ProductInfo.support_mixing_audio == false && is_source == true)
	{
		if(ProcMgr.CurOutputMixVolume == 1)
		{			
			PluginAPIMgr.MuteMic(false);
			PluginAPIMgr.SetTVMixVolume(0);
			PluginAPIMgr.SetCallMixVolume(100);
			ProcMgr.CurOutputMixVolume = 0;

			$("#video_call_no_volume_mixing_tv").css('color','#696969');
			$("#video_call_no_volume_mixing_skype").css('color','#FFFFFF');
		}
		else
		{
			PluginAPIMgr.MuteMic(true);
			PluginAPIMgr.SetCallMixVolume(0);			
			PluginAPIMgr.SetTVMixVolume(100);
			ProcMgr.CurOutputMixVolume = 1;
			
			$("#video_call_no_volume_mixing_tv").css('color','#FFFFFF');
			$("#video_call_no_volume_mixing_skype").css('color','#696969');
		}		
	}
	else
	{
		//unmute
		if(is_source == true)
		{			
			if(ProcMgr.CallInfo.IsSpeakerMute == true)
			{
				StateMgr.Start_Volume_Speaker_State(VOLUME_MODE.SOURCE_MUTE);
			}
			else
			{
				StateMgr.Start_Volume_Speaker_State(VOLUME_MODE.SOURCE);
			}
		}
		else
		{
			StateMgr.Start_Volume_Speaker_State(VOLUME_MODE.MASTER);
		}
	}    
}


SceneVideoCall.prototype.startTimer = function()
{

	if(this.is_receiving_video == false || this.flag_tv_mode == true)
	{
		return;
	}

		
    alert("SceneVideoCall.startTimer() ");
	
	if(this.HideTimer == true)
	{
		PluginAPIMgr.RestartOSDTimer("10000" ,ENUM_TIMER_TYPE.CALL_INFO);
	}
	else
	{		
		PluginAPIMgr.StartOSDTimer("10000" , function() { sf.scene.get('VideoCall').hideTimerCallback();}, ENUM_TIMER_TYPE.CALL_INFO);	
		this.HideTimer = true;	
	}
	
}

SceneVideoCall.prototype.stopTimer = function()
{
    alert("SceneVideoCall.stopTimer() ");
	
	if(this.HideTimer == true)
	{
		PluginAPIMgr.StopOSDTimer(ENUM_TIMER_TYPE.CALL_INFO);
		this.HideTimer = false;		
	}

}

SceneVideoCall.prototype.hideTimerCallback = function()
{
   alert("SceneVideoCall.hideTimerCallback() ");
   if(this.HideTimer==false)
   {
   	return
   }
   
   this.stopTimer();
   //this.InfoArea.hiddenObj();
   $('#video_call_info_area').css("display","none");
       
   this.VideoCallView.EnableOnClick();
   this.InfoAreaShowState= false;
}


SceneVideoCall.prototype.processClickEvent = function(obj){
	alert("SceneVideoCall.processClickEvent() ");
	
	if(obj == this.VideoCallView)
	{
		this.ShowInfoArea();
		return;
	}
	
	this.startTimer();
	    
	this.processEnterKey();
}

SceneVideoCall.prototype.ShowInfoArea = function(){
	alert("SceneVideoCall.ShowInfoArea() ");

	this.startTimer();
	//show Info Area
	if(this.InfoAreaShowState == false)
	{
		$('#video_call_info_area').css("display","block");
		this.VideoCallView.DisableOnClick();
		this.InfoAreaShowState = true;
		
		sf.key.preventDefault();
		return true;
	}
	
	return false;
}


SceneVideoCall.prototype.showWindowView = function(){
	alert("SceneVideoCall.showWindowView() ");

	var view_type = SKYPE_CALL_VIEW_TYPE.INIT;

	if(this.flag_tv_mode == true)
	{
		if(this.is_receiving_video == true)
		{
			if(this.is_sending_video == true)
			{
				if(ProcMgr.ProductInfo.support_mixing_video == false)
				{
					view_type = SKYPE_CALL_VIEW_TYPE.TV_YOUR_MY_IN_X12;
				}
				else
				{
					view_type = SKYPE_CALL_VIEW_TYPE.TV_YOUR_MY;
				}
			}
			else
			{
				view_type = SKYPE_CALL_VIEW_TYPE.TV_AND_YOUR;
			}
		}
		else{

			if(this.is_sending_video == true)
			{
				if(ProcMgr.ProductInfo.support_mixing_video == false)
				{
					view_type = SKYPE_CALL_VIEW_TYPE.TV_AND_MY_IN_X12;
				}
				else
				{
					view_type = SKYPE_CALL_VIEW_TYPE.TV_AND_MY;
				}
			}
			else
			{
				view_type = SKYPE_CALL_VIEW_TYPE.ONLY_TV;
			}
		}
	}
	else
	{
		if(this.is_receiving_video == true)
		{
			if(this.is_sending_video == true)
			{
				view_type = SKYPE_CALL_VIEW_TYPE.YOUR_AND_MY;
			}
			else
			{
				view_type = SKYPE_CALL_VIEW_TYPE.ONLY_YOUR;
			}
		}
		else{

			if(this.is_sending_video == true)
			{
				view_type = SKYPE_CALL_VIEW_TYPE.ONLY_MY;
			}
			else
			{
				view_type = SKYPE_CALL_VIEW_TYPE.INIT;
			}
		}		
	}

	alert("view_type="+view_type);
	if(this.flag_skype_call_view_type == view_type)
	{
		alert("same type!!");
		return;	
	}

	this.processLoadingWindow(view_type);
	
	this.flag_skype_call_view_type = view_type;
}


SceneVideoCall.prototype.visibleView = function(type){
	alert("SceneVideoCall.visibleView --" + type);

	if(this.flag_close_all == true)
	{
		alert("flag_close_all is true");
		return;
	}
	
	//this.flag_cur_skype_call_bg_type = -1;
	
	switch(type)
	{		
		case SKYPE_CALL_VIEW_TYPE.INIT:
			$("#skype_main_bg").css('background-image','url(images/720p/skype_bg.png)');
			this.flag_cur_skype_call_bg_type = 0;
			break;
		
		case SKYPE_CALL_VIEW_TYPE.ONLY_YOUR:
		case SKYPE_CALL_VIEW_TYPE.YOUR_AND_MY:
			$("#skype_main_bg").css('background-image','');
			this.flag_cur_skype_call_bg_type = -1;
			break;
			
		case SKYPE_CALL_VIEW_TYPE.ONLY_MY:
			$("#skype_main_bg").css('background-image','url(images/720p/skype_bg_normal_preview.png)');
			//$("#skype_main_bg").css('background-image','url('+WndMgr.Skype_call_normal_preview_bg.src+')');	
			this.flag_cur_skype_call_bg_type = 1;
			break;
		case SKYPE_CALL_VIEW_TYPE.TV_AND_MY_IN_X12:
		case SKYPE_CALL_VIEW_TYPE.ONLY_TV:		
			$("#skype_main_bg").css('background-image','url(images/720p/skype_bg_tv_only.png)');
			this.flag_cur_skype_call_bg_type = 2;
			break;
			
		case SKYPE_CALL_VIEW_TYPE.TV_YOUR_MY_IN_X12:
		case SKYPE_CALL_VIEW_TYPE.TV_AND_YOUR:
			$("#skype_main_bg").css('background-image','url(images/720p/skype_bg_tv_remote.png)');
			this.flag_cur_skype_call_bg_type = 3;
			break;

		case SKYPE_CALL_VIEW_TYPE.TV_AND_MY:
			$("#skype_main_bg").css('background-image','url(images/720p/skype_bg_tv_preview.png)');
			this.flag_cur_skype_call_bg_type = 4;
			break;

		case SKYPE_CALL_VIEW_TYPE.TV_YOUR_MY:
			$("#skype_main_bg").css('background-image','url(images/720p/skype_bg_tv_all.png)');
			this.flag_cur_skype_call_bg_type = 5;
			break;			
			
	}

	if(ProcMgr.ProductInfo.support_mixing_video == false && this.flag_tv_mode == true)
	{
		if(type == SKYPE_CALL_VIEW_TYPE.TV_AND_MY_IN_X12 || type == SKYPE_CALL_VIEW_TYPE.TV_YOUR_MY_IN_X12)
		{
			this.MyCameraNotSurpportLabel.SetText(TV_SID_YOUR_VIDEO_IS_BEING_SENT);
			
			if(PluginAPIMgr.GetDBAutoTracking() == 1)
			{
				this.MyCameraAutoFaceTrackingLabel.visibleObj();
			}
			else
			{
				this.MyCameraAutoFaceTrackingLabel.hiddenObj();
			}
		}
		else
		{
			this.MyCameraNotSurpportLabel.SetText(TV_SID_YOUR_VIDEO_IS_NOT_BEING_SENT);
			this.MyCameraAutoFaceTrackingLabel.hiddenObj();
		}
		
		this.MyCameraNotSurpportLabel.visibleObj();
	}
	else
	{
		this.MyCameraNotSurpportLabel.hiddenObj();
		this.MyCameraAutoFaceTrackingLabel.hiddenObj();
	}
}

SceneVideoCall.prototype.hiddenView = function(){
	alert("SceneVideoCall.hiddenView()");
	
	$("#skype_main_bg").css('background-image','url(images/720p/skype_bg.png)');
	this.flag_cur_skype_call_bg_type = 0;
	
	if(ProcMgr.ProductInfo.support_mixing_video == false)
	{
		this.MyCameraNotSurpportLabel.hiddenObj();
		this.MyCameraAutoFaceTrackingLabel.hiddenObj();
	}
}

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

	if(this.flag_close_all == true)
	{
		alert("flag_close_all is true");
		return;
	}

	//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)
	{
		//normal or Fox/Fox_SBB
		if(this.flag_tv_mode == false || ProcMgr.ProductInfo.support_mixing_video == true)
		{
			//show thumbnail
			if(this.flag_shown_my_avatar == false)
			{		
				alert("MyThumbnail.Show");
				this.MyThumbnail.Show();
				this.flag_shown_my_avatar = true;
			}
		}
		//X12 tv mode, naver show my avatar
		else
		{
			if(this.flag_shown_my_avatar == true)
			{		
				alert("MyThumbnail.Hide");		
				this.MyThumbnail.Hide();
				this.flag_shown_my_avatar = false;
			}
		}
	}
	else
	{
		if(this.flag_shown_my_avatar == true)
		{		
			alert("MyThumbnail.Hide");		
			this.MyThumbnail.Hide();
			this.flag_shown_my_avatar = false;
		}
	}
	
	//2. set position
	if(this.flag_tv_mode == true)
	{
		this.YourNameTextLabel.hiddenObj();
		this.MyNameTextLabel.hiddenObj();
		
		//Your
		if(this.flag_shown_your_avatar == true)
		{
			
			if(ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.INCOMING_PSTN  ||  ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.OUTGOING_PSTN)
			{
				$('#your_thumbnail_hd_avatar').css('top','120px');
			}
			else
			{
				$('#your_thumbnail_hd_avatar').css('top','107px');
			}
			$('#your_thumbnail_hd_avatar').css('left','910px');
			//$('#your_thumbnail_hd_avatar').css('width','213px');
			//$('#your_thumbnail_hd_avatar').css('height','213px');
		}			
		
		//My
		if(this.flag_shown_my_avatar == true)
		{
			$('#my_thumbnail_hd_avatar').css('left','910px');
			$('#my_thumbnail_hd_avatar').css('top','344px');
			//$('#my_thumbnail_hd_avatar').css('width','213px');
			//$('#my_thumbnail_hd_avatar').css('height','213px');
		}
	}
	else
	{
		if(this.flag_voice_call == true)
		{
			//visible name
			$('#video_call_your_name').css('left','305px');
			$('#video_call_my_name').css('left','725px');
			this.YourNameTextLabel.visibleObj();
			this.MyNameTextLabel.visibleObj();			

			//Your
			if(this.flag_shown_your_avatar == true)
			{
				$('#your_thumbnail_hd_avatar').css('left','323px');
				$('#your_thumbnail_hd_avatar').css('top','222px');
				//$('#your_thumbnail_hd_avatar').css('width','250px');
				//$('#your_thumbnail_hd_avatar').css('height','250px');	
			}			
			
			//My
			if(this.flag_shown_my_avatar == true)
			{
				$('#my_thumbnail_hd_avatar').css('left','743px');
				$('#my_thumbnail_hd_avatar').css('top','222px');
				//$('#my_thumbnail_hd_avatar').css('width','250px');
				//$('#my_thumbnail_hd_avatar').css('height','250px');
			}
		}
		else
		{
			$('#video_call_your_name').css('left','515px');			
			
			this.MyNameTextLabel.hiddenObj();
						
			//Your
			if(this.flag_shown_your_avatar == true)
			{
				this.YourNameTextLabel.visibleObj();
				
				$('#your_thumbnail_hd_avatar').css('left','533px');
				$('#your_thumbnail_hd_avatar').css('top','222px');
				//$('#your_thumbnail_hd_avatar').css('width','250px');
				//$('#your_thumbnail_hd_avatar').css('height','250px');					
			}
			else
			{
				this.YourNameTextLabel.hiddenObj();	
			}
			
			//My
			if(this.flag_shown_my_avatar == true)
			{
				$('#my_thumbnail_hd_avatar').css('left','976px');			
				$('#my_thumbnail_hd_avatar').css('top','487px');
				//$('#my_thumbnail_hd_avatar').css('width','213px');
				//$('#my_thumbnail_hd_avatar').css('height','213px');
			}
		}			
	}

}

SceneVideoCall.prototype.showAllAvartarInEnd = function(){
	alert("SceneVideoCall.showAllAvartarInEnd()");
	
	if(this.flag_shown_your_avatar == false)
	{
		alert("CallMemberThumbnail.Show");
		this.CallMemberThumbnail.Show();
		this.flag_shown_your_avatar = true;
	}	

	var avartarCount = 1;

	if(this.flag_shown_my_avatar == true)
	{
		avartarCount++;
	}
	
	//set position
	if(avartarCount == 1)
	{
		$('#your_thumbnail_hd_avatar').css('left','533px');
		$('#your_thumbnail_hd_avatar').css('top','222px');
	}
	else if(avartarCount == 2)
	{
		$('#your_thumbnail_hd_avatar').css('left','323px');
		$('#your_thumbnail_hd_avatar').css('top','222px');
		
		$('#my_thumbnail_hd_avatar').css('left','743px');
		$('#my_thumbnail_hd_avatar').css('top','222px');
	}
		
	
}

SceneVideoCall.prototype.hiddenAvartar = function(){
	alert("SceneVideoCall.hiddenAvartar()");

	if(this.flag_shown_your_avatar == true)
	{
		alert("CallMemberThumbnail.Hide");
		this.CallMemberThumbnail.Hide();
		this.flag_shown_your_avatar = false;
	}	

	if(this.flag_shown_my_avatar == true)
	{		
		alert("MyThumbnail.Hide");
		this.MyThumbnail.Hide();
		this.flag_shown_my_avatar = false;
	}
}

SceneVideoCall.prototype.changeCameraBtn= function()
{
	if( this.CameraOnBtn.GetFlagVisible() == true)
	{
		this.CameraOnBtn.hiddenObj();
		this.CameraOnBtn.blur();		
		this.highlight(this.CameraOffBtn);	
		this.CameraOffBtn.visibleObj();	
		this.is_sending_video = false;
				
		ProcMgr.StopSendVideo();
	}
	else
	{
		this.CameraOffBtn.hiddenObj();
		this.CameraOffBtn.blur();		
		this.highlight(this.CameraOnBtn);			
		this.CameraOnBtn.visibleObj();
		this.is_sending_video = true;
		
		ProcMgr.StartSendVideo();
	}	
	
	//setting btn 
	this.BtnSetting();
}

SceneVideoCall.prototype.changeMuteBtn = function()
{
    alert("SceneVideoCall.changeMuteBtn() ");
    
    if(this.flag_camera_unplugged == true)
    {
    	return;
    }
       
	if( this.MicMuteOnBtn.GetFlagVisible() == true)
	{
		alert("show MicMuteOffBtn");		
		this.MicMuteOnBtn.hiddenObj();
		this.MicMuteOnBtn.blur();		
		this.highlight(this.MicMuteOffBtn);	
		this.MicMuteOffBtn.visibleObj();
		this.ChangeTooltipText(IDWS_MOIP_SKYPE_UNMUTE_MIC);
		
		PluginAPIMgr.MuteMic(true);		
	}
	else
	{
		alert("show MicMuteOnBtn");			
		this.MicMuteOffBtn.hiddenObj();
		this.MicMuteOffBtn.blur();		
		this.highlight(this.MicMuteOnBtn);			
		this.MicMuteOnBtn.visibleObj();
		this.ChangeTooltipText(IDWS_MOIP_SKYPE_MUTE_MIC);
		
		PluginAPIMgr.MuteMic(false);
	}
}

SceneVideoCall.prototype.changeFaceTrackingBtn = function()
{
    alert("SceneVideoCall.changeFaceTrackingBtn() ");
    
    if(this.flag_camera_unplugged == true)
    {
    	return;
    }
       
	if( this.FaceTrackingOnBtn.GetFlagVisible() == true)
	{
		alert("show FaceTrackingOffBtn");		
		this.FaceTrackingOnBtn.hiddenObj();
		this.FaceTrackingOnBtn.blur();		
		this.highlight(this.FaceTrackingOffBtn);	
		this.FaceTrackingOffBtn.visibleObj();

		PluginAPIMgr.SaveDBAutoTracking(false);
		
		PluginAPIMgr.FaceTracking(false);
		this.flag_tracking_face = true;
				
		PluginAPIMgr.StartOSDTimer("4000" , function() { 
			var this_ = sf.scene.get("VideoCall");			
			this_.flag_tracking_face = false;

			PluginAPIMgr.SyncZoomState();
			PluginAPIMgr.SyncPanState();
			PluginAPIMgr.SyncTiltState();
						
		}, ENUM_TIMER_TYPE.OTHER);

	}
	else
	{
		alert("show FaceTrackingOnBtn");			
		this.FaceTrackingOffBtn.hiddenObj();
		this.FaceTrackingOffBtn.blur();		
		this.highlight(this.FaceTrackingOnBtn);			
		this.FaceTrackingOnBtn.visibleObj();

		
		PluginAPIMgr.SaveDBAutoTracking(true);
		
		PluginAPIMgr.FaceTracking(true);
		this.flag_tracking_face = true;
				
		PluginAPIMgr.StartOSDTimer("3000" , function() { 
			var this_ = sf.scene.get("VideoCall");			
			this_.flag_tracking_face = false;
		}, ENUM_TIMER_TYPE.OTHER);
	
	}

	//setting btn 
	this.BtnSetting();	
	
}


//0.volume 1. setting 2.face tracking 3. camera  4.mute  5.tv  6. end call
SceneVideoCall.prototype.AdjustBtnPosition = function(){
	alert("SceneVideoCall.AdjustBtnPosition() ");

	var btn_count = 1;
	var btn_cur_index = 0;
	
	//reset
	for(var i=0;i < 7;i++)
	{
		this.Btn_arry[i] = null;
	}
	
	//Step 1. count button number
	//tv & end call btn

	if(this.flag_enable_voume_btn == true)
	{
		btn_count++;
		this.Btn_arry[btn_cur_index++] = 'volume';
	}
	if(this.flag_enable_setting_btn == true) 
	{
		btn_count++;
		this.Btn_arry[btn_cur_index++] = 'setting';
	}
	if(this.flag_enable_face_tracking_btn == true) 
	{
		btn_count++;
		this.Btn_arry[btn_cur_index++] = 'faceTracking';
	}	
	if(this.flag_enable_camera_btn == true)
	{	
		btn_count++;
		this.Btn_arry[btn_cur_index++] = 'camera';
	}
	if(this.flag_enable_mute_btn == true)
	{
		btn_count++;
		this.Btn_arry[btn_cur_index++] = 'mute';
	}
	if(this.flag_enable_tv_btn == true)
	{
		btn_count++;
		this.Btn_arry[btn_cur_index++] = 'tv';
	}	
	
	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);
	}
	
}

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

	var OnBtnEID = null;
	var OffBtnEID = null;
	
	if(BtnName == 'volume')
	{
		OnBtnEID = '#video_call_volume_hd_btn';
	}
	else if(BtnName == 'setting')
	{
		OnBtnEID = '#video_call_setting_hd_btn';
	}	
	else if(BtnName == 'faceTracking')
	{	
		OnBtnEID = '#video_call_face_tracking_on_hd_btn';
		OffBtnEID = '#video_call_face_tracking_off_hd_btn';
	}		
	else if(BtnName == 'mute')
	{	
		OnBtnEID = '#video_call_mute_on_hd_btn';
		OffBtnEID = '#video_call_mute_off_hd_btn';
	}	
	else if(BtnName == 'camera')
	{
		OnBtnEID = '#video_call_camera_on_hd_btn';
		OffBtnEID = '#video_call_camera_off_hd_btn';
	}
	else if(BtnName == 'tv')
	{
		OnBtnEID = '#video_call_tv_mode_on_btn';
		OffBtnEID = '#video_call_tv_mode_off_btn';
	}
	else if(BtnName == 'endcall')
	{
		OnBtnEID = '#video_call_end_hd_btn';
	}
	
	//set on btn position
	$(OnBtnEID).css('left',SKYPE_CALL_BTN_POS_ARRY[totalNum-1][index]);
	
	//set off btn position
	if(OffBtnEID != null)
	{
		$(OffBtnEID).css('left',SKYPE_CALL_BTN_POS_ARRY[totalNum-1][index]);
	}	
}

SceneVideoCall.prototype.RemoteHold = function()
{
	this.setHold(true);
}

SceneVideoCall.prototype.Resume = function()
{
	this.setHold(false);
}

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

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

SceneVideoCall.prototype.setHold = function(showFlag)
{
	if(showFlag == true)
	{
		if(this.flag_shown_hold_icon == false)
		{
			$('#video_call_hold_area').css("display","block");
			this.highlight(null);
			this.HideTooltip();
					
			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;
		}
	}
}

SceneVideoCall.prototype.updateCallDuration = function(time)
{
     this.CallDurationTimeLabel.SetText(time);
}

SceneVideoCall.prototype.closingProcess = function()
{
	this.flag_close_all = true;
	
	this.hiddenView();
	this.showAllAvartarInEnd();
		
	this.flag_skype_call_view_type	= SKYPE_CALL_VIEW_TYPE.INIT;
}

SceneVideoCall.prototype.changeTVBtn = function()
{
    alert("SceneVideoCall.changeTVBtn() ");
    
	if(this.TVModeOnBtn.GetFlagVisible() == true)
	{
		alert("change ShowTV off --> on");			
		if(ProcMgr.IsDualViewMode() == false)
		{
			//set flag		
			this.flag_tv_mode = true;
					
			if(ProcMgr.ProductInfo.support_mixing_video == false && PluginAPIMgr.GetFaceTracking() == true)
			{
				PluginAPIMgr.FaceTracking(false);
			}
					
			ProcMgr.ChangeSourceMode(true);
	
			this.showWindowView();
			this.BtnSetting();
			this.showAvartar();
			this.stopTimer();	
			this.ShowInfoArea();		
	    
		}
	}
	else
	{
		alert("change ShowTV on --> off");
		//set flag
		this.flag_tv_mode = false;
						
		ProcMgr.ChangeSourceMode(false);

		if(ProcMgr.ProductInfo.support_mixing_video == false)
		{
			PluginAPIMgr.SyncAutoFaceTracking();
		}
		
		this.BtnSetting();		
		
		if(ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.INCOMING_PSTN  ||  ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.OUTGOING_PSTN)
		{
			StateMgr.Start_Skype_Out_Call_State(); 
		}
		else
		{
			this.showWindowView();
			this.showAvartar();
			this.stopTimer();	
			this.ShowInfoArea();
			
		}
	}
}


SceneVideoCall.prototype.showCredit = function()
{	
	if(ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.INCOMING_PSTN  ||  ProcMgr.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.OUTGOING_PSTN)
	{
		//show
		this.MyCreditBgLabel.visibleObj();		
		this.updateCredit();
		$('#video_call_duration_bg').css("top","10px");
	}
	else
	{
		//hide
		this.MyCreditBgLabel.hiddenObj();
		$('#video_call_duration_bg').css("top","20px");
	}
}


SceneVideoCall.prototype.updateCredit = function()
{	
	this.MyCreditText.SetText(PluginAPIMgr.GetMyCredit());
}

SceneVideoCall.prototype.toggleVoumeBtn = function()
{	
	if(this.flag_tv_mode == true)
	{
		this.VolumeBtn.visibleObj();
		this.flag_enable_voume_btn = true;	
	}
	else
	{
		var currentHighlight =  this.VideoCallView.getCurrentHighlight();

        if(currentHighlight == this.VolumeBtn)
        {
			this.highlight(this.CallEndBtn);			
        }
		
		this.VolumeBtn.hiddenObj();
		this.flag_enable_voume_btn = false;
	}
}

SceneVideoCall.prototype.ShowTooltip = function(toolttip_text,btn_index)
{
	alert('SceneVideoCall.ShowTooltip');
	
	var btn_position = SKYPE_CALL_BTN_POS_ARRY[this.Btn_total_num-1][btn_index];
	var LeftLen = btn_position.indexOf('px');
	var l_int = parseInt(btn_position.substring(0,LeftLen));
	var tooltip_left = (l_int + 32) + 'px';
	alert('tooltip_left >>>>> ' + tooltip_left);
	
	//1st. show
	if(this.flag_shown_tooltip == false)
	{
		$('#video_call_btn_tooltip').sfTooltip('show');
		this.flag_shown_tooltip = true;
	}

	$('#video_call_btn_tooltip').sfTooltip('setText',toolttip_text);
	$('#video_call_btn_tooltip').css('left',tooltip_left);
	
	this.StartTimerTooltip();
}


SceneVideoCall.prototype.ChangeTooltipText = function(toolttip_text)
{	
	alert('SceneVideoCall.ChangeTooltipText');
	
	//1st. show
	if(this.flag_shown_tooltip == false)
	{
		$('#video_call_btn_tooltip').sfTooltip('show');
		this.flag_shown_tooltip = true;
	}

	$('#video_call_btn_tooltip').sfTooltip('setText',toolttip_text);
	
	this.StartTimerTooltip();
}


SceneVideoCall.prototype.ResetTooltip = function()
{
	alert('SceneVideoCall.ResetTooltip');	

    var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    var cur_index;
    
    if(currentHighlight == null)
    {
        //cur_index = this.GetBtnIndex(this.CallEndBtn);
        return;
    }
    else
    {
        cur_index = this.GetBtnIndex(currentHighlight);
    }

	this.ShowTooltip(this.GetTooltipText(currentHighlight),cur_index);
}

SceneVideoCall.prototype.GetTooltipText = function(btn_obj)
{
    switch(btn_obj)
    {
        case this.CallEndBtn:
        	return TV_SID_END_CALL;
            
        case this.CameraOnBtn:
        	return IDWS_MOIP_CAM_OFF;
        	
        case this.CameraOffBtn:
        	return IDWS_MOIP_CAM_ON;
        	
        case this.MicMuteOnBtn:
        	return IDWS_MOIP_SKYPE_MUTE_MICs;
        	
        case this.MicMuteOffBtn:
        	return IDWS_MOIP_SKYPE_UNMUTE_MIC;        	
        	        	           
        case this.TVModeOnBtn:
        	var tooltip_text = TV_SID_SHOW_TV;
			if(ProcMgr.IsDualViewMode() == true)
			{
				tooltip_text = "<font color='#005EA2'>" + TV_SID_SHOW_TV + "</font><br>" + TV_SID_FUNCTION_UNAVAILABEL_WHILE_SAMSUNG_MULTI_VIEW + "<br>" + TV_SID_TO_USE_FUNCTION_MUST_STOP_SAMSUNG_MULTI_VIEW;
			}     
        	return tooltip_text;
        	
        case this.TVModeOffBtn:
        	return TV_SID_HIDE_TV;
        	        	           
        case this.SettingBtn:
        	return TV_SID_VIDEO_CALL_SETTINGS;

        case this.VolumeBtn:
        	return SID_VOLUME;
        	
        case this.FaceTrackingOnBtn:
        	return TV_SID_AUTO_FACE_TRACKING_OF;
        	
        case this.FaceTrackingOffBtn:
        	return TV_SID_AUTO_FACE_TRACKING_ON;
    }
}




SceneVideoCall.prototype.GetTooltipPosition = function(btn_index)
{
	
	var btn_position = SKYPE_CALL_BTN_POS_ARRY[this.Btn_total_num-1][btn_index];
	var LeftLen = btn_position.indexOf('px');
	var l_int = parseInt(btn_position.substring(0,LeftLen));
	var tooltip_left = (l_int + 32) + 'px';
	alert('tooltip_left >>>>> ' + tooltip_left);
		
	return tooltip_left;
}


SceneVideoCall.prototype.StartTimerTooltip = function()
{
	if(this.TooltipTimer)
	{
		clearTimeout(this.TooltipTimer);
	}
    
	this.TooltipTimer = setTimeout("HideToolTipCallBack()", 6000);
	
	HideToolTipCallBack = function(){
		sf.scene.get('VideoCall').HideTooltip();
		
    }	
}

SceneVideoCall.prototype.HideTooltip = function()
{
	$('#video_call_btn_tooltip').sfTooltip('hide');
	this.flag_shown_tooltip = false;
}


SceneVideoCall.prototype.createLoading = function()
{

	var ResStr = sf.env.getResolution();
	this.LoadingAniImagePath = "images/"+ResStr+"/loading/loading_64/";

    var a=0;
    for (a=0; a < this.LoadingAniArray.length; a++)
    {
        var b = (a+1);
        if(b<10)
        {
            this.LoadingAniArray[a] = this.LoadingAniImagePath +"loading_64_"+"0"+b+".png";
        }
        else
        {
            this.LoadingAniArray[a] = this.LoadingAniImagePath +"loading_64_"+b+".png";
        }
    }
 	this.LoadingAniLabel = new Label("video_call_loading_animation", null);
    this.LoadingAniLabel.SetBgImage(this.LoadingAniArray[this.iCurrAniImage]);
}

SceneVideoCall.prototype.ShowLoading = function()
{
	alert('SceneVideoCall.ShowLoading');
	
	this.LoadingAniLabel.visibleObj();
	this.flag_shown_loading_ani = true;

	var scene = sf.scene.get('VideoCall');
    this.LoadingTimer = setInterval("LoadingTimerCF()", 150);
    LoadingTimerCF = function(){scene.loadingTimerCallback();}
}

SceneVideoCall.prototype.HideLoading = function()
{
	alert('SceneVideoCall.HideLoading');
	
	clearInterval(this.LoadingTimer);

    this.LoadingTimer = null;
    this.iCurrAniImage = 0;
    this.LoadingAniLabel.hiddenObj();
    this.flag_shown_loading_ani = false;
}

SceneVideoCall.prototype.loadingTimerCallback= function()
{
	this.iCurrAniImage++;
     
    if(this.iCurrAniImage >= this.LoadingAniArray.length)
    {
        this.iCurrAniImage = 0;
    }   
    
    this.LoadingAniLabel.SetBgImage(this.LoadingAniArray[this.iCurrAniImage]);
}

SceneVideoCall.prototype.processLoadingWindow = function(windwo_type)
{
	alert('SceneVideoCall.processLoadingWindow -- ' + windwo_type);
	
	if(this.LoadingTimer != null)
	{
		alert('under loading process');
		return;
	}
	
	if(this.flag_skype_call_view_type < SKYPE_CALL_VIEW_TYPE.ONLY_TV)
	{
		if(windwo_type < SKYPE_CALL_VIEW_TYPE.ONLY_TV)
		{
			this.visibleView(windwo_type);
			return;
		}
	}
	else
	{
		if(windwo_type > SKYPE_CALL_VIEW_TYPE.YOUR_AND_MY)
		{
			this.visibleView(windwo_type);
			return;
		}
	}
		
	//hide all window
	this.hiddenView();
	this.ShowLoading();
	
	var loading_time = 10000;
		
	PluginAPIMgr.StartOSDTimer(String(loading_time), 
		function() { 
			var this_ = sf.scene.get("VideoCall");
			this_.visibleView(this_.flag_skype_call_view_type);
			this_.HideLoading();
			
			var NNaviPlugin = sf.core.plugin('NNavi');
						
			if(ProcMgr.CallInfo.IsTvMode == true) {
				NNaviPlugin.SetBannerState(2);
			}
			else {
				NNaviPlugin.SetBannerState(1); 
			}
		},
		ENUM_TIMER_TYPE.OTHER
	);
	
}


//volume btn is first!!
SceneVideoCall.prototype.SetNoVolumeMixingLabel = function()
{
	if(ProcMgr.ProductInfo.support_mixing_audio == true)
	{
		return;
	}
	
	if(this.flag_enable_voume_btn == true)
	{
		this.NoVolumeMixingTVLabel.visibleObj();
		this.NoVolumeMixingSkypeLabel.visibleObj();
	}
	else
	{
		this.NoVolumeMixingTVLabel.hiddenObj();
		this.NoVolumeMixingSkypeLabel.hiddenObj();
		return;
	}
	
	var btn_position = SKYPE_CALL_BTN_POS_ARRY[this.Btn_total_num-1][0];
	var LeftLen = btn_position.indexOf('px');
	var l_int = parseInt(btn_position.substring(0,LeftLen));
	var tv_label_left = (l_int -10) + 'px';
	var skype_label_left = (l_int + 20) + 'px';
	
	alert('tv_label_left='+tv_label_left);
	alert('skype_label_left='+skype_label_left);
	
	$("#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 == 1)
	{
		$("#video_call_no_volume_mixing_skype").css('color','#696969');
		$("#video_call_no_volume_mixing_tv").css('color','#FFFFFF');
	}
	else
	{
		$("#video_call_no_volume_mixing_tv").css('color','#696969');
		$("#video_call_no_volume_mixing_skype").css('color','#FFFFFF');		
	}
}

SceneVideoCall.prototype.processBtnOver = function(obj){
	//alert("SceneVideoCall.processBtnOver() ");
	
	if(this.InfoAreaShowState == false)
	{
		return;
	}
	
	this.startTimer();
	
	var currentHighlight =  this.VideoCallView.getCurrentHighlight();
    if(currentHighlight != obj)
    {      	
        var end_btn_index = this.GetBtnIndex(obj);
        this.highlightBtnWithIndex(end_btn_index); 
    }
}

SceneVideoCall.prototype.processVolumeBtnOver = function()
{
	this.processBtnOver(this.VolumeBtn);
}

SceneVideoCall.prototype.processSettingBtnOver = function()
{
	this.processBtnOver(this.SettingBtn);
}

SceneVideoCall.prototype.processSettingBtnOver = function()
{
	this.processBtnOver(this.SettingBtn);
}

SceneVideoCall.prototype.processTVModeOnBtnOver = function()
{
	this.processBtnOver(this.TVModeOnBtn);
}

SceneVideoCall.prototype.processTVModeOffBtnOver = function()
{
	this.processBtnOver(this.TVModeOffBtn);
}

SceneVideoCall.prototype.processMicMuteOnBtnOver = function()
{
	this.processBtnOver(this.MicMuteOnBtn);
}

SceneVideoCall.prototype.processMicMuteOffBtnOver = function()
{
	this.processBtnOver(this.MicMuteOffBtn);
}

SceneVideoCall.prototype.processCameraOffBtnOver = function()
{
	this.processBtnOver(this.CameraOffBtn);
}

SceneVideoCall.prototype.processCameraOnBtnOver = function()
{
	this.processBtnOver(this.CameraOnBtn);
}

SceneVideoCall.prototype.processCallEndBtnOver = function()
{
	this.processBtnOver(this.CallEndBtn);
}

SceneVideoCall.prototype.processCameraOnBtnOver = function()
{
	this.processBtnOver(this.CameraOnBtn);
}

SceneVideoCall.prototype.processFaceTrackingOnBtnOver = function()
{
	this.processBtnOver(this.FaceTrackingOnBtn);
}

SceneVideoCall.prototype.processFaceTrackingOffBtnOver = function()
{
	this.processBtnOver(this.FaceTrackingOffBtn);
}

SceneVideoCall.prototype.processMuteKey = function()
{
	alert("SceneVideoCall.processMuteKey()");
	
	if(this.flag_shown_loading_ani == true)
	{
		return;
	}
		
	if(ProcMgr.CallInfo.IsSpeakerMute == false)
	{
	    ProcMgr.processVolumeMute(true);
	    StateMgr.Start_Volume_Speaker_State(VOLUME_MODE.MASTER_MUTE);
	}																					
	else
	{
		ProcMgr.processVolumeMute(false);
    	StateMgr.Start_Volume_Speaker_State(VOLUME_MODE.MASTER);
	}
}
