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

 var MAIN_STATE={
        INIT : 0,
        MAIN : 1,
                
        CALLING : 2,
        VIDEO_CALL : 3,
        CONFERENCE_CALL:4,
        SKYPE_OUT_CALL : 5,
                		
		VIDEO_SNAPSHOT : 6,
		
		WELCOME : 7,
		SIGNIN : 8,
		CREATE_ACCOUNT : 9,
		
		CAMERA_CHECK_CONNECTED : 10,
		CAMERA_CHECK_DISCONNECTED : 11,
		
		CREATE_ACCOUNT_SUCCESS :12,
		FACE_RECOG_SIGNIN : 13,
		FACE_RECOG_REGISTRATION : 14,
        VOICE_MAIL: 15,
        CALL_CAMERA_CONTROL : 16,
		GUIDE_PAGE : 17,
		
		MAX_MAIN_STATE : 18
}

 var SUB_STATE={
        ADD_CONTACT : 0,
        ONLINE_STATUS : 1,
        CHANGE_PICTURE	: 2,
        CHANGE_PASSWORD : 3,
        CALL_ENDING : 5,
        VOLUME_SPEAKER : 6,
        SIGNOUT : 9,
		LIST_TOOLS : 10,
		VIEW_PROFILE : 11,
		RENAME : 12,
        REMOVE_CONTACT : 13,
		REMOVE : 14,
		BLOCK :	15,
		CALL_CONFIRM : 16,
		CALL_SETTING : 17,
		CAMERA_ADJUST : 4,    //caution number 4!!!
		FORGOT_PWD: 18,
		EXIT: 19,
		ADD_PHONE_NUMBER : 20,
		ACCOUNT_MANAGER : 21,
	//add
		GENDER : 22,
		BIRTHDATE : 23,
		PROFILEPHONENUMBERSET : 24,

		SETTINGSGENERAL : 25,
		SETTINGSFACERECOGNITION : 26,
		SETTINGSVIDEO : 27,
		SETTINGSBLOCKEDCONTACTS : 28,
		SETTINGSPRIVACY : 29,
		SETTINGSCALLFORWARDING : 30,
		SETTINGSVOICEMAIL : 31,
		SETTINGSVOICEMAILUNABLE : 32,
		SETTINGSABOUTSKYPE : 33,
		PLUS_LIST: 34,
	        CHANGE_PHONE_NUMBER : 35,
		CHANGE_PHONE_NUMBER_SELECT : 36,
		LISTMAIN_PHONE_NUMBER : 37,
		MAX_SUB_STATE : 38
}

var NOTI_STATE = {
	
	INCOMING_CALL	: 0	,
	CONTEXT_LOADING	: 1	,
	MAX_NOTI_STATE	: 2
}

StateMgr = {
    MainStateList : new Array(MAIN_STATE.MAX_MAIN_STATE),    
    SubStateList : new Array(SUB_STATE.MAX_SUB_STATE),   
	
    currentState : "Deactivate",
    preState : "Deactivate",
    
    MainInfo : null,
        
    currentSubState : "",
    preSubState : "",
    
    PopupInfo : null,
    NotiInfo : null,
    
    skypeLoadCheckTimer : null,
	
    FuncParamA : null,
	FuncParamB : null,
	FuncParamC : null,
	FuncParamD : null,
	
	delaySubLoadingState : null,
	flagDelaySubLoading : false,

}

StateMgr.GetCurrentState = function()
{
    return this.currentState;
}

StateMgr.GetCurrentSubState = function()
{
    return this.currentSubState;
}

StateMgr.GetPreSubState = function()
{
    return this.preSubState;
}

