
var NORMAL_ITEM_H = 88;

var CONTACT_BUTTON_HIGHLIGHT = { 
 
	NO_ONE						:	0,		//return Main or another Scene
	VIDEO_BUTTON				:	1,
	VOICE_BUTTON				:	2,
	PLUS_BUTTON					:	3,
	ADD_BUTTON					:	4,
	IGNORE_BUTTON				:	5,	
	BLOCK_BUTTON				:	6,
	GO_CALL_BUTTON				:	7,
	END_CALL_BUTTON				:	8,
	POPUP_AND_SUB_LIST			:	9,		//select button & show sub Scene	ex) calling wnd, tool list
	MAX							:	10,

}

var CONTACT_BUTTON_MODE = { 
 
	NOTHING_TYPE				:	0,
	NORMAL_TYPE					:	1,		//video,voice,plus
	NO_VIDEO_CALL_TYPE			:	2,		//voice,plus
	REQUEST_AUTH_TYPE			:	3,		//add, ignor, block
	LIVE_CALL_TYPE				:	4,		//go call, end call, chat
	LIVE_CONFERENCE_CALL_TYPE	:	5,		//go call, end call
}

function ContactFuncPopup () {

	//bg ground
	this.Frame			    = null,
	
	//buttons
	this.VideoButton	    = null,
	this.VoiceButton	    = null,
	this.PlusButton		    = null,
	this.AddButton		    = null,
	this.IgnoreButton		= null,
	this.BlockButton		= null,
	this.GoCallButton		= null,
	this.EndCallButton		= null,
	
	//for type & positon		
	this.CurContactName		= null;
	this.CurPosition		= -1;
		
	//for highlight
	this.LastHighlight			= CONTACT_BUTTON_HIGHLIGHT.NO_ONE;
	this.LastHighlightButton	= null;
	
	//for button mode	
	this.PrevButtonMode     = CONTACT_BUTTON_MODE.NOTHING_TYPE;
	this.ButtonMode			= CONTACT_BUTTON_MODE.NOTHING_TYPE;
		
	//flag
	this.flag_Focus		= false;
	this.Popup_mode		= null;
	this.CurSubScene	= null;
	this.flag_InCall	= false;
	
}

ContactFuncPopup.prototype.Create = function() {

	alert("ContactFuncPopup.Create()");
	
	this.Popup_mode	= false;
	this.CreateObject("contact");
}


