if(!this.ProcMgr) {
	this.ProcMgr = new Object();
}

ProcMgr ={
	isWelcomeMode : true,
	
	flagQuit : false,
	
	loggedIn : false,
	cblSync : false,
	
	isLoginCencel : false,
	
	isConferenceCall: false,
	isCalling : false,
	isCallCencel : false,
	isVoiceMailSending : false,
	callHoldTimer : false,
	callResumeTimer : false,
	
	callEndWaitingTimer : false,
	isLogoutAfterCallEnd : false,
	isQuitAfterCallEnd : false,
	isCloseAfterCallEnd : false,
	isExitAfterCallEnd : false,

	isCallStartAfterCallEnd : false,
	isCallingFail : false,
	
	isIncomingCall : false,
	isReceivingVideo : false,
	isPauseVideo : false,
	
	isTypingChatMsg : false,
	numOfChatMember :0,
	ChatMember :"",
	ChatParticipants : "",
	ChatMemberSkypeName :"",
	
	isVoiceMailPlaying : false,
	
	isKeyRegister: false,
	isCallKeyRegister: false,
	
	isTTXMIX: false,
	isGenoaS: false,
	ModelCode : null,
	isNTVmodel : false,
	isUDmodel : false,
	
	isVideoAvailable:false,

	cameraZoomValue :0,
	
	MainListFuncType : null,
	//start_main : false,
	
	isExitAfterSignout : false,
	
	//isGestureRecognition : false,
	
	isAutoFocus:false,
	
	isFaceRecog : false,
	isFaceDetect : false,
	isFaceTraining : false,
	
	FaceRecogTimer:false,
	FaceDetectTimer:false,
	
	CountOfRecogFail : 0,
	CountOfTrainingFail :0,
	CountOfRecogInfo : 0,
	
	isRegisteredFace : false,
	isReRegisterFace : false,
	FaceRegistrationCallerState : "",
	isFaceRegistrationAfterSignin : false,
	isSigninAfterPwdCheck : false,

	HoldReceiveVideo : false , 
	
	CurOutputMixVolume : 0,	
	
	CallInfo : new Object(),
	
	skypeName : null,
	isRidgeFlick:false,
	
	flag_show_exit_popup : false,	
	falg_converting_UD_to_FHD : false
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  TV Model / Target location / remote control ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ProcMgr.getTVModel =function()
{	
	var tv_model = PluginAPIMgr.GetTVModel();
	
	//model string "T-GASAKUC", "T-GAPAKUC", "T-MST10PDEUC" , "T-FXPAKUC", "T-FXP9NAKUC"
	
	alert("##mini##***** ProcMgr.getTVModel() :  " + tv_model );
	
	var dash_index = tv_model.indexOf("-");
	var model_checker = tv_model.substring(dash_index+1,dash_index+3);
	this.isNTVmodel = false;
	this.isUDmodel = false;
		
	if(model_checker == "FX")
	{
		if(dash_index == 1)
		{
			this.ModelCode = TV_MODEL_CODE.FOX;
			alert('TV_MODEL_CODE.FOX');
			
			//9500 model
			var NTV_checker = tv_model.substring(dash_index+4,dash_index+6);
			if(NTV_checker == "9N")
			{
				this.isNTVmodel = true;
			}

			var model_config = PluginAPIMgr.GetModelConfig();
			
			if(model_config == "US9" || model_config == "UF9000")
			{
				this.isUDmodel = true;
			}
			
		}
		else if(dash_index == 2)
		{
			this.ModelCode = TV_MODEL_CODE.FOX_SBB;
			alert('TV_MODEL_CODE.FOX_SBB');
		}
		else
		{
			this.ModelCode = TV_MODEL_CODE.NORMAL;
			alert('TV_MODEL_CODE.NORMAL');
		}
	}
	else
	{
		model_checker = tv_model.substring(dash_index+1,dash_index+6);
		if(model_checker == 'MST12')
		{
			this.ModelCode = TV_MODEL_CODE.X12;
			alert('TV_MODEL_CODE.X12');
		}
		else
		{
			this.ModelCode = TV_MODEL_CODE.NORMAL;
			alert('TV_MODEL_CODE.NORMAL');
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Key  register / unregister / process  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ProcMgr.registerKey =function()
{   
	alert("##mini##***** ProcMgr.registerKey()");
	if(this.isKeyRegister== false)
	{
		var p = $.sf.plugin('APPCOMMON');
		var i=0;
		for(i=0; i < KEY_CODE_LIST.length; i++)
		{         
		     if(p){
		        p.RegisterKey(KEY_CODE_LIST[i]);
		    }
		}	
		if(this.isNTVmodel == true)		//prevent dualview key
		{
			p.RegisterKey(ENUM_CALL_BLOCK_KEY_CODE.DUALVIEW);
		}
		this.isKeyRegister=true;
	}
}

ProcMgr.unregisterKey =function()
{  
	alert("##mini##***** ProcMgr.unregisterKey ()");
	if(this.isKeyRegister== true && this.isCalling==false)
	{
		try{
		var p = $.sf.plugin('APPCOMMON');
		
		var i=0;
		for(i=0; i < KEY_CODE_LIST.length; i++)
		{             
		    if(p){
				p.UnregisterKey(KEY_CODE_LIST[i]);
		    }
		}
		if(this.isNTVmodel == true)
		{
			p.UnregisterKey(ENUM_CALL_BLOCK_KEY_CODE.DUALVIEW);
		}
		this.isKeyRegister=false;
		}catch(e){
			alert(e);
		}
	}
}

ProcMgr.registerCallKey =function()
{	
	alert("##mini##***** ProcMgr.registerCallKey()");

	if(this.isCallKeyRegister== false)
	{
		var p = $.sf.plugin('APPCOMMON');
		var i=0;
		for(i=0; i < CALL_BLOCK_KEY_CODE_LIST.length; i++)
		{         
		     if(p){
				p.RegisterKey(CALL_BLOCK_KEY_CODE_LIST[i]);
		    }
		}		
		this.isCallKeyRegister=true;
	}
}

ProcMgr.unregisterCallKey  =function()
{
	alert("##mini##***** ProcMgr.unregisterCallKey ()");
		
	if(this.isCallKeyRegister== true && this.isCalling==false)
	{
		try{
			var p = $.sf.plugin('APPCOMMON');
		
			var i=0;
			for(i=0; i < CALL_BLOCK_KEY_CODE_LIST.length; i++)
			{             
			    if(p){
			        p.UnregisterKey(CALL_BLOCK_KEY_CODE_LIST[i]);
			    }
			}				
			this.isCallKeyRegister=false;
		}catch(e){
			alert(e);
		}
	}
}

ProcMgr.processBlockKey  =function(key_code)
{
    alert("##mini##***** ProcMgr.processBlockKey () key_code : " + key_code);
    
    if(key_code== 40000002 || key_code== 40000003 || key_code== 40000004 || key_code== 40000005)
    {
    	return;
    }

    //check ridge
    if(key_code > 50100000 && key_code < 50500000)
    {
		return;
    }
  
	var BlockKey = false;
    var i=0;
    for(i=0; i < CHANNEL_KEY_CODE_LIST.length; i++)
    {             
        if (CHANNEL_KEY_CODE_LIST[i] == key_code) 
		{
            if(this.isCalling == true  && StateMgr.GetCurrentSubState().length <= 0)
            {
					
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_KEY);
				BlockKey = true;
				$.sfKey.block(event);
            }
			else
			{
				return;
			}
        }
    }
	
	for(i=0; i < CALL_BLOCK_KEY_CODE_LIST.length; i++)
    {             
        if (CALL_BLOCK_KEY_CODE_LIST[i] == key_code) 
		{
			if(this.isCalling == true  && StateMgr.GetCurrentSubState().length <= 0)
			{
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_KEY);
				BlockKey = true;
				//check block function!!
				$.sfKey.block(event);
				//event.preventDefault();
			}
			else
			{
				return;
			}
        }
    }
			
	if(BlockKey==false)
	{
		if(StateMgr.GetCurrentSubState().length <= 0)
        {
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_KEY);
        }
		$.sfKey.block(event);
	}
}

ProcMgr.processInfolinkKey  =function()
{
    alert("##mini##***** ProcMgr.processInfolinkKey ()");
     
    if(this.isCalling == true || StateMgr.GetCurrentSubState().length >0 || ProcMgr.isShowNotyOfMainState()==true)
    {
        if(this.isCalling == true  && StateMgr.GetCurrentSubState().length <= 0)
        {
			if(g_NumObj != null)
			{
				g_NumObj.blur();	
			}	
				
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_KEY);
        }

        $.sfKey.block(event);
    }
    else
    {
		this.CloseWidget();
        $.sfKey.block(event);
    }
}