StateMgr.initState = function(){
 alert("***** StateMgr.initState ()");

    this.initMainState();
    this.initSubState();
	this.initNotiState();

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////  Main State  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


StateMgr.initMainState = function(){
    var a=0;
    for(a=0; a<this.MainStateList.length; a++)
    {
        this.MainStateList[a] = new Object();
        this.MainStateList[a].flagLoad = false;
        this.MainStateList[a].flagLoading = false;
    }
        
    this.MainStateList[MAIN_STATE.INIT].id = "Init";
    this.MainStateList[MAIN_STATE.MAIN].id = "Main"; 
    this.MainStateList[MAIN_STATE.VIDEO_CALL].id = "VideoCall";
    this.MainStateList[MAIN_STATE.CONFERENCE_CALL].id = "ConferenceCall";
    this.MainStateList[MAIN_STATE.SKYPE_OUT_CALL].id = "SkypeOutCall";
    this.MainStateList[MAIN_STATE.CALLING].id = "Calling";   
    this.MainStateList[MAIN_STATE.VOICE_MAIL].id = "VoiceMail";
    this.MainStateList[MAIN_STATE.VIDEO_SNAPSHOT].id = "VideoSnapshot";	
	this.MainStateList[MAIN_STATE.WELCOME].id ="Welcome";
	this.MainStateList[MAIN_STATE.SIGNIN].id = "Signin";	
	this.MainStateList[MAIN_STATE.CREATE_ACCOUNT].id = "CreateAccount";	
	this.MainStateList[MAIN_STATE.CAMERA_CHECK_CONNECTED].id = "CameraCheckConnected";
	this.MainStateList[MAIN_STATE.CAMERA_CHECK_DISCONNECTED].id = "CameraCheckDisconnected";
	this.MainStateList[MAIN_STATE.CREATE_ACCOUNT_SUCCESS].id = "CreateAccountSuccess";	
	this.MainStateList[MAIN_STATE.FACE_RECOG_SIGNIN].id = "FaceRecogSignin";
	this.MainStateList[MAIN_STATE.FACE_RECOG_REGISTRATION].id = "FaceRecogRegistration";	
	this.MainStateList[MAIN_STATE.CALL_CAMERA_CONTROL].id = "CallCameraControl";
	this.MainStateList[MAIN_STATE.GUIDE_PAGE].id = "GuidePage";
	    
    this.MainStateList[MAIN_STATE.INIT].flagLoad = true;

    MainInfo = new Object();      
    MainInfo.prevState = null;
    MainInfo.curState = null;
        
}

StateMgr.setMainStateLoading = function(index){
    
	this.initMainStateLoading();    
    this.MainStateList[index].flagLoading = true;
}

StateMgr.initMainStateLoading = function(){
	
    var a=0;
    for(a=0; a<this.MainStateList.length; a++)
    {
        this.MainStateList[a].flagLoading = false;
    }
}

StateMgr.showMainState = function(index , callbackShowFn){
    
     if(this.MainStateList[index].flagLoading == true)
    {
        return;
    }

    if(this.MainStateList[index].flagLoad ==false)
    {
    	alert("StateMgr.showMainState >>>>> file loading!!!  : " + index);
    	
        StateMgr.setMainStateLoading(index); 
        

       var modeName =  eval("SKYPE_MODE." + this.MainStateList[index].id);
       	
		alert("length of scenes : " + modeName.scenes.length);
    
		sf.scene.loadScenes(modeName.scenes, function () {

		    sf.core.loadJS(modeName.files, function () {

	            StateMgr.MainStateList[index].flagLoad = true;
	            if(StateMgr.MainStateList[index].flagLoading == true)
	            {
	                StateMgr.MainStateList[index].flagLoading = false;
	                callbackShowFn();
					
					if(StateMgr.flagDelaySubLoading == true)
					{
						StateMgr.flagDelaySubLoading = false; //init
						StateMgr.delaySubLoadingState();
						StateMgr.setDelaySubLoadingState(null); //init
					}
	            }
		    });
		});
    }
    else{
		StateMgr.initMainStateLoading();
        callbackShowFn();
    }
}

StateMgr.isMainStateLoaing = function()
{
	var a=0;
    for(a=0; a<this.MainStateList.length; a++)
    {
		if(this.MainStateList[a].flagLoading == true)
		{
			return true;
		} 
    }
	
	return false;
}

StateMgr.setDelaySubLoadingState = function(callbackSubStartFn)
{
	this.delaySubLoadingState =callbackSubStartFn;
}

StateMgr.Start_Init_State = function(){
	
	StateMgr.initState(); 
    this.currentState = this.MainStateList[MAIN_STATE.INIT].id;
    alert("***** Start_Init_State = new [" +  this.currentState + "]");
    
    //call function as soon as possible !!!
    ResMgr.initResource();
    WndMgr.init();
    
    WndMgr.ShowInit();
      
    PluginAPIMgr.initPluginAPI();
    EventMgr.initEvent();
        	
	ProcMgr.setDefaultRemoteType();

	setTimeout("CloseTimerCF()", 0);
	CloseTimerCF = function(){
		ProcMgr.getProductInfo();
		ProcMgr.OpenPluginAboutNTV();
		ProcMgr.getIMERemoconAreaId();
		
		//WndMgr.ImagePreLoad();
	
		PluginAPIMgr.GetPanelResolution();

		ProcMgr.SetVideoCallRect(true);
									
		if(PluginAPIMgr.GetSkypeState() == 1)
	    {
	        ProcMgr.StartWidget();
	    }			
	}	
}

StateMgr.Start_Main_State = function(){
    this.preState =  this.currentState;
    alert("***** Start_Main_State = old [" +  this.preState + "]");
    
    StateMgr.showMainState(MAIN_STATE.MAIN, function(){ StateMgr.Show_Main_State();}) ;
}

StateMgr.Show_Main_State = function(){
    this.currentState = this.MainStateList[MAIN_STATE.MAIN].id;
    alert("***** Start_Main_State = [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Main_State ()");
    this.StopPreState();
    
    WndMgr.ShowMain();

}

StateMgr.Start_Jump_To_Main_State = function(category,index){
    this.preState =  this.currentState;
    alert("***** Start_Jump_To_Main_State = old [" +  this.preState + "]");
	
	this.FuncParamA = category;
    this.FuncParamB = index;
    
    StateMgr.showMainState(MAIN_STATE.MAIN, function(){ StateMgr.Show_Jump_To_Main_State();}) ;
}

StateMgr.Show_Jump_To_Main_State = function(){
    this.currentState = this.MainStateList[MAIN_STATE.MAIN].id;
    alert("***** Show_Jump_To_Main_State = [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Jump_To_Main_State ()");
    this.StopPreState();
    
    WndMgr.ShowJumpToMain(this.FuncParamA,this.FuncParamB);
    
    this.FuncParamA = null;
    this.FuncParamB = null;
}

StateMgr.Start_Video_Call_State = function(){

    if( this.MainStateList[MAIN_STATE.VIDEO_CALL].flagLoading == true)
    {
        return;
    }
    
    this.preState =  this.currentState;
    alert("***** Start_Video_Call_State = old [" +  this.preState + "]");

    StateMgr.showMainState(MAIN_STATE.VIDEO_CALL, function(){ StateMgr.Show_Video_Call_State();}) ;
}

StateMgr.Show_Video_Call_State = function(){
		
	if(this.currentSubState == "CallEnding")
	{
		alert(" current sub state is /CallEnding/ ");
		return;
	}
	
    this.currentState = this.MainStateList[MAIN_STATE.VIDEO_CALL].id;
    alert("***** Start_Video_Call_State = new [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Video_Call_State ()");
    
    this.StopPreState();
    
    WndMgr.ShowVideoCall();

}

StateMgr.Start_Conference_Call_State = function(){
    this.preState =  this.currentState;
    alert("***** Start_Conference_Call_State = old [" +  this.preState + "]");

    StateMgr.showMainState(MAIN_STATE.CONFERENCE_CALL, function(){ StateMgr.Show_Conferenc_Call_State();}) ;
}

StateMgr.Show_Conferenc_Call_State = function(){
	if(this.currentSubState == "CallEnding")
	{
		return;
	}
	
    this.currentState =this.MainStateList[MAIN_STATE.CONFERENCE_CALL].id;
    alert("***** Start_Conference_Call_State = new [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Conferenc_Call_State ()");
    this.StopPreState();
    
    WndMgr.ShowConferenceCall();
}

StateMgr.Start_Skype_Out_Call_State = function(){
    this.preState =  this.currentState;
    alert("***** Start_Skype_Out_Call_State = old [" +  this.preState + "]");

    StateMgr.showMainState(MAIN_STATE.SKYPE_OUT_CALL, function(){ StateMgr.Show_Skype_Out_Call_State();}) ;
}

StateMgr.Show_Skype_Out_Call_State = function(){
	if(this.currentSubState == "CallEnding")
	{
		return;
	}
	
    this.currentState = this.MainStateList[MAIN_STATE.SKYPE_OUT_CALL].id;
    alert("***** Start_Skype_Out_Call_State = new [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Skype_Out_Call_State ()");
    this.StopPreState();
    
    WndMgr.ShowSkypeOutCall();
}

StateMgr.Start_Chat_State = function(){
    this.preState =  this.currentState;
    alert("***** Start_Chat_State = old [" +  this.preState + "]");

    StateMgr.showMainState(MAIN_STATE.CHAT, function(){ StateMgr.Show_Chat_State();}) ;
}

StateMgr.Show_Chat_State = function(){
    this.currentState =  this.MainStateList[MAIN_STATE.CHAT].id;
    alert("***** Start_Chat_State = new [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Chat_State ()");
   // WndMgr.StartLoading(LoadingTypeIndex.WAIT);
    
    this.StopPreState();
    
    WndMgr.InitChat();
    WndMgr.ShowChat();
}

StateMgr.Start_Vidoe_Snapshot_State = function(){
	
    this.preState =  this.currentState;
    alert("***** Start_Vidoe_Snapshot_State = old [" +  this.preState + "]");
    
    StateMgr.showMainState(MAIN_STATE.VIDEO_SNAPSHOT, function(){ StateMgr.Show_Vidoe_Snapshot_State();}) ;
}

StateMgr.Show_Vidoe_Snapshot_State = function(){

    this.currentState =  this.MainStateList[MAIN_STATE.VIDEO_SNAPSHOT].id;	
    alert("***** Start_Vidoe_Snapshot_State = new [" +  this.currentState + "]");
	
    alert("***** StateMgr.Show_Vidoe_Snapshot_State ()");
	    
    this.StopPreState();
    
    WndMgr.ShowVideoSnapshot();
}

StateMgr.Start_Welcome_State = function(){
    this.preState =  this.currentState;
    alert("***** Start_Welcome_State = old [" +  this.preState + "]");

     StateMgr.showMainState(MAIN_STATE.WELCOME, function(){ StateMgr.Show_Welcome_State();}) ;
}

StateMgr.Show_Welcome_State = function(){
    this.currentState = this.MainStateList[MAIN_STATE.WELCOME].id;
    alert("***** Start_Welcome_State = [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Create_Account_State ()");
    this.StopPreState();
	
	if(this.MainStateList[MAIN_STATE.MAIN].flagLoad ==true)
    {
        WndMgr.DestroyMain();
    }

    WndMgr.ShowWelcome();   
}

StateMgr.Start_Signin_State = function(){
    this.preState =  this.currentState;
    alert("***** Start_Signin_State = old [" +  this.preState + "]");

     StateMgr.showMainState(MAIN_STATE.SIGNIN, function(){ StateMgr.Show_Signin_State();}) ;
}

StateMgr.Show_Signin_State = function(){
    this.currentState = this.MainStateList[MAIN_STATE.SIGNIN].id;
    alert("***** Start_Signin_State = [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Signin_State ()");
	if(this.preState == this.currentState)
    {
        WndMgr.ReturnSignin();
        return;
    }
	
    this.StopPreState();
    
    WndMgr.InitSignin();
    WndMgr.ShowSignin();   
}

StateMgr.Start_Create_Account_State = function(){
    this.preState =  this.currentState;
    alert("***** Start_Create_Account_State = old [" +  this.preState + "]");

     StateMgr.showMainState(MAIN_STATE.CREATE_ACCOUNT, function(){ StateMgr.Show_Create_Account_State();}) ;
}

StateMgr.Show_Create_Account_State = function(){
    this.currentState = this.MainStateList[MAIN_STATE.CREATE_ACCOUNT].id;
    alert("***** Start_Create_Account_State = [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Create_Account_State ()");
    this.StopPreState();
    
    WndMgr.InitCreateAccount();
    WndMgr.ShowCreateAccount();   
}

StateMgr.Start_Camera_Check_Connected_State = function(){
	
    this.preState =  this.currentState;
    alert("***** Start_Camera_Check_Connected_State = old [" +  this.preState + "]");
    
    StateMgr.showMainState(MAIN_STATE.CAMERA_CHECK_CONNECTED, function(){ StateMgr.Show_Camera_Check_Connected_State();}) ;
}

StateMgr.Show_Camera_Check_Connected_State = function(){

    this.currentState =  this.MainStateList[MAIN_STATE.CAMERA_CHECK_CONNECTED].id;	
    alert("***** Start_Camera_Check_Connected_State = new [" +  this.currentState + "]");
	
    alert("***** StateMgr.Show_Camera_Check_Connected_State ()");
	    
    this.StopPreState();
    
    WndMgr.ShowCameraCheckConnected();
}

StateMgr.Start_Camera_Check_Disconnected_State = function(){
	
    this.preState =  this.currentState;
    alert("***** Start_Camera_Check_Disconnected_State = old [" +  this.preState + "]");
    
    StateMgr.showMainState(MAIN_STATE.CAMERA_CHECK_DISCONNECTED, function(){ StateMgr.Show_Camera_Check_Disconnected_State();}) ;
}

StateMgr.Show_Camera_Check_Disconnected_State = function(){

    this.currentState =  this.MainStateList[MAIN_STATE.CAMERA_CHECK_DISCONNECTED].id;	
    alert("***** Start_Camera_Check_Disconnected_State = new [" +  this.currentState + "]");
	
    alert("***** StateMgr.Show_Camera_Check_Disconnected_State ()");
	    
    this.StopPreState();
    
    WndMgr.ShowCameraCheckDisconnected();
}

StateMgr.Start_Create_Account_Success_State = function(){
	
    this.preState =  this.currentState;
    alert("***** Start_Create_Account_Success_State = old [" +  this.preState + "]");
    
    StateMgr.showMainState(MAIN_STATE.CREATE_ACCOUNT_SUCCESS, function(){ StateMgr.Show_Create_Account_Success_State();}) ;
}

StateMgr.Show_Create_Account_Success_State = function(){

    this.currentState =  this.MainStateList[MAIN_STATE.CREATE_ACCOUNT_SUCCESS].id;	
    alert("***** Start_Create_Account_Success_State = new [" +  this.currentState + "]");
	
    alert("***** StateMgr.Show_Create_Account_Success_State ()");
	    
    this.StopPreState();
    
    WndMgr.ShowCreateAccountSuccess();
}

StateMgr.Start_Face_Recog_Signin_State = function(){
	
    this.preState =  this.currentState;
    alert("***** Start_Face_Recog_Signin_State = old [" +  this.preState + "]");
    
    StateMgr.showMainState(MAIN_STATE.FACE_RECOG_SIGNIN, function(){ StateMgr.Show_Face_Recog_Signin_State();}) ;
}

StateMgr.Show_Face_Recog_Signin_State = function(){

    this.currentState =  this.MainStateList[MAIN_STATE.FACE_RECOG_SIGNIN].id;	
    alert("***** Start_Face_Recog_Signin_State = new [" +  this.currentState + "]");
	
    alert("***** StateMgr.Show_Face_Recog_Signin_State ()");
	if(this.preState=="Signin"){
		alert("Init FaceRecogSignin Scene Tab Flag")
		sf.scene.get("FaceRecogSignin").flagFromSignTab=true;
	}else if(this.preState=="GuidePage"){
		//from guidePage State
		WndMgr.FaceRecogSigninStep="InputInfo";
	}    
    this.StopPreState();
    
    WndMgr.InitFaceRecogSignin();
    WndMgr.ShowFaceRecogSignin();
}

StateMgr.Start_Face_Recog_Registration_State = function(flag){
	
    this.preState =  this.currentState;
    alert("***** Start_Face_Recog_Registration_State = old [" +  this.preState + "]");
    if(flag==undefined){
	    StateMgr.showMainState(MAIN_STATE.FACE_RECOG_REGISTRATION, function(){ StateMgr.Show_Face_Recog_Registration_State();}) ;
    }else if(flag=="TrainThumnail"){
    	alert("[SkypeDebug]from trainthumnail");
    	StateMgr.showMainState(MAIN_STATE.FACE_RECOG_REGISTRATION, function(){ StateMgr.Show_Face_Recog_Registration_State(flag);}) ;
    }
}

StateMgr.Show_Face_Recog_Registration_State = function(flag){

    this.currentState =  this.MainStateList[MAIN_STATE.FACE_RECOG_REGISTRATION].id;	
    alert("***** Start_Face_Recog_Registration_State = new [" +  this.currentState + "]");
	
    alert("***** StateMgr.Show_Face_Recog_Registration_State ()");
	    
    this.StopPreState();
    if(flag==undefined){
	    WndMgr.ShowFaceRecogRegistration();
    }else if(flag=="TrainThumnail"){
    	alert("[SkypeDebug]change 2nd step");
    	WndMgr.FaceRecogRegistrationStep="Complete";	//change 2nd step
    	WndMgr.ShowFaceRecogRegistration();
    }
    
}

StateMgr.Start_Calling_State = function(){
	
    this.preState =  this.currentState;
    
    alert("***** Start_Calling_State = old [" +  this.preState + "]");

    StateMgr.showMainState(MAIN_STATE.CALLING, function(){ StateMgr.Show_Calling_State();}, function(){ StateMgr.Start_Calling_State();}) ;

}

StateMgr.Show_Calling_State = function(){
	
    this.currentState = this.MainStateList[MAIN_STATE.CALLING].id;
    alert("***** Start_Calling_State = new [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Calling_State ()");

    this.StopPreState();
    
    WndMgr.ShowCalling();
}

    
StateMgr.Start_Voice_Mail_State = function(){
	
    this.preState =  this.currentState;

    alert("***** Start_Voice_Mail_State = old [" +  this.preState + "]");
    
	StateMgr.showMainState(MAIN_STATE.VOICE_MAIL, function(){ StateMgr.Show_Voice_Mail_State();}, function(){ StateMgr.Start_Voice_Mail_State();}) ;
    
    }

StateMgr.Show_Voice_Mail_State = function(){
    this.currentState = this.MainStateList[MAIN_STATE.VOICE_MAIL].id;
    alert("***** Start_Voice_Mail_State = new [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Voice_Mail_State ()");

    this.StopPreState();
    
    WndMgr.ShowVoiceMail();
}

StateMgr.Start_Call_Camera_Control_State = function(){
	
    this.preState =  this.currentState;

    alert("***** Start_Call_Camera_Control_State = old [" +  this.preState + "]");
    
	StateMgr.showMainState(MAIN_STATE.CALL_CAMERA_CONTROL, function(){ StateMgr.Show_Call_Camera_Control_State();}, function(){ StateMgr.Start_Call_Camera_Control_State();}) ;
    
}

StateMgr.Show_Call_Camera_Control_State = function(){
    this.currentState = this.MainStateList[MAIN_STATE.CALL_CAMERA_CONTROL].id;
    alert("***** Start_Call_Camera_Control_State = new [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Call_Camera_Control_State ()");

    this.StopPreState();
    
    WndMgr.ShowCallCameraControl();
}
StateMgr.Start_Guide_Page_State = function(type){

    this.preState =  this.currentState;
    this.FuncParamA = type;

    alert("***** Start_Guide_Page_State = old [" +  this.preState + "]");
    
	StateMgr.showMainState(MAIN_STATE.GUIDE_PAGE, function(){ StateMgr.Show_Guide_Page_State();}, function(){ StateMgr.Start_Guide_Page_State();}) ;
    
}

StateMgr.Show_Guide_Page_State = function(){
    this.currentState = this.MainStateList[MAIN_STATE.GUIDE_PAGE].id;
    alert("***** Start_Guide_Page_State = new [" +  this.currentState + "]");
    
    alert("***** StateMgr.Show_Guide_Page_State ()");

    this.StopPreState();
    
    WndMgr.ShowGuidePage(this.FuncParamA);
 
}




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////  Sub State  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

StateMgr.initSubState = function(){
	
	alert('StateMgr.initSubState');
    var b=0;
    for(b=0; b<SUB_STATE.MAX_SUB_STATE; b++)
    {
        this.SubStateList[b] = new Object();
        this.SubStateList[b].id = null;
        this.SubStateList[b].flagLoad = false;
        this.SubStateList[b].flagLoading = false;
    }
    
    this.SubStateList[SUB_STATE.ADD_CONTACT].id = "AddContact";
    this.SubStateList[SUB_STATE.ONLINE_STATUS].id = "OnlineStatus";
    this.SubStateList[SUB_STATE.CHANGE_PICTURE].id = "ChangePicture";
    this.SubStateList[SUB_STATE.CHANGE_PASSWORD].id = "ChangePassword";
    this.SubStateList[SUB_STATE.CALL_ENDING].id = "CallEnding";
    this.SubStateList[SUB_STATE.VOLUME_SPEAKER].id = "Volume";
    this.SubStateList[SUB_STATE.SIGNOUT].id = "Signout"; 
	this.SubStateList[SUB_STATE.LIST_TOOLS].id = "ListMainToolList";
	this.SubStateList[SUB_STATE.VIEW_PROFILE].id = "ViewProfile"; 	
    this.SubStateList[SUB_STATE.RENAME].id = "Rename"; 	
    this.SubStateList[SUB_STATE.REMOVE_CONTACT].id = "RemoveContact";
	this.SubStateList[SUB_STATE.REMOVE].id = "Remove";
    this.SubStateList[SUB_STATE.BLOCK].id = "Block"; 			
	this.SubStateList[SUB_STATE.CALL_CONFIRM].id = "CallConfirmPopup";
	this.SubStateList[SUB_STATE.CALL_SETTING].id = "CallSettingPopup";	
	this.SubStateList[SUB_STATE.FORGOT_PWD].id = "ForgotPassword";
	this.SubStateList[SUB_STATE.EXIT].id = "Exit"; 
	this.SubStateList[SUB_STATE.ADD_PHONE_NUMBER].id = "AddAssignedPhoneNumber";  
	this.SubStateList[SUB_STATE.LISTMAIN_PHONE_NUMBER].id = "ListMainContactPhoneNumberList";  
	this.SubStateList[SUB_STATE.CHANGE_PHONE_NUMBER].id = "ChangePhoneNumber";  
	this.SubStateList[SUB_STATE.CHANGE_PHONE_NUMBER_SELECT].id = "ChangePhoneNumberSelect";  
	this.SubStateList[SUB_STATE.ACCOUNT_MANAGER].id = "AccountManager"; 	   
	this.SubStateList[SUB_STATE.GENDER].id = "Gender";
	this.SubStateList[SUB_STATE.BIRTHDATE].id = "BirthDate";
	this.SubStateList[SUB_STATE.PROFILEPHONENUMBERSET].id = "ProfilePhoneNumberSet";
	this.SubStateList[SUB_STATE.SETTINGSGENERAL].id = "SettingsGeneral";
	this.SubStateList[SUB_STATE.SETTINGSFACERECOGNITION].id = "SettingsFaceRecognition";
	this.SubStateList[SUB_STATE.SETTINGSVIDEO].id = "SettingsVideo";
	this.SubStateList[SUB_STATE.SETTINGSPRIVACY].id = "SettingsPrivacy";
	this.SubStateList[SUB_STATE.SETTINGSBLOCKEDCONTACTS].id = "SettingsBlockedContacts";
	this.SubStateList[SUB_STATE.SETTINGSCALLFORWARDING].id = "SettingsCallForwarding";
	this.SubStateList[SUB_STATE.SETTINGSVOICEMAIL].id = "SettingsVoicemail";
	this.SubStateList[SUB_STATE.SETTINGSVOICEMAILUNABLE].id = "SettingsVoicemailUnable";
	this.SubStateList[SUB_STATE.SETTINGSABOUTSKYPE].id = "SettingsAboutSkype";
	this.SubStateList[SUB_STATE.PLUS_LIST].id = "ListMainPlusList"; 
	this.SubStateList[SUB_STATE.CAMERA_ADJUST].id = "CameraLightAdjControl"; 
    this.SubStateList[SUB_STATE.CALL_ENDING].flagLoad = true;    
    

//Add by lee dong hee
	var stateInfo = null;
	var stateId = null;
    this.PopupInfo = new Object();
    this.PopupInfo.stateList = new Array(SUB_STATE.MAX_SUB_STATE);
    this.PopupInfo.prevState = -1;
    this.PopupInfo.curState = -1;
    this.PopupInfo.waitState = -1;
      
      
    for(b=0; b<SUB_STATE.MAX_SUB_STATE; b++)
    {
    	stateId = this.SubStateList[b].id;
    	if(stateId)
    	{
	    	//stateInfo =  eval("SUB_STATE_INFO." + this.SubStateList[b].id);
	    	
	        this.PopupInfo.stateList[b] = new Object();
	        this.PopupInfo.stateList[b].flag_Loaded_state = false;
		    this.PopupInfo.stateList[b].id = stateId;
    	}
    }
    
    this.PopupInfo.stateList[SUB_STATE.ADD_CONTACT].focusFunc = function(){WndMgr.ReturnAddContact();};
	this.PopupInfo.stateList[SUB_STATE.ONLINE_STATUS].focusFunc	= function(){WndMgr.ReturnOnlineStatus();};
    this.PopupInfo.stateList[SUB_STATE.CHANGE_PICTURE].focusFunc = function(){WndMgr.ReturnChangePicture();};
	this.PopupInfo.stateList[SUB_STATE.CHANGE_PASSWORD].focusFunc = function(){WndMgr.ReturnChangePassword();};
    this.PopupInfo.stateList[SUB_STATE.SIGNOUT].focusFunc = function(){WndMgr.ReturnSignout();};
	this.PopupInfo.stateList[SUB_STATE.LIST_TOOLS].focusFunc = function(){WndMgr.ReturnListTools();};
    this.PopupInfo.stateList[SUB_STATE.VIEW_PROFILE].focusFunc = function(){WndMgr.ReturnViewProfile();};
	this.PopupInfo.stateList[SUB_STATE.RENAME].focusFunc = function(){WndMgr.ReturnRename();};		
    this.PopupInfo.stateList[SUB_STATE.REMOVE_CONTACT].focusFunc = function(){WndMgr.ReturnRemoveContact();};    
	this.PopupInfo.stateList[SUB_STATE.REMOVE].focusFunc = function(){WndMgr.ReturnRemove();};	
    this.PopupInfo.stateList[SUB_STATE.BLOCK].focusFunc = function(){WndMgr.ReturnBlock();};    
	this.PopupInfo.stateList[SUB_STATE.CALL_CONFIRM].focusFunc = function(){WndMgr.ReturnCallConfirmPopup();};	
    this.PopupInfo.stateList[SUB_STATE.CALL_SETTING].focusFunc = function(){WndMgr.ReturnCallSettingPopup();};    
	this.PopupInfo.stateList[SUB_STATE.FORGOT_PWD].focusFunc = function(){WndMgr.ReturnForgotPwd();};
    this.PopupInfo.stateList[SUB_STATE.EXIT].focusFunc = function(){WndMgr.ReturnExit();};    
	this.PopupInfo.stateList[SUB_STATE.ADD_PHONE_NUMBER].focusFunc = function(){WndMgr.ReturnAddPhoneNumber();};	
	this.PopupInfo.stateList[SUB_STATE.LISTMAIN_PHONE_NUMBER].focusFunc = function(){WndMgr.ReturnListMainPhoneNumber();};	
	this.PopupInfo.stateList[SUB_STATE.CHANGE_PHONE_NUMBER].focusFunc = function(){WndMgr.ReturnChangePhoneNumber();};	
	this.PopupInfo.stateList[SUB_STATE.CHANGE_PHONE_NUMBER_SELECT].focusFunc = function(){WndMgr.ReturnChangePhoneNumberSelect();};	
	this.PopupInfo.stateList[SUB_STATE.ACCOUNT_MANAGER].focusFunc = function(){WndMgr.ReturnAccountManager();};	
	this.PopupInfo.stateList[SUB_STATE.GENDER].focusFunc = function(){WndMgr.ReturnGender();};
    this.PopupInfo.stateList[SUB_STATE.BIRTHDATE].focusFunc = function(){WndMgr.ReturnBirthDate();};    
	this.PopupInfo.stateList[SUB_STATE.PROFILEPHONENUMBERSET].focusFunc = function(){WndMgr.ReturnProfilePhoneNumberSet();};	
    this.PopupInfo.stateList[SUB_STATE.SETTINGSGENERAL].focusFunc = function(){WndMgr.ReturnSettingsGeneral();};
    this.PopupInfo.stateList[SUB_STATE.SETTINGSFACERECOGNITION].focusFunc = function(){WndMgr.ReturnSettingsFaceRecognition();};	
    this.PopupInfo.stateList[SUB_STATE.SETTINGSVIDEO].focusFunc = function(){WndMgr.ReturnSettingsVideo();};    
	this.PopupInfo.stateList[SUB_STATE.SETTINGSBLOCKEDCONTACTS].focusFunc = function(){WndMgr.ReturnSettingsBlockedContacts();};	
	this.PopupInfo.stateList[SUB_STATE.SETTINGSPRIVACY].focusFunc = function(){WndMgr.ReturnSettingsPrivacy();};	
    this.PopupInfo.stateList[SUB_STATE.SETTINGSCALLFORWARDING].focusFunc = function(){WndMgr.ReturnSettingsCallForwarding();};    
	this.PopupInfo.stateList[SUB_STATE.SETTINGSVOICEMAIL].focusFunc = function(){WndMgr.ReturnSettingsVoicemail();};	
	this.PopupInfo.stateList[SUB_STATE.SETTINGSVOICEMAILUNABLE].focusFunc = function(){WndMgr.ReturnSettingsVoicemailUnable();};	
	this.PopupInfo.stateList[SUB_STATE.SETTINGSABOUTSKYPE].focusFunc = function(){WndMgr.ReturnSettingsAboutSkype();};
	this.PopupInfo.stateList[SUB_STATE.PLUS_LIST].focusFunc = function(){WndMgr.ReturnListPlus();};
	this.PopupInfo.stateList[SUB_STATE.CAMERA_ADJUST].focusFunc = function(){WndMgr.ReturnCameraAdjustPopup();};
}

StateMgr.IsLoadSubState = function(SubStateIndex){

	return this.SubStateList[SubStateIndex].flagLoad;
	
}

StateMgr.setSubStateLoading = function(index)
{
    this.initSubStateLoading();
    this.SubStateList[index].flagLoading = true;
}

StateMgr.initSubStateLoading= function(){
	var b=0;
    for(b=0; b<this.SubStateList.length; b++)
    {
        this.SubStateList[b].flagLoading = false;
    }
}

StateMgr.showSubState = function(index , callbackShowFn, callbackStartFn){
	
	if(this.SubStateList[index].flagLoading == true)
    {
        return;
    }
/*
	if(this.NotiInfo.waitState)
	{
		this.NotiInfo.waitState = null;
	}
*/
	if(StateMgr.flagDelaySubLoading == true) // cancel delay loading
	{
		StateMgr.flagDelaySubLoading = false;
		StateMgr.setDelaySubLoadingState(null); 
	}

    if(this.SubStateList[index].flagLoad ==false)
    {
    	
/*
		if(StateMgr.isMainStateLoaing() == true)
		{
			this.NotiInfo.waitState = curState;
			return;
		}
*/        	
    	
		if(StateMgr.isMainStateLoaing()== true)
		{
			StateMgr.flagDelaySubLoading = true;
			StateMgr.setDelaySubLoadingState(callbackStartFn);
			return;
		}
		
        StateMgr.setSubStateLoading(index); 
        
        utill_LoadMode(this.SubStateList[index].id, function() {

            StateMgr.SubStateList[index].flagLoad = true;
            if(StateMgr.SubStateList[index].flagLoading == true)
            {
                StateMgr.SubStateList[index].flagLoading = false;
                callbackShowFn();
            }
        });
    }
    else{
		this.initSubStateLoading();
        callbackShowFn();
    }
}

StateMgr.Start_Add_Contact_State = function(){
    this.preSubState = this.currentSubState;
    
    alert("***** Start_Add_Contact_State = old [" +  this.preSubState + "]");

    StateMgr.showSubState(SUB_STATE.ADD_CONTACT, function(){ StateMgr.Show_Add_Contact_State();}, function(){ StateMgr.Start_Add_Contact_State();}) ;
}

StateMgr.Show_Add_Contact_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.ADD_CONTACT;

    this.currentSubState =this.SubStateList[SUB_STATE.ADD_CONTACT].id;
    alert("***** Start_Add_Contact_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Add_Contact_State ()");
    StateMgr.StopPreSubState();
	
    WndMgr.InitAddContact();
    WndMgr.ShowAddContact();
}