ContactFuncPopup.prototype.CreateObject = function(Ename) {

	var Scene;
	
	if(this.Popup_mode == false)
	{
		Scene = sf.scene.get("ListMainContact");
	}
	else
	{
		Scene = sf.scene.get("LiveContactSwitch");
	}
	var This_ = Scene.list.FuncPopup;
	//contactButtons
	//contactVideoButton

    this.Frame = new CompBase();
    this.Frame.CreateBG(Ename + "Buttons");
//    this.Frame.SetBGImage("");	
    
	//create video button
    this.VideoButton = new ButtonBase();
	this.VideoButton.Create(Ename + "VideoButton",BUTTON_BASE_TYPE.BG_FG_TEXT, 24);
    this.VideoButton.SetBgImage(BUTTON_BASE_STATE.NORMAL,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.VideoButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
	this.VideoButton.SetBgImage(BUTTON_BASE_STATE.SELECT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.VideoButton.SetBgImage(BUTTON_BASE_STATE.DIM,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_DIM_BG);
    this.VideoButton.SetText(IDWS_MOIP_VIDEO_CALL_KR_VOICE);
	this.VideoButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur");
	this.VideoButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");		
	this.VideoButton.SetTextStyle(BUTTON_BASE_STATE.DIM,"cFuncButton_Text_Dim");		
	this.VideoButton.SetFgImage(BUTTON_BASE_STATE.NORMAL,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_ICON);
	this.VideoButton.SetFgImage(BUTTON_BASE_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_ICON_SELECT);
	this.VideoButton.SetFgImage(BUTTON_BASE_STATE.SELECT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_ICON_SELECT);
	this.VideoButton.SetFgImage(BUTTON_BASE_STATE.DIM,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_ICON);
    this.VideoButton.SetID(CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON);
	this.VideoButton.SetOnClickCallbackFunc(function(){This_.ClickVideoButton(false);}, true);


    this.VoiceButton = new ButtonBase();
    this.VoiceButton.Create(Ename + "VoiceButton",BUTTON_BASE_TYPE.BG_FG_TEXT, 24);
    this.VoiceButton.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.VoiceButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
    this.VoiceButton.SetBgImage(BUTTON_BASE_STATE.SELECT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.VoiceButton.SetText(IDWS_MOIP_VOICE_CALL_KR_VOICE);
	this.VoiceButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur");
	this.VoiceButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");
	this.VoiceButton.SetFgImage(BUTTON_BASE_STATE.NORMAL,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VOICE_ICON);
    this.VoiceButton.SetFgImage(BUTTON_BASE_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VOICE_ICON_SELECT);
    this.VoiceButton.SetFgImage(BUTTON_BASE_STATE.SELECT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VOICE_ICON_SELECT);
	this.VoiceButton.SetID(CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON);
	this.VoiceButton.SetOnClickCallbackFunc(function(){This_.ClickVoiceButton(false);}, true);
	
	this.PlusButton = new ButtonBase();
    this.PlusButton.Create(Ename + "PlusButton",BUTTON_BASE_TYPE.ONLY_BG);
    this.PlusButton.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_PLUS_ICON);
    this.PlusButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_PLUS_ICON_SELECT);	
    this.PlusButton.SetBgImage(BUTTON_BASE_STATE.SELECT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_PLUS_ICON_SELECT);
	this.PlusButton.SetBgImage(BUTTON_BASE_STATE.DIM, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_PLUS_ICON_DIM);
    this.PlusButton.SetID(CONTACT_BUTTON_HIGHLIGHT.PLUS_BUTTON);
	this.PlusButton.SetOnClickCallbackFunc(function(){This_.ClickPlusButton(false);}, true);    
	
	/************************************************modify by minseok***************************/
    this.AddButton = new ButtonBase();
    this.AddButton.Create(Ename + "AddButton",BUTTON_BASE_TYPE.BG_TEXT, 24);
    this.AddButton.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.AddButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
    this.AddButton.SetBgImage(BUTTON_BASE_STATE.SELECT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.AddButton.SetText(IDWS_MOIP_ADD_TO_CONTACTS);
	this.AddButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur"); 
	this.AddButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");   
	this.AddButton.SetID(CONTACT_BUTTON_HIGHLIGHT.ADD_BUTTON);
	this.AddButton.SetOnClickCallbackFunc(function(){This_.ClickAddButton(false);}, true);
 
	this.IgnoreButton = new ButtonBase();
    this.IgnoreButton.Create(Ename + "IgnoreButton",BUTTON_BASE_TYPE.BG_TEXT, 24);
    this.IgnoreButton.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.IgnoreButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
    this.IgnoreButton.SetBgImage(BUTTON_BASE_STATE.SELECT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.IgnoreButton.SetText(SID_IGNORE_KR_SHORT);
	this.IgnoreButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur");
	this.IgnoreButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");	
    this.IgnoreButton.SetID(CONTACT_BUTTON_HIGHLIGHT.IGNORE_BUTTON);
	this.IgnoreButton.SetOnClickCallbackFunc(function(){This_.ClickIgnoreButton(false);}, true);

	this.BlockButton = new ButtonBase();
    this.BlockButton.Create(Ename + "BlockButton",BUTTON_BASE_TYPE.BG_TEXT, 24);
    this.BlockButton.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.BlockButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
    this.BlockButton.SetBgImage(BUTTON_BASE_STATE.SELECT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.BlockButton.SetText(IDWS_MOIP_SKYPE_BLOCK);
	this.BlockButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur");
	this.BlockButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");	
    this.BlockButton.SetID(CONTACT_BUTTON_HIGHLIGHT.BLOCK_BUTTON);
	this.BlockButton.SetOnClickCallbackFunc(function(){This_.ClickBlockButton(false);}, true);    

	this.GoCallButton = new ButtonBase();
    this.GoCallButton.Create(Ename + "GoCallButton",BUTTON_BASE_TYPE.BG_TEXT, 24);
    this.GoCallButton.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.GoCallButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
    this.GoCallButton.SetBgImage(BUTTON_BASE_STATE.SELECT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.GoCallButton.SetText(TV_SID_CALL_SCREEN);
	this.GoCallButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur");
	this.GoCallButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");	
    this.GoCallButton.SetID(CONTACT_BUTTON_HIGHLIGHT.GO_CALL_BUTTON);    
	this.GoCallButton.SetOnClickCallbackFunc(function(){This_.ClickGoCallButton(false);});

	this.EndCallButton = new ButtonBase();
    this.EndCallButton.Create(Ename + "EndCallButton",BUTTON_BASE_TYPE.BG_TEXT, 24);
    this.EndCallButton.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.EndCallButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
    this.EndCallButton.SetBgImage(BUTTON_BASE_STATE.SELECT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.EndCallButton.SetText(TV_SID_END_CALL);
	this.EndCallButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur");
	this.EndCallButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");	
	this.EndCallButton.SetID(CONTACT_BUTTON_HIGHLIGHT.END_CALL_BUTTON);
	this.EndCallButton.SetOnClickCallbackFunc(function(){This_.ClickEndCallButton(false);});

	this.VideoButton.SetOnMouseOverCallbackFunc(function(){This_.ClickVideoButton(true);});
	this.VoiceButton.SetOnMouseOverCallbackFunc(function(){This_.ClickVoiceButton(true);});
	this.PlusButton.SetOnMouseOverCallbackFunc(function(){This_.ClickPlusButton(true);});
	this.AddButton.SetOnMouseOverCallbackFunc(function(){This_.ClickAddButton(true);});
	this.IgnoreButton.SetOnMouseOverCallbackFunc(function(){This_.ClickIgnoreButton(true);});
	this.BlockButton.SetOnMouseOverCallbackFunc(function(){This_.ClickBlockButton(true);});
	this.GoCallButton.SetOnMouseOverCallbackFunc(function(){This_.ClickGoCallButton(true);});
	this.EndCallButton.SetOnMouseOverCallbackFunc(function(){This_.ClickEndCallButton(true);});
} 

ContactFuncPopup.prototype.Show = function() {
alert("ContactFuncPopup.prototype.Show");
    this.Frame.Show();
} 

ContactFuncPopup.prototype.Hide = function() {
	alert("ContactFuncPopup.prototype.Hide");
    this.Frame.Hide();   
    
}

ContactFuncPopup.prototype.SetCurPosition = function(nItemIndex) {

	alert("ContactFuncPopup.SetCurPosition(" + nItemIndex + ")");
	
	if(nItemIndex < 0 || nItemIndex > MaxNumOfMainItem){
		
		alert("Error nItemIndex is not valid!!!");
		this.CurPosition = 0;
	}
	else {
		this.CurPosition = nItemIndex;
	}
    
	this.MovePosition();

}

ContactFuncPopup.prototype.SetCurProperty = function(Name) {

	alert("ContactFuncPopup.SetCurProperty");

	this.CurContactName = Name;

	var CurButtonType;
	var Availability;
	
	//process exception..
	if(Name && Name.length > 0){
		
		Availability = parseInt(PluginAPIMgr.GetContactAvailabilityWithName(Name));		
	}
	else{
		
		Availability = null;
	}

	//TEMPCODE 	
	var Camera_State = PluginAPIMgr.GetCameraState();
	this.flag_InCall = ProcMgr.GetIsInCall();
		
//LIVE CALL
	if(this.flag_InCall == true && this.CurPosition == 0){
		
		var IsConferenceCall = ProcMgr.GetIsConferenceCall();
		var CallMemberType = PluginAPIMgr.GetCallMemberType();
			
		if(IsConferenceCall == true || 
			CallMemberType == ENUM_CALL_MEMBE_TYPE.OUTGOING_PSTN || CallMemberType == ENUM_CALL_MEMBE_TYPE.INCOMING_PSTN || 
			Name == "echo123"){ 
			alert("LIVE_CONFERENCE_CALL_TYPE");
			CurButtonType = CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE;			
		}
		else{
			alert("LIVE_CALL_TYPE");
			CurButtonType = CONTACT_BUTTON_MODE.LIVE_CALL_TYPE;			
//LIVE_CONFERENCE_CALL_TYPE  <== ok 

		}
		
	}
//ERROR		
	else if(Availability == null) 
	{
		alert("Availability is null");
		CurButtonType = CONTACT_BUTTON_MODE.NOTHING_TYPE;
	}	
	else if(Availability == ENUM_CONTACT_AVAILABILITY.UNKNOWN)
	{
		alert("REQUEST_AUTH_TYPE");
		CurButtonType = CONTACT_BUTTON_MODE.REQUEST_AUTH_TYPE;
	}
//Default(Video/Voice/Chat)
	else if(Availability == ENUM_CONTACT_AVAILABILITY.SKYPEOUT || 
		Availability == ENUM_CONTACT_AVAILABILITY.BLOCKED_SKYPEOUT || 
		Name == "echo123")
	{
		alert("NO_VIDEO_CALL_TYPE");
		CurButtonType = CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE;
	}
	else{

		var video_enable = false;

		//if((Camera_State == ENUM_CAM_STATE.CAM_STATE_READY) || 
		//	(Camera_State == ENUM_CAM_STATE.CAM_STATE_PLAYING && IsInCall == true))
		//change for KITE camera 
		if(!(Camera_State == ENUM_CAM_STATE.CAM_STATE_DISCONNECTED || Camera_State == ENUM_CAM_STATE.CAM_STATE_CONNECTING))
		{			
			video_enable = true;
		}	 		
			
		if (video_enable) {
		
			alert("NORMAL_TYPE");
			CurButtonType = CONTACT_BUTTON_MODE.NORMAL_TYPE;			
		}
		else {
				
			alert("NO_VIDEO_CALL_TYPE 2");
			CurButtonType = CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE;
		}		
	}

    this.PrevButtonMode = this.ButtonMode;
	this.ButtonMode = CurButtonType;
	
	this.InitButtons();

}
	
	
ContactFuncPopup.prototype.MovePosition = function() {

	var tempY = (this.CurPosition * NORMAL_ITEM_H)+9;	
	var TopP = tempY + 'px';
	
	//this.Frame.MoveResize(0,tempY,0,0);
	$("#"+ this.Frame.GetBGLayer().Obj).css('top', TopP );
	
}


ContactFuncPopup.prototype.InitButtons = function() {
    
	alert("ContactFuncPopup.InitButtons");
	
	if(this.PrevButtonMode == this.ButtonMode) {
		alert("Not Changed");
		return;
	}
		
	this.ReSetHighlight();

	if(this.ButtonMode == CONTACT_BUTTON_MODE.NORMAL_TYPE)
	{
		if(this.PrevButtonMode == CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE){
			
			this.VideoButton.blur();
		}
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.REQUEST_AUTH_TYPE){

			this.AddButton.Hide();
			this.IgnoreButton.Hide();
			this.BlockButton.Hide();	
			
			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();					
		}
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CALL_TYPE){
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();

			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();					
		}
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE){
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();

			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();
								
		}		
		//CONTACT_BUTTON_MODE.NOTHING_TYPE
		else 
		{
			alert("First Initialized Buttons");
						
			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();	
				
		}
	}

	else if(this.ButtonMode == CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE) 
	{
		if(this.PrevButtonMode == CONTACT_BUTTON_MODE.NORMAL_TYPE)		{
			
			this.VideoButton.dim();
		}
		if(this.PrevButtonMode == CONTACT_BUTTON_MODE.REQUEST_AUTH_TYPE) 
		{
			this.AddButton.Hide();
			this.IgnoreButton.Hide();
			this.BlockButton.Hide();	
			
			this.VideoButton.dim();
						
			this.VideoButton.Show();					
			this.VoiceButton.Show();			
			this.PlusButton.Show();
		}
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CALL_TYPE){
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();

			this.VideoButton.dim();
			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();
						
		}		
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE){
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();

			this.VideoButton.dim();
			
			this.VideoButton.Show();
			this.VoiceButton.Show();
			
			this.PlusButton.Show();			
			
		}
		else {
			
			this.VideoButton.dim();
						
			this.VideoButton.Show();					
			this.VoiceButton.Show();			
			this.PlusButton.Show();
		}				
	}
	else if(this.ButtonMode == CONTACT_BUTTON_MODE.REQUEST_AUTH_TYPE){
		
		//change blur state form dim state...
		if(this.PrevButtonMode == CONTACT_BUTTON_MODE.NORMAL_TYPE){
			
			this.VoiceButton.Hide();
			this.VideoButton.Hide();
			this.PlusButton.Hide();			
		}		
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE){

			this.VideoButton.blur();			
		
			this.VideoButton.Hide();
			this.VoiceButton.Hide();			
			this.PlusButton.Hide();
		}
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CALL_TYPE){
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();
			this.PlusButton.Hide();
		}		
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE){
			
			this.PlusButton.blur();
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();
			this.PlusButton.Hide();
		}
				
		this.AddButton.Show();
		this.IgnoreButton.Show();
		this.BlockButton.Show();	
					
	}
	else if(this.ButtonMode == CONTACT_BUTTON_MODE.LIVE_CALL_TYPE){

		if (this.PrevButtonMode == CONTACT_BUTTON_MODE.NORMAL_TYPE) {
		
			this.VoiceButton.Hide();
			this.VideoButton.Hide();
			this.PlusButton.Hide();
			
		}
		else if (this.PrevButtonMode == CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE) {
		
			this.VideoButton.blur();
			
			this.VoiceButton.Hide();
			this.VideoButton.Hide();
			this.PlusButton.Hide();
		
		}
		else if (this.PrevButtonMode == CONTACT_BUTTON_MODE.REQUEST_AUTH_TYPE) {
		
			this.AddButton.Hide();
			this.IgnoreButton.Hide();
			this.BlockButton.Hide();
		}
		else if (this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE) {
			this.PlusButton.blur();
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();
			this.PlusButton.Hide();
		}
		else{
			alert("First Initialized Buttons");			
			this.VoiceButton.Hide();
			this.VideoButton.Hide();
			this.PlusButton.Hide();
		}

		this.GoCallButton.Show();
		this.EndCallButton.Show();		
	}

	else if(this.ButtonMode == CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE){

		if(this.PrevButtonMode == CONTACT_BUTTON_MODE.NORMAL_TYPE){
			
			this.VoiceButton.Hide();
			this.VideoButton.Hide();
			this.PlusButton.Hide();
			
		}
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE){
			
			this.VideoButton.blur();
			
			this.VoiceButton.Hide();
			this.VideoButton.Hide();
			this.PlusButton.Hide();						
		}
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.REQUEST_AUTH_TYPE){
			
			this.AddButton.Hide();
			this.IgnoreButton.Hide();
			this.BlockButton.Hide();	
		}		
		else{
			alert("First Initialized Buttons");
			
			this.PlusButton.dim();
			this.PlusButton.Show();
		}

		this.GoCallButton.Show();
		this.EndCallButton.Show();		
	}
	else{
		alert("InitButtons() Error ??? ");

		if(this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CALL_TYPE){
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();
			this.PlusButton.Hide();

		}
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE){
			
			this.GoCallButton.Hide();
			this.EndCallButton.Hide();
			this.PlusButton.Hide();

		}		
		else if(this.PrevButtonMode == CONTACT_BUTTON_MODE.REQUEST_AUTH_TYPE){
			
			this.AddButton.Hide();
			this.IgnoreButton.Hide();
			this.BlockButton.Hide();	
			
		}
		else {

			this.VideoButton.blur();		
			
			this.VideoButton.Hide();
			this.VoiceButton.Hide();			
			this.PlusButton.Hide();
			
		}
					
	}
}