ProcMgr.isShowNotyOfMainState =function()
{
    alert("##mini##***** ProcMgr.isShowNotyOfMainState ()");
    
    var result = false;
    
    if(StateMgr.GetCurrentState()=="CreateAccountSuccess")
    {
    	if(WndMgr.CreateAccountSuccessStep != "Success")
    	{
    		result=true;
    	}
    }
    else if(StateMgr.GetCurrentState()=="FaceRecogSignin")
    {
		if(WndMgr.FaceRecogSigninStep != "FaceRecog" && WndMgr.FaceRecogSigninStep != "Result")
    	{
			result=true;
    	}
    }
    else if(StateMgr.GetCurrentState()=="FaceRecogRegistration")
    {
		if(WndMgr.FaceRecogRegistrationStep != "FaceDetect")
    	{
			result=true;
    	}
    }
    else
    {
    	result=false;
    }
    
    return result;    
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// Widget Start /  Stop  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ProcMgr.StartWidget = function()
{     
    alert("##mini##***** ProcMgr.StartWidget() :" +TVCOMM_SERVICE_MODE);
	if(TVCOMM_SERVICE_MODE == TVCHAT_MODE_HIDDEN){
		PluginAPIMgr.SetSkypeWidgetState(0);
		PluginAPIMgr.WidgetHandleIncomingCall(0);
	}
	else if(PluginAPIMgr.GetScreenViewMode()==1){
		PluginAPIMgr.WidgetHandleIncomingCall(0);
		PluginAPIMgr.SetSkypeWidgetState(2);	//widget main start : 1, widget social start : 2, widget destroy : 0
	}else{
		PluginAPIMgr.WidgetHandleIncomingCall(1);
		PluginAPIMgr.SetSkypeWidgetState(2);
	}
	
	ProcMgr.InitCameraOption();
	
	var LoginState = PluginAPIMgr.GetLoginState();

    if(LoginState == "0")  //logged out state
    {
       if(PluginAPIMgr.IsDefaultAccountAvailable() ==1) // auto login
      {
            PluginAPIMgr.AutoLogin(); 
       }
       else  //manual login 
       {
    		//StateMgr.SetCurrentState(MAIN_STATE.WELCOME);
    		StateMgr.Start_Current_State(MAIN_STATE.WELCOME);
			// StateMgr.Start_Welcome_State();		
       }
    }    	
    else if(LoginState == "2") //logged in state
    {
        	if(PluginAPIMgr.IsCallInProgress() == "1")
	     	{  
	     		if(PluginAPIMgr.GetScreenViewMode()==1){
	     			//modify by minseok : 130610
	     			//during dual view -> go to skype
	     			this.isCalling = true;
	     			StateMgr.Start_NotCall_In_DualView_State();
	     		}else{
	     			this.isCalling = true;
		     		this.getCallInfo();
		     		this.StartCall();	
	     		}
	     	}
	     	else
	     	{
	     		if(PluginAPIMgr.IsInCall()==1) //incoming call
         		{
         			if(!PluginAPIMgr.IsConference())
         			{
         				ProcMgr.IncomingCall();
         			}
         			else
         			{
         				ProcMgr.IncomingConferenceCall();
         			} 
         		}
         		else
         		{
         			StateMgr.Start_Current_State(MAIN_STATE.MAIN);
         		}
	     		
	     	}           	
     }
    
    RecogMgr.StartVoiceRecog();       
}

ProcMgr.CloseWidget = function()
{
	if(StateMgr.GetCurrentState()== "VideoSnapshot" || StateMgr.GetCurrentState()== "CameraCheckConnected")
	{
		PluginAPIMgr.StopPreview();	
	}
	
	setTimeout("WaitTimerCF()", 0);
	WaitTimerCF = function(){
     $.sf.exit(false);
    }
}

ProcMgr.ExitWidget = function()
{
	if(StateMgr.GetCurrentState()== "VideoSnapshot" || StateMgr.GetCurrentState()== "CameraCheckConnected")
	{
		PluginAPIMgr.StopPreview();	
	}
	
	setTimeout("WaitTimerCF()", 0);
	WaitTimerCF = function(){
     $.sf.exit(true);
    }
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////Signin , Create Account, Signout, Exit////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ProcMgr.Signin = function(id, pwd, savePwd)
{    
    alert("##mini##***** ProcMgr.Signin ()");
     
    g_Data.SetSigninInputInfo(id, pwd , savePwd);

    PluginAPIMgr.Login();
    
    if(StateMgr.GetCurrentState()=="Signin")
    {
    	WndMgr.NextStepSignin();
    }
    
    if(StateMgr.GetCurrentState()=="FaceRecogSignin")
    {
    	WndMgr.NextStepFaceRecogSignin();
    }    
}

ProcMgr.CancelSignin = function()
{    
    alert("##mini##***** ProcMgr.CancelSignin ()");
    
    this.loggedIn = false;  //init
    this.cblSync = false;  //init
    
    this.isLoginCencel = true;
    ProcMgr.Signout(false);
}

ProcMgr.CreateAccount = function()
{
    alert("##mini##***** ProcMgr.CreateAccount()");

    PluginAPIMgr.Register();
    WndMgr.NextStepCreateAccount();        
}

ProcMgr.CreateAccountWithNewSkypeName = function(id)
{
    alert("##mini##***** ProcMgr.CreateAccountWithNewSkypeName ()");
    g_Data.SetCreateAccountSkypeName(id);
	WndMgr.UpdateCreateAccount(id);
	
    PluginAPIMgr.Register();
    WndMgr.NextStepCreateAccount();
}

ProcMgr.ReceivedLoggedIn= function()
{
    alert("##mini##***** ProcMgr.ReceivedLoggedIn()");
    
    this.loggedIn = true;
    
    if(this.cblSync==true)
    {
        ProcMgr.HandleLoggedIn();
    }
}

ProcMgr.ReceivedCblSync= function()
{
    alert("##mini##***** ProcMgr.ReceivedCblSync()");
    
    this.cblSync = true;
     
    if(this.loggedIn==true)
    {
        ProcMgr.HandleLoggedIn();
    }
}

ProcMgr.SavePwd= function()
{
    if(StateMgr.GetCurrentState()=="Signin")
    {
    	alert("##mini##***** ProcMgr.SavePwd(): Siginin");
    	this.SetMyPwd(g_Data.DATA_SIGNIN_INPUT_INFO.pwd);
    	PluginAPIMgr.SetLoginMode(0);    	
    }
    
    if(StateMgr.GetCurrentState()=="CreateAccount")
    {
    	alert("##mini##***** ProcMgr.SavePwd(): CreateAccount");
    	this.SetMyPwd(g_Data.DATA_CREATE_ACCOUNT_INPUT_INFO.pwd);
    	PluginAPIMgr.SetLoginMode(0); 
    }
    
    if(StateMgr.GetCurrentState()=="FaceRecogSignin")
    {
    	if(this.isFaceRegistrationAfterSignin== true || this.isSigninAfterPwdCheck == true)
    	{
	    	alert("##mini##***** ProcMgr.SavePwd(): FaceRecogSignin");
    		this.SetMyPwd(g_Data.DATA_SIGNIN_INPUT_INFO.pwd);    		
    	}
    	
    	PluginAPIMgr.SetLoginMode(1); 
    }
    
}

ProcMgr.HandleLoggedIn= function()
{
    alert("##mini##***** ProcMgr.HandleLoggedIn()");
    
    if(PluginAPIMgr.RecognitionPluginAvailable == true)
    {
    	this.SavePwd();
    }	
    
	this.StartLoggedInState();


    this.loggedIn = false;  //init
    this.cblSync = false;  //init
    this.isFaceRegistrationAfterSignin = false; //init
    this.isSigninAfterPwdCheck = false; //init
}

ProcMgr.StartLoggedInState = function()
{
    alert("##mini##***** ProcMgr.StartLoggedInState()");
	
	StateMgr.Start_Current_State(MAIN_STATE.MAIN);
	
	RecogMgr.ChangeVoiceHelpbar();
}

ProcMgr.Signout = function(flag_quit)
{    
    alert("##mini##***** ProcMgr.Signout () Quit : " + flag_quit);
     
    if(StateMgr.GetCurrentState()== "VideoSnapshot" || StateMgr.GetCurrentState()== "CameraCheckConnected")
	{
		PluginAPIMgr.StopPreview();	
	}
		
	setTimeout("WaitTimerCF()", 0);
	WaitTimerCF = function(){
     
	    ProcMgr.flagQuit = flag_quit;
	    
	    if( ProcMgr.flagQuit == true)
	    {
	        PluginAPIMgr.Logout(0);
	    }
	    else
	    {
	        PluginAPIMgr.Logout(1);
	    }
   }
}

ProcMgr.HandleLoggedOut= function()
{
	alert("##mini##***** ProcMgr.HandleLoggedOut()");
    
    RecogMgr.ChangeVoiceHelpbar();
    
	var LoggedOut_Reason = PluginAPIMgr.GetLogoutReason();
	 
    switch(LoggedOut_Reason)
    {
        case ENUM_LOGOUTREASON.LOGOUT_CALLED : 
		
            if(this.flagQuit == false)
            {
                if(this.isLoginCencel == true)
                {
                	if(StateMgr.GetCurrentState() =="Signin") 
                    {
	                    WndMgr.BackStepSignin();
						StateMgr.Start_Signin_State();
                    }
                	else if(StateMgr.GetCurrentState() =="FaceRecogSignin") 
                    {
	                    WndMgr.BackStepFaceRecogSignin();
						//WndMgr.ReturnFaceRecogSignin();
						StateMgr.Start_Welcome_State();
                    }

                    this.isLoginCencel = false; //init
                    
					return;
                }
				              
			   	StateMgr.Start_Welcome_State();           
            }
            else
            {
                $.sf.exit(this.isExitAfterSignout);
            }
            
        break;
 ///synchronous login, regiteration
		case ENUM_LOGOUTREASON.HTTPS_PROXY_AUTH_FAILED :
		case ENUM_LOGOUTREASON.SOCKS_PROXY_AUTH_FAILED : 
		case ENUM_LOGOUTREASON.P2P_CONNECT_FAILED :

			if(StateMgr.GetCurrentState() =="Signin")
            {
                WndMgr.BackStepSignin();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_EXTERNAL_NETWORK_CONNECTION_FAIL);
            }
            else if(StateMgr.GetCurrentState() =="CreateAccount")
            {
                WndMgr.BackStepCreateAccount();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_EXTERNAL_NETWORK_CONNECTION_FAIL);
            }
        	else if(StateMgr.GetCurrentState() =="FaceRecogSignin") 
            {
                WndMgr.BackStepFaceRecogSignin();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_EXTERNAL_NETWORK_CONNECTION_FAIL);
            }
            else
            {
                if(PluginAPIMgr.IsDefaultAccountAvailable() ==1) // auto login
                {
                     StateMgr.Start_Welcome_State();
                }
            }

        break;
		
		case ENUM_LOGOUTREASON.SERVER_CONNECT_FAILED : 
		case ENUM_LOGOUTREASON.SERVER_OVERLOADED :
		
			if(StateMgr.GetCurrentState() =="Signin")
            {
                WndMgr.BackStepSignin();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_SERVER_CONNECTION_FAIL);
            }
            else if(StateMgr.GetCurrentState() =="CreateAccount")
            {
                WndMgr.BackStepCreateAccount();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_SERVER_CONNECTION_FAIL);
            }
        	else if(StateMgr.GetCurrentState() =="FaceRecogSignin") 
            {
                WndMgr.BackStepFaceRecogSignin();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_SERVER_CONNECTION_FAIL);
            }
            else
            {
                if(PluginAPIMgr.IsDefaultAccountAvailable() ==1) // auto login
                {
                     StateMgr.Start_Welcome_State();
                }
            }
   
        break;
		
		case ENUM_LOGOUTREASON.DB_IN_USE :

			if(StateMgr.GetCurrentState() =="Signin")
            {
                WndMgr.BackStepSignin();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_IMPOSSIBLE);
            }
            else if(StateMgr.GetCurrentState() =="CreateAccount")
            {
                WndMgr.BackStepCreateAccount();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_IMPOSSIBLE);
            }
        	else if(StateMgr.GetCurrentState() =="FaceRecogSignin") 
            {
                WndMgr.BackStepFaceRecogSignin();
				WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_IMPOSSIBLE);
            }
            else
            {
                if(PluginAPIMgr.IsDefaultAccountAvailable() ==1) // auto login
                {
                     StateMgr.Start_Welcome_State();
                }
            } 

        break;
 ///synchronous regiteration
		case ENUM_LOGOUTREASON.INVALID_SKYPENAME : 

			WndMgr.BackStepCreateAccount();
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_INVALID_SKYPENAME);
			
        break;
		case ENUM_LOGOUTREASON.INVALID_EMAIL : 

			WndMgr.BackStepCreateAccount();
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_INVALID_EMAIL);
			
        break;
		case ENUM_LOGOUTREASON.UNACCEPTABLE_PASSWORD : 

			WndMgr.BackStepCreateAccount();
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_UNACCEPTABLE_PASSWORD);
			
        break;
		case ENUM_LOGOUTREASON.SKYPENAME_TAKEN : 
		
            WndMgr.StopLoading();
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_SKYPENAME_TAKEN);
			
        break;
		case ENUM_LOGOUTREASON.REJECTED_AS_UNDERAGE :

			WndMgr.BackStepCreateAccount();
        	WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_REJECTED_AS_UNDERAGE);
			
        break;
 ///synchronous  login
		case ENUM_LOGOUTREASON.NO_SUCH_IDENTITY :

		  if(PluginAPIMgr.IsDefaultAccountAvailable() ==1) // auto login
          {
                 StateMgr.Start_Welcome_State();
          }
          else
          {
            if(StateMgr.GetCurrentState() =="Signin")
            {
            	WndMgr.BackStepSignin();
            }            
        	else if(StateMgr.GetCurrentState() =="FaceRecogSignin") 
            {
                WndMgr.BackStepFaceRecogSignin();
            }
            
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_NO_SUCH_IDENTITY);
          }

        break;
		case ENUM_LOGOUTREASON.INCORRECT_PASSWORD :

		  if(PluginAPIMgr.IsDefaultAccountAvailable() ==1) // auto login
          {
                 StateMgr.Start_Welcome_State();
          }
          else
          {
                if(StateMgr.GetCurrentState() =="Signin")
	            {
	            	WndMgr.BackStepSignin();
	            	WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_INCORRECT_PASSWORD);
	            }            
	        	else if(StateMgr.GetCurrentState() =="FaceRecogSignin") 
	            {	            	
	                WndMgr.BackStepFaceRecogSignin();
	                if(this.isFaceRegistrationAfterSignin == true || this.isSigninAfterPwdCheck== true)
	                {
	                	WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_INCORRECT_PASSWORD);
	                }
	                else
	                {
	                	PluginAPIMgr.SetLoginMode(0);
	                	WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_PASSWORD_HAS_CHANGED);
	                }	                
	            }
          }

        break;
		case ENUM_LOGOUTREASON.TOO_MANY_LOGIN_ATTEMPTS :
		
          if(PluginAPIMgr.IsDefaultAccountAvailable() ==1) // auto login
          {
                 StateMgr.Start_Welcome_State();
          }
          else
          {
            if(StateMgr.GetCurrentState() =="Signin")
            {
            	WndMgr.BackStepSignin();
            }            
        	else if(StateMgr.GetCurrentState() =="FaceRecogSignin") 
            {
                WndMgr.BackStepFaceRecogSignin();
            }
            
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_TOO_MANY_LOGIN_ATTEMPTS);
          }
            
        break;
