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

EventMgr ={

	WidgetName : "Skype",
	isHighlight : true
}

EventMgr.initEvent = function()
{
    alert("***** EventMgr.initEvent ()");
// 
    PluginAPIMgr.MoIPPlugin.OnEvent = OnSkypeEvent;
	PluginAPIMgr.CameraPlugin.OnEvent = OnCameraEvent;
	
	PluginAPIMgr.RecognitionPlugin.OnEvent = OnRecogEvent;
	
	curWidget.onWidgetEvent = OnWidgetEngineEvent;
	
	//for number input by Smart control 
	//PluginAPIMgr.AppCommonPlugin.OnEvent = OnAppCommonEvent;
	
	//virtual event
	// curWidget.onWidgetEvent = receiveEvent;
}

function OnWidgetEngineEvent(event)
{
	alert("OnWidgetEngineEvent event.type : "+event.type);

	if(event.type == 10502)
	{
		alert("EVENT_MOUSE_STATE_SHOW");
		WndMgr.SetFlagMouseCusorShow(true);
		WndMgr.ShowReturnIcon();
	}
	
	if(event.type == 10503)
	{
		alert("EVENT_MOUSE_STATE_HIDE");
		WndMgr.SetFlagMouseCusorShow(false);
		WndMgr.HideReturnIcon();
		if(StateMgr.MainStateList[MAIN_STATE.MAIN].flagLoad){
		var scene = sf.scene.get("ListMain");
		if(scene){
			scene.InitMouseOver();
		} 
		}
		WndMgr.HideTabOverImage();
	}	
	if(event.type == 47)
	{
		alert("LOSE HIGHLIGHT");
		EventMgr.isHighlight = false;
		WndMgr.ShowWidgetDimBG();
		WndMgr.HideMouseArrow();
	}
	if(event.type == 48)
	{
		alert("SET HIGHLIGHT");
		EventMgr.isHighlight = true;
		WndMgr.HideWidgetDimBG();
	}
	
}

function OnAppCommonEvent(prop, szData, param)
{
	alert("OnAppCommonEvent");
	alert("prop = " + prop );
	alert("szData = " + szData );	
	
    var rlt = szData.split("/", 2);

    rlt[0] = Number(rlt[0]);
    rlt[1] = Number(rlt[1]);
   
    //g_NumObj.processNumberKey(rlt[1]);
    event.preventDefault();
    //sf.key.preventDefault();
}


function OnRecogEvent(eventType, strEvent, Result)
{
	alert("OnRecogEvent");
	alert("eventType = " + eventType );
	alert("strEvent = " + strEvent );
	alert("Result = " + Result );	
	
	switch( parseInt(eventType) )
	{
		case 6510: //MESSAGE_RECOGNITION_VOICE
			RecogMgr.OnVoiceRecogEvent(strEvent, Result);
			break;
	
	    case 6511: //MESSAGE_RECOGNITION_GESTURE
			if(strEvent == 'EVENT_GESTURE_2HAND_ZOOM-Skype')
			{
				WndMgr.GestureZoomInOut(Result);
			}
			else if(strEvent == 'EVENT_GESTURE_SECONDARY_DETECT-Skype')
			{
				WndMgr.StartGestureZoom();
			}
			else if(strEvent == 'EVENT_GESTURE_SECONDARY_LOST-Skype')
			{
				WndMgr.StopGestureZoom();
			}
			break;
	
		case 6512: //MESSAGE_RECOGNITION_FACE
			RecogMgr.OnFaceRecogEvent(strEvent, Result);
			break;
	
	  	default:
	   		break;
   	}
}

function OnSkypeEvent(eventType, data1, data2)
{
	alert("OnSkypeEvent");
	alert("eventType = " + eventType );
	alert("data1 = " + data1 );
	alert("data2 = " + data2 );	
	
	var intEventType = parseInt(eventType);
	if(intEventType < 100000)
	{
		SkypeWidgetType = intEventType - 0x100;  // for excluding hardwired event
	}
	else
	{
		SkypeWidgetType = intEventType;
	}
	
	if(SkypeWidgetType >= 0)
	{
		if(SkypeWidgetType== ENUM_EVENT_TYPE.CALL_DURATION)
		{
			OnSkypeDurationCB(parseInt(data1));
		}
		else
		{
			OnSkypeEventCB(parseInt(SkypeWidgetType), data1, data2);
		}	
	}
}