ContactFuncPopup.prototype.toggleCameraOffBtnEnable=function()
{
    alert("ContactFuncPopup.toggleCameraOffBtnEnable() ");
    
    var camera_state = PluginAPIMgr.GetCameraState();
    
    if(camera_state == ENUM_CAM_STATE.CAM_STATE_DISCONNECTED)
    {
        alert("camera_state : ENUM_CAM_STATE.CAM_STATE_DISCONNECTED : "+ camera_state );
		this.VideoButton.dim();
		if(this.ButtonMode > CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE) {
			this.VideoButton.Hide();
		}
		else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON) {
			this.ButtonMode = CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE;
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON;
			this.VoiceButton.highlight();
			this.LastHighlightButton = this.VoiceButton;
		}
    }
	else if(camera_state == ENUM_CAM_STATE.CAM_STATE_CONNECTING)
	{
        alert("camera_state : ENUM_CAM_STATE.CAM_STATE_CONNECTING : "+ camera_state );
		this.VideoButton.blur();
		if(this.ButtonMode == CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE)
			this.ButtonMode = CONTACT_BUTTON_MODE.NORMAL_TYPE;
		else if(this.ButtonMode > CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE)
			this.VideoButton.Hide();

	}
}

ContactFuncPopup.prototype.ReSetHighlight = function(){
	alert("ContactFuncPopup.ReSetHighlight");
	//unselect
    if(this.LastHighlightButton)
    {
        this.LastHighlightButton.blur();
    }
	
	//reset lighlight
	this.LastHighlight			= CONTACT_BUTTON_HIGHLIGHT.NO_ONE;
	this.LastHighlightButton	= null;
	
}