/// Asynchronous 
		case ENUM_LOGOUTREASON.PASSWORD_HAS_CHANGED : 
			PluginAPIMgr.SetLoginMode(0);
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_PASSWORD_HAS_CHANGED);
        break;
		case ENUM_LOGOUTREASON.PERIODIC_UIC_UPDATE_FAILED : 
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_PERIODIC_UIC_UPDATE_FAILED);
        break;
		case ENUM_LOGOUTREASON.DB_DISK_FULL : 
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_DB_DISK_FULL);
        break;
		case ENUM_LOGOUTREASON.DB_IO_ERROR :
		case ENUM_LOGOUTREASON.DB_CORRUPT : 
		case ENUM_LOGOUTREASON.DB_FAILURE :
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.LOGGEDOUT_DB_PROBLEM);
        break;
        
/// don't use
		case ENUM_LOGOUTREASON.INVALID_APP_ID : 
        break;
		case ENUM_LOGOUTREASON.APP_ID_BLACKLISTED  : 
        break;
    }
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///// Main Update  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


ProcMgr.AccountAvataImageChanged= function()
{
    alert("##mini##***** ProcMgr.AccountAvataImageChanged()");
     if(StateMgr.GetCurrentState() =="miniMainContact")
    {
        $.sfScene.get({id:"miniMainContact", scope:WIDGET.id}).updateAvata();
    }
}

ProcMgr.AccountCreditChanged= function()
{
    alert("##mini##***** ProcMgr.AccountCreditChanged()");

	if(StateMgr.GetCurrentState() =="miniSkypeCall")
	{
          $.sfScene.get({id:"miniSkypeCall", scope:WIDGET.id}).updateCredit();
	}
}

ProcMgr.AccountAvailabilityChanged= function()
{
    alert("##mini##***** ProcMgr.AccountAvailabilityChanged()");
    if(StateMgr.GetCurrentState() =="miniMainContact")
    {
    	$.sfScene.get({id:"miniMainContact", scope:WIDGET.id}).updateOnlineStatus();
    }
}

ProcMgr.AccountMoodMsgChanged= function()
{
    alert("##mini##***** ProcMgr.AccountMoodMsgChanged()");
     if(StateMgr.GetCurrentState() =="miniMainContact")
    {
          $.sfScene.get({id:"miniMainContact", scope:WIDGET.id}).updateMoodMessage();
    }
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Call  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ProcMgr.IncomingCall = function()
{
    alert("##mini##***** ProcMgr.IncomingCall()");
   this.isConferenceCall = false;
   
   	if(this.callEndWaitingTimer == false)
	{
		if(StateMgr.GetCurrentState()!= "miniCalling")// && StateMgr.MainStateList[MAIN_STATE.CALLING].flagLoading == false)
		{
			this.isIncomingCall = true;
			StateMgr.Start_Incoming_Call_State();
			
			RecogMgr.ChangeVoiceHelpbar();
		}
	}
}

ProcMgr.IncomingConferenceCall = function()
{
    alert("##mini##***** ProcMgr.IncomingConferenceCall()");
   this.isConferenceCall = true;

   	if(this.callEndWaitingTimer == false)
	{
		if(StateMgr.GetCurrentState()!= "miniCalling")// && StateMgr.MainStateList[MAIN_STATE.CALLING].flagLoading == false)
		{
			this.isIncomingCall = true;
			StateMgr.Start_Incoming_Call_State();
			
			RecogMgr.ChangeVoiceHelpbar();
		}
	}
}

ProcMgr.AnswerByVideo = function()
{
	alert("##mini##***** ProcMgr.AnswerByVideo()");
	RecogMgr.StopVoiceRecog(true);
	PluginAPIMgr.ShowConnectingWnd();
	PluginAPIMgr.AnswerWithVideo();
}

ProcMgr.AnswerByVoice = function()
{
	alert("##mini##***** ProcMgr.AnswerByVoice()");
	RecogMgr.StopVoiceRecog(true);
	PluginAPIMgr.ShowConnectingWnd();
	PluginAPIMgr.AnswerWithVoice();
}

ProcMgr.DeclineIncomingCall = function()
{
    alert("##mini##***** ProcMgr.DeclineIncomingCall()");
	PluginAPIMgr.RejectCall();
}

ProcMgr.DeclineIncomingConferenceCall = function()
{
    alert("##mini##***** ProcMgr.DeclineIncomingConferenceCall()");
    PluginAPIMgr.DisconnectCall(0);
}

ProcMgr.GetIsInCall = function(){
	
	return this.isCalling;
}

ProcMgr.GetIsConferenceCall = function(){
	
	return this.isConferenceCall; 
}

ProcMgr.CreateCall = function(callee_name, call_type)
{
    alert("##mini##***** ProcMgr.CreateCall()");
    //check dual view : prevent call(130604)
    if(PluginAPIMgr.GetScreenViewMode()==1){	//dual view
    	alert("##mini##***** dual view...cannot call");
    	StateMgr.Start_NotCall_In_DualView_State();
    	return;
    }
	
	if(PluginAPIMgr.GetAccountInfo(ENUM_ACCOUNT_PROPERTY.P_AVAILABILITY) == ENUM_ACCOUNT_AVAILABILITY.CONNECTING )
    {
		var scene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
		if(scene)
		{
			scene.Activation();
		}
			
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.CREATE_CALL_FAIL_NETWORK_ERROR);
		return;	
	}
  
    g_Data.SetCreateCallInputInfo(callee_name, call_type);
	
	if(this.isUDmodel == true && TVCOMM_SERVICE_MODE == TVCHAT_MODE_FULL && this.falg_converting_UD_to_FHD == false)
	{
		this.falg_converting_UD_to_FHD = true;		
		PluginAPIMgr.ConvetFHDfromUD(true);
	}
	
    if(PluginAPIMgr.CreateCall()==1)
	{
		RecogMgr.StopVoiceRecog(true);
		this.registerCallKey();
		StateMgr.Start_Calling_State();
	} 
	else
	{
		var scene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
		if(scene)
		{
			scene.Activation();
		}
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.CREATE_CALL_FAIL_PHONE_NUMBER_ERROR);	
	}
}