function OnSkypeEventCB(data, param1, param2){
	if(typeof(EVENT_TYPE[data]) !== 'undefined')
	{
		alert("@@@@@@ OnSkypeEventCB data = [" + data + "] : " + EVENT_TYPE[data]);
	}
			
	if (data == ENUM_EVENT_TYPE.SKYPE_LOADED) //115
	{
		ProcMgr.StartWidget();
	}
	
	if (data == ENUM_EVENT_TYPE.LOGGED_IN) //0
	{
		ProcMgr.ReceivedLoggedIn();
	}
	
	if (data == ENUM_EVENT_TYPE.LOGGED_OUT) //1
	{
		ProcMgr.HandleLoggedOut();
	}
	
	if (data == ENUM_EVENT_TYPE.FIRST_CBL_IN_SYNC) //15
	{
		ProcMgr.ReceivedCblSync();
	}
	
	if (data == ENUM_EVENT_TYPE.CONTACTLIST ||
	data == ENUM_EVENT_TYPE.CONTACT_AVAILABILITY) //2
	{
        if(StateMgr.MainStateList[MAIN_STATE.MAIN].flagLoad == true && 
			WndMgr.GetMainSubIndex() == 0)
        {
            var scene = sf.scene.get("ListMainContact");
            scene.Refresh();
         }
		 
		 ProcMgr.CallandChatMemberUpdate();
	}
	//voice recognition!!!
	if (data == ENUM_EVENT_TYPE.GOTO_CONTACT ) //2
	{
		alert(">>>>>>>> process GOTO_CONTACT");
				
		if(ProcMgr.isCalling == true)
		{
			return;	
		}				
		//stop SubState
		StateMgr.ReturnToMainState();
		
		//Change Main state
		if(StateMgr.GetCurrentState() != "Main")
		{
			StateMgr.Start_Main_State();	
		}	
		
		var ListMain = sf.scene.get("ListMain");
		ListMain.gotoContact();

        var ListMainContact = sf.scene.get("ListMainContact");
        ListMainContact.RefreshForIndex(parseInt(param1));
        		 
	}
	
		
	if (data == ENUM_EVENT_TYPE.ACCOUNT_AVATAR_IMAGE) //88
	{
		ProcMgr.AccountAvataImageChanged();
	}
	
	if (data == ENUM_EVENT_TYPE.ACCOUNT_SKYPEOUT_BALANCE) //89
	{
		ProcMgr.AccountCreditChanged();
	}
	
	if (data == ENUM_EVENT_TYPE.ACCOUNT_AVAILABILITY) //90
	{
		ProcMgr.AccountAvailabilityChanged();
	}
	
	if (data == ENUM_EVENT_TYPE.ACCOUNT_MOOD_TEXT) //91
	{
		ProcMgr.AccountMoodMsgChanged();
	}
	
	if (data == ENUM_EVENT_TYPE.CONTACT_REMOVED) //3
	{
		//when block & removed
		//event order : remove ==> Blocked
		if(WndMgr.GetStepOfRemoveContact() == "RemovingContact"){
		
		 	var Scene = sf.scene.get(WndMgr.GetMainSubSceneID());
			var Display_name = Scene.list.GetCurDisplayName();
			var Identity_name	= Scene.list.GetCurIdentityName();

			WndMgr.NextStepRemoveContact(Identity_name, Display_name);	
		}		
	}
	
	if (data == ENUM_EVENT_TYPE.CONTACT_BLOCKED) //4
	{
		ProcMgr.Blocked();	
	}
	
	if (data == ENUM_EVENT_TYPE.CONTACT_UNBLOCKED) //32
	{
		ProcMgr.UnBlocked();
	}
	
	if (data == ENUM_EVENT_TYPE.RING_OUT) //6
	{
		WndMgr.UpdateCallingStatus(ENUM_CALL_STATUS.RINGING_OUT);
		ProcMgr.UpdateCallMemberStatus();	
	}
	
	if (data == ENUM_EVENT_TYPE.LOCALHOLD) //8
	{
		ProcMgr.LocalHold();
	}
	
	if (data == ENUM_EVENT_TYPE.REMOTEHOLD) //9
	{
		ProcMgr.RemoteHold();
	}
	
	if (data == ENUM_EVENT_TYPE.FINISHED) //12
	{
		WndMgr.UpdateCallingStatus(ENUM_CALL_STATUS.FINISHED);
	}
	
	if (data == ENUM_EVENT_TYPE.REFUSED) //13
	{
		if(ProcMgr.callEndWaitingTimer == false)
		{
			WndMgr.UpdateCallingStatus(ENUM_CALL_STATUS.REFUSED);
		}	
	}
	
    if (data == ENUM_EVENT_TYPE.DROPPED) //21 
   {
          ProcMgr.DropCall(); 
   }
	
	if (data == ENUM_EVENT_TYPE.FAILED) //18
	{
		if (ProcMgr.isCallCencel == true) {
			WndMgr.UpdateCallingStatus(ENUM_CALL_STATUS.CANCELLED);
			ProcMgr.isCallCencel = false; //init
		}
		else {
			WndMgr.UpdateCallingStatus(ENUM_CALL_STATUS.FAILED);
		}
	}
	
	if (data == ENUM_EVENT_TYPE.CALL_BEING_FORWARDED) {
		WndMgr.UpdateCallingStatus(ENUM_CALL_STATUS.CALL_BEING_FORWARDED);
	}
	
	if (data == ENUM_EVENT_TYPE.INPROGRESS) //7   
	{
		ProcMgr.InprogressCall();
	}
	
	if (data == ENUM_EVENT_TYPE.INCOMING_CALL) //11
	{
		ProcMgr.IncomingCall();
	}
	
	if (data == ENUM_EVENT_TYPE.CONFERENCE_CALL) //33
	{
		ProcMgr.IncomingConferenceCall();
	}
	
	if (data == ENUM_EVENT_TYPE.CONFERENCE_CALL_END) //35
	{
		ProcMgr.EndCall();
	}
	
	if(data == ENUM_EVENT_TYPE.CALL_END_BY_CALLMEMBER)
	{
		WndMgr.CloseVideoCallRect();
	}
	
	if (data == ENUM_EVENT_TYPE.CALL_END_DISPLAYED)
	{
        if (ProcMgr.isVoiceMailSending == true) 
        {
			ProcMgr.EndVoiceMail();
		}
		else
		{
			ProcMgr.EndCall();
		}		
	}
	
	if (data == ENUM_EVENT_TYPE.CHANGE_TO_CONFERENCE_CALL) //85
	{
		ProcMgr.ChangeToConferenceCall();
	}
	
	if (data == ENUM_EVENT_TYPE.UPDATE_MEMBER_STATUS) //87
	{
		ProcMgr.UpdateCallMemberStatus();
	}
	if (data == ENUM_EVENT_TYPE.CALLMEMBER_VIDEO_AVAILABLE ) //95
	{
		ProcMgr.isVideoAvailable=true;	
		if(ProcMgr.isCalling==false)
		{
			return;	
		}
		else
		{
			ProcMgr.ProcessReceiveVideo();	
		}		 
	}
	//data == ENUM_EVENT_TYPE.CALLMEMBER_VIDEO_STARTING 
	if (data == ENUM_EVENT_TYPE.CALLMEMBER_VIDEO_RUNNING) //96 ,98
	{
		//alert('CALLMEMBER_VIDEO_STARTING || CALLMEMBER_VIDEO_RUNNING');
		if(ProcMgr.isCalling==true)
		{
			ProcMgr.StartReceiveVideo();
		}
	}
	
	if (data == ENUM_EVENT_TYPE.CALLMEMBER_VIDEO_STOPPING || data == ENUM_EVENT_TYPE.CALLMEMBER_VIDEO_NOT_AVAILABLE) //94 ,99
	{
		if(ProcMgr.isCalling==true)
		{
			ProcMgr.StopReceiveVideo();
		}
        
	}
	
	if (data == ENUM_EVENT_TYPE.CALLMEMBER_VIDEO_PAUSED) //100
	{
		if(ProcMgr.isCalling==true)
		{
			ProcMgr.isPauseVideo=true;
		}
        
	}
    
	if(data == ENUM_EVENT_TYPE.SD_VIDEO_RECEIVED) // 135,
    {

    }
    
	if(data == ENUM_EVENT_TYPE.HD_VIDEO_RECEIVED) // 136,
    {

    }
    
    if(data == ENUM_EVENT_TYPE.VIDEO_QUALITY_LEVEL_0)  // : 117,
    {
          ProcMgr.UpdateCallQuality(1);
    }
	if(data == ENUM_EVENT_TYPE.VIDEO_QUALITY_LEVEL_1)  //: 118,
   {
          ProcMgr.UpdateCallQuality(2);
    }
	if(data == ENUM_EVENT_TYPE.VIDEO_QUALITY_LEVEL_2)  // : 119,
    {
          ProcMgr.UpdateCallQuality(3);
    }
	if(data == ENUM_EVENT_TYPE.VIDEO_QUALITY_LEVEL_3)  // : 120,
    {
          ProcMgr.UpdateCallQuality(4);
    }
	if(data == ENUM_EVENT_TYPE.VIDEO_QUALITY_LEVEL_4)  // : 121,
    {
          ProcMgr.UpdateCallQuality(5);
    }
    	
	if (data == ENUM_EVENT_TYPE.CONTACT_SEARCH_FINISHED) //101
	{
		WndMgr.NextStepAddContact();
	}
	
	if (data == ENUM_EVENT_TYPE.CONTACT_SEARCH_FAILED) //102
	{
		ProcMgr.HandleSearchFailNewContact(OneBtnPopupIndex.CONTACT_SEARCH_FAILED);
	}
	
	if (data == ENUM_EVENT_TYPE.CONTACT_SEARCH_NOT_FOUND) {
		ProcMgr.HandleSearchFailNewContact(OneBtnPopupIndex.CONTACT_CANNOT_FOUND);
	}
	
	if (data == ENUM_EVENT_TYPE.CONTACT_PROFILE_SEARCH_FINISHED) //103
	{
		WndMgr.NextStepAddContact();
	}
	
	if (data == ENUM_EVENT_TYPE.AUTHORIZATION_REQUEST) {
		
	}
	
	if (data == ENUM_EVENT_TYPE.INCOMING_VOICE_MAIL) {
		
	}
	
	if (data == ENUM_EVENT_TYPE.UPDATE_CHAT) {
		ProcMgr.UpdateChat();
	}
	
	if (data == ENUM_EVENT_TYPE.NEW_CHAT_MESSAGE) {
		ProcMgr.NewChat();
	}

	if (data == ENUM_EVENT_TYPE.UPDATE_UNREAD_CHAT_NUM) {
		//dWndMgr.UpdateNewChatMsg();
	}	
	
	if (data == ENUM_EVENT_TYPE.CHATMEMBER_CHANGE) {
		ProcMgr.UpdateChatMember();
	}	
	
	//TEMPCODE:
	if (data == ENUM_EVENT_TYPE.HISTORYLIST) {

		ProcMgr.UpdateHistoryList();
	}
	 
    if(data==ENUM_EVENT_TYPE.PWD_OK )//: 65
    {
    	ProcMgr.SaveChangedPassword();
        ProcMgr.HandleChangePassword( OneBtnPopupIndex.PWD_OK);
    }
        
    if(data==ENUM_EVENT_TYPE.PWD_INVALID_OLD_PASSWORD)// : 67,
    {
         ProcMgr.HandleChangePassword( OneBtnPopupIndex.PWD_INVALID_OLD_PASSWORD);
    }
    
    if(data==ENUM_EVENT_TYPE.PWD_MUST_DIFFER_FROM_OLD)// : 70,
    {
         ProcMgr.HandleChangePassword( OneBtnPopupIndex.PWD_MUST_DIFFER_FROM_OLD);
    }
    if(data==ENUM_EVENT_TYPE.PWD_INVALID_NEW_PWD) // : 71, 
    {
         ProcMgr.HandleChangePassword( OneBtnPopupIndex.PWD_INVALID_NEW_PWD);
    }
    
    if(data==ENUM_EVENT_TYPE.PWD_SERVER_CONNECT_FAILED || data==ENUM_EVENT_TYPE.PWD_OK_BUT_CHANGE_SUGGESTED || data==ENUM_EVENT_TYPE.PWD_MUST_LOG_IN_TO_CHANGE)// : 68, 
    {
         ProcMgr.HandleChangePassword( OneBtnPopupIndex.PWD_SERVER_CONNECT_FAILED);
    }
    
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_1)// : 104, //1000, 6009, 6113, 6519, 8401, 9502, 10408, 10420, 10480, 10482, 10486, 10487, 10500, 10502, 10503, 10504, 10600, 10603, 10686
   {
        //test call +9900013721000
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_1);
   }
    if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_2)// : 105, //6423
    {
        //test call +9900013726423
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_2);
    }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_3)// : 106, //9401
     {
        //test call +9900013729401
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_3);
     }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_4 )//: 107, //9402
    {
        //test call +9900013729402
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_4);
    }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_5)// : 108, //9403, 9407, 9408
    {
        //test call +9900013729403
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_5);
    }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_6)// : 109, //9409
    {              
        //can not reproduce 
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_6);
    }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_7) // : 110, //10403
    {
        //test call +99000137210403
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_7);
    }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_8) //: 111, //10404
    {
        //test call +99000137210404
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_8);
    }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_9) // : 112, //10484
    {
        //test call +99000137210484
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_9);
    }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_10)// : 113, //10604
    {
        //test call +99000137210604
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_10);
    }
     if(data==ENUM_EVENT_TYPE.SKYPEOUT_FAIL_REASON_11)// : 114, //13406
    {
        //emergency call
        ProcMgr.ProcessCallingFail(ENUM_CALL_STATUS.SKYPEOUT_FAIL_REASON_11);
    }