ContactFuncPopup.prototype.Highlight = function(){

	alert("ContactFuncPopup.Highlight(LastHighlight : "+this.LastHighlight+")");

	//1. move contact with Focus
	if(this.flag_Focus){
		
		alert("flag_Focus");
		//initialize highlight
		if(this.ButtonMode != this.PrevButtonMode){
			this.InitializeHighlight();				
		}		
		else {
			if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.NO_ONE){
		
				this.InitializeHighlight();     
		    } 
			else {
		        this.LastHighlightButton.highlight();
		        this.LastHighlight = this.LastHighlightButton.GetID();
	    	}
		}
	}
	//2. return to previous focus
    else if(this.LastHighlightButton && this.LastHighlightButton.GetState() == BUTTON_BASE_STATE.SELECT)
    {
		//check CONTACT_BUTTON_HIGHLIGHT.SELECT_POPUP_AND_SUB_LIST		
        this.LastHighlightButton.highlight();
        this.LastHighlight = this.LastHighlightButton.GetID();
    }
	else if(this.LastHighlightButton){ // current sate is NORMAL because this.Blur();
		
		this.LastHighlightButton.highlight();
		this.LastHighlight = this.LastHighlightButton.GetID();
	}
	//3. first going  	
    else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.NO_ONE){
		
          this.InitializeHighlight();     
    }
	else {
		alert("Highlight Nothing!!!");
	}
	   	
	this.flag_Focus = true;
	this.CurSubScene = null;
}