StateMgr.Stop_Add_Contact_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Add_Contact_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Add_Contact_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideAddContact();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}


StateMgr.Start_Remove_Contact_State = function(Identity,Display){
    this.preSubState = this.currentSubState;
    
    alert("***** Start_Remove_Contact_State = old [" +  this.preSubState + "]");

	this.FuncParamA = Identity;
	this.FuncParamB = Display;

    StateMgr.showSubState(SUB_STATE.REMOVE_CONTACT, function(){ StateMgr.Show_Remove_Contact_State();}, function(){ StateMgr.Start_Remove_Contact_State(Identity,Display);}) ;
}

StateMgr.Show_Remove_Contact_State = function(){

    this.currentSubState = this.SubStateList[SUB_STATE.REMOVE_CONTACT].id;	

    alert("***** Start_Remove_Contact_State = new [" +  this.currentSubState + "]");
    
    StateMgr.StopPreSubState();

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.REMOVE_CONTACT;

    WndMgr.ShowRemoveContact(this.FuncParamA,this.FuncParamB);

	this.FuncParamA = null;
	this.FuncParamB = null;

}

StateMgr.Stop_Remove_Contact_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Remove_Contact_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
	
    alert("***** Stop_Remove_Contact_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideRemoveContact();
	
    if(flagReturn==true)
    {
        this.ReturnState();
    }

}