ProcMgr.DisconnectCall = function(endType)
{
    alert("##mini##***** ProcMgr.DisconnectCall()");
    
    this.unregisterCallKey();
    PluginAPIMgr.DisconnectCall(endType);
    
    StateMgr.Start_Call_Ending_State(true);
}

ProcMgr.CancelCall = function()
{
    alert("##mini##***** ProcMgr.CancelCall()");
    this.isCallCencel = true;
    PluginAPIMgr.DisconnectCall();
}

 ProcMgr.InprogressCall= function()
 {
    alert("##mini##***** ProcMgr.InprogressCall()");
    
    //close preview of  calling wnd
    WndMgr.CloseCallingPreView();
        
	if(this.isUDmodel == true && TVCOMM_SERVICE_MODE == TVCHAT_MODE_FULL && this.falg_converting_UD_to_FHD == false)
	{
		this.falg_converting_UD_to_FHD = true;		
		PluginAPIMgr.ConvetFHDfromUD(true);
	}
    
    this.getCallInfo();
    
    this.isIncomingCall= false;
    
    if( this.isCalling == true)
    {
        if(g_Data.GetCallRemoteHold() == true)
        {
            this.Resume();
        }
		else 
		{
			if(this.isConferenceCall==true && StateMgr.GetCurrentState()=="ConferenceCall")
			{
				WndMgr.UpdateConferenceCallMemberInfo();
			}
		}
        return;
    }
    else
    {
        this.isCalling = true;
    }
    this.registerCallKey();
    	
    //init vol. & mic.
	if(this.ModelCode == TV_MODEL_CODE.X12 || this.ModelCode == TV_MODEL_CODE.FOX_SBB)
	{
		this.CurOutputMixVolume = 0;
		PluginAPIMgr.SetTVMixVolume(0);
		PluginAPIMgr.SetCallMixVolume(100);						
	}
	PluginAPIMgr.MuteMic(false);
	
	var camera_state = PluginAPIMgr.GetCameraState();
	
	if(this.CallInfo.IsSendingVideo == true && (camera_state == ENUM_CAM_STATE.CAM_STATE_DISCONNECTED || camera_state == ENUM_CAM_STATE.CAM_STATE_CONNECTING))
	{
		PluginAPIMgr.StopSendVideo();  
	}
	
	this.StartCall(); 
 }

ProcMgr.StartCall = function()
{
    alert("##mini##***** ProcMgr.StartCall()");
    
    this.flag_show_exit_popup = false;
    RecogMgr.StopVoiceRecog(true);

	if(this.CallInfo.IsConference == true) 
    {
		if(this.CallInfo.IsSendingVideo == true ||this.isReceivingVideo == true)
		{
			StateMgr.Start_Video_Call_State();
		}
		else
		{
			StateMgr.Start_Conference_Call_State();
		}
        
    }
    else if(this.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.INCOMING_P2P  ||  this.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.OUTGOING_P2P)  
        {
    	//check
		if(this.CallInfo.IsVideo == true)
        {
	        if(this.CallInfo.IsSendingVideo == false)
            {
	        	alert('##################################################################################');        	
	        	alert('######################### isReceivingVideo = true ################################');
	        	alert('##################################################################################');        	
                this.isReceivingVideo =true;
            }
        }
    	StateMgr.Start_Video_Call_State();
                        		
		setTimeout("startTimerCF()", 1000);
		startTimerCF = function(){
			ProcMgr.ProcessReceiveVideo();
		}
    } 
     else if(this.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.INCOMING_PSTN  ||  this.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.OUTGOING_PSTN)
    {
        StateMgr.Start_Video_Call_State(); 
    }
    PluginAPIMgr.HideConnectingWnd();
}
 
ProcMgr.GoCall = function()
{
    alert("##mini##***** ProcMgr.GoCall()");
    
    if(StateMgr.currentState == "Main" ||  StateMgr.currentState == "Chat")
    {
          ProcMgr.StartCall();
    }
    else
    { 
          StateMgr.ReturnToMainState(); 
    }    
}

 ProcMgr.EndCall = function()
{
	if(this.callEndWaitingTimer != false)
	{
		alert("##mini##***** ProcMgr.EndCall()-> aready call ending" );
		if(this.isIncomingCall ==true)
		{
			this.isIncomingCall =false;
		}
		return;
	}
	
    alert("##mini##***** ProcMgr.EndCall()-> calling : " + this.isCalling);
	if(StateMgr.GetCurrentState()!="miniCalling" && this.isCalling==false)
	{
		if(PluginAPIMgr.IsWidgetActivatedByAnswer()==0) 
		{
			if(this.isIncomingCall==false)
			{
				return;
			}
		}
	}

    if(this.isCalling == true)
    {
		if(this.ModelCode == TV_MODEL_CODE.X12 || this.ModelCode == TV_MODEL_CODE.FOX_SBB)
		{
			alert("turn on tv mix volume");
			PluginAPIMgr.SetTVMixVolume(100);
			PluginAPIMgr.SetCallMixVolume(0);
			this.CurOutputMixVolume = 1;
		}
		PluginAPIMgr.MuteMic(false);
	}	
	
    g_Data.SetCallRemoteHold(false);//init
    this.isCalling = false; //init
    this.isConferenceCall = false; //init
    this.isVoiceMailSending = false; //init
    this.isReceivingVideo =false; //init
    this.cameraZoomValue =0; //init
    this.isPauseVideo = false; //init
    
	
	if(this.falg_converting_UD_to_FHD == true)
	{
		this.falg_converting_UD_to_FHD = false;		
		PluginAPIMgr.ConvetFHDfromUD(false);
	}
            
    if(this.isIncomingCall ==true)  // incoming call reject
    {
		alert("##mini##***** ProcMgr.EndCall()-> isIncomingCall : " + this.isIncomingCall);
        this.isIncomingCall =false;
		if(StateMgr.GetCurrentSubState()!="miniCalling")// && StateMgr.MainStateList[MAIN_STATE.CALLING].flagLoading != true)
       {
	   		if(StateMgr.GetCurrentState()!="Init")
			{				
				//for mini			
				//StateMgr.Stop_Incoming_Call_State();
				StateMgr.Start_Main_State();
			}
			else
			{
				StateMgr.Start_Main_State();
			}
			if(this.flag_show_exit_popup == true)
			{
				this.flag_show_exit_popup = false;
				$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processExitKey();
			}
			return;
	   }
    }
    
	PluginAPIMgr.BlockIncomingCall();
    ProcMgr.unregisterCallKey();
	
	if(StateMgr.GetCurrentState()!="Init")
	{
		PluginAPIMgr.HideConnectingWnd();
	}
	
    StateMgr.Start_Call_Ending_State(false);
	
	this.callEndWaitingTimer= true;
	if(this.isCallingFail==false)
	{
		PluginAPIMgr.StartOSDTimer("2000" , function() { ProcMgr.EndCallTimerCallback();}, ENUM_TIMER_TYPE.CALL_END);  
	}
	else
	{
		PluginAPIMgr.StartOSDTimer("10000" , function() { ProcMgr.EndCallTimerCallback();}, ENUM_TIMER_TYPE.CALL_END);  
	}    
}

 ProcMgr.DropCall = function()
 {
    alert("##mini##***** ProcMgr.DropCall()");
    WndMgr.UpdateCallDroppedStatus();
 }

 ProcMgr.EndCallTimerCallback = function()
 {
     alert("##mini##***** ProcMgr.EndCallTimerCallback()");
	 this.callEndWaitingTimer = false;
	 this.isCallingFail = false;
	 
	 PluginAPIMgr.UnblockIncomingCall(0);
		   
	if(StateMgr.GetCurrentState() == 'miniMainContact')
	{
		var contactScene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
		contactScene.InitializeScene();	
	}
			
	StateMgr.Start_Main_State();  
	RecogMgr.StartVoiceRecog();

	if(this.flag_show_exit_popup == true)
	{
		this.flag_show_exit_popup = false;
		$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processExitKey();
	}
}
 