ContactFuncPopup.prototype.Blur = function(){	
	alert("ContactFuncPopup.Blur(LastHighlight : "+this.LastHighlight+")");	
	
	//check case at return scene
	if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST){
		
		this.LastHighlightButton.select();
	}
	//return main 
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.NO_ONE){
		
		//highlight button change to blur
		if(this.LastHighlightButton){			
		    this.LastHighlightButton.blur();
			this.LastHighlightButton = null;			
		}
	}
	//case: Popup, to return here!!! 	
	else if(this.LastHighlightButton){			
	    this.LastHighlightButton.blur();			
	}	

	this.flag_Focus = false;
	
}


ContactFuncPopup.prototype.InitializeHighlight = function(){

					
	alert("InitializeHighlight(ButtonMode : "+this.ButtonMode+")");
	
    if(this.ButtonMode == CONTACT_BUTTON_MODE.NORMAL_TYPE)
    {
        this.VideoButton.highlight();
        this.LastHighlightButton = this.VideoButton;
        this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON;                     
    }
    else if(this.ButtonMode == CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE)
    {
        this.VoiceButton.highlight();
        this.LastHighlightButton = this.VoiceButton;
        this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON;        
    }
    else if(this.ButtonMode == CONTACT_BUTTON_MODE.REQUEST_AUTH_TYPE)
    {
        this.AddButton.highlight();
        this.LastHighlightButton = this.AddButton;
        this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.ADD_BUTTON;			
    }		
    else if(this.ButtonMode == CONTACT_BUTTON_MODE.LIVE_CALL_TYPE || 
		this.ButtonMode == CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE)
    {
        this.GoCallButton.highlight();
        this.LastHighlightButton = this.GoCallButton;
        this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.GO_CALL_BUTTON;			
    }
}

ContactFuncPopup.prototype.KeyProcess = function (keyCode) {
	
	alert("ContactFuncPopup.KeyProcess");
	switch (keyCode) {

		case sf.key.LEFT:
			this.processLeftKey();
			break;		
			
		case sf.key.RIGHT:
			this.processRightKey();
			break;
			
		case sf.key.ENTER:
			this.processEnterKey();
			break;
			
		case sf.key.TOOLS:
			this.processToolKey();
			break;
			
		case sf.key.RETURN:
            sf.key.preventDefault();
			this.processReturn2Key();			
			break;
			
		case sf.key.EXIT:
			this.processExitKey();
            sf.key.preventDefault();
			break;
            
        case 147:  //infolink
        case 261:  //contents
        case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
            
        default:
            ProcMgr.processBlockKey(keyCode);
            break;  
				
	}
	
}

ContactFuncPopup.prototype.processLeftKey = function() {
    
    alert("ContactFuncPopup.processLeftKey(LastHighlight : "+this.LastHighlight+")");        
	
	if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON
        || this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.ADD_BUTTON
		|| this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.GO_CALL_BUTTON) { 
		
		if(this.Popup_mode == false){
			//Modify 11.27
			this.processReturnKey();
		}
					
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON) {
	
		if(this.ButtonMode == CONTACT_BUTTON_MODE.NO_VIDEO_CALL_TYPE)
		{
			if(this.Popup_mode == false){
				//Modify 11.27
				this.processReturnKey();
			}
		}
		else {
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON;
			
			this.VideoButton.highlight();
			this.LastHighlightButton = this.VideoButton;
			
			this.VoiceButton.blur();			
		}
				
				
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.PLUS_BUTTON) {

//		if(this.ButtonMode == CONTACT_BUTTON_MODE.LIVE_CALL_TYPE){
//			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.END_CALL_BUTTON;
//			this.EndCallButton.highlight();
//			this.LastHighlightButton = this.EndCallButton;
//		}
//		else{

			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON;
					
			this.VoiceButton.highlight();
			this.LastHighlightButton = this.VoiceButton;
			
//		}
		this.PlusButton.blur();
				
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.IGNORE_BUTTON) {

		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.ADD_BUTTON;
				
		this.AddButton.highlight();
		this.LastHighlightButton = this.AddButton;
		
		this.IgnoreButton.blur();
				
	} 
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.BLOCK_BUTTON) {

		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.IGNORE_BUTTON;
			
		this.IgnoreButton.highlight();
		this.LastHighlightButton = this.IgnoreButton;
		
		this.BlockButton.blur();
				
	}  	   	   
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.END_CALL_BUTTON) {

		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.GO_CALL_BUTTON;
			
		this.GoCallButton.highlight();
		this.LastHighlightButton = this.GoCallButton;
		
		this.EndCallButton.blur();
				
	}
}