StateMgr.Start_Online_Status_State = function(){
    this.preSubState = this.currentSubState;
    
    alert("***** Start_Online_Status_State = old [" +  this.preSubState + "]");

    StateMgr.showSubState(SUB_STATE.ONLINE_STATUS, function(){ StateMgr.Show_Online_Status_State();}, function(){ StateMgr.Start_Online_Status_State();});
}

StateMgr.Show_Online_Status_State = function(){
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.ONLINE_STATUS;
	
    this.currentSubState = this.SubStateList[SUB_STATE.ONLINE_STATUS].id ;
    alert("***** Start_Online_Status_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Online_Status_State ()");
    StateMgr.StopPreSubState();
    WndMgr.ShowOnlineStatus();
}

StateMgr.Stop_Online_Status_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Online_Status_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Online_Status_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideOnlineStatus();
    
	if(flagReturn == true) {
		this.ReturnState();
	}
}
// 7.31 add
StateMgr.Start_Gender_State = function() {
	this.preSubState = this.currentSubState;
	alert("***** Start_Gender_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.GENDER, function() {
		StateMgr.Show_Gender_State();
	}, function() {
		StateMgr.Start_Gender_State();
	});
}
StateMgr.Show_Gender_State = function() {
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.GENDER;

	this.currentSubState = this.SubStateList[SUB_STATE.GENDER].id;
	alert("***** Show_Gender_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_Gender_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowGender();
}
StateMgr.Stop_Gender_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_Gender_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_Gender_State = new [" + this.currentSubState + "]");

	WndMgr.HideGender();

	if(flagReturn == true) {
		this.ReturnState();
	}
}
// 8.1 add
StateMgr.Start_BirthDate_State = function() {		
	this.preSubState = this.currentSubState;
	alert("***** Start_BirthDate_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.BIRTHDATE, function() {
		StateMgr.Show_BirthDate_State();
	}, function() {
		StateMgr.Start_BirthDate_State();
	});
}
StateMgr.Show_BirthDate_State = function() {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.BIRTHDATE;	
	
	this.currentSubState = this.SubStateList[SUB_STATE.BIRTHDATE].id;
	alert("***** Show_BirthDate_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_BirthDate_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowBirthDate();
}
StateMgr.Stop_BirthDate_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_BirthDate_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_BirthDate_State = new [" + this.currentSubState + "]");

	WndMgr.HideBirthDate();

	if(flagReturn == true) {
        this.ReturnState();
    }
}
//8.17 add
StateMgr.Start_ProfilePhoneNumberSet_State = function() {
	this.preSubState = this.currentSubState;
	alert("***** Start_ProfilePhoneNumberSet_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.PROFILEPHONENUMBERSET, function() {
		StateMgr.Show_ProfilePhoneNumberSet_State();
	}, function() {
		StateMgr.Start_ProfilePhoneNumberSet_State();
	});
}
StateMgr.Show_ProfilePhoneNumberSet_State = function() {
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.PROFILEPHONENUMBERSET;	
	
	this.currentSubState = this.SubStateList[SUB_STATE.PROFILEPHONENUMBERSET].id;
	alert("***** Show_ProfilePhoneNumberSet_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_ProfilePhoneNumberSet_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowProfilePhoneNumberSet();
}
StateMgr.Stop_ProfilePhoneNumberSet_State = function(flagReturn) {
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_ProfilePhoneNumberSet_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_ProfilePhoneNumberSet_State = new [" + this.currentSubState + "]");

	WndMgr.HideProfilePhoneNumberSet();

	if(flagReturn == true) {
        this.ReturnState();
    }
}

//8.9 add
StateMgr.Start_SettingsGeneral_State = function() {
	this.preSubState = this.currentSubState;
	alert("***** Start_SettingsGeneral_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSGENERAL, function() {
		StateMgr.Show_SettingsGeneral_State();
	}, function() {
		StateMgr.Start_SettingsGeneral_State();
	});
}
StateMgr.Show_SettingsGeneral_State = function() {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSGENERAL;
	
	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSGENERAL].id;
	alert("***** Show_SettingsGeneral_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsGeneral_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowSettingsGeneral();
}
StateMgr.Stop_SettingsGeneral_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsGeneral_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsGeneral_State = new [" + this.currentSubState + "]");

	WndMgr.HideSettingsGeneral();

	if(flagReturn == true) {
        this.ReturnState();
    }
}

//8.10 add
StateMgr.Start_SettingsFaceRecognition_State = function(return_flag) {
	this.preSubState = this.currentSubState;
	alert("***** Start_SettingsFaceRecognition_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSFACERECOGNITION, function() {
		StateMgr.Show_SettingsFaceRecognition_State(return_flag);
	}, function() {
		StateMgr.Start_SettingsFaceRecognition_State();
	});
}
StateMgr.Show_SettingsFaceRecognition_State = function(return_flag) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSFACERECOGNITION;
	
	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSFACERECOGNITION].id;
	alert("***** Show_SettingsFaceRecognition_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsFaceRecognition_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	if(return_flag!=null && return_flag==true){
		WndMgr.ShowSettingsFaceRecognition();
	}else{
		WndMgr.StartCheckPwd();
	}
	// WndMgr.ShowSettingsFaceRecognition();
}
StateMgr.Stop_SettingsFaceRecognition_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsFaceRecognition_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsFaceRecognition_State = new [" + this.currentSubState + "]");

	if(WndMgr.isShowCheckPwd==true){
		WndMgr.HideCheckPwd();		
	}else if(WndMgr.isShowConfirmPopup==true){
		WndMgr.StopConfirmPopup();
		WndMgr.HideSettingsFaceRecognition();
		// return;
	}else{
		WndMgr.HideSettingsFaceRecognition();
	}
	// alert("flagReturn : "+flagReturn);
	if(flagReturn == true) {
        this.ReturnState();
    }
}

//8.10 add
StateMgr.Start_SettingsVideo_State = function(arg) {	
	this.preSubState = this.currentSubState;
	this.FuncParamA = arg;
	alert("***** Start_SettingsVideo_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSVIDEO, function() {
		StateMgr.Show_SettingsVideo_State();
	}, function() {
		StateMgr.Start_SettingsVideo_State();
	});
}
StateMgr.Show_SettingsVideo_State = function() {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSVIDEO;
	
	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSVIDEO].id;
	alert("***** Show_SettingsVideo_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsVideo_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowSettingsVideo(this.FuncParamA);
}
StateMgr.Stop_SettingsVideo_State = function(flagReturn) {
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
		
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsVideo_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsVideo_State = new [" + this.currentSubState + "]");

	WndMgr.HideSettingsVideo();

	if(flagReturn == true) {
        this.ReturnState();
    }
    this.FuncParamA = null;
}
//8.10 add
StateMgr.Start_SettingsPrivacy_State = function() {
	this.preSubState = this.currentSubState;
	alert("***** Start_SettingsPrivacy_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSPRIVACY, function() {
		StateMgr.Show_SettingsPrivacy_State();
	}, function() {
		StateMgr.Start_SettingsPrivacy_State();
	});
}
StateMgr.Show_SettingsPrivacy_State = function() {
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSPRIVACY;
	
	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSPRIVACY].id;
	alert("***** Show_SettingsPrivacy_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsPrivacy_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowSettingsPrivacy();
}
StateMgr.Stop_SettingsPrivacy_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsPrivacy_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsPrivacy_State = new [" + this.currentSubState + "]");

	WndMgr.HideSettingsPrivacy();

	if(flagReturn == true) {
        this.ReturnState();
    }
}
//8.9 add
StateMgr.Start_SettingsBlockedContacts_State = function() {
	this.preSubState = this.currentSubState;
	alert("***** Start_SettingsBlockedContacts_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSBLOCKEDCONTACTS, function() {
		StateMgr.Show_SettingsBlockedContacts_State();
	}, function() {
		StateMgr.Start_SettingsBlockedContacts_State();
	});
}
StateMgr.Show_SettingsBlockedContacts_State = function() {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSBLOCKEDCONTACTS;
	
	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSBLOCKEDCONTACTS].id;
	alert("***** Show_SettingsBlockedContacts_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsBlockedContacts_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowSettingsBlockedContacts();
}
StateMgr.Stop_SettingsBlockedContacts_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsBlockedContacts_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsBlockedContacts_State = new [" + this.currentSubState + "]");

	WndMgr.HideSettingsBlockedContacts();

	if(flagReturn == true) {
        this.ReturnState();
    }
}
//8.10 add
StateMgr.Start_SettingsCallForwarding_State = function() {
	this.preSubState = this.currentSubState;
	alert("***** Start_SettingsCallForwarding_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSCALLFORWARDING, function() {
		StateMgr.Show_SettingsCallForwarding_State();
	}, function() {
		StateMgr.Start_SettingsCallForwarding_State();
	});
}
StateMgr.Show_SettingsCallForwarding_State = function() {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSCALLFORWARDING;
	
	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSCALLFORWARDING].id;
	alert("***** Show_SettingsCallForwarding_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsCallForwarding_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowSettingsCallForwarding();
}
StateMgr.Stop_SettingsCallForwarding_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsCallForwarding_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsCallForwarding_State = new [" + this.currentSubState + "]");

	WndMgr.HideSettingsCallForwarding();

	if(flagReturn == true) {
        this.ReturnState();
    }
}
//8.9 add
StateMgr.Start_SettingsVoicemail_State = function() {
	this.preSubState = this.currentSubState;
	alert("***** Start_SettingsVoicemail_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSVOICEMAIL, function() {
		StateMgr.Show_SettingsVoicemail_State();
	}, function() {
		StateMgr.Start_SettingsVoicemail_State();
	});
}
StateMgr.Show_SettingsVoicemail_State = function() {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSVOICEMAIL;
	
	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSVOICEMAIL].id;
	alert("***** Show_SettingsVoicemail_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsVoicemail_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowSettingsVoicemail();
}
StateMgr.Stop_SettingsVoicemail_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsVoicemail_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsVoicemail_State = new [" + this.currentSubState + "]");

	WndMgr.HideSettingsVoicemail();

	if(flagReturn == true) {
        this.ReturnState();
    }
}
StateMgr.Start_SettingsVoicemailUnable_State = function() {
	this.preSubState = this.currentSubState;
	alert("***** Start_SettingsVoicemailUnable_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSVOICEMAILUNABLE, function() {
		StateMgr.Show_SettingsVoicemailUnable_State();
	}, function() {
		StateMgr.Start_SettingsVoicemailUnable_State();
	});
}
StateMgr.Show_SettingsVoicemailUnable_State = function() {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSVOICEMAILUNABLE;

	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSVOICEMAILUNABLE].id;
	alert("***** Show_SettingsVoicemailUnable_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsVoicemailUnable_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowSettingsVoicemailUnable();
}
StateMgr.Stop_SettingsVoicemailUnable_State = function(flagReturn) {
	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsVoicemailUnable_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsVoicemailUnable_State = new [" + this.currentSubState + "]");

	WndMgr.HideSettingsVoicemailUnable();

	if(flagReturn == true) {
        this.ReturnState();
    }
}