ProcMgr.ProcessCallingFail = function(fail_reason)
{
	alert("##mini##***** ProcMgr.ProcessCallingFail() reason -> " + fail_reason );
	this.isCallingFail = true;
	WndMgr.UpdateCallingMessage(fail_reason);
}

ProcMgr.StopCallingFailMsg = function()
{
	alert("##mini##***** ProcMgr.StopCallingFailMsg()");
	if(this.isCallingFail == true)
	{
		if(this.callEndWaitingTimer== true)
		{
			 PluginAPIMgr.StopOSDTimer(ENUM_TIMER_TYPE.CALL_END); 
		}
		ProcMgr.EndCallTimerCallback();
	}
}

ProcMgr.ProcessReceiveVideo= function()
{
    alert("##mini##***** ProcMgr.ProcessReceiveVideo()-> this.isVideoAvailable : "+ this.isVideoAvailable);
	if(this.IsReceivingVideo == true)
	{
		alert("##mini##***** ProcMgr.ProcessReceiveVideo()-> already receive video");
		return;
	}	
	//PluginAPIMgr.IsCallMemberVideoAvailable()==0
	if(this.isVideoAvailable == false && this.CallInfo.IsRecvVideoAvailable == false)
	{
		alert("***** no video *****");
		return;
	}
	
    this.isVideoAvailable = false; //init
	
	if(this.CallInfo.IsAutoRecvVieo == true  || this.CallInfo.IsConference == true) //don't change during conf call.
	{
		 return; 
	}
	else
	{
		WndMgr.StartCallConfirmPopup(MINI_CALL_CONFIRM_POPUP.CALLING_VIA_VIDEO);
	}
 }
 
ProcMgr.SetStartReceiveVideo= function()
{
	alert("##mini##***** ProcMgr.SetStartReceiveVideo()");
	PluginAPIMgr.StartReceiveVideo();
}
 
 ProcMgr.StartReceiveVideo= function()
 {
    alert("##mini##***** ProcMgr.StartReceiveVideo()");
    
	this.isPauseVideo=false;
	this.isReceivingVideo = true;
     
			WndMgr.UpdateVideoCallYourVideo();
	
			}	
			
ProcMgr.HoldReceiveVideo= function()
			{
	this.HoldReceiveVideo = true;
 }
 
ProcMgr.StopReceiveVideo= function()
{
    alert("##mini##***** ProcMgr.StopReceiveVideo()-> PluginAPIMgr.IsSendingVideo() : "+ PluginAPIMgr.IsSendingVideo());
    
    this.isReceivingVideo =false;
    
        WndMgr.UpdateVideoCallYourVideo();
     }
 
ProcMgr.IsReceivingVideo= function()
{
   return  this.isReceivingVideo;
}

 ProcMgr.StartSendVideo= function()
 {
    alert("##mini##***** ProcMgr.StartSendVideo()");
PluginAPIMgr.StartSendVideo();
WndMgr.UpdateVideoCallMyVideo();
    
 }
 
ProcMgr.StopSendVideo= function()
{  
    PluginAPIMgr.StopSendVideo();
    
        WndMgr.UpdateVideoCallMyVideo();
    }
 
ProcMgr.InitCameraOption= function()
{
	alert("##mini##***** ProcMgr.InitCameraOption()");

	this.isAutoFocusEnable();
	PluginAPIMgr.SetAutoFocus(PluginAPIMgr.GetAutoFocus()); 
	PluginAPIMgr.SetMicVolume(PluginAPIMgr.GetMicVolume());
}

ProcMgr.isAutoFocusEnable= function()
{
	alert("##mini##***** ProcMgr.isAutoFocusEnable()");
	if(PluginAPIMgr.isAutoFocusEnable()==1)
	{
		ProcMgr.isAutoFocus = true;
	}
	
	return ProcMgr.isAutoFocus;
}
 
ProcMgr.UpdateCameraState= function()
{
    alert("##mini##***** ProcMgr.UpdateCameraState()");
    
    if(StateMgr.GetCurrentSubState() == "VolumeMic")
    {
        StateMgr.Stop_Volume_Mic_State(true); 
    }
	
	ProcMgr.SetCameraZoomValue(0);
    
   // WndMgr.UpdateVoiceCallCameraState();
   // WndMgr.UpdateSkypeOutCallCameraState();
   // WndMgr.UpdateConferenceCallCameraState();
	//WndMgr.UpdateChatCameraState();

//Modified by Donghee
	if(this.isCalling == true)
	{
	   if(PluginAPIMgr.IsSendingVideo() ==0)
	   {
	        WndMgr.UpdateVideoCallCameraState();
	   }
	   else
	   {
	   		//Modified by Donghee
	   		// if(this.isCalling == true)
			ProcMgr.StopSendVideo(); 
	   }  
	} 
   
  // WndMgr.UpdateVideoSnapshotCameraState();   

 //  WndMgr.UpdateChangePictureCameraState();	
 
//camera update

	WndMgr.UpdateMiniContactCallMenu();
	 
  // WndMgr.UpdateMainCameraState();

   WndMgr.UpdateCameraCheckState();
      
    alert("##mini##***** ProcMgr.UpdateCameraState() End");
   
}
 
  ProcMgr.ChangeToConferenceCall= function()
 {
    alert("##mini##***** ProcMgr.ChangeToConferenceCall() -> isConferenceCall : " + this.isConferenceCall);
    
    if(this.isCalling==true && this.isConferenceCall == false)
    {
        this.isConferenceCall = true;
                
	    if(WndMgr.isShowVideoCall == true)
	    {    
	        $.sfScene.get({id:"miniSkypeCall", scope:WIDGET.id}).hiddenAllView();
	    }
	    
		setTimeout("StopSendVideoTimerCF()", 500);
		StopSendVideoTimerCF = function(){
			PluginAPIMgr.StopSendVideo();
	    }
    	    
		if(StateMgr.GetCurrentState()=="miniMainContact" )
		{
			return;  // don't change to conf call	
		}
			
        StateMgr.Start_Conference_Call_State();

     }
 }
 
 ProcMgr.UpdateCallDuration = function( time)
{
    alert("##mini##***** ProcMgr.UpdateCallDuration()" + time);
    
    WndMgr.UpdateVideoCallDuration(time);
    WndMgr.UpdateConferenceCallDuration(time);
    WndMgr.UpdateVoiceMailRecordingDuration(time);
}
 
 ProcMgr.UpdateCallMemberStatus = function()
 {
    alert("##mini##***** ProcMgr.UpdateCallMemberStatus()");
    
    WndMgr.UpdateConferenceCallMemberInfo();
 }
 
  ProcMgr.RemoteHold = function()
 {
    alert("##mini##***** ProcMgr.RemoteHold()");
    g_Data.SetCallRemoteHold(true);
    WndMgr.VideoCallRemoteHold();
    //WndMgr.ConferenceCallRemoteHold();

 }

  ProcMgr.Resume = function()
 {
    alert("##mini##***** ProcMgr.Resume()");
    g_Data.SetCallRemoteHold(false);
    WndMgr.VideoCallResume();
    //WndMgr.ConferenceCallResume();
	
 }
 
ProcMgr.SelectCallSwitch = function()
{
	alert("##mini##***** ProcMgr.SelectCallSwitch()");
	StateMgr.Start_Call_Switch_State(); 
	
}

ProcMgr.StartCallSwitch = function()
{
	alert("##mini##***** ProcMgr.StartCallSwitch()");
	this.isCallStartAfterCallEnd = true;
	ProcMgr.DisconnectCall();
	
}

ProcMgr.CancelCallSwitch = function()
{
	alert("##mini##***** ProcMgr.CancelCallSwitch()");

	StateMgr.Stop_Call_Switch_State(true);	
}

ProcMgr.CameraZoomUp = function()
{
	if(this.cameraZoomValue>=2)
	{
		return;
	}
	this.cameraZoomValue++;
	
	PluginAPIMgr.Zoom(this.cameraZoomValue);
	
}

ProcMgr.CameraZoomDown = function()
{
	if(this.cameraZoomValue<=0)
	{
		return;
	}
	this.cameraZoomValue--;
	
	PluginAPIMgr.Zoom(this.cameraZoomValue);	
}

ProcMgr.GetCameraZoomValue = function()
{
	return this.cameraZoomValue;
}