ContactFuncPopup.prototype.processRightKey = function() {
    
    alert("ContactFuncPopup.processRightKey(LastHighlight : "+this.LastHighlight+")");
    
	if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON) {
		
		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON;
		
		this.VideoButton.blur();		
		this.VoiceButton.highlight();
		
		this.LastHighlightButton = this.VoiceButton;
				
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON) {
		
		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.PLUS_BUTTON;
		
		this.VoiceButton.blur();				
		this.PlusButton.highlight();
        
		this.LastHighlightButton = this.PlusButton;

	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.PLUS_BUTTON) {        
		//Nothing						
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.ADD_BUTTON) {

		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.IGNORE_BUTTON;
			
		this.IgnoreButton.highlight();
		this.LastHighlightButton = this.IgnoreButton;
		
		this.AddButton.blur();
				
	}     
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.IGNORE_BUTTON) {

		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.BLOCK_BUTTON;
			
		this.BlockButton.highlight();
		this.LastHighlightButton = this.BlockButton;
		
		this.IgnoreButton.blur();
				
	}  	   
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.END_CALL_BUTTON) {

		if(this.ButtonMode == CONTACT_BUTTON_MODE.LIVE_CONFERENCE_CALL_TYPE)
		{
			return;
		}
//		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.PLUS_BUTTON;
//		this.PlusButton.highlight();
//		this.LastHighlightButton = this.PlusButton;
//		this.EndCallButton.blur();
				
	}     
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.GO_CALL_BUTTON) {

		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.END_CALL_BUTTON;
			
		this.EndCallButton.highlight();
		this.LastHighlightButton = this.EndCallButton;
		
		this.GoCallButton.blur();
				
	}
    else{
        alert("Nothins else");        
    }
	
}

ContactFuncPopup.prototype.processEnterKey = function() {
     
    alert("ContactFuncPopup.processEnterKey(LastHighlight : "+this.LastHighlight+")");        
	var ReturnScene;
		
	if(this.Popup_mode == false)
	{
		ReturnScene = sf.scene.get('ListMainContact');
	}
	else{
		ReturnScene = sf.scene.get('LiveContactSwitch');
	}	
	
	
	if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON) {		

		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		else {
		
			if(this.Popup_mode == false)
			{
				ReturnScene.Deactivation();			
			}

			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON;//POPUP_AND_SUB_LIST;	
			ProcMgr.CreateCall(this.CurContactName ,1);									
		}
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON) {
						
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		else {
			if(this.Popup_mode == false)
			{
				ReturnScene.Deactivation();			
			}

			//TEMPCODE:		
			if(PluginAPIMgr.GetContactPropWithName(this.CurContactName,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER)) {
				ProcMgr.CreateCall( this.CurContactName ,0);
			}
			else
			{																
				if(this.Popup_mode == true)
				{
					ProcMgr.CreateCall( this.CurContactName ,0);
				}
				else
				{
					if(this.flag_InCall == true)
					{
						//create call directlry
						ProcMgr.CreateCall( this.CurContactName ,0);
					}
					else
					{
						if(PluginAPIMgr.GetPhoneNumberCnt(this.CurContactName, true) == 0) {
							ProcMgr.CreateCall( this.CurContactName ,0);
						} else {
						this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
						WndMgr.Show_ContactPhoneNumberList('ListMainContact', this.CurContactName);	
						}
					}
															
				}
				this.CurSubScene = 'ListMainContactPhoneNumberList';
			}
		}	
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.PLUS_BUTTON) {
		
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		else {
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Plus_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST, this.CurPosition);
		}
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.ADD_BUTTON && this.Popup_mode == false) {
				
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		else{
			ProcMgr.AuthorizeContact(this.CurContactName);
		}				
				
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.IGNORE_BUTTON && this.Popup_mode == false) {

		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		else{
			ProcMgr.IgnoreAuthReqContact(this.CurContactName);
		}
				
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.BLOCK_BUTTON && this.Popup_mode == false) {
			
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		else{
			ProcMgr.BlockAuthReqContact(this.CurContactName);
		}				
				
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.GO_CALL_BUTTON) {

		ProcMgr.GoCall();				
	}
	else if(this.LastHighlight == CONTACT_BUTTON_HIGHLIGHT.END_CALL_BUTTON) {
			
		ProcMgr.DisconnectCall();		
	}
}


ContactFuncPopup.prototype.processReturnKey = function() {
		
    alert("ContactFuncPopup.processReturnKey(LastHighlight : "+this.LastHighlight+")");        
	if(this.Popup_mode){
		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.NO_ONE;
		StateMgr.Stop_Live_Contact_List_State(true);		
	}
	else{
		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.NO_ONE;
		WndMgr.ReturnSubToMain();
		this.Hide();
		sf.scene.get("ListMainContact").list.CurrentItemInit();
	}	
}