//8.10 add
StateMgr.Start_SettingsAboutSkype_State = function() {
	
	this.preSubState = this.currentSubState;
	alert("***** Start_SettingsAboutSkype_State = old [" + this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.SETTINGSABOUTSKYPE, function() {
		StateMgr.Show_SettingsAboutSkype_State();
	}, function() {
		StateMgr.Start_SettingsAboutSkype_State();
	});
}
StateMgr.Show_SettingsAboutSkype_State = function() {

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SETTINGSABOUTSKYPE;
	
	this.currentSubState = this.SubStateList[SUB_STATE.SETTINGSABOUTSKYPE].id;
	alert("***** Show_SettingsAboutSkype_State = new [" + this.currentSubState + "]");

	alert("***** StateMgr.Show_SettingsAboutSkype_State ()");
	StateMgr.StopPreSubState();
	// window mgr
	WndMgr.ShowSettingsAboutSkype();
}
StateMgr.Stop_SettingsAboutSkype_State = function(flagReturn) {

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;

	alert("***** Stop_SettingsAboutSkype_State = old [" + this.preSubState + "]");

	this.currentSubState = "";
	alert("***** Stop_SettingsAboutSkype_State = new [" + this.currentSubState + "]");

	WndMgr.HideSettingsAboutSkype();

	if(flagReturn == true) {
        this.ReturnState();
    }
}
StateMgr.Start_Change_Picture_State = function(){
	
    this.preSubState = this.currentSubState;
    
    alert("***** Start_Change_Picture_State = old [" +  this.preSubState + "]");

    StateMgr.showSubState(SUB_STATE.CHANGE_PICTURE, function(){ StateMgr.Show_Change_Picture_State();}, function(){ StateMgr.Start_Change_Picture_State();}) ;
}

StateMgr.Show_Change_Picture_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.CHANGE_PICTURE;
	
    this.currentSubState = this.SubStateList[SUB_STATE.CHANGE_PICTURE].id;
    alert("***** Start_Change_Picture_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Change_Picture_State ()");

    StateMgr.StopPreSubState();
    WndMgr.ShowChangePicture();
}

StateMgr.Stop_Change_Picture_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Change_Picture_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Change_Picture_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideChangePicture(true);
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}

StateMgr.Start_Change_Password_State = function(){
    this.preSubState = this.currentSubState;   
    alert("***** Start_Change_Password_State = old [" +  this.preSubState + "]");

     StateMgr.showSubState(SUB_STATE.CHANGE_PASSWORD, function(){ StateMgr.Show_Change_Password_State();}, function(){ StateMgr.Start_Change_Password_State();}) ;
}

StateMgr.Show_Change_Password_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.CHANGE_PASSWORD;
	
    this.currentSubState = this.SubStateList[SUB_STATE.CHANGE_PASSWORD].id;
    alert("***** Start_Change_Password_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Change_Password_State ()");

    StateMgr.StopPreSubState();
    
    WndMgr.InitChangePassword();
    WndMgr.ShowChangePassword();
}

StateMgr.Stop_Change_Password_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Change_Password_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Change_Password_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideChangePassword();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}


StateMgr.Start_Call_Ending_State = function(flagCallEndByMe){
    if(this.currentState == "Calling" || StateMgr.MainStateList[MAIN_STATE.CALLING].flagLoading == true)
    {
        WndMgr.updateCallingButton(true);
        return;
    }

    this.preSubState = this.currentSubState;

	this.FuncParamA = flagCallEndByMe;
	
   
    alert("***** Start_Call_Ending_State = old [" +  this.preSubState + "]");

    StateMgr.showSubState(SUB_STATE.CALL_ENDING, function(){ StateMgr.Show_Call_Ending_State();}, function(){ StateMgr.Start_Call_Ending_State(flagCallEndByMe);}) ;
}

StateMgr.Show_Call_Ending_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.CALL_ENDING;
	
    this.currentSubState =this.SubStateList[SUB_STATE.CALL_ENDING].id;
    alert("***** Start_Call_Ending_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Call_Ending_State ()");
    if(this.preSubState ==  this.currentSubState)
    {
        WndMgr.UpdateCallEndingStatus();
    }
     else
	{
        StateMgr.StopPreSubState();
        WndMgr.ShowCallEnding(this.FuncParamA);
	}
	
	this.FuncParamA = null;
}

StateMgr.Stop_Call_Ending_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Call_Ending_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Call_Ending_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideCallEnding();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}


StateMgr.Start_Volume_Speaker_State = function(SourceMode){
    this.preSubState = this.currentSubState;
    
    alert("***** Start_Volume_Speaker_State = old [" +  this.preSubState + "]");
	
	this.FuncParamA = SourceMode;

    StateMgr.showSubState(SUB_STATE.VOLUME_SPEAKER, function(){ StateMgr.Show_Volume_Speaker_State();}, function(){ StateMgr.Start_Volume_Speaker_State(SourceMode);}) ;
}

StateMgr.Show_Volume_Speaker_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.VOLUME_SPEAKER;
	
    this.currentSubState = this.SubStateList[SUB_STATE.VOLUME_SPEAKER].id ;
    alert("***** Start_Volume_Speaker_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Volume_Speaker_State ()");

    StateMgr.StopPreSubState();
    
    WndMgr.ShowVolumeSpeaker(this.FuncParamA);
	
	this.FuncParamA = null;
}


StateMgr.Stop_Volume_Speaker_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Volume_Speaker_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Volume_Speaker_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideVolumeSpeaker();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}

StateMgr.Start_Signout_State = function(){
    this.preSubState = this.currentSubState;
    
    alert("***** Start_Signout_State = old [" +  this.preSubState + "]");

     StateMgr.showSubState(SUB_STATE.SIGNOUT, function(){ StateMgr.Show_Signout_State();}, function(){ StateMgr.Start_Signout_State();}) ;
}

StateMgr.Show_Signout_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.SIGNOUT;
	
    this.currentSubState = this.SubStateList[SUB_STATE.SIGNOUT].id;
    alert("***** Start_Signout_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Signout_State ()");
    StateMgr.StopPreSubState();
    WndMgr.ShowSignout();
}

StateMgr.Stop_Signout_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Signout_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Signout_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideSignout();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}

StateMgr.Start_List_Tools_State = function(ToolType){
    
	this.preSubState = this.currentSubState;

	this.FuncParamA = ToolType;	    
    
	alert("***** Start_List_Tools_State = old [" +  this.preSubState + "]");
	
	StateMgr.showSubState(SUB_STATE.LIST_TOOLS, function(){ StateMgr.Show_List_Tools_State();} , function(){ StateMgr.Start_List_Tools_State();}) ;

}

StateMgr.Show_List_Tools_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.LIST_TOOLS;
			
    this.currentSubState = this.SubStateList[SUB_STATE.LIST_TOOLS].id;
	
    alert("***** Start_List_Tools_State = new [" +  this.currentSubState + "]");
    
    StateMgr.StopPreSubState();
    WndMgr.ShowListTools(this.FuncParamA);

	this.FuncParamA = null;    
    
}

StateMgr.Stop_List_Tools_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;
	
	alert("***** Stop_List_Tools_State = old [" +  this.preSubState + "]");
	
	this.currentSubState = "";
	alert("***** Stop_List_Tools_State = new [" +  this.currentSubState + "]");
	
	WndMgr.HideListTools();
	
	if(flagReturn==true)
	{
		this.ReturnState();
	}
}

StateMgr.Start_View_Profile_State = function(IdentityName){
    
	this.preSubState = this.currentSubState;
    
	alert("***** Start_View_Profile_State = old [" +  this.preSubState + "]");
	
	this.FuncParamA = IdentityName;
	
	StateMgr.showSubState(SUB_STATE.VIEW_PROFILE, function(){ StateMgr.Show_View_Profile_State();}, function(){ StateMgr.Start_View_Profile_State();}) ;

}

StateMgr.Show_View_Profile_State = function(){
	
    this.currentSubState = this.SubStateList[SUB_STATE.VIEW_PROFILE].id;
	
    alert("***** Start_View_Profile_State = new [" +  this.currentSubState + "]");
    
    this.StopPreSubState();

	//set PopupInfo.curState after call StateMgr.StopPreSubState();
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.VIEW_PROFILE;

    WndMgr.ShowViewProfile(this.FuncParamA);
	
	this.FuncParamA = null;
}

StateMgr.Stop_View_Profile_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;
	
	alert("***** Stop_View_Profile_State = old [" +  this.preSubState + "]");
	
	this.currentSubState = "";
	alert("***** Stop_View_Profile_State = new [" +  this.currentSubState + "]");
	
	WndMgr.HideViewProfile();
	
	if(flagReturn==true)
	{
		this.ReturnState();
	}
}


StateMgr.Start_Rename_State = function(IdentityName){
    
	this.preSubState	= this.currentSubState;
	    
	alert("***** Start_Rename_State = old [" +  this.preSubState + "]");

	this.FuncParamA = IdentityName;
		
	StateMgr.showSubState(SUB_STATE.RENAME, function(){ StateMgr.Show_Rename_State();}, function(){ StateMgr.Start_Rename_State();}) ;

}

StateMgr.Show_Rename_State = function(){
	
    this.currentSubState = this.SubStateList[SUB_STATE.RENAME].id;
	
    alert("***** Start_Rename_State = new [" +  this.currentSubState + "]");
    
    StateMgr.StopPreSubState();
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.RENAME;    
    
    WndMgr.ShowRename(this.FuncParamA);
	
	this.FuncParam = null;
}

StateMgr.Stop_Rename_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;
	
	alert("***** Stop_Rename_State = old [" +  this.preSubState + "]");
	
	this.currentSubState = "";
	alert("***** Stop_Rename_State = new [" +  this.currentSubState + "]");
	
	WndMgr.HideRename();
	
	if(flagReturn==true)
	{
		this.ReturnState();
	}
}

StateMgr.Start_Block_State = function(Type,Identity,Display){
    
	this.preSubState	= this.currentSubState;
	
	this.FuncParamA		= Type;
    this.FuncParamB		= Identity;
	this.FuncParamC		= Display;
	
	alert("***** Start_Block_State = old [" +  this.preSubState + "]");
		
	StateMgr.showSubState(SUB_STATE.BLOCK, function(){ StateMgr.Show_Block_State();}, function(){ StateMgr.Start_Block_State(StateMgr.FuncParamA, StateMgr.FuncParamB,StateMgr.FuncParamC,StateMgr.FuncParamD);}) ;

}

StateMgr.Show_Block_State = function(){
	
    this.currentSubState = this.SubStateList[SUB_STATE.BLOCK].id;
	
    alert("***** Show_Block_State = new [" +  this.currentSubState + "]");
    
    StateMgr.StopPreSubState();

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.BLOCK;    
    
    WndMgr.ShowBlock(this.FuncParamA, this.FuncParamB, this.FuncParamC);
	
	this.FuncParamA = null;
	this.FuncParamB = null;
	this.FuncParamC = null;
}

StateMgr.Stop_Block_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;
	
	alert("***** Stop_Block_State = old [" +  this.preSubState + "]");
	
	this.currentSubState = "";
	alert("***** Stop_Block_State = new [" +  this.currentSubState + "]");
	
	WndMgr.HideBlock();
	
	if(flagReturn==true)
	{
		this.ReturnState();
	}
}