ProcMgr.SetCameraZoomValue = function(zoom_value)
{
	this.cameraZoomValue = zoom_value;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Voice Mail  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 
ProcMgr.SendingVoiceMail= function()
{
    alert("##mini##***** ProcMgr.SendingVoiceMail()");
     this.isCalling = false; //init
    this.isVoiceMailSending = true;
    g_Data.SetVoiceMailInputInfo(g_Data.DATA_CREATE_CALL_INPUT_INFO.callee_name);
    
    ProcMgr.registerCallKey();

	WndMgr.ShowSendVoiceMail();    
}

ProcMgr.UploadVoiceMail= function()
{
    alert("##mini##***** ProcMgr.UploadVoiceMail()");
    PluginAPIMgr.DisconnectCall();
    
}

ProcMgr.CancelVoiceMail= function()
{
    alert("##mini##***** ProcMgr.CancelVoiceMail()");
    
    PluginAPIMgr.CancelVoicemail();
    
}

ProcMgr.EndVoiceMail= function()
{
     alert("##mini##***** ProcMgr.EndVoiceMail()");
    this.isVoiceMailSending = false; //init
	
	this.callEndWaitingTimer= true;
	PluginAPIMgr.StartOSDTimer("2000" , function() { ProcMgr.EndCallTimerCallback();}, ENUM_TIMER_TYPE.CALL_END);  
}

ProcMgr.PlayHistoryVoicemail = function(nIndex)
{
	var result = PluginAPIMgr.PlayHistoryVoicemail(nIndex);
	
	if(result == '1')
	{
		this.isVoiceMailPlaying=true;
	}
	else
	{
		this.isVoiceMailPlaying=false;
	}
	
	return result;
}

ProcMgr.StopHistoryVoicemail = function(nIndex)
{
	var result = PluginAPIMgr.StopHistoryVoicemail(nIndex);
	this.isVoiceMailPlaying=false;
	
	return result;   	
}
 
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
//// Settings  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////  Online State
ProcMgr.SetOnlineStatus= function(setIndex)
{
    alert("##mini##***** ProcMgr.SetOnlineStatus()");
    PluginAPIMgr.SetAvailability(setIndex);
    StateMgr.Stop_Online_Status_State(true);
}

////  Change Picture
ProcMgr.SetAvatar = function(avatarImg)
{
    alert("##mini##***** ProcMgr.SetAvatar()");
	PluginAPIMgr.SetMyAvatar(avatarImg)
    StateMgr.Stop_Change_Picture_State(true);
}

////  Change Password
ProcMgr.ChangePassword= function(old_pwd, new_pwd, re_pwd)
{  
    alert("##mini##***** ProcMgr.ChangePassword()");
    
    g_Data.SetChangePWDInfo(old_pwd, new_pwd, re_pwd);
    
     WndMgr.NextStepChangePassword();
     
     if(new_pwd !=re_pwd)
     {       
        ProcMgr.HandleChangePassword( OneBtnPopupIndex.PWD_NEW_REPEAT_PWD_NOT_MATCH);
     }
     else
     {
        PluginAPIMgr.ChangePassword();
     }
}

ProcMgr.HandleChangePassword= function(result)
{
    alert("##mini##***** ProcMgr.HandleChangePassword()");
    WndMgr.NextStepChangePassword();
    
    if(result == OneBtnPopupIndex.PWD_INVALID_NEW_PWD)
    {
        var error_type = PluginAPIMgr.ValidatePasswd(PluginAPIMgr.GetMySkyeName() , g_Data.DATA_CHANGE_PWD_INPUT_INFO.new_pwd);
        
         switch(error_type)
        {
            case ENUM_PWD_VALIDATERESULT.NOT_VALIDATED :
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_INVALID_NEW_PWD);
                break;
            case ENUM_PWD_VALIDATERESULT.TOO_SHORT :
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_TOO_SHORT);
                break;
            case ENUM_PWD_VALIDATERESULT.TOO_LONG : 
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_TOO_LONG);
                break;
            case ENUM_PWD_VALIDATERESULT.CONTAINS_INVALID_CHAR :
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_CONTAINS_INVALID_CHAR);
                break;
            case ENUM_PWD_VALIDATERESULT.CONTAINS_SPACE : 
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_CONTAINS_SPACE);
                break;
            case ENUM_PWD_VALIDATERESULT.SAME_AS_USERNAME : 
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_SAME_AS_USERNAME);
                break;
            case ENUM_PWD_VALIDATERESULT.INVALID_FORMAT : 
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_INVALID_FORMAT);
                break;
            case ENUM_PWD_VALIDATERESULT.CONTAINS_INVALID_WORD : 
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_CONTAINS_INVALID_WORD);
                break;
            case ENUM_PWD_VALIDATERESULT.TOO_SIMPLE : 
                WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_TOO_SIMPLE);
                break;
                
             default:
                 WndMgr.StartOneBottonPopup(OneBtnPopupIndex.PWD_INVALID_NEW_PWD);
                break;
                
        }
    }
    else
    {
        WndMgr.StartOneBottonPopup(result);
    }
}

ProcMgr.SaveChangedPassword= function()
{
    alert("##mini##***** ProcMgr.SaveChangedPassword()");
    
    if(PluginAPIMgr.RecognitionPluginAvailable==false)
    {
    	return;
    }

    var new_pwd = g_Data.GetChangedPWDInfo();
    
    ProcMgr.SetMyPwd(new_pwd);
}

////  Edit Profile 
ProcMgr.SaveProfile = function(mood_msg, full_name ,email, country_code, home_phone, office_phone, mobile_phone, province, city, gender, birth_day )
{
    alert("##mini##***** ProcMgr.SaveProfile()");
    
    WndMgr.NextStepEditProfile();
    
     if(PluginAPIMgr.IsValidEmail(email) == 1)
    {
        g_Data.SetEditProfileInfo(mood_msg, full_name,email, country_code, home_phone, office_phone, mobile_phone, province, city, gender, birth_day);
    
        PluginAPIMgr.ChangeMoodMsg();
        PluginAPIMgr.ChangeFullName();
        PluginAPIMgr.ChangeEmail();    
        PluginAPIMgr.ChangeCountryCode();
        PluginAPIMgr.ChangeHomePhone();
        PluginAPIMgr.ChangeOfficePhone();
        PluginAPIMgr.ChangeMobilePhone();
        PluginAPIMgr.ChangeProvince();
        PluginAPIMgr.ChangeCity();
        PluginAPIMgr.ChangeGender();
        PluginAPIMgr.ChangeBirthDay();
        
        WndMgr.NextStepEditProfile();
        WndMgr.StartOneBottonPopup(OneBtnPopupIndex.EDIT_PROFILE_OK);
    }
    else
    {
        WndMgr.NextStepEditProfile();
        WndMgr.StartOneBottonPopup(OneBtnPopupIndex.EDIT_PROFILE_INVALID_EMAIL);
    }
        
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// add contact /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ProcMgr.SearchNewContact = function(contact_name)
{
    var normalized_contact_name = PluginAPIMgr.NormalizeIdentity(contact_name);
    
    if(normalized_contact_name.length >0)
    {
         alert("##mini##***** ProcMgr.SearchNewContact() : true");
    PluginAPIMgr.SearchNewContact(contact_name);
    }
    else
    {
        alert("##mini##***** ProcMgr.SearchNewContact() : false");
        PluginAPIMgr.SearchNewContact(contact_name);
    }
    
    WndMgr.NextStepAddContact(); 
}

ProcMgr.HandleSearchFailNewContact = function(result)
{
    alert("##mini##***** ProcMgr.HandleSearchNewContact()");
    WndMgr.BackStepAddContact();
    WndMgr.StartOneBottonPopup(result);
}

ProcMgr.SearchContactProfile = function(contact_name)
{
    alert("##mini##***** ProcMgr.SearchContactProfile()");
    WndMgr.NextStepAddContact(); 
    PluginAPIMgr.SearchContactProfile(contact_name);    
}

ProcMgr.AddContact = function(skype_name, hello_msg)
{   
     alert("##mini##***** ProcMgr.AddContact()");
     if(PluginAPIMgr.IsBlocked(skype_name) == 1)
     {
        WndMgr.NextStepAddContact(); 
         WndMgr.StartOneBottonPopup(OneBtnPopupIndex.IS_BLOCKED_SKYPE_NAME);
     }
     else if(PluginAPIMgr.IsMyName(skype_name) == 1)
     {
        WndMgr.NextStepAddContact();
         WndMgr.StartOneBottonPopup(OneBtnPopupIndex.IS_MY_SKYPE_NAME);
     }
     else if(PluginAPIMgr.IsMyBuddy(skype_name) == 1)
     {
        WndMgr.NextStepAddContact();
        WndMgr.StartOneBottonPopup(OneBtnPopupIndex.IS_ALREADY_EXIST_SKYPE_NAME, skype_name);
     }
     else
     {
        PluginAPIMgr.AddContact(skype_name, hello_msg);
        
        WndMgr.NextStepAddContact();
        WndMgr.StartOneBottonPopup(OneBtnPopupIndex.ADD_CONTACT_SENT);
    }
}

ProcMgr.AddSkypeOutContact = function(phone_number, diplay_name)
{   
    alert("##mini##***** ProcMgr.AddSkypeOutContact()");
	 if(phone_number.length <=0)
	 {
	        WndMgr.NextStepAddContact(); 
	        WndMgr.StartOneBottonPopup(OneBtnPopupIndex.INVALID_PHONE_NUMBER);
	 }
     else if(PluginAPIMgr.IsBlocked(phone_number) == 1)
     {
        WndMgr.NextStepAddContact(); 
         WndMgr.StartOneBottonPopup(OneBtnPopupIndex.IS_BLOCKED_PHONE_NUMBER);
     }
     else if(PluginAPIMgr.IsMyBuddy(phone_number) == 1)
     {
        WndMgr.NextStepAddContact();
        WndMgr.StartOneBottonPopup(OneBtnPopupIndex.IS_ALREADY_EXIST_PHONE_NUMBER, phone_number);
     }
     else
     {
        PluginAPIMgr.AddSkypeOutContact(phone_number, diplay_name);
        WndMgr.NextStepAddContact();
        WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NEW_CONTACT_ADDED);
     }
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////TOOLS///////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ProcMgr.BlockContact = function(skypeName,removeOption,type)
{
	
	if(removeOption){

		if(type == MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_BLOCK){
			
			this.MainListFuncType = MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_BLOCK_REMOVE;
		}
		else if(type == MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_BLOCK){
			
			this.MainListFuncType = MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_BLOCK_REMOVE;
		}
		else if(type == MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_BLOCK){
			
			this.MainListFuncType = MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_BLOCK_REMOVE;
		}			
	}
	else{
		
		this.MainListFuncType = type;	
	}
	
	PluginAPIMgr.BlockContact(skypeName,removeOption);
}

ProcMgr.UnblockContact = function(skypeName,type){
	
	this.MainListFuncType = type;
	PluginAPIMgr.UnblockContact(skypeName);
}

ProcMgr.AuthorizeContact = function(skypeName){
	PluginAPIMgr.AuthorizeContact(skypeName);
}

ProcMgr.IgnoreAuthReqContact = function(skypeName){
	
	PluginAPIMgr.RejectAndBlock(skypeName, "0");
}

ProcMgr.BlockAuthReqContact = function(skypeName){
	
	this.MainListFuncType = MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_BLOCK_REQEST;
	this.skypeName = skypeName;
	PluginAPIMgr.RejectAndBlock(skypeName, "1");
}

ProcMgr.Blocked = function(){

	switch(this.MainListFuncType) {
		case MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_BLOCK_REQEST:	
			var scene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
			scene.Refresh();
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.BLOCKED_NEW_CONTACT,this.skypeName);
			break;
	}
	this.MainListFuncType = MAIN_LIST_POPUP_FUNCTION_TYPE.NOTHING;
}