ContactFuncPopup.prototype.processReturn2Key = function() {
		
    alert("ContactFuncPopup.processReturn2Key(LastHighlight : "+this.LastHighlight+")");        
	if(this.Popup_mode){
		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.NO_ONE;
		StateMgr.Stop_Live_Contact_List_State(true);		
	}
	else{
		StateMgr.Start_Exit_State(true);
	}	
}

ContactFuncPopup.prototype.processExitKey = function() {
		
    alert("ContactFuncPopup.processExitKey(LastHighlight : "+this.LastHighlight+")");        
	if(this.Popup_mode){				
		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.NO_ONE;
		StateMgr.Stop_Live_Contact_List_State(true);			
	}
	else{
		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.NO_ONE;
		StateMgr.Start_Exit_State(false);		
	}	
}


ContactFuncPopup.prototype.processToolKey = function() {

    alert("ContactFuncPopup.processToolKey");        
	if(this.Popup_mode == false){
		
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		else{
	
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;	
	
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST);	
		}		
	}
    
}

ContactFuncPopup.prototype.HideSubScene = function(){
	
	if(this.CurSubScene){
		//sf.scene.hide(this.CurSubScene);
		//temp
		
		WndMgr.Hide_ContactPhoneNumberList(); 
//		StateMgr.Stop_ListMain_Phone_Number_State();
	}   	
}


ContactFuncPopup.prototype.MoveToVideoCallBtn = function(){
	
	alert("ContactFuncPopup.MoveToVideoCallBtn");
		
	if(this.ButtonMode == CONTACT_BUTTON_MODE.NORMAL_TYPE)
	{
		this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON;
		this.VoiceButton.blur();
		this.LastHighlightButton = this.VideoButton;		
	}
	else
	{
		alert("ButtonMode has no video button");
	}

}

ContactFuncPopup.prototype.ClickVideoButton = function(type){
	alert("ContactFuncPopup.ClickVideoButton(LastHighlight : "+this.LastHighlight+")");	

	if(this.VideoButton.GetState() == BUTTON_BASE_STATE.DIM)
	{
		alert("this.VideoButton.GetState() == BUTTON_BASE_STATE.DIM");	
		return;
	}
	else if(event.button == 2 && (this.Popup_mode == true || this.flag_InCall == true))
	{
		alert("Do Nothing!!!!");	
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		return;
	}
	
	if(this.Popup_mode == false)
	{
		var ReturnScene = sf.scene.get('ListMainContact');
		ReturnScene.Deactivation();

	    if(this.flag_Focus == false)
		{   
			sf.scene.get('ListMain').selectOnCurrHighlight();
			this.flag_Focus = true;
			this.CurSubScene = null;			
		}		
	}
		
	if(this.LastHighlightButton)
	{
		this.LastHighlightButton.blur();
	}
	
	this.LastHighlightButton = this.VideoButton;
	this.VideoButton.highlight();	
	this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VIDEO_BUTTON;//POPUP_AND_SUB_LIST;
	if(type == true)
		return;
	if(this.flag_InCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
	}
	else {
	
		if(event.button == 2)
		{
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST);
		}
		else
		{	
				ProcMgr.CreateCall(this.CurContactName ,1);			
		}
	}
}

ContactFuncPopup.prototype.ClickVoiceButton = function(type){
	alert("ContactFuncPopup.ClickVoiceButton(LastHighlight : "+this.LastHighlight+")");	

	if(event.button == 2 && (this.Popup_mode == true || this.flag_InCall == true))
	{
		alert("Do Nothing!!!!");	
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		return;
	}

	if(this.Popup_mode == false)
	{
		var ReturnScene = sf.scene.get('ListMainContact');
		ReturnScene.Deactivation();

	    if(this.flag_Focus == false)
		{   
			sf.scene.get('ListMain').selectOnCurrHighlight();
			this.flag_Focus = true;
			this.CurSubScene = null;			
		}		
	}
	
	if(this.LastHighlightButton)
	{
		this.LastHighlightButton.blur();
	}
	
	this.LastHighlightButton = this.VoiceButton;
	this.VoiceButton.highlight();
	this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.VOICE_BUTTON;

	if(type == true)
		return;
	if(this.flag_InCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
	}
	else {
		if(event.button == 2)
		{
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST);
		}
		else
		{	
			if(PluginAPIMgr.GetContactPropWithName(this.CurContactName,ENUM_CONTACT_PROPERTY.P_PSTNNUMBER)) {
				
				ProcMgr.CreateCall( this.CurContactName ,0);
			}
			else{
																
				if(this.Popup_mode == true)
				{
					ProcMgr.CreateCall( this.CurContactName ,0);
				}
				else
				{
					if(PluginAPIMgr.GetPhoneNumberCnt(this.CurContactName, true) == 0) {
						ProcMgr.CreateCall( this.CurContactName ,0);
					} else {
					this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;				
					WndMgr.Show_ContactPhoneNumberList('ListMainContact',this.CurContactName);
					}
				}
				
				this.CurSubScene = 'ListMainContactPhoneNumberList';
			}
		}
	}

}

ContactFuncPopup.prototype.ClickPlusButton = function(type){
	alert("ContactFuncPopup.ClickPlusButton(LastHighlight : "+this.LastHighlight+")");	

	if(event.button == 2 && (this.Popup_mode == true || this.flag_InCall == true))
	{
		alert("Do Nothing!!!!");	
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		return;
	}

	if(this.Popup_mode == false)
	{
		var ReturnScene = sf.scene.get('ListMainContact');
		ReturnScene.Deactivation();

	    if(this.flag_Focus == false)
		{   
			sf.scene.get('ListMain').selectOnCurrHighlight();
			this.flag_Focus = true;
			this.CurSubScene = null;			
		}		
	}
	
	if(this.LastHighlightButton)
	{
		this.LastHighlightButton.blur();
	}
		
	this.LastHighlightButton = this.PlusButton;
	this.PlusButton.highlight();
	this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.PLUS_BUTTON;

	if(type == true)
		return;
	if(this.flag_InCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
	}
	else {
		if(event.button == 2)
		{
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST);
		}
		else
		{	
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Plus_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST, this.CurPosition);
		}
	}
}