StateMgr.Start_Remove_State = function(Index){
    
	this.preSubState = this.currentSubState;
 
 	this.FuncParamA		= Index;
    
    alert("***** Start_Remove_State = old [" +  this.preSubState + "]");

    StateMgr.showSubState(SUB_STATE.REMOVE, function(){ StateMgr.Show_Remove_State();}, function(){ StateMgr.Start_Remove_State(StateMgr.FuncParamA);}) ;
}


StateMgr.Show_Remove_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.REMOVE;
	
    this.currentSubState = this.SubStateList[SUB_STATE.REMOVE].id;	
    alert("***** Start_Remove_State = new [" +  this.currentSubState + "]");
    
    StateMgr.StopPreSubState();
	
    WndMgr.ShowRemove(this.FuncParamA);

	this.FuncParamA = null;
	
}

StateMgr.Stop_Remove_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Remove_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
	
    alert("***** Stop_Remove_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideRemove();

    if(flagReturn==true)
    {
        this.ReturnState();
    }

}

StateMgr.Start_Call_Confirm_State = function(Type){
    this.preSubState = this.currentSubState;
    alert("***** Start_Call_Confirm_State = old [" +  this.preSubState + "]");

 	this.FuncParamA = Type;

	StateMgr.showSubState(SUB_STATE.CALL_CONFIRM, function(){ StateMgr.Show_Call_Confirm_State();}, function(){ StateMgr.Start_Call_Confirm_State(Type);}) ;
}

StateMgr.Show_Call_Confirm_State = function(){
	if(this.currentSubState == "CallEnding")
	{
		return;
	}

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.CALL_CONFIRM;
	
    this.currentSubState = this.SubStateList[SUB_STATE.CALL_CONFIRM].id;
    alert("***** Show_Call_Confirm_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Call_Confirm_State ()");
    StateMgr.StopPreSubState();
    WndMgr.ShowCallConfirmPopup(this.FuncParamA);
    
    this.FuncParamA = null;
}

StateMgr.Stop_Call_Confirm_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Call_Confirm_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Call_Confirm_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideCallConfirmPopup();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}

StateMgr.Start_Call_Setting_State = function(Type){
    this.preSubState = this.currentSubState;
    alert("***** Start_Call_Setting_State = old [" +  this.preSubState + "]");

 	this.FuncParamA = Type;

	StateMgr.showSubState(SUB_STATE.CALL_SETTING, function(){ StateMgr.Show_Call_Setting_State();}, function(){ StateMgr.Start_Call_Setting_State();}) ;
}

StateMgr.Show_Call_Setting_State = function(){
	if(this.currentSubState == "CallEnding")
	{
		return;
	}
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.CALL_SETTING;
 	
	
    this.currentSubState = this.SubStateList[SUB_STATE.CALL_SETTING].id;
    alert("***** Show_Call_Setting_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Call_Setting_State ()");
    StateMgr.StopPreSubState();
    
    WndMgr.ShowCallSettingPopup();
    
}

StateMgr.Stop_Call_Setting_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Call_Setting_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Call_Setting_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideCallSettingPopup();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}

StateMgr.Start_Camera_Adjust_State = function(){
    this.preSubState = this.currentSubState;
    alert("***** Start_Camera_Adjust_State = old [" +  this.preSubState + "]");

	StateMgr.showSubState(SUB_STATE.CAMERA_ADJUST, function(){ StateMgr.Show_Camera_Adjust_State();}, function(){ StateMgr.Start_Camera_Adjust_State();}) ;
}

StateMgr.Show_Camera_Adjust_State = function(){
	if(this.currentSubState == "CallEnding")
	{
		return;
	}
	
    this.currentSubState = this.SubStateList[SUB_STATE.CAMERA_ADJUST].id;
    alert("***** Show_Camera_Adjust_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Camera_Adjust_State ()");
    StateMgr.StopPreSubState();
    
    WndMgr.ShowCameraAdjustPopup();
    
}

StateMgr.Stop_Camera_Adjust_State = function(flagReturn){
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Camera_Adjust_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Camera_Adjust_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideCameraAdjustPopup();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}

StateMgr.Start_Forgot_Pwd_State = function(){
    this.preSubState = this.currentSubState;
    alert("***** Start_Forgot_Pwd_State = old [" +  this.preSubState + "]");

     StateMgr.showSubState(SUB_STATE.FORGOT_PWD, function(){ StateMgr.Show_Forgot_Pwd_State();}, function(){ StateMgr.Start_Forgot_Pwd_State();}) ;
}

StateMgr.Show_Forgot_Pwd_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.FORGOT_PWD;

    this.currentSubState = this.SubStateList[SUB_STATE.FORGOT_PWD].id;
    alert("***** Start_Forgot_Pwd_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Forgot_Pwd_State ()");
    StateMgr.StopPreSubState();
    WndMgr.ShowForgotPwd();
}


StateMgr.Stop_Forgot_Pwd_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Forgot_Pwd_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Forgot_Pwd_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideForgotPwd();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}

StateMgr.Start_Exit_State = function(fromReturnKey){
 	
 	if(PluginAPIMgr.IsWidgetSupportMultitasking() == 1)
 	{
 		if(fromReturnKey==true){
 			ProcMgr.CloseWithSignIn();
 		}
 		else{
 			ProcMgr.ExitWithSignIn();
 		} 
		
 		return; 
 	}
 	
    this.preSubState = this.currentSubState;
    alert("***** Start_Exit_State = old [" +  this.preSubState + "]");

     StateMgr.showSubState(SUB_STATE.EXIT, function(){ StateMgr.Show_Exit_State(fromReturnKey);}, function(){ StateMgr.Start_Exit_State();}) ;
}

StateMgr.Show_Exit_State = function(fromReturnKey){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.EXIT;
	
    this.currentSubState = this.SubStateList[SUB_STATE.EXIT].id;
    alert("***** Start_Exit_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Exit_State ()");
    StateMgr.StopPreSubState();
    WndMgr.ShowExit(fromReturnKey);
    
    //2013 modify by minseok : for multiapplication
 	// if(fromReturnKey==true){
 		// ProcMgr.CloseWithSignIn();
 	// }else{
 		// ProcMgr.ExitWithSignIn();
 	// }   
}

StateMgr.Stop_Exit_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Exit_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Exit_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideExit();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}



/* 	<parameter1: type>
 *   0 : add type
 *   1 : assign number 1 change or delete
 *   2 : assign number 2 change or delete
 *   3 : assign number 3 change or delete
 *  <parameter2: phone number>
 * 
 */
StateMgr.Start_Add_Phone_Number_State = function(Identity)
{
    this.preSubState = this.currentSubState;
    alert("***** Start_Add_Phone_Number_State = old [" +  this.preSubState + "]");

 	this.FuncParamA		= Identity;
    // this.FuncParamB		= PhoneNumber;
    // this.FuncParamC		= SkypeName;
        
	StateMgr.showSubState(SUB_STATE.ADD_PHONE_NUMBER, function(){ StateMgr.Show_Add_Phone_Number_State();}, function(){ StateMgr.Start_Add_Phone_Number_State(Identity);}) ;
}

StateMgr.Show_Add_Phone_Number_State = function()
{
    this.currentSubState = this.SubStateList[SUB_STATE.ADD_PHONE_NUMBER].id;
    alert("***** Start_Add_Phone_Number_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Add_Phone_Number_State ()");
    StateMgr.StopPreSubState();

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.ADD_PHONE_NUMBER;
    
    WndMgr.ShowAddPhoneNumber(this.FuncParamA);
    
 	this.FuncParamA		= null;
    // this.FuncParamB		= null;
	// this.FuncParamC		= null;
}


StateMgr.Stop_Add_Phone_Number_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Add_Phone_Number_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Add_Phone_Number_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideAddPhoneNumber();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}


StateMgr.Start_ListMain_Phone_Number_State = function(SceneName,SkypeName)
{
    this.preSubState = this.currentSubState;
    alert("***** Start_ListMain_Phone_Number_State = old [" +  this.preSubState + "]");

 	this.FuncParamA		= SceneName;
    this.FuncParamB		= SkypeName;
        
	StateMgr.showSubState(SUB_STATE.LISTMAIN_PHONE_NUMBER, function(){ StateMgr.Show_ListMain_Phone_Number_State();}, function(){ StateMgr.Start_ListMain_Phone_Number_State();}) ;
}

StateMgr.Show_ListMain_Phone_Number_State = function()
{
    this.currentSubState = this.SubStateList[SUB_STATE.LISTMAIN_PHONE_NUMBER].id;
    alert("***** Show_ListMain_Phone_Number_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_ListMain_Phone_Number_State ()");
    StateMgr.StopPreSubState();

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.LISTMAIN_PHONE_NUMBER;
    
    WndMgr.ShowListMainPhoneNumber(this.FuncParamA, this.FuncParamB);
    
 	this.FuncParamA		= null;
    this.FuncParamB		= null;
	// this.FuncParamC		= null;
}


StateMgr.Stop_ListMain_Phone_Number_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Add_Phone_Number_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Add_Phone_Number_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideListMainPhoneNumber();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}


StateMgr.Start_Change_Phone_Number_State = function(Identity,prop,PhoneLabel,PhoneNumber)
{
    this.preSubState = this.currentSubState;
    alert("***** Start_Change_Phone_Number_State = old [" +  this.preSubState + "]");

    this.FuncParamA		= Identity;
	this.FuncParamB		= prop;
	this.FuncParamC		= PhoneLabel;
	this.FuncParamD		= PhoneNumber;
        
	StateMgr.showSubState(SUB_STATE.CHANGE_PHONE_NUMBER, function(){ StateMgr.Show_Change_Phone_Number_State();}, function(){ StateMgr.Start_Change_Phone_Number_State();}) ;
}

StateMgr.Show_Change_Phone_Number_State = function()
{
	
    this.currentSubState = this.SubStateList[SUB_STATE.CHANGE_PHONE_NUMBER].id;
    alert("***** Start_Change_Phone_Number_State = new [" +  this.currentSubState + "]");
    
    alert("***** StateMgr.Show_Change_Phone_Number_State ()");
    StateMgr.StopPreSubState();
    
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.CHANGE_PHONE_NUMBER;
    
    WndMgr.ShowChangePhoneNumber(this.FuncParamA, this.FuncParamB, this.FuncParamC, this.FuncParamD);
    
 	this.FuncParamA		= null;
	this.FuncParamB		= null;
	this.FuncParamC		= null;
	this.FuncParamD		= null;
}


StateMgr.Stop_Change_Phone_Number_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Change_Phone_Number_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Change_Phone_Number_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideChangePhoneNumber();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}


StateMgr.Start_Change_Phone_Number_Select_State = function(SceneName,SkypeName)
{
    this.preSubState = this.currentSubState;
    alert("***** Start_Change_Phone_Number_Select_State = old [" +  this.preSubState + "]");

	this.FuncParamA		= SceneName;
    this.FuncParamB		= SkypeName;
        
	StateMgr.showSubState(SUB_STATE.CHANGE_PHONE_NUMBER_SELECT, function(){ StateMgr.Show_Change_Phone_Number_Select_State();}, function(){ StateMgr.Start_Change_Phone_Number_Select_State();}) ;
}

StateMgr.Show_Change_Phone_Number_Select_State = function()
{
    alert("***** StateMgr.Show_Change_Phone_Number_Select_State ()");

    this.currentSubState = this.SubStateList[SUB_STATE.CHANGE_PHONE_NUMBER_SELECT].id;
    alert("***** Start_Change_Phone_Number_Select_State = new [" +  this.currentSubState + "]");
    
    StateMgr.StopPreSubState();

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.CHANGE_PHONE_NUMBER_SELECT;

    WndMgr.ShowChangePhoneNumberSelect(this.FuncParamA, this.FuncParamB);
    
 	this.FuncParamA		= null;
    this.FuncParamB		= null;
}


StateMgr.Stop_Change_Phone_Number_Select_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;	
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Change_Phone_Number_Select_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Change_Phone_Number_Select_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideChangePhoneNumberSelect();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}