///////// voice mail  play////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	if(data==ENUM_EVENT_TYPE.VOICEMAIL_BUFFERING)
	{
		var scene = sf.scene.get("ListMainHistory");		
		if(scene){			
			scene.ProcessVM(ENUM_VOICE_MAIL_STATUS.BUFFERING);	
		}		
	}
	if(data==ENUM_EVENT_TYPE.VOICEMAIL_PLAYING)
	{
		var scene = sf.scene.get("ListMainHistory");
		if(scene){
			scene.ProcessVM(ENUM_VOICE_MAIL_STATUS.PLAYING);
		}
	}
	if(data==ENUM_EVENT_TYPE.VOICEMAIL_PLAYED)
	{
		var scene = sf.scene.get("ListMainHistory");
		if(scene){
			scene.ProcessVM(ENUM_VOICE_MAIL_STATUS.PLAYED);
		} 
	}
	if(data==ENUM_EVENT_TYPE.VOICEMAIL_UNPLAYED)
	{
		var scene = sf.scene.get("ListMainHistory");
		if(scene){
			scene.ProcessVM(ENUM_VOICE_MAIL_STATUS.UNPLAYED);
		}
	}		
	if(data==ENUM_EVENT_TYPE.VOICEMAIL_FAILED)
	{
		var scene = sf.scene.get("ListMainHistory");
		if(scene){
			scene.ProcessVM(ENUM_VOICE_MAIL_STATUS.FAILED);
		} 
	}
	if(data==ENUM_EVENT_TYPE.VOICEMAIL_DELETING)
	{
		var scene = sf.scene.get("ListMainHistory");
		if(scene){
			scene.ProcessVM(ENUM_VOICE_MAIL_STATUS.DELETING);
		}
	}
	if(data==ENUM_EVENT_TYPE.VOICEMAIL_DELETING_FAILED)
	{
		var scene = sf.scene.get("ListMainHistory");
		if(scene){
			scene.ProcessVM(ENUM_VOICE_MAIL_STATUS.DELETING_FAILED);
		}
	}		
	if(data==ENUM_EVENT_TYPE.VOICEMAIL_EMPTY)
	{
		var scene = sf.scene.get("ListMainHistory");
		if(scene){
			scene.ProcessVM(ENUM_VOICE_MAIL_STATUS.BLANK);
		}
	}
    
    ///////// voice mail  send////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if(data==ENUM_EVENT_TYPE.VOICE_MAIL_SENDING)
	{
        if(ProcMgr.isVoiceMailSending !=true)
        {
            ProcMgr.SendingVoiceMail();
        }
	}
    
    if(data==ENUM_EVENT_TYPE.VOICEMAIL_GREETING)
	{
        WndMgr.UpdateVoiceMailMessage(ENUM_CALL_STATUS.VM_PLAYING_GREETING);
	}
    
    if(data==ENUM_EVENT_TYPE.VOICEMAIL_RECORDING)
	{
        WndMgr.UpdateVoiceMailMessage(ENUM_CALL_STATUS.VM_RECORDING);
	}
	
    if(data==ENUM_EVENT_TYPE.VOICEMAIL_UPLOADING)
   	{
        WndMgr.UpdateVoiceMailMessage(ENUM_CALL_STATUS.VM_UPLOADING);
	}
	
    if(data==ENUM_EVENT_TYPE.VOICEMAIL_SENT)
    {
        WndMgr.UpdateVoiceMailMessage(ENUM_CALL_STATUS.VM_SENT);
	}
	
    if(data==ENUM_EVENT_TYPE.VOICEMAIL_CANCELLED)
    {
        WndMgr.UpdateVoiceMailMessage(ENUM_CALL_STATUS.VM_CANCELLED);
	}
	
    if(data==ENUM_EVENT_TYPE.VOICEMAIL_SEND_FAILED)
	{
        WndMgr.UpdateVoiceMailMessage(ENUM_CALL_STATUS.VM_SEND_FAILED);
	}
	
    if(data==ENUM_EVENT_TYPE.AUTHREQ_PROCESSED)
	{
		ProcMgr.ProcessAuthRequest();		
	}

    if(data==ENUM_EVENT_TYPE.AUTHREQ_IGNORED)
	{
		ProcMgr.IgnoreAuthRequest();		
	}
	// modify 9.12
 ///////// Settings///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
   if(data==ENUM_EVENT_TYPE.COMMIT_SUCCESS)  
    {
        alert("Commit success");
		var currentState = StateMgr.GetCurrentSubState();
		alert("EventManager.currentState = " +currentState);
        if(!(currentState =="SettingsPrivacy" ||currentState =="SettingsCallForwarding"))
        {
            return;
        }
        var this_ = sf.scene.get(currentState);
        alert("scene.waitingcommit = "+this_.waitingCommit );
        if(this_.waitingCommit ==true)
        {
            this_.waitingCommit =false; // init
            WndMgr.StopLoading();
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.OPTIONS_COMMITED);
        }
    }

    if(data==ENUM_EVENT_TYPE.COMMITTING_TO_SERVER)  
    {
        alert("Committing to server");
    }

    if(data==ENUM_EVENT_TYPE.COMMIT_FAILED)  
    {
        alert("Commit failed");
 		alert("EventManager.currentState = " +currentState);
      var currentState = StateMgr.GetCurrentSubState();
        if(!(currentState =="SettingsPrivacy" ||currentState =="SettingsCallForwarding"))
        {
            return;
        }
        var this_ = sf.scene.get(currentState);
         alert("scene.waitingcommit = "+this_.waitingCommit );
        if(this_.waitingCommit ==true)
        {
            this_.waitingCommit =false; // init
            WndMgr.StopLoading();
            WndMgr.StartOneBottonPopup(OneBtnPopupIndex.OPTIONS_COMMIT_FAILED);
        }
    }
	
	if(data>=ENUM_EVENT_TYPE.OSD_TIMER_EXPIRED_0 && data<=ENUM_EVENT_TYPE.OSD_TIMER_EXPIRED_4)
	{ 
		alert("OSD_TIMER_EXPIRED");
		var offset = data - ENUM_EVENT_TYPE.OSD_TIMER_EXPIRED_0;
		
		if(g_Data.DATA_OSD_TIMER_CALLBACK[offset])
		{
			g_Data.DATA_OSD_TIMER_CALLBACK[offset]();
			g_Data.DATA_OSD_TIMER_CALLBACK[offset] = null;
		}
	}
	if(data == ENUM_EVENT_TYPE.CREATE_CALL_REQUEST)
	{
		ProcMgr.CreateCall(param1, parseInt(param2));
	}
	if(data == ENUM_EVENT_TYPE.PREPARE_RUN_WIDGET)
	{
		if(param1 == '0'&& Flag_Shown_Complete == false)
		{
			ProcMgr.ContextLoading();
		}
	}
	if(data == ENUM_EVENT_TYPE.CALLMEMBER_REFUSE_RECEIVE_VIDEO)
	{
		ProcMgr.StopSendVideo();
	}
	if(data == ENUM_EVENT_TYPE.RESUME_NORMAL_MODE_VIDEO)
	{
		if(!ProcMgr.CallInfo.IsSpeakerMute)
		{
			alert("***IsSpeakerMute : false ");
			PluginAPIMgr.MuteSpeaker(ProcMgr.CallInfo.IsSpeakerMute);
		}
		else
		{
			alert("***IsSpeakerMute : true ");
		}
	}
		
	if(data >= 100000)
	{
		alert("Conf call member Activated");
		if(StateMgr.GetCurrentState()=="ConferenceCall")
		{
			sf.scene.get('ConferenceCall').updateActiveMemberInfo(data-100000,param1);
		}		
	}
		
}