ContactFuncPopup.prototype.ClickAddButton = function(type){
	alert("ContactFuncPopup.ClickAddButton(LastHighlight : "+this.LastHighlight+")");	

	if(this.Popup_mode == true || ( event.button == 2 && this.flag_InCall == true))
	{
		alert("Do Nothing!!!!");	
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		return;
	}

    if(this.flag_Focus == false)
	{   
		sf.scene.get('ListMain').selectOnCurrHighlight();
		this.flag_Focus = true;
		this.CurSubScene = null;		
	}

	if(this.LastHighlightButton)
	{
		this.LastHighlightButton.blur();
	}
		
	this.LastHighlightButton = this.AddButton;
	this.AddButton.highlight();	
	this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.ADD_BUTTON; 

	if(type == true)
		return;
	if(this.flag_InCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
	}
	else{
		if(event.button == 2)
		{
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST);
		}
		//left click
		else
		{	
			ProcMgr.AuthorizeContact(this.CurContactName);
		}
	}
}

ContactFuncPopup.prototype.ClickIgnoreButton = function(type){
	alert("ContactFuncPopup.ClickIgnoreButton(LastHighlight : "+this.LastHighlight+")");	

	if(this.Popup_mode == true || ( event.button == 2 && this.flag_InCall == true))
	{
		alert("Do Nothing!!!!");	
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		return;
	}

    if(this.flag_Focus == false)
	{   
		sf.scene.get('ListMain').selectOnCurrHighlight();
		this.flag_Focus = true;
		this.CurSubScene = null;		
	}

	if(this.LastHighlightButton)
	{
		this.LastHighlightButton.blur();
	}
		
	this.LastHighlightButton = this.IgnoreButton;
	this.IgnoreButton.highlight();
	this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.IGNORE_BUTTON; 

	if(type == true)
		return;
	if(this.flag_InCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
	}
	else{
		if(event.button == 2)
		{
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST);
		}
		else
		{
				ProcMgr.IgnoreAuthReqContact(this.CurContactName);
		}
	}
}

ContactFuncPopup.prototype.ClickBlockButton = function(type){
	alert("ContactFuncPopup.ClickBlockButton(LastHighlight : "+this.LastHighlight+")");	

	if(this.Popup_mode == true || ( event.button == 2 && this.flag_InCall == true))
	{
		alert("Do Nothing!!!!");	
		if(this.flag_InCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
		}
		return;
	}

    if(this.flag_Focus == false)
	{   
		sf.scene.get('ListMain').selectOnCurrHighlight();
		this.flag_Focus = true;
		this.CurSubScene = null;		
	}

	if(this.LastHighlightButton)
	{
		this.LastHighlightButton.blur();
	}
		
	this.LastHighlightButton = this.BlockButton;
	this.BlockButton.highlight();	
	this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.BLOCK_BUTTON; 

	if(type == true)
		return;
	if(this.flag_InCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_CONTACT_LIST);
	}
	else{
		if(event.button == 2)
		{
			this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.CONTACT_LIST);
		}
		else
		{
			ProcMgr.BlockAuthReqContact(this.CurContactName);
		}
	}
}


ContactFuncPopup.prototype.ClickGoCallButton = function(type){
	alert("ContactFuncPopup.ClickGoCallButton(LastHighlight : "+this.LastHighlight+")");	

    if(this.Popup_mode == false && this.flag_Focus == false)
	{   
		sf.scene.get('ListMain').selectOnCurrHighlight();
		this.flag_Focus = true;
		this.CurSubScene = null;		
	}

	if(this.LastHighlightButton)
	{
		this.LastHighlightButton.blur();
	}
		
	this.LastHighlightButton = this.GoCallButton;
	this.GoCallButton.highlight();	
	this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.GO_CALL_BUTTON; 

	if(type == true)
		return;
	ProcMgr.GoCall();
}

ContactFuncPopup.prototype.ClickEndCallButton = function(type){
	alert("ContactFuncPopup.ClickEndCallButton(LastHighlight : "+this.LastHighlight+")");	

    if(this.Popup_mode == false && this.flag_Focus == false)
	{   
		sf.scene.get('ListMain').selectOnCurrHighlight();
		this.flag_Focus = true;
		this.CurSubScene = null;		
	}

	if(this.LastHighlightButton)
	{
		this.LastHighlightButton.blur();
	}
		
	this.LastHighlightButton = this.EndCallButton;
	this.EndCallButton.highlight();	
	this.LastHighlight = CONTACT_BUTTON_HIGHLIGHT.END_CALL_BUTTON; 

	if(type == true)
		return;
	ProcMgr.DisconnectCall();
}


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


function pContactFuncPopup () {

	ContactFuncPopup.call(this);
}

pContactFuncPopup.prototype = new ContactFuncPopup(); 

pContactFuncPopup.prototype.Create = function(){

	alert("pContactFuncPopup.Create()");
	
	this.Popup_mode = true;
	this.CreateObject("pContact");
	
}