StateMgr.Start_Account_Manager_State = function(){
    this.preSubState = this.currentSubState;
    alert("***** Start_Account_Manager_State = old [" +  this.preSubState + "]");

     StateMgr.showSubState(SUB_STATE.ACCOUNT_MANAGER, function(){ StateMgr.Show_Account_Manager_State();}, function(){ StateMgr.Start_Account_Manager_State();}) ;
}

StateMgr.Show_Account_Manager_State = function(){

	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.ACCOUNT_MANAGER;
	
    this.currentSubState = this.SubStateList[SUB_STATE.ACCOUNT_MANAGER].id;
    alert("***** Start_Account_Manager_State = new [" +  this.currentSubState + "]");
    
    alert("***** Show_Account_Manager_State ()");
    StateMgr.StopPreSubState();
    
    WndMgr.InitAccountManager();
    WndMgr.ShowAccountManager();
}

StateMgr.Stop_Account_Manager_State = function(flagReturn){

	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
    this.preSubState = this.currentSubState;
    
    alert("***** Stop_Account_Manager_State = old [" +  this.preSubState + "]");

    this.currentSubState = "";
    alert("***** Stop_Account_Manager_State = new [" +  this.currentSubState + "]");
    
    WndMgr.HideAccountManager();
    
    if(flagReturn==true)
    {
        this.ReturnState();
    }
}

StateMgr.Start_List_Plus_State = function(PlusType, PlusIndex){
    
	this.preSubState = this.currentSubState;
   	this.FuncParamA = PlusType;	    
   	this.FuncParamB = PlusIndex;	    

	alert("***** Start_List_Plus_State = old [" +  this.preSubState + "]");
	
	StateMgr.showSubState(SUB_STATE.PLUS_LIST, function(){ StateMgr.Show_List_Plus_State();}, function(){ StateMgr.Start_List_Plus_State();}) ; // StateMgr.FuncParamA, StateMgr.FuncParamB

}

StateMgr.Show_List_Plus_State = function(){
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
 	this.PopupInfo.curState = SUB_STATE.PLUS_LIST;
	
    this.currentSubState = this.SubStateList[SUB_STATE.PLUS_LIST].id;
	
    alert("***** Show_List_Plus_State = new [" +  this.currentSubState + "]");
    
    StateMgr.StopPreSubState();
    WndMgr.ShowListPlus(this.FuncParamA, this.FuncParamB);

   	this.FuncParamA = null;
   	this.FuncParamB = null;
}