ProcMgr.BlockedByAnotherDevice = function(){

	//Skip
	alert("##mini##ProcMgr.BlockedByAnotherDevice");

}

ProcMgr.UnBlocked = function(){

	this.MainListFuncType = MAIN_LIST_POPUP_FUNCTION_TYPE.NOTHING;
}

ProcMgr.RemoveItem = function(Index, type)
{
	
	if(type == REMOVE_TYPE.HISTORY){
		this.MainListFuncType = MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_REMOVE;
		PluginAPIMgr.RemoveHistory(Index);		
	}
	else if(type == REMOVE_TYPE.CHAT){
		this.MainListFuncType = MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_REMOVE; 
		PluginAPIMgr.RemoveChat(Index);		
	}
	
}

ProcMgr.ProcessAuthRequest = function(){

	if(StateMgr.MainStateList[MAIN_STATE.MAIN].flagLoad == true ){
		/*
		var scene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
				scene.Refresh();*/
		var scene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
		scene.Refresh();
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.ADDED_NEW_CONTACT); 
	}
}

ProcMgr.IgnoreAuthRequest = function(){

	if (StateMgr.MainStateList[MAIN_STATE.MAIN].flagLoad == true ) {
		var scene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
		scene.Refresh();
		$.sfScene.focus({id:"miniMainContact", scope:WIDGET.id});
	}	
}

ProcMgr.ShowPopupMessageForTextTest = function(data){

	var Index = data - 1;

	if(Index < 0){
		
		alert("##mini##Error!!");
		return;
	}
	
	WndMgr.StartOneBottonPopup(Index);
}


///////Face Recognition //////////////////////////////////////////////////////////////////////

///// management of ID, PWD, Face image path


ProcMgr.SetMyPwd = function(pwd)
{
	alert("##mini##ProcMgr.SetMyPwd");
		
	var myId = PluginAPIMgr.GetMySkyeName();
	
	var saved_info = PluginAPIMgr.GetMyStorageInfo();
	var info = null;
	var index =0;
	
	var flagSaved = false;
	
	if(saved_info)
	{
		info = JSON.parse(saved_info);
		
		alert("##mini##***** ProcMgr.SetMyPwd() --> saved_info : "+saved_info);	
		
		for(index=0; index<info.SkypeAccount.length; ++index)
		{
			if(info.SkypeAccount[index].id == myId)
			{
				flagSaved = true;
				break;
			}
		}	
	}
	else
	{
		info = new Object();
		info.SkypeAccount = new Array();
	}

	alert("##mini##***** ProcMgr.SetMyPwd() --> index : "+index);
		
	if(flagSaved == false)
	{
		info.SkypeAccount[index] = new Object();
		info.SkypeAccount[index].id = myId;
		info.SkypeAccount[index].face = "none";	
		info.SkypeAccount[index].face_id = -1;
		info.SkypeAccount[index].pwd_check = false;	
	}
	
	info.SkypeAccount[index].pwd = pwd;
	
	var info_string = JSON.stringify(info);	
	
	alert("##mini##***** ProcMgr.SetMyPwd() --> info_string : "+info_string);
	
	PluginAPIMgr.SetMyStorageInfo(info_string); 
}

ProcMgr.GetMyPwd = function(pwd)
{
	alert("##mini##ProcMgr.GetMyPwd");
	
	var myId = PluginAPIMgr.GetMySkyeName();
	
	var saved_info = PluginAPIMgr.GetMyStorageInfo();
	var info = null;
	var index =0;
	
	var myId_saved = false;
	
	if(saved_info)
	{
		info = JSON.parse(saved_info);
		alert("##mini##***** ProcMgr.GetMyPwd() --> saved_info : "+saved_info);	
		
		
		for(index=0; index<info.SkypeAccount.length; index++)
		{
			if(info.SkypeAccount[index].id == myId)
			{
				myId_saved = true;
				break;
			}
		}
	}
	else
	{
		return "";
	}
	
	var pwd = "";
	
	if(myId_saved==true)
	{
		pwd =info.SkypeAccount[index].pwd;
	}
	
	return pwd;
}

ProcMgr.SetMyFaceImagePath = function(path, recogId)
{
	alert("##mini##ProcMgr.SetMyFaceImagePath");
	
	var myId = PluginAPIMgr.GetMySkyeName();
	
	var saved_info = PluginAPIMgr.GetMyStorageInfo();
	var info = null;
	var index =0;
	
	if(saved_info)
	{
		info = JSON.parse(saved_info);
		alert("##mini##***** ProcMgr.SetMyFaceImagePath() --> saved_info : "+saved_info);	
		
		
		for(index=0; index<info.SkypeAccount.length; index++)
		{
			if(info.SkypeAccount[index].id == myId)
			{
				break;
			}
		}
	}

	info.SkypeAccount[index].face = path;
	info.SkypeAccount[index].face_id = recogId;	

	var info_string = JSON.stringify(info);	
	
	alert("##mini##***** ProcMgr.SetMyFaceImagePath() --> info_string : "+info_string);	
	
	PluginAPIMgr.SetMyStorageInfo(info_string); 
	
	g_Data.SetFaceRecogCompleteSkypeName(myId);	
}

ProcMgr.GetMyFaceImagePath = function()
{
	alert("##mini##ProcMgr.GetMyFaceImagePath");
	
	var myId = PluginAPIMgr.GetMySkyeName();
	
	var saved_info = PluginAPIMgr.GetMyStorageInfo();
	var info = null;
	var index =0;
	
	this.isRegisteredFace = false;
	
	if(saved_info)
	{
		info = JSON.parse(saved_info);
		alert("##mini##***** ProcMgr.GetMyFaceImagePath() --> saved_info : "+saved_info);	
				
		for(index=0; index<info.SkypeAccount.length; index++)
		{
			if(info.SkypeAccount[index].id == myId)
			{
				break;
			}
		}
	}
	else
	{
		return "";
	}
	
	var path = info.SkypeAccount[index].face;
	
	if(path == "none")
	{
		return "";
	}
	else
	{
		this.isRegisteredFace = true;
		alert("##mini##***** ProcMgr.GetMyFaceImagePath() : "+path);
		return path;
	}	
}

ProcMgr.InitMyFaceImagePath = function()
{
	alert("##mini##ProcMgr.InitMyFaceImagePath");
	
	var myId = PluginAPIMgr.GetMySkyeName();
	
	var saved_info = PluginAPIMgr.GetMyStorageInfo();
	var info = null;
	var index =0;
	
	if(saved_info)
	{
		info = JSON.parse(saved_info);
		alert("##mini##***** ProcMgr.SetMyFaceImagePath() --> saved_info : "+saved_info);	
		
		
		for(index=0; index<info.SkypeAccount.length; index++)
		{
			if(info.SkypeAccount[index].id == myId)
			{
				break;
			}
		}
	}

	PluginAPIMgr.EraseFace(info.SkypeAccount[index].face_id);
	
	info.SkypeAccount[index].face = "none";	
	info.SkypeAccount[index].face_id = -1;
	
	var info_string = JSON.stringify(info);	
	
	alert("##mini##***** ProcMgr.InitMyFaceImagePath() --> info_string : "+info_string);	
	
	PluginAPIMgr.SetMyStorageInfo(info_string);
	
	this.isRegisteredFace = false; 	
}

ProcMgr.CheckImageDuplicate= function(path, recogId)
{
	alert("##mini##ProcMgr.CheckImageDuplicate");
	
	var myId = PluginAPIMgr.GetMySkyeName();
	
	var saved_info = PluginAPIMgr.GetMyStorageInfo();
	var info = null;
	var index =0;
	
	if(saved_info)
	{
		info = JSON.parse(saved_info);
		alert("##mini##***** ProcMgr.CheckImageDuplicate() --> saved_info : "+saved_info);	
				
		for(index=0; index<info.SkypeAccount.length; index++)
		{
			if(info.SkypeAccount[index].id != myId)
			{
				if(info.SkypeAccount[index].face == path && info.SkypeAccount[index].face_id==recogId)
				{
					g_Data.SetFaceRecogDupliceteSkypeName(info.SkypeAccount[index].id);
					return true;
				}
			}
		}
	}
	
	return false;
}