function OnSkypeDurationCB(data)
{  
	var time = g_Data.TransDuration(data);	
    
        
    alert("@@@@@@ OnSkypeDurationCB data = [" + data + "]" + time);
    
    ProcMgr.UpdateCallDuration(time); 
    g_Data.SetCallDuration(time);
  
}

function OnCameraEvent(eventType, data1, data2)
{
	alert("OnCameraEvent");
	alert("eventType = " + eventType );
	alert("data1 = " + data1 );
	alert("data2 = " + data2 );	
    
    if(eventType == ENUM_CAM_EVENT_TYPE.CAM_EVENT_DISCONNECTED)
	{
        ProcMgr.UpdateCameraState();
        ProcMgr.InitEPTZState();	// camera changed
	}
	else if(eventType == ENUM_CAM_EVENT_TYPE.CAM_EVENT_CONNECTING)
	{
		WndMgr.UpdateMainCameraState();
	}
    else if(eventType == ENUM_CAM_EVENT_TYPE.CAM_EVENT_READY)
	{
		ProcMgr.InitCameraOption();
        ProcMgr.UpdateCameraState();
        ProcMgr.getCameraInfo();
        //140528 add minseok check camera model whether 14 or not
        ProcMgr.Check14CameraForKPILog();
	}
	else if(eventType == ENUM_CAM_EVENT_TYPE.CAM_EVENT_JPG_CAPTURED)
	{
	    var VideoSnaphotScene =  sf.scene.get("VideoSnapshot");
	    
	    if(VideoSnaphotScene != null)
		{
			VideoSnaphotScene.TrunOffKeyBlock();
		}
	}

}