StateMgr.Stop_List_Plus_State = function(flagReturn){
	
	this.PopupInfo.prevState = this.PopupInfo.curState;
	this.PopupInfo.curState = -1;
	
	this.preSubState = this.currentSubState;
	
	alert("***** Stop_List_Plus_State = old [" +  this.preSubState + "]");
	
	this.currentSubState = "";
	alert("***** Stop_List_Plus_State = new [" +  this.currentSubState + "]");
	
	WndMgr.HideListPlus();
	
	if(flagReturn==true)
	{
		this.ReturnState();
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////  Noti State  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


StateMgr.initNotiState = function(){

    this.NotiInfo = new Object();
    this.NotiInfo.stateList = new Array(NOTI_STATE.MAX_NOTI_STATE);
    this.NotiInfo.prevState = -1;
    this.NotiInfo.curState = -1;
    this.NotiInfo.waitState = -1;
    
    var c=0;
    for(c=0; c<NOTI_STATE.MAX_NOTI_STATE; c++)
    {
    	alert("initNotiState >> " + c);
        this.NotiInfo.stateList[c] = new Object();
        this.NotiInfo.stateList[c].flag_Loaded_state = false;
    }
    
    this.NotiInfo.stateList[NOTI_STATE.INCOMING_CALL].id = "IncomingCall";
    this.NotiInfo.stateList[NOTI_STATE.INCOMING_CALL].flag_Loaded_state = true;
	this.NotiInfo.stateList[NOTI_STATE.CONTEXT_LOADING].id = "ContextLoading";
	this.NotiInfo.stateList[NOTI_STATE.CONTEXT_LOADING].flag_Loaded_state = true;
            
    this.NotiInfo.stateList[NOTI_STATE.INCOMING_CALL].showFunc = function(){WndMgr.ShowIncomingCall();};
    this.NotiInfo.stateList[NOTI_STATE.INCOMING_CALL].hideFunc =  function(){WndMgr.HideIncomingCall();}; 

    this.NotiInfo.stateList[NOTI_STATE.CONTEXT_LOADING].showFunc = function(){WndMgr.ShowContextLoading();};
    this.NotiInfo.stateList[NOTI_STATE.CONTEXT_LOADING].hideFunc =  function(){WndMgr.HideContextLoading();}; 
    
}

StateMgr.Start_Noti_State = function(curState) {

	if(this.NotiInfo.curState == curState)
	{
		alert("error --> curState = " + curState);
		return;
	}
    
    alert("***** Start_Noti_State = " + this.NotiInfo.stateList[curState].id);
    
    if(this.NotiInfo.stateList[curState].flag_Loaded_state == false)
    {    
        utill_LoadMode(this.NotiInfo.stateList[curState].id, function() {

            StateMgr.NotiInfo.stateList[curState].flag_Loaded_state = true;            
			StateMgr.Show_Noti_State(curState);
        });
    }
    else{
        this.Show_Noti_State(curState);
    }
}


StateMgr.Show_Noti_State = function(State){

	alert("StateMgr.Show_Noti_State >> " + State);

    // WndMgr.HideTextEditor();
	WndMgr.HideOneBottonPopup();
	// WndMgr.HideKeypad();
		
	alert("NotiInfo.curState = " + this.NotiInfo.curState);
	
    //only one noti state. so do not check preve noti state!!!!!
	//hide pre noti
	this.NotiInfo.prevState = this.NotiInfo.curState;
	if(this.NotiInfo.prevState >= 0 && this.NotiInfo.stateList[this.NotiInfo.prevState] != null)
	{
		if(this.NotiInfo.stateList[this.NotiInfo.prevState].hideFunc)
		{
    		this.NotiInfo.stateList[this.NotiInfo.prevState].hideFunc();
    	}
	}	
	
	//show cur noti
    if(State >= 0 && this.NotiInfo.stateList[State] != null)
    {
    	if(this.NotiInfo.stateList[State].showFunc)
    	{
			this.NotiInfo.curState = State;	
		    this.NotiInfo.stateList[State].showFunc();
		}
    }
    
}

//never call in function
StateMgr.Stop_Noti_State = function() {
	    
	this.Hide_Noti_State();
    
    alert("StateMgr.Stop_Noti_State");
    

	var curStateIndex = this.PopupInfo.curState;
	alert("curStateIndex = " + curStateIndex);
		
	//return focus
    //only one noti state. so do not check preve noti state!!!!!
    if(curStateIndex >= 0 && this.PopupInfo.stateList[curStateIndex] != null)
    {
    	alert("stateList is not null!!");
    	if(this.PopupInfo.stateList[curStateIndex].focusFunc)
    	{
    		alert("process sub-state to focus");
    		this.PopupInfo.stateList[curStateIndex].focusFunc();
    		WndMgr.restartPopupHideTimer();
    	}
    }
    else
    {
    	if(WndMgr.isShowTextEditor == true)
    	{
    		WndMgr.ReturnTextEditor();
    	}
    	else
    	{
    		this.ReturnToMainState();
    	}
    	
    }    
}

StateMgr.Hide_Noti_State = function(){

    alert("StateMgr.Hide_Noti_State");
    
    var curStateIndex = this.NotiInfo.curState;
    
	if(curStateIndex >= 0 && this.NotiInfo.stateList[curStateIndex] != null)
	{
		if(this.NotiInfo.stateList[curStateIndex].hideFunc)
		{
    		this.NotiInfo.stateList[curStateIndex].hideFunc();
    	}
	    this.NotiInfo.curState = -1;
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////// Return  State  ////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

StateMgr.ReturnToMainState = function()
{
	alert("StateMgr.ReturnToMainState");
    WndMgr.HideTextEditor();
	WndMgr.HideOneBottonPopup();
	WndMgr.HideKeypad(); 
    
    if(this.currentSubState.length != 0)
    {
        this.StopSubState();
    }
    
    StateMgr.ReturnState(); 
}

StateMgr.ReturnState = function()
{
	alert("***** ReturnState");
	
	switch(this.currentState)
	{     
		case "Main": 
			WndMgr.ReturnMain();
			break;

		case "Calling":
			WndMgr.ReturnCalling(); 
			break;
		
		case "VideoCall":     
			WndMgr.ReturnVideoCall();
			break;
		
		case "ConferenceCall":     
			WndMgr.ReturnConferenceCall();
			break;
		
		case "SkypeOutCall":     
			WndMgr.ReturnSkypeOutCall();
			break;
		
		case "Chat":     
			WndMgr.ReturnChat();
			break;
		
		case "VideoSnapshot":     
			WndMgr.ReturnVideoSnapshot();
			break;
			
		case "Welcome": 
			WndMgr.ReturnWelcome(); 
			break;	
			
		case "Signin": 	
			WndMgr.ReturnSignin() 
			break;
			
		case "CreateAccount":     
			WndMgr.ReturnCreateAccount();
			break;	
			
		case "CameraCheckConnected":     
			WndMgr.ReturnCameraCheckConnected();
			break;	
		
		case "CameraCheckDisconnected":     
			WndMgr.ReturnCameraCheckDisconnected();
			break;		
			
		case "CreateAccountSuccess":
			WndMgr.ReturnCreateAccountSuccess();
			break;	
			
		case "FaceRecogSignin":
			WndMgr.ReturnFaceRecogSignin();
			break;
			
		case "FaceRecogRegistration":
			WndMgr.ReturnFaceRecogRegistration();
			break;	
	
		case "VoiceMail":
			WndMgr.ReturnVoiceMail(); 
			break;    			

		case "CallCameraControl":
			WndMgr.ReturnCallCameraControl(); 
			break;    
	
	}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// Stop Pre State   //////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
StateMgr.StopPreState = function() {

	alert("***** StopPreState");
	  	
	//check by lee dong hee
	this.Hide_Noti_State();	

    if(this.currentSubState.lenght != 0)
    {
        this.StopSubState();
    }
    
    this.StopState(this.preState);
}

StateMgr.StopState = function(Sate) {
	
	alert("***** StateMgr.StopState >>>" + Sate);
		
    switch(Sate)
    {
       case "Init":     
            this.Stop_Init_State(); 
            break;
              
        case "Main":     
            this.Stop_Main_State(); 
            break;

		case "Calling":
			this.Stop_Calling_State(); 
			break;
            
        case "VideoCall":     
            this.Stop_Video_Call_State(); 
            break;
            
        case "ConferenceCall":     
            this.Stop_Conference_Call_State(); 
            break;
            
        case "SkypeOutCall":     
            this.Stop_Skype_Out_Call_State(); 
            break;
            
         case "Chat":     
            this.Stop_Chat_State(); 
            break;

        case "VideoSnapshot":     
            this.Stop_Video_Snapshot_State(); 
			
			break;
		
		case "Welcome": 
			this.Stop_Welcome_State(); 
			break;
			
		case "Signin": 
            if(this.currentState == "Main" || this.currentState == "CameraCheckConnected" || this.currentState == "CameraCheckDisconnected")
            {
                WndMgr.DestroySignin();  //init 
                if(this.MainStateList[MAIN_STATE.WELCOME].flagLoad == true)
                {
                	WndMgr.DestroyWelcome();  //init 
                }
                
            }
			else if(this.currentState == "Welcome")
			{
				WndMgr.DestroySignin();  //init 
			}
			
            this.Stop_Signin_State(); 
            break;       
			
		case "CreateAccount":  
			//2013 modify by minseok  
		    if(this.currentState == "Main" || this.currentState == "CameraCheckConnected" || this.currentState == "CameraCheckDisconnected" || this.currentState == "CreateAccountSuccess")
            {
                WndMgr.DestroyCreateAccount();  //init 
                if(this.MainStateList[MAIN_STATE.WELCOME].flagLoad == true)
                {
                	WndMgr.DestroyWelcome();  //init 
                }
            }
			else if(this.currentState == "Welcome")
			{
				WndMgr.DestroyCreateAccount();  //init  
			}
			   
            this.Stop_Create_Account_State(); 
            break;	
			
		case "CameraCheckConnected":
			this.Stop_Camera_Check_Connected_State(); 
			break;	
			
		case "CameraCheckDisconnected":
			this.Stop_Camera_Check_Disconnected_State(); 
			break;
			
		case "CreateAccountSuccess":
			this.Stop_Create_Account_Success_State(); 
			break;	
			
		case "FaceRecogSignin":
			if(this.currentState == "Welcome")
            {
            	if(this.MainStateList[MAIN_STATE.SIGNIN].flagLoad == true)
                {
                	WndMgr.DestroySignin();  //init 
                }
            }
			this.Stop_Face_Recog_Signin_State(); 
			break;
			
		case "FaceRecogRegistration":
			this.Stop_Face_Recog_Registration_State(); 
			break;

		case "VoiceMail":
			this.Stop_Voice_Mail_State(); 
			break;    
			
		case "CallCameraControl":
			this.Stop_Call_Camera_Control_State(); 
			break; 
		case "GuidePage":
			this.Stop_Guide_Page_State();
			break;
			
    }
}

StateMgr.Stop_Init_State = function(){
    alert("***** Stop_Init_State =  [" +  this.preState + "]");
    
    WndMgr.HideInit();
}

StateMgr.Stop_Main_State = function(){
    alert("***** Stop_Main_State =  [" +  this.preState + "]");
    
    WndMgr.HideMain();
}


StateMgr.Stop_Video_Call_State = function()
{
    alert("***** Stop_Video_Call_State =  [" +  this.preState + "]");
    
    
    WndMgr.HideVideoCall();
}

StateMgr.Stop_Conference_Call_State = function()
{
    alert("***** Stop_Conference_Call_State =  [" +  this.preState + "]");
    
    WndMgr.HideConferenceCall();
}

StateMgr.Stop_Skype_Out_Call_State = function()
{
    alert("***** Stop_Skype_Out_Call_State =  [" +  this.preState + "]");
    
    WndMgr.HideSkypeOutCall();
}

StateMgr.Stop_Chat_State = function()
{
    alert("***** Stop_Chat_State =  [" +  this.preState + "]");
    
    WndMgr.HideChat();
}

StateMgr.Stop_Video_Snapshot_State = function()
{
    alert("***** Stop_Video_Snapshot_State =  [" +  this.preState + "]");
    
    WndMgr.HideVideoSnapshot();
}

StateMgr.Stop_Welcome_State = function()
{
    alert("***** Stop_Welcome_State =  [" +  this.preState + "]");
    
    WndMgr.HideWelcome();
}

StateMgr.Stop_Signin_State = function(){
    alert("***** Stop_Signin_State =  [" +  this.preState + "]");
    
    WndMgr.HideSignin();
}

StateMgr.Stop_Create_Account_State = function()
{
    alert("***** Stop_Create_Account_State =  [" +  this.preState + "]");
    
    WndMgr.HideCreateAccount();
}

StateMgr.Stop_Camera_Check_Connected_State = function()
{
    alert("***** Stop_Camera_Check_Connected_State =  [" +  this.preState + "]");
    
    WndMgr.HideCameraCheckConnected();
}

StateMgr.Stop_Camera_Check_Disconnected_State = function()
{
    alert("***** Stop_Camera_Check_Disconnected_State =  [" +  this.preState + "]");
    
    WndMgr.HideCameraCheckDisconnected();
}

StateMgr.Stop_Create_Account_Success_State = function()
{
    alert("***** Stop_Create_Account_Success_State =  [" +  this.preState + "]");
    
    WndMgr.HideCreateAccountSuccess();
}

StateMgr.Stop_Face_Recog_Signin_State = function()
{
    alert("***** Stop_Face_Recog_Signin_State =  [" +  this.preState + "]");
    
    WndMgr.HideFaceRecogSignin();
}

StateMgr.Stop_Face_Recog_Registration_State = function()
{
    alert("***** Stop_Face_Recog_Registration_State =  [" +  this.preState + "]");
    
    WndMgr.HideFaceRecogRegistration();
}

StateMgr.Stop_Calling_State = function(){
    
    alert("***** Stop_Calling_State = old [" +  this.preState + "]");

    WndMgr.HideCalling();
}


StateMgr.Stop_Voice_Mail_State = function(){
    
    alert("***** Stop_Voice_Mail_State = old [" +  this.preState + "]");
    
    WndMgr.HideVoiceMail();
    
}

StateMgr.Stop_Call_Camera_Control_State = function(){
    
    alert("***** Stop_Call_Camera_Control_State = old [" +  this.preState + "]");
    
    WndMgr.HideCallCameraControl();
    
}

StateMgr.Stop_Guide_Page_State = function(){

    alert("***** Stop_Guide_Page_State = old [" +  this.preState + "]");

    WndMgr.HideGuidePage();
    
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////Stop Sub State///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


StateMgr.StopSubState = function() {
	
    alert("***** StateMgr.StopSubState");
	
    switch(this.currentSubState)
    {
		case "AddContact":
			this.Stop_Add_Contact_State(); 
			break;   
		
		case "RemoveContact":
			this.Stop_Remove_Contact_State(); 
			break;   
		
		case "OnlineStatus":
			this.Stop_Online_Status_State(); 
			break;
		
		
		case "ChangePicture":
			this.Stop_Change_Picture_State(); 
			break;
		
		case "ChangePassword":
			this.Stop_Change_Password_State(); 
			break;  
		
		case "CallEnding":
			this.Stop_Call_Ending_State(); 
			break;     
		
		case "Volume":
			this.Stop_Volume_Speaker_State(); 
			break;
		
		case "Signout":     
			this.Stop_Signout_State(); 
			break;

		case "ListMainToolList":     
			this.Stop_List_Tools_State(); 
			break;
						
		case "ViewProfile":     
			this.Stop_View_Profile_State(); 
			break;	
			
		case "Rename":     
			this.Stop_Rename_State(); 
			break;
			
		case "Block":     
			this.Stop_Block_State(); 
			break;		
			
		case "Remove":     
			this.Stop_Remove_State(); 
			break;
									
		case "CallConfirmPopup":     
			this.Stop_Call_Confirm_State();
			break;
			
		case "CallSettingPopup":     
			this.Stop_Call_Setting_State(); 
			break;
			
		case "CameraLightAdjControl":
			this.Stop_Camera_Adjust_State(); 
			break;
			
		case "ForgotPassword":   	
			this.Stop_Forgot_Pwd_State();
			break;	
			
		case "Exit":     
			this.Stop_Exit_State(); 
			break;	

		case "AddAssignedPhoneNumber":     
			this.Stop_Add_Phone_Number_State(); 
			break;	
			
		case "ChangePhoneNumber":     
			this.Stop_Change_Phone_Number_State(); 
			break;	
			
		case "ChangePhoneNumberSelect":     
			this.Stop_Change_Phone_Number_Select_State(); 
			break;	
			
		case "AccountManager":     
			this.Stop_Account_Manager_State(); 
			break;	

		case "Gender":
			this.Stop_Gender_State();
			break;
		case "BirthDate":
			this.Stop_BirthDate_State();
			break;
		case "ProfilePhoneNumberSet":
			this.Stop_ProfilePhoneNumberSet_State();
			break;
		case "SettingsGeneral":
			this.Stop_SettingsGeneral_State();
			break;
		case "SettingsFaceRecognition":
			this.Stop_SettingsFaceRecognition_State();
			break;
		case "SettingsVideo":
			this.Stop_SettingsVideo_State();
			break;
		case "SettingsPrivacy":
			this.Stop_SettingsPrivacy_State();
			break;
		case "SettingsBlockedContacts":
			this.Stop_SettingsBlockedContacts_State();
			break;
		case "SettingsCallForwarding":
			this.Stop_SettingsCallForwarding_State();
			break;
		case "SettingsVoicemail":
			this.Stop_SettingsVoicemail_State();
			break;
		case "SettingsVoicemailUnable":
			this.Stop_SettingsVoicemailUnable_State();
			break;
		case "SettingsAboutSkype":
			this.Stop_SettingsAboutSkype_State();
			break;
		case "ListMainPlusList":     
			this.Stop_List_Plus_State(); 
			break;	
    }
}

//////Stop Pre Sub State///////////////////////////////////////////////////////////////////////////////////////////////////

StateMgr.StopPreSubState = function() {
    
	alert("StateMgr.StopPreSubState");
    
    WndMgr.HideTextEditor();
	WndMgr.HideOneBottonPopup();
	WndMgr.HideKeypad();
    
    if(this.preSubState.length ==0)
    {
            return;
    }
    
    var nextSubState = this.currentSubState;
    
    switch(this.preSubState)
    {
		case "AddContact":
			this.Stop_Add_Contact_State(); 
			break;    
		
		case "RemoveContact":
			this.Stop_Remove_Contact_State(); 
			break;   			
		
		case "OnlineStatus":
			this.Stop_Online_Status_State(); 
			break; 
		
		
		case "ChangePicture":
			this.Stop_Change_Picture_State(); 
			break; 
		
		case "ChangePassword":
			this.Stop_Change_Password_State(); 
			break;  
		
		
		case "CallEnding":
			this.Stop_Call_Ending_State(); 
			break;     
		
		case "Volume":
			this.Stop_Volume_Speaker_State(); 
			break;
				
		case "Signout":     
			this.Stop_Signout_State(); 
			break;
		
		case "ListMainToolList":     
			this.Stop_List_Tools_State(); 
			break;
			
		case "ViewProfile":     
			this.Stop_View_Profile_State(); 
			break;
		
		case "Rename":     
			this.Stop_Rename_State(); 
			break;
			
		case "Block":     
			this.Stop_Block_State(); 
			break;								

		case "Remove":     
			this.Stop_Remove_State(); 
			break;
			
		case "CallConfirmPopup":     
			this.Stop_Call_Confirm_State(); 
			break;

		case "CallSettingPopup":     
			this.Stop_Call_Setting_State(); 
			break;	
			
		case "CameraLightAdjControl":     
			this.Stop_Camera_Adjust_State(); 
			break;				
			
		case "ForgotPassword":   	
			this.Stop_Forgot_Pwd_State();
			break;	
			
		case "Exit":     
			this.Stop_Exit_State(); 
			break;

		case "AddAssignedPhoneNumber":     
			this.Stop_Add_Phone_Number_State(); 
			break;	
			
		case "ChangePhoneNumber":     
			this.Stop_Change_Phone_Number_State(); 
			break;	
			
		case "ChangePhoneNumberSelect":     
			this.Stop_Change_Phone_Number_Select_State(); 
			break;	
			
		case "AccountManager":     
			this.Stop_Account_Manager_State(); 
			break;	
		case "Gender":
			this.Stop_Gender_State();
			break;
		case "BirthDate":
			this.Stop_BirthDate_State();
			break;
		case "ProfilePhoneNumberSet":
			this.Stop_ProfilePhoneNumberSet_State();
			break;
		case "SettingsGeneral":
			this.Stop_SettingsGeneral_State();
			break;
		case "SettingsFaceRecognition":
			this.Stop_SettingsFaceRecognition_State();
			break;
		case "SettingsVideo":
			this.Stop_SettingsVideo_State();
			break;
		case "SettingsPrivacy":
			this.Stop_SettingsPrivacy_State();
			break;
		case "SettingsBlockedContacts":
			this.Stop_SettingsBlockedContacts_State();
			break;
		case "SettingsCallForwarding":
			this.Stop_SettingsCallForwarding_State();
			break;
		case "SettingsVoicemail":
			this.Stop_SettingsVoicemail_State();
			break;
		case "SettingsVoicemailUnable":
			this.Stop_SettingsVoicemailUnable_State();
			break;	
		case "SettingsAboutSkype":
			this.Stop_SettingsAboutSkype_State();
			break;
		case "ListMainPlusList":     
			this.Stop_List_Plus_State(); 
			break;	
    }
    
    this.currentSubState = nextSubState;
}