ProcMgr.SetFlagPwdCheck = function(flagPwdCheck)
{
	alert("##mini##ProcMgr.SetFlagPwdCheck");
	
	var myId = PluginAPIMgr.GetMySkyeName();
	
	var saved_info = PluginAPIMgr.GetMyStorageInfo();
	var info = null;
	var index =0;
	
	if(saved_info)
	{
		info = JSON.parse(saved_info);
		alert("##mini##***** ProcMgr.SetFlagPwdCheck() --> saved_info : "+saved_info);	
				
		for(index=0; index<info.SkypeAccount.length; index++)
		{
			if(info.SkypeAccount[index].id == myId)
			{
				break;
			}
		}
	}

	info.SkypeAccount[index].pwd_check = flagPwdCheck;	

	var info_string = JSON.stringify(info);	
	
	alert("##mini##***** ProcMgr.SetFlagPwdCheck() --> info_string : "+info_string);	
	
	PluginAPIMgr.SetMyStorageInfo(info_string); 
}

ProcMgr.GetFlagPwdCheck = function()
{
	alert("##mini##ProcMgr.GetFlagPwdCheck");
	
	var myId = PluginAPIMgr.GetMySkyeName();
	
	var saved_info = PluginAPIMgr.GetMyStorageInfo();
	var info = null;
	var index =0;
	
	if(saved_info)
	{
		info = JSON.parse(saved_info);
		alert("##mini##***** ProcMgr.GetFlagPwdCheck() --> saved_info : "+saved_info);	
		
		
		for(index=0; index<info.SkypeAccount.length; index++)
		{
			if(info.SkypeAccount[index].id == myId)
			{
				break;
			}
		}
	}
	else
	{
		return false;
	}
		
	if(info.SkypeAccount[index].pwd_check == 'undefined')
	{
		alert("##mini##***** ProcMgr.GetFlagPwdCheck() : undefined");
		return false;
	}
	else
	{
		alert("##mini##***** ProcMgr.GetFlagPwdCheck() : "+info.SkypeAccount[index].pwd_check);
		return info.SkypeAccount[index].pwd_check;
	}	
}


/// Account Manager
ProcMgr.CheckInputPwd= function(input_pwd)
{
	alert("##mini##ProcMgr.CheckInputPwd");
	if(StateMgr.GetCurrentSubState()=="AccountManager")
	{
		ProcMgr.CheckInputPwdForAccountManager(input_pwd);
	}
	else
	{
		ProcMgr.CheckInputPwdForSignin(input_pwd);
	}
}

ProcMgr.CancelCheckPwd= function()
{
	alert("##mini##ProcMgr.CancelCheckPwd");
	if(StateMgr.GetCurrentSubState()=="AccountManager")
	{
		WndMgr.BackStepAccountManager();
	}
	else
	{
		//WndMgr.BackStepFaceRecogSignin();
		StateMgr.Start_Welcome_State();
	}
}

ProcMgr.CheckInputPwdForAccountManager= function(input_pwd)
{
	alert("##mini##ProcMgr.CheckInputPwdForAccountManager");
	WndMgr.NextStepAccountManager();
	
	var curr_pwd = ProcMgr.GetMyPwd();
	
	if(curr_pwd==input_pwd)
	{
		if(this.isRegisteredFace==true)
		{
			if(this.isReRegisterFace==true)
			{
				ProcMgr.StartFaceRecogRegistration();
			}
			else
			{
				WndMgr.NextStepAccountManager();
			}
			
		}
		else
		{
			ProcMgr.StartFaceRecogRegistration();
		}		
	}
	else
	{
		WndMgr.StopLoading();
		
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.ACCOUNT_INCORRECT_PASSWORD);
		WndMgr.BackStepAccountManager();
	}
}

ProcMgr.CheckInputPwdForSignin= function(input_pwd)
{	
	alert("##mini##ProcMgr.CheckInputPwdForSignin");
	
	var index = g_Data.GetFaceRecogSelectedIndex();
	var RecogResult = g_Data.GetFaceRecogResult();
	alert("##mini##ProcMgr.CheckInputPwdForSignin", RecogResult[index].pwd);
	
	WndMgr.NextStepFaceRecogSignin();
	
	/*if(RecogResult[index].pwd==input_pwd)
	{
		ProcMgr.Signin(RecogResult[index].id, RecogResult[index].pwd, false);		
	}
	else
	{
		WndMgr.StopLoading();
		
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.FACE_RECOG_INCORRECT_PASSWORD);
		WndMgr.BackStepFaceRecogSignin();
	}*/
	
	ProcMgr.Signin(RecogResult[index].id, input_pwd, false);	 
}

ProcMgr.ProcessReRegisterFace= function()
{
	alert("##mini##ProcMgr.ProcessReRegisterFace");
	this.isReRegisterFace = true;
	
	ProcMgr.InitMyFaceImagePath();
	WndMgr.NextStepAccountManager();
}

ProcMgr.ProcessDeleteFace= function()
{
	alert("##mini##ProcMgr.ProcessDeleteFace");
	ProcMgr.InitMyFaceImagePath();
	
	WndMgr.StartOneBottonPopup(OneBtnPopupIndex.ACCOUNT_DELETE_PWD_COMPLETE);
	WndMgr.NextStepAccountManager();
}

ProcMgr.ProcessSigninAfterPwdCheck = function(index)
{
	alert("##mini##ProcMgr.ProcessSigninAfterPwdCheck");
	this.isSigninAfterPwdCheck=true;
	g_Data.SetFaceRecogSelectedIndex(index);
	
	WndMgr.InputPwdStepFaceRecogSignin(); 
}

//only inprogress... 
ProcMgr.getCallInfo= function()
{
	alert("##mini##getCallInfo");
	var callInfoMsg = PluginAPIMgr.GetCallInfo();

	if(this.CallInfo == null)
	{
		this.CallInfo = new Object();
	}
	
	alert("##mini##getCallInfo" + callInfoMsg);
	if(callInfoMsg)
	{
	var STX = String.fromCharCode(2);
	var ETX = String.fromCharCode(3);
	var splitter = ETX + STX;
	
	var Result = callInfoMsg.split(splitter);
	
	//1. IsConferneceCall
	if(Result[0] == '1')
	{
		alert("##mini##this is conference call");
		this.CallInfo.IsConference = true;
	}
	else
	{
		this.CallInfo.IsConference = false;
	}
	//2.Call type
	if(Result[1] == '1')
	{
		alert("##mini##this is vicdeo call");
		this.CallInfo.IsVideo = true;
	}
	else
	{
		this.CallInfo.IsVideo = false;
	}	

	//3.Call member type
	this.CallInfo.CallType = parseInt(Result[2]);
	
	//4. Call Identity
	this.CallInfo.Identity = Result[3];	

	//5. Call displayName
	this.CallInfo.DisplayName = Result[4];

	//6. Call avata image
	this.CallInfo.AvataImg = Result[5];			
	if(this.CallInfo.Identity == 'echo123' || this.CallInfo.AvataImg.length ==0)
	{		
			if(this.CallInfo.Identity == 'echo123')
		{
			alert("##mini##test call");
			this.CallInfo.AvataImg = g_Image.IMAGE_DEFAULT_AVATAR_TEST_CALL_128;
		}
			else if(this.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.INCOMING_PSTN || this.CallInfo.CallType == ENUM_CALL_MEMBE_TYPE.OUTGOING_PSTN)
			{
				alert("##mini##no AvataImg -- PSTN");
				this.CallInfo.AvataImg = g_Image.IMAGE_DEFAULT_AVATAR_PSTN_128;			
			}
		else
		{
			alert("##mini##no AvataImg -- pepeople");
			this.CallInfo.AvataImg = g_Image.IMAGE_DEFAULT_AVATAR_BLANK_128;
		}		
	}
	
	//7. sending video
	if(Result[6] == '1')
	{
		this.CallInfo.IsSendingVideo = true;
	}
	else
	{
		this.CallInfo.IsSendingVideo = false;
	}		

	//8. receicving video
	if(Result[7] == '1')
	{
		this.CallInfo.IsRecvVideoAvailable = true;
	}
	else
	{
		this.CallInfo.IsRecvVideoAvailable = false;
	}

	//9. auto recieve
	if(Result[8] == '1')
	{
		this.CallInfo.IsAutoRecvVieo = true;
	}
	else
	{
		this.CallInfo.IsAutoRecvVieo = false;
	}
	}
	//check status
	this.CallInfo.IsMicMute = false;
	//check status
	this.CallInfo.IsTvMode = false;
}
ProcMgr.returnTab = function(){
	alert("##mini##ProcMgr.returnTab(go social tv tab)");

   $.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).tabFocus=true;
   $.sfScene.focus({id:WIDGET.name, scope:WIDGET.id});

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Ridge Flick Timer  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ProcMgr.StartRidgeTimer = function()
{
	alert('##mini##ProcMgr.StartRidgeTimer');
	ProcMgr.isRidgeFlick = true;
	PluginAPIMgr.StartOSDTimer("700" , function() { ProcMgr.isRidgeFlick = false;}, ENUM_TIMER_TYPE.POPUP_WND);
}

ProcMgr.GetRidgeFlick = function()
{
	alert('##mini##ProcMgr.GetRidgeFlick -- ' + this.isRidgeFlick);

	return ProcMgr.isRidgeFlick;
}