function receiveEvent(pData){
	//alert("receiveEvent("+pData.type+")");

	if(pData.type == Common.API.EVENT_ENUM.LOSE_HIGHTLIGHT)
	{
		alert("Common.API.EVENT_ENUM.LOSE_HIGHTLIGHT");
		sf.scene.show('DeactivateClickEvent');		
	}
	else if (pData.type == Common.API.EVENT_ENUM.GET_HIGHTLIGHT)
	{
		alert("Common.API.EVENT_ENUM.LOSE_HIGHTLIGHT");
		sf.scene.hide('DeactivateClickEvent');
	}
}


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

var CAM_EVENT_TYPE =
[
	"CAM_EVENT_DISCONNECTED",
	"CAM_EVENT_CONNECTING",
	"CAM_EVENT_READY",
];


var EVENT_TYPE =[  
		"LOGGED_IN" ,                                                                       //0
		"LOGGED_OUT",
		"CONTACTLIST",
		"CONTACT_REMOVED",
		"CONTACT_BLOCKED",
		"CONTACT_VIEWDETAIL",
		"RING_OUT",
		"INPROGRESS",
		"LOCALHOLD",
		"REMOTEHOLD",
		"MUTED",                                                                              //10
		"INCOMING_CALL", 
		"FINISHED",
		"REFUSED",
		"REJECTED",
		"FIRST_CBL_IN_SYNC",
		"CBL_SYNC_FAILED",
		"AVAILABILITY_CHANGED",
		"FAILED",
		"MISSED",
		"BUSY",                                                                              //20
		"DROPPED", 
		"GET_CONTACT_FINISH",
		"QUIT_APP",
		"CALL_END_DISPLAYED",
		"SEARCH_FINISH",
		"AUTHORIZATION_REQUEST",
		"CALL_INITIATE", //for playing ringing sournd
		"CALL_CANCEL", //for stopping ringing sournd
		"SETTING_WND_CLOSED",
		"HISTORY_RESULT",                                                             //30 
		"CONTACT_VIEWPROFILE", 
		"CONTACT_UNBLOCKED",
		"CONFERENCE_CALL",
	 	"CONFERENCE_CALLMEMBER_UPDATE",
	 	"CONFERENCE_CALL_END",
	 	"SETTING_FINISHED",
	 	"SETTING_SAVE_QUERY",
		"INCOMING_VOICE_MAIL",
	 	"VOICE_MAIL_MY_GREETING", 
	 	"VOICE_MAIL_SENDING",  //40
	 	"CHANGE_VIDEO_CALL",
	 	"CHANGE_VOICE_CALL",
	 	"VIDEO_START_RENDERER",
	 	"CALLMEMBER_VIDEO_STATUS",
	 	"SETTING_SAVE_START",
	 	"CONTACT_GROUP_REFRESH",
	 	"CALL_END_BY_CALLMEMBER",
	 	"CALL_END_BY_ME",
	 	"CALL_REJECT_BY_ME", 
	 	"SHOW_CALL_FORWARDING_WARNING",  //50
	 	"CALL_DURATION",
	 	"CHANGE_ACCOUNT_INFO",
	 	"CALL_REDIRECT_VOICEMAIL",
	 	"CALL_BEING_FORWARDED",
	 	"CREATE_CALL",
	 	"BLOCKED_CALL_TRY",
	 	"PSTN_STATUS",
	 	"UPDATE_NETWORK_ERROR",
	 	"UPDATE_DATA_ERROR",
	 	"NO_UPGREADE_VERSION_IN_SERVER",  //60
	 	"UPDATE_SKYPE_INSTALL",
	 	"UPDATE_SKYPE_COMPLETE",	 	
	 	"UPDATE_SKYPE_CANCELED",
	 	"EXIT_WND_CLOSED",
		"PWD_OK",  
		"PWD_CHANGING",		
		"PWD_INVALID_OLD_PASSWORD", 
		"PWD_SERVER_CONNECT_FAILED", 
		"PWD_OK_BUT_CHANGE_SUGGESTED", 
		"PWD_MUST_DIFFER_FROM_OLD", //70
		"PWD_INVALID_NEW_PWD", 
		"PWD_MUST_LOG_IN_TO_CHANGE", 		
		"CAMERA_DISCONNECTED",
		"CAMERA_CONNECTED",
		"CAMERA_PLUGGED_IN",
		"VOICE_MAIL_REMOVE",
		"AV_QUALITY_STATUS",
		"CALL_TOTAL_DURATION",
		"HISTORY_CALL_RESULT",
		"HISTORY_VM_RESULT",  //80
		"SEND_VM_DURATION",
		"RECEIVE_VM_DURATION",
		"SEARCH_RESULT",
		"CONFERENCE_CALLMEMBER_ADD",
		"CHANGE_TO_CONFERENCE_CALL",
		"CHANGE_TO_NORMAL_VOICE_CALL",
	 	"UPDATE_MEMBER_STATUS",
        
		//new added event
		"ACCOUNT_AVATAR_IMAGE",
		"ACCOUNT_SKYPEOUT_BALANCE ",
		"ACCOUNT_AVAILABILITY ",  //90
		"ACCOUNT_MOOD_TEXT ",
        "INCOMING_PSTN",

		"CONTACT_AVAILABILITY ",
        
        "CALLMEMBER_VIDEO_NOT_AVAILABLE",
		"CALLMEMBER_VIDEO_AVAILABLE",
		"CALLMEMBER_VIDEO_STARTING ",
		"CALLMEMBER_VIDEO_REJECTED ",
		"CALLMEMBER_VIDEO_RUNNING ",
		"CALLMEMBER_VIDEO_STOPPING ",
		"CALLMEMBER_VIDEO_PAUSED ",  //100
        
        "CONTACT_SEARCH_FAILED",
		"CONTACT_SEARCH_FINISHED",
		"CONTACT_PROFILE_SEARCH_FINISHED",
        
        "SKYPEOUT_FAIL_REASON_1", 
		"SKYPEOUT_FAIL_REASON_2", 
		"SKYPEOUT_FAIL_REASON_3", 
		"SKYPEOUT_FAIL_REASON_4",
		"SKYPEOUT_FAIL_REASON_5", 
		"SKYPEOUT_FAIL_REASON_6", 
		"SKYPEOUT_FAIL_REASON_7",  //110
		"SKYPEOUT_FAIL_REASON_8", 
		"SKYPEOUT_FAIL_REASON_9",
		"SKYPEOUT_FAIL_REASON_10", 
		"SKYPEOUT_FAIL_REASON_11", 

		"SKYPE_LOADED",
                
        "UPDATE_CHAT", 

		"VIDEO_QUALITY_LEVEL_0",
		"VIDEO_QUALITY_LEVEL_1",
		"VIDEO_QUALITY_LEVEL_2",
		"VIDEO_QUALITY_LEVEL_3",  //120
		"VIDEO_QUALITY_LEVEL_4",

		"HISTORYLIST",

		"VOICEMAIL_PLAYING",
		"VOICEMAIL_PLAYED",
		"VOICEMAIL_UNPLAYED",
		"VOICEMAIL_BUFFERING",
		"VOICEMAIL_FAILED",
		"VOICEMAIL_DELETING",
		"VOICEMAIL_DELETING_FAILED",
		"VOICEMAIL_EMPTY ",    	//130

		"COMMIT_SUCCESS ",
		"COMMITTING_TO_SERVER",
		"COMMIT_FAILED",
        
        "CONTACT_SEARCH_NOT_FOUND",

		"SD_VIDEO_RECEIVED",
		"HD_VIDEO_RECEIVED",

		"VOICEMAIL_GREETING",
		"VOICEMAIL_BUFFERING_GREETING",
		"VOICEMAIL_RECORDING",
		"VOICEMAIL_UPLOADING", 		//140
		"VOICEMAIL_SENT",
		"VOICEMAIL_CANCELLED",
        "VOICEMAIL_SEND_FAILED",
			
        "AUTHREQ_PROCESSED",
        "NEW_CHAT_MESSAGE",
		"AUTHREQ_IGNORED",
				
		"OSD_TIMER_EXPIRED_0",
		"OSD_TIMER_EXPIRED_1" ,
		"OSD_TIMER_EXPIRED_2" ,
		"OSD_TIMER_EXPIRED_3" , 		//150
		"OSD_TIMER_EXPIRED_4" ,
		"OSD_TIMER_EXPIRED_5" ,
		"OSD_TIMER_EXPIRED_6" ,
		"OSD_TIMER_EXPIRED_7" ,
		"OSD_TIMER_EXPIRED_8" ,
		"OSD_TIMER_EXPIRED_9" ,		
		
		"UPDATE_UNREAD_CHAT_NUM" ,				
		"CALLMEMBER_AVATAR_CHANGE",
  		"CHATMEMBER_AVATAR_CHANGE",
  		"CHATMEMBER_CHANGE",					//160
  		
  		"HIDE_BLACK_BG",

		"ONLINE_CONTACT_OBJECT",
		"VIDEO_AVAILABLE",
		"CALLMEMBER_VIDEOSTATUS_SEND_ENABLED",
		
  		"CREATE_CALL_REQUEST",
  		
  		"GOTO_CONTACT",
		
  		"SHOW_BLACK_BG",

		"SHOW_CALL_ENDED_NOTY",
		"SHOW_MISSED_CALL_NOTY",
		"HIDE_MISSED_CALL_NOTY",

		"PREPARE_RUN_WIDGET",		
		"CURSOR_STATE_CHANGED",

		"CALLMEMBER_REFUSE_RECEIVE_VIDEO",
		
		"RESUME_TV_MODE_VIDEO",
		"RESUME_NORMAL_MODE_VIDEO"		
];
