
var HISTORY_BUTTON_HIGHLIGHT = { 

	NO_ONE				:	0,
	VIDEO_BUTTON		:	1,
	VOICE_BUTTON		:	2,
	PLUS_BUTTON			:	3,
	PLAY_BUTTON			:	4,	
	DELETE_BUTTON		:	5,	
	VM_PLUS_BUTTON		:	6,
	POPUP_AND_SUB_LIST	:	7,
	MAX					:	8

}

var HISTORY_BUTTON_MODE = { 

	NOTHING_TYPE			:	0,
	
	//enable 3 button
	NORMAL_TYPE				:	1,

	//enable 2 button
	NO_VIDEO_CALL_TYPE		:	2,

	VOICEMAIL_TYPE			:	3,
	
}



/*
var HISTORY_BUTTONS_START_Y = 40;
var HISTORY_PHONE_NUMBER_LIST_START_Y = 80;
var HISTORY_PHONE_NUMBER_LIST_HIGHT = 185;
var HISTORY_NORMAL_ITEM_H = 62;
*/

function HistoryFuncButtons () {

	this.Frame			    = null,
	
	this.VideoButton	    = null,
	this.VoiceButton	    = null,
	this.PlusButton		    = null,
	this.PlayStopButton		= null,	
	this.DeleteButton		= null,	
	this.VMPlusButton	    = null,
	
	this.DurationLabel		= null,
	
	this.CurHistoryIndex 	= -1;
	this.CurHistoryIdentiry	= null;	
	this.CurPosition		= -1;
	
	this.LastHighlight			= HISTORY_BUTTON_HIGHLIGHT.NO_ONE;	
	this.LastHighlightButton	= null;	

	this.PrevButtonMode     = HISTORY_BUTTON_MODE.NOTHING_TYPE;
	this.ButtonMode			= HISTORY_BUTTON_MODE.NOTHING_TYPE;	
	
	//for voice mail
	this.IS_PLAY_BTN = true; 
	this.DurationTime = null;	
	this.VMStatus = ENUM_VOICE_MAIL_STATUS.PLAYED;
	this.flag_Waiting_VM_event = false;
	

	//flag
	this.flag_Focus		= false;
	this.CurSubScene	= null;
	
}

HistoryFuncButtons.prototype.Create = function() {

	alert("HistoryFuncButtons.Create()");
	
	var Scene = sf.scene.get("ListMainHistory");
	var This_ = Scene.list.FuncPopup;

    this.Frame = new CompBase();
    this.Frame.CreateBG("historyButtons");
    //this.Frame.SetBGImage("");	
    

	//create video button
    this.VideoButton = new ButtonBase();
	this.VideoButton.Create("historyVideoButton",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.DIM,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_ICON);
    this.VideoButton.SetID(HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON);
    this.VideoButton.SetOnClickCallbackFunc(function(){This_.ClickVideoButton(false);},true);
    
    this.VoiceButton = new ButtonBase();
    this.VoiceButton.Create("historyVoiceButton",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.SetID(HISTORY_BUTTON_HIGHLIGHT.VOICE_BUTTON);
	this.VoiceButton.SetOnClickCallbackFunc(function(){This_.ClickVoiceButton(false);},true);
	
	this.PlusButton = new ButtonBase();
    this.PlusButton.Create("historyPlusButton",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(HISTORY_BUTTON_HIGHLIGHT.PLUS_BUTTON);
    this.PlusButton.SetOnClickCallbackFunc(function(){This_.ClickPlusButton(false);},true);

    this.PlayStopButton = new ButtonBase();
	this.PlayStopButton.Create("historyPlayButton",BUTTON_BASE_TYPE.BG_FG_TEXT, 24);
    this.PlayStopButton.SetBgImage(BUTTON_BASE_STATE.NORMAL,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.PlayStopButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
	this.PlayStopButton.SetBgImage(BUTTON_BASE_STATE.SELECT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.PlayStopButton.SetBgImage(BUTTON_BASE_STATE.DIM,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_DIM_BG);
    this.PlayStopButton.SetText(SID_PLAY);
	this.PlayStopButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur");
	this.PlayStopButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");	
	this.PlayStopButton.SetTextStyle(BUTTON_BASE_STATE.DIM,"cFuncButton_Text_Dim");		
    this.PlayStopButton.SetID(HISTORY_BUTTON_HIGHLIGHT.PLAY_BUTTON);
    this.PlayStopButton.SetOnClickCallbackFunc(function(){This_.ClickPlayStopButton(false);},true);

    this.DeleteButton = new ButtonBase();
	this.DeleteButton.Create("historyDeleteButton",BUTTON_BASE_TYPE.BG_FG_TEXT, 24);
    this.DeleteButton.SetBgImage(BUTTON_BASE_STATE.NORMAL,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_NORMAL_BG);
    this.DeleteButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_HIGHLIGHT_BG);	
	this.DeleteButton.SetBgImage(BUTTON_BASE_STATE.SELECT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_SELECT_BG);
    this.DeleteButton.SetBgImage(BUTTON_BASE_STATE.DIM,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_VIDEO_BTN_DIM_BG);
    this.DeleteButton.SetText(SID_DELETE);
	this.DeleteButton.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"cFuncButton_Text_Blur");
	this.DeleteButton.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cFuncButton_Text_Highlight");	
	this.DeleteButton.SetTextStyle(BUTTON_BASE_STATE.DIM,"cFuncButton_Text_Dim");		
    this.DeleteButton.SetID(HISTORY_BUTTON_HIGHLIGHT.DELETE_BUTTON);
    this.DeleteButton.SetOnClickCallbackFunc(function(){This_.ClickDeleteButton(false);},true);

 	this.VMPlusButton = new ButtonBase();
    this.VMPlusButton.Create("historyVMPlusButton",BUTTON_BASE_TYPE.ONLY_BG);
    this.VMPlusButton.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_PLUS_ICON);
    this.VMPlusButton.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_PLUS_ICON_SELECT);	
    this.VMPlusButton.SetBgImage(BUTTON_BASE_STATE.SELECT, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_PLUS_ICON_SELECT);
	this.VMPlusButton.SetBgImage(BUTTON_BASE_STATE.DIM, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_PLUS_ICON_DIM);
    this.VMPlusButton.SetID(HISTORY_BUTTON_HIGHLIGHT.VM_PLUS_BUTTON);
    this.VMPlusButton.SetOnClickCallbackFunc(function(){This_.ClickPlusButton(false);},true);
   
    this.DurationLabel = new Label(null,"historyDuration");
	this.DurationLabel.SetIsTextInTable(true);
	
	this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.NO_ONE;

	this.VideoButton.SetOnMouseOverCallbackFunc(function(){This_.ClickVideoButton(true);});
	this.VoiceButton.SetOnMouseOverCallbackFunc(function(){This_.ClickVoiceButton(true);});
	this.PlusButton.SetOnMouseOverCallbackFunc(function(){This_.ClickPlusButton(true);});
	this.PlayStopButton.SetOnMouseOverCallbackFunc(function(){This_.ClickPlayStopButton(true);});
	this.DeleteButton.SetOnMouseOverCallbackFunc(function(){This_.ClickDeleteButton(true);});
	this.VMPlusButton.SetOnMouseOverCallbackFunc(function(){This_.ClickPlusButton(true);});
						
}

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

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

HistoryFuncButtons.prototype.SetCurPosition = function(nItemIndex) {

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

}

HistoryFuncButtons.prototype.SetCurProperty = function(nCurHistoryIndex) {
	
	alert("HistoryFuncButtons.SetCurProperty(" + nCurHistoryIndex + ")");
	
	this.CurHistoryIndex = nCurHistoryIndex;
	
	var CurButtonType;
	var Type;	
	var IS_PSTN;
	var IS_CONFERENCE;
	var Availability;
	var Identity;
	var Camera_State;
	var IsInCall;
	
	//process exception..
	if(nCurHistoryIndex < 0){
		alert("CurHistoryIndex < 0  error!!!");
		Availability = null;
		this.CurHistoryIdentity = null;
	}
	else{

		Type = PluginAPIMgr.GetHistoryPropWithIndex(nCurHistoryIndex,ENUM_HISTORY_PROPERTY.P_TYPE);
		IS_PSTN = PluginAPIMgr.GetHistoryPropWithIndex(nCurHistoryIndex,ENUM_HISTORY_PROPERTY.P_IS_PSTN);
		IS_CONFERENCE = PluginAPIMgr.GetHistoryPropWithIndex(nCurHistoryIndex,ENUM_HISTORY_PROPERTY.P_IS_CONFERENCE);
		this.CurHistoryIdentity = PluginAPIMgr.GetHistoryNameWithIndex(nCurHistoryIndex);
		Camera_State = PluginAPIMgr.GetCameraState();
		IsInCall = ProcMgr.GetIsInCall();	

		alert("Type = " + Type);
		alert("IS_PSTN = " + IS_PSTN);
		alert("Identity = " + this.CurHistoryIdentity);
		alert("Camera_State = " + Camera_State);
		alert("IS_CONFERENCE = " + IS_CONFERENCE);		
		
	}
		

	if(Type == "1"){
		
		alert("VOICEMAIL_TYPE");
		CurButtonType = HISTORY_BUTTON_MODE.VOICEMAIL_TYPE;	
		
		var totalDurationTime = PluginAPIMgr.GetHistoryPropWithIndex(nCurHistoryIndex,ENUM_HISTORY_PROPERTY.P_DURATION);
		this.DurationTime = g_Data.TransDuration(totalDurationTime);		
		this.DurationLabel.SetText("00:00:00 / " + this.DurationTime);
	}
	else{
		
		var video_available;
		var chat_available;
		
		//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_available = true
		}
		else{
			
			video_available = false;
		}
		
		if (IS_CONFERENCE == "2") {
		
			chat_available = false;
		
		}
		else {
			
			chat_available = true;
		}
	

		if(IS_PSTN == "1" || this.CurHistoryIdentity == 'echo123' || (video_available == false && chat_available == false)){
			
			alert("NO_VIDEO_CALL_TYPE");
			CurButtonType = HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE;
			
		}
		else if(video_available == false && chat_available == true){

			alert("NO_VIDEO_CALL_TYPE");
			CurButtonType = HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE;
			
		}
		else{

			alert("NORMAL_TYPE")
			CurButtonType = HISTORY_BUTTON_MODE.NORMAL_TYPE;
			
		}	
				
	}

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

}

HistoryFuncButtons.prototype.MovePosition = function() {

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

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

		if(this.PrevButtonMode == HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE){
			
			this.VideoButton.blur();
		}		
		else if(this.PrevButtonMode == HISTORY_BUTTON_MODE.VOICEMAIL_TYPE){
			
			this.DurationLabel.hiddenObj();			
			this.PlayStopButton.Hide();			
			this.DeleteButton.Hide();
			this.VMPlusButton.Hide();
						
			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();	

		}
		//Nothing 
		else {
			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();				
		}

	}
	else if(this.ButtonMode == HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE){
		
		if(this.PrevButtonMode == HISTORY_BUTTON_MODE.NORMAL_TYPE){
			this.VideoButton.dim();
		}
		else if(this.PrevButtonMode == HISTORY_BUTTON_MODE.VOICEMAIL_TYPE){
			
			this.DurationLabel.hiddenObj();							
			this.PlayStopButton.Hide();			
			this.DeleteButton.Hide();
			this.VMPlusButton.Hide();
			
			this.VideoButton.dim();
						
			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();	
		}
		//nothing
		else {
			this.VideoButton.Show();
			this.VoiceButton.Show();
			this.PlusButton.Show();	

			this.VideoButton.dim();					
		}		

	}
	else if(this.ButtonMode == HISTORY_BUTTON_MODE.VOICEMAIL_TYPE){
		
		alert("this.ButtonMode == HISTORY_BUTTON_MODE.VOICEMAIL_TYPE");
		if(this.PrevButtonMode == HISTORY_BUTTON_MODE.NORMAL_TYPE)
		{
			this.VideoButton.Hide();
			this.VoiceButton.Hide();
			this.PlusButton.Hide();
			
			this.DurationLabel.visibleObj();
			this.PlayStopButton.Show();				
			this.DeleteButton.Show();
			this.VMPlusButton.Show();
		}
		else if(this.PrevButtonMode == HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE){
			alert("this.PrevButtonMode == HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE");
			this.VideoButton.Hide();
			this.VoiceButton.Hide();
			this.PlusButton.Hide();

			this.VideoButton.blur();
	
			this.DurationLabel.visibleObj();						
			this.PlayStopButton.Show();						
			this.DeleteButton.Show();
			this.VMPlusButton.Show();
		}	
		//nothing
		else {
			this.DurationLabel.visibleObj();
			this.PlayStopButton.Show();					
			this.DeleteButton.Show();
			this.VMPlusButton.Show();
		}
	}	
			
}

HistoryFuncButtons.prototype.toggleCameraOffBtnEnable=function()
{
    alert("HistoryFuncButtons.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 > HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE) {
			this.VideoButton.Hide();
		}
		else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON) {
			
			this.LastHighlight = HISTORY_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 > HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE)
			this.VideoButton.Hide();
		else if(this.ButtonMode == HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE)
			this.ButtonMode = HISTORY_BUTTON_MODE.NORMAL_TYPE;
	}
}

HistoryFuncButtons.prototype.Highlight = function(){

	alert("HistoryFuncButtons.Highlight");
	
	if(this.CurHistoryIndex < 0){
		alert("Error!! (CurHistoryIndex < 0 )");
		return;
	}


	if(this.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();
	    	}
		}
	}	
    else if(this.LastHighlightButton && this.LastHighlightButton.GetState() == BUTTON_BASE_STATE.SELECT)
    {
		alert("unSelect!!!");
        this.LastHighlightButton.highlight();
        this.LastHighlight = this.LastHighlightButton.GetID();
    }
	else if(this.LastHighlightButton){
		this.LastHighlightButton.highlight();
		this.LastHighlight = this.LastHighlightButton.GetID();
	}		
    else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.NO_ONE){
		
          this.InitializeHighlight();     
    }
	
	this.flag_Focus = true;
	this.CurSubScene = null;
}

HistoryFuncButtons.prototype.Blur = function(){	
	alert("HistoryFuncButtons.Blur");	
	
	//check case at return scene
	if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST){
		
		if(this.LastHighlightButton){
			
			this.LastHighlightButton.select();
		}
		
	}
	//return main ....
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.NO_ONE){
		
		//highlight button change to blur
		if(this.LastHighlightButton){			
		    this.LastHighlightButton.blur();
			this.LastHighlightButton = null;			
		}
	}
	else if(this.LastHighlightButton){			
	    this.LastHighlightButton.blur();			
	}	

	this.flag_Focus = false;
	
}

HistoryFuncButtons.prototype.InitializeHighlight = function(){

	//09.01
	//prev highlight blur....
	if(this.LastHighlightButton && this.LastHighlightButton.GetState() == BUTTON_BASE_STATE.HIGHLIGHT){
		this.LastHighlightButton.blur();
	}		
			
	alert("InitializeHighlight");
	
    if(this.ButtonMode == HISTORY_BUTTON_MODE.NORMAL_TYPE)
    {		
        this.VideoButton.highlight();
        this.LastHighlightButton = this.VideoButton;
        this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON;             
        
    }
    else if(this.ButtonMode == HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE)
    {
        this.VoiceButton.highlight();
        this.LastHighlightButton = this.VoiceButton;
        this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.VOICE_BUTTON;            
    }
    else if(this.ButtonMode == HISTORY_BUTTON_MODE.VOICEMAIL_TYPE)
    {			
        this.PlayStopButton.highlight();
        this.LastHighlightButton = this.PlayStopButton;
        this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.PLAY_BUTTON;
    } 	

}


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

		case sf.key.LEFT:
			alert("KEY_LEFT");
			this.processLeftKey();
			break;	
			
		case sf.key.RIGHT:
			alert("KEY_RIGHT");
			this.processRightKey();
			break;
			
		case sf.key.ENTER:
			alert("KEY_ENTER");
			this.processEnterKey();
			break;
		
		case sf.key.TOOLS:
			alert("KEY_TOOLS");
			this.processToolKey();
			break;
			
		case sf.key.RETURN:
			alert("KEY_RETURN");
			this.processReturn2Key();
			sf.key.preventDefault();
			break;	
			
		case sf.key.EXIT:
			alert("KEY_EXIT");			
			StateMgr.Start_Exit_State(false);
			sf.key.preventDefault();
			break;	
			
        case 147:  //infolink
        case 261:  //contents
        case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
            
         default:
            ProcMgr.processBlockKey(keyCode);
            break;  

	}
	
}

HistoryFuncButtons.prototype.processLeftKey = function() {
    
	alert("HistoryFuncButtons.processLeftKey(LastHighlight : "+this.LastHighlight+")");

	if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON) {
		//modify 11.27
		this.processReturnKey();
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VOICE_BUTTON) {
	
		if(this.ButtonMode == HISTORY_BUTTON_MODE.NORMAL_TYPE)
		{
			this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON;
			
			this.VideoButton.highlight();
			this.LastHighlightButton = this.VideoButton;
			
			this.VoiceButton.blur();		
		}
		else if(this.ButtonMode == HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE){
			//modify 11.27
		     this.processReturnKey();
		}
		
				
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.PLUS_BUTTON) {

		this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.VOICE_BUTTON;
				
		this.VoiceButton.highlight();
		this.LastHighlightButton = this.VoiceButton;
		
		this.PlusButton.blur();
				
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.PLAY_BUTTON) {

		ProcMgr.StopHistoryVoicemail(this.CurHistoryIndex);	
  		this.processReturnKey();
	}	
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.DELETE_BUTTON) {

			this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.PLAY_BUTTON;
			
			this.PlayStopButton.highlight();
			this.LastHighlightButton = this.PlayStopButton;
			
			this.DeleteButton.blur();		
	}	
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VM_PLUS_BUTTON) {

		this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.DELETE_BUTTON;
				
		this.DeleteButton.highlight();
		this.LastHighlightButton = this.DeleteButton;
		
		this.VMPlusButton.blur();
				
	}	
}

HistoryFuncButtons.prototype.processRightKey = function() {
    
	alert("HistoryFuncButtons.processRightKey(LastHighlight : "+this.LastHighlight+")");

	if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON) {
		
		this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.VOICE_BUTTON;
		
		this.VideoButton.blur();		
		this.VoiceButton.highlight();
		
		this.LastHighlightButton = this.VoiceButton;
				
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VOICE_BUTTON) {
		

		if(this.ButtonMode == HISTORY_BUTTON_MODE.NORMAL_TYPE ||
			this.ButtonMode == HISTORY_BUTTON_MODE.NO_VIDEO_CALL_TYPE)
		{
			this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.PLUS_BUTTON;
			
			this.VoiceButton.blur();				
			this.PlusButton.highlight();
			
			this.LastHighlightButton = this.PlusButton;
		}	
						
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.PLAY_BUTTON) {
		
		this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.DELETE_BUTTON;
		
		this.PlayStopButton.blur();		
		this.DeleteButton.highlight();
		
		this.LastHighlightButton = this.DeleteButton;
				
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.DELETE_BUTTON) {
		

		if(this.ButtonMode == HISTORY_BUTTON_MODE.VOICEMAIL_TYPE)
		{
			this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.VM_PLUS_BUTTON;
			
			this.DeleteButton.blur();				
			this.VMPlusButton.highlight();
			
			this.LastHighlightButton = this.VMPlusButton;
		}	
						
	}

}


HistoryFuncButtons.prototype.processReturnKey = function() {
		
	alert("HistoryFuncButtons.processReturnKey(LastHighlight : "+this.LastHighlight+")");

    this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.NO_ONE;		        
	WndMgr.ReturnSubToMain();
	this.Hide();
	sf.scene.get("ListMainHistory").list.CurrentItemInit();
		
}

HistoryFuncButtons.prototype.processReturn2Key = function() {
    
	alert("HistoryFuncButtons.processReturn2Key(LastHighlight : "+this.LastHighlight+")");

    this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.NO_ONE;		        
	WndMgr.ReturnSubToMainContact();
		
}

HistoryFuncButtons.prototype.processToolKey = function() {

	var IsInCall = ProcMgr.GetIsInCall();
	
	if (IsInCall) {
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
	}
	else {

		this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
				
		StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST);
		
		//this.CurSubScene = 'ListMainHistoryToolList';

	}
    


}

HistoryFuncButtons.prototype.processEnterKey = function() {
    
	alert("HistoryFuncButtons.processEnterKey(LastHighlight : "+this.LastHighlight+"), HistoryName = " + this.CurHistoryIdentity);
	
	var IsInCall = ProcMgr.GetIsInCall();

	if(this.CurHistoryIdentity == null){
		
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_IN_HISTORY_LIST);
		return;
	}	

	if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON) {
		
		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
		}
		else {
			this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON;// NO_ONE;	

			var ReturnScene = sf.scene.get('ListMainHistory');
			ReturnScene.Deactivation();
			
			ProcMgr.CreateCall( this.CurHistoryIdentity ,1);
		}			
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VOICE_BUTTON) {

		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
		}
		else {
			var ReturnScene = sf.scene.get('ListMainHistory');
			ReturnScene.Deactivation();

			if(PluginAPIMgr.GetHistoryPropWithIndex(this.CurHistoryIndex, ENUM_HISTORY_PROPERTY.P_IS_PSTN)) {
				ProcMgr.CreateCall( this.CurHistoryIdentity ,0);
			} else if(PluginAPIMgr.GetPhoneNumberCnt(this.CurHistoryIdentity, true) == 0) {
				ProcMgr.CreateCall( this.CurHistoryIdentity ,0);
			} else {
				this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
				WndMgr.Show_ContactPhoneNumberList('ListMainHistory', this.CurHistoryIdentity);
				this.CurSubScene = 'ListMainContactPhoneNumberList';			
			}		
		}
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.PLUS_BUTTON) {
		
		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
		}
		else {
			this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Plus_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST, this.CurHistoryIndex);
		}
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.PLAY_BUTTON) {
		
		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
		}
		else{
			
			if(this.IS_PLAY_BTN){
				this.PushPlayBtn();
			}
			else{
				this.PushStopBtn();
			}
		}		
				
	}	
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.DELETE_BUTTON) {
		
		ProcMgr.StopHistoryVoicemail(this.CurHistoryIndex);	
		this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
		StateMgr.Start_Remove_State(this.CurPosition);
	}
	else if(this.LastHighlight == HISTORY_BUTTON_HIGHLIGHT.VM_PLUS_BUTTON) {
		
		ProcMgr.StopHistoryVoicemail(this.CurHistoryIndex);	
		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
		}
		else {
			this.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Plus_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST, this.CurHistoryIndex);
		}
	}
	
}


HistoryFuncButtons.prototype.SetPlayBtn = function(){

	alert("HistoryFuncButtons.SetPlayBtn");
	this.PlayStopButton.SetText(SID_PLAY);
	this.IS_PLAY_BTN = true;
	
}

HistoryFuncButtons.prototype.SetStopBtn = function(){

	alert("HistoryFuncButtons.SetStopBtn");
	this.PlayStopButton.SetText(SID_STOP);
	this.IS_PLAY_BTN = false;
}

HistoryFuncButtons.prototype.PushPlayBtn = function(){
	
	alert("HistoryFuncButtons.PushPlayBtn");
	
	
	//if(PluginAPIMgr.PlayHistoryVoicemail(this.CurHistoryIndex)== '1')
	if(ProcMgr.PlayHistoryVoicemail(this.CurHistoryIndex)== '1')
	{

		var scene = sf.scene.get("ListMainHistory");
		scene.StartVMPlay();	
		this.SetStopBtn();
		
		this.DurationLabel.SetText(SID_CHECKING_NETWORK_STATUS);		
			
	}
	else
	{
		
		this.VMStatus = ENUM_VOICE_MAIL_STATUS.FAILED;	
		this.DurationLabel.SetText(IDWS_MOIP_VOICEMAIL_FAILED);	
	}
	
}

HistoryFuncButtons.prototype.PushStopBtn = function(){
	
	alert("HistoryFuncButtons.PushStopBtn");
	
	if(this.flag_Waiting_VM_event == false){
		
		this.flag_Waiting_VM_event = true;
		this.DurationLabel.SetText(TV_SID_WAITING_DOT);	
		
		alert("StopHistoryVoicemail");
		ProcMgr.StopHistoryVoicemail(this.CurHistoryIndex);	
	}
	
	
}

HistoryFuncButtons.prototype.FinishVMPlay = function(bSucess){
	
	alert("HistoryFuncButtons.FinishVMPlay");
		
	this.SetPlayBtn();
	
	if(bSucess){
		this.VMStatus = ENUM_VOICE_MAIL_STATUS.PLAYED;	
		this.DurationLabel.SetText("00:00:00 / "+this.DurationTime);
	}
	else{
		this.VMStatus = ENUM_VOICE_MAIL_STATUS.FAILED;	
		this.DurationLabel.SetText(IDWS_MOIP_VOICEMAIL_FAILED);
	}
	
	//resume key
	var scene = sf.scene.get("ListMainHistory");
	scene.StopVMPlay();
	
	this.flag_Waiting_VM_event = false;	
	
}

HistoryFuncButtons.prototype.ProcessVM = function(EventType){
	alert("HistoryFuncButtons.ProcessVM(" + EventType + ")");

	switch(EventType) {
		case ENUM_VOICE_MAIL_STATUS.BUFFERING:		
			this.DurationLabel.SetText(IDWS_MOIP_SKYPE_BUFFERING);
			this.VMStatus = ENUM_VOICE_MAIL_STATUS.BUFFERING;
			break;
			
		case ENUM_VOICE_MAIL_STATUS.PLAYING:
			if(this.VMStatus == ENUM_VOICE_MAIL_STATUS.BUFFERING){
				this.VMStatus = ENUM_VOICE_MAIL_STATUS.PLAYING;			
			}
			break;
			
		case ENUM_VOICE_MAIL_STATUS.PLAYED:
			this.FinishVMPlay(true);	
			break;		
			
		case ENUM_VOICE_MAIL_STATUS.UNPLAYED:
			this.FinishVMPlay(false);
			break;
			
		case ENUM_VOICE_MAIL_STATUS.FAILED:
			this.FinishVMPlay(true);
			break;
			
		case ENUM_VOICE_MAIL_STATUS.DELETING:
			break;		
			
		case ENUM_VOICE_MAIL_STATUS.BLANK:
			break;				
	}
}


HistoryFuncButtons.prototype.ProgressPlayBack = function(strTime){
	
	this.DurationLabel.SetText(strTime + " / " + this.DurationTime);	 
}

HistoryFuncButtons.prototype.HideSubScene = function(){

	if(this.CurSubScene){
		//sf.scene.hide(this.CurSubScene);
		//tmep
		WndMgr.Hide_ContactPhoneNumberList();  
//		StateMgr.Stop_ListMain_Phone_Number_State();
	}   
}

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

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

}

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

	var ReturnScene = sf.scene.get('ListMainHistory');
	var This_ = ReturnScene.list.FuncPopup;
	var IsInCall = ProcMgr.GetIsInCall();
	
	if(this.VideoButton.GetState() == BUTTON_BASE_STATE.DIM)
	{
		alert("this.VideoButton.GetState() == BUTTON_BASE_STATE.DIM");	
		return;
	}
	else if(event.button == 2 && IsInCall == true)
	{
		alert("Do Nothing!!!!");	
		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
		}
		return;
	}
	
	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 = HISTORY_BUTTON_HIGHLIGHT.VIDEO_BUTTON;// NO_ONE;		

	if(type == true) 
		return;
	if(IsInCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
	} 
	else {
		if(event.button == 2)
		{
			This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST);
		}
		else
		{	
			ProcMgr.CreateCall( This_.CurHistoryIdentity ,1);		
		}
	}
}
		
HistoryFuncButtons.prototype.ClickVoiceButton = function(type){
	alert("HistoryFuncButtons.ClickVoiceButton(LastHighlight : "+this.LastHighlight+")");	

	var ReturnScene = sf.scene.get('ListMainHistory');
	var This_ = ReturnScene.list.FuncPopup;
	var IsInCall = ProcMgr.GetIsInCall();

	if(event.button == 2 && IsInCall == true)
	{
		alert("Do Nothing!!!!");	
		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
		}
		return;
	}
	
	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 = HISTORY_BUTTON_HIGHLIGHT.VOICE_BUTTON;

	if(type == true) 
		return;
	
	if(IsInCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
	} 
	else {
		if(event.button == 2)
		{
			This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST);
		}
		else
		{	
			if(PluginAPIMgr.GetHistoryPropWithIndex(this.CurHistoryIndex, ENUM_HISTORY_PROPERTY.P_IS_PSTN)) {
				
				ProcMgr.CreateCall( This_.CurHistoryIdentity ,0);
			}
			else{
				if(PluginAPIMgr.GetPhoneNumberCnt(This_.CurHistoryIdentity, true) == 0) {
					ProcMgr.CreateCall( This_.CurHistoryIdentity ,0);
				} else {
					This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
					WndMgr.Show_ContactPhoneNumberList('ListMainHistory', This_.CurHistoryIdentity);
					This_.CurSubScene = 'ListMainContactPhoneNumberList';			
				}
			}
		}
	}
}

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

	var ReturnScene = sf.scene.get('ListMainHistory');
	var This_ = ReturnScene.list.FuncPopup;
	var IsInCall = ProcMgr.GetIsInCall();

	if(event.button == 2 && IsInCall == true)
	{
		alert("Do Nothing!!!!");	
		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_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();
	}
		
	if(This_.ButtonMode == HISTORY_BUTTON_MODE.VOICEMAIL_TYPE) {
		This_.LastHighlightButton = This_.VMPlusButton;
		This_.VMPlusButton.highlight();
	}
	else {
	This_.LastHighlightButton = This_.PlusButton;
	This_.PlusButton.highlight();
	}
	if(type == true) return;
	
	ProcMgr.StopHistoryVoicemail(this.CurHistoryIndex);	
	if(IsInCall){
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
	} 
	else {
		if(event.button == 2)
		{
			This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST);
		}
		else 
		{
			This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
	//		ProcMgr.OpenChatWithContact( This_.CurHistoryIdentity);		
			StateMgr.Start_List_Plus_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST, this.CurHistoryIndex);
		}
	}
}

HistoryFuncButtons.prototype.ClickPlayStopButton = function(type){
	alert("HistoryFuncButtons.ClickPlayStopButton(LastHighlight : "+this.LastHighlight+")");	

	var ReturnScene = sf.scene.get('ListMainHistory');
	var This_ = ReturnScene.list.FuncPopup;
	var IsInCall = ProcMgr.GetIsInCall();

    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_.PlayStopButton;
	This_.PlayStopButton.highlight();
	if(type == true) return;
	
	if(IsInCall){
		This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.PLAY_BUTTON;
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
	}
	else{
		
		if(event.button == 2)
		{
			This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST);
		}
		else
		{
			
			This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.PLAY_BUTTON;
					
			if(This_.IS_PLAY_BTN){
				This_.PushPlayBtn();
			}
			else{
				This_.PushStopBtn();
			}
		}
	}	
}

HistoryFuncButtons.prototype.ClickDeleteButton = function(type){
	alert("HistoryFuncButtons.ClickDeleteButton(LastHighlight : "+this.LastHighlight+")");	


	var ReturnScene = sf.scene.get('ListMainHistory');
	var This_ = ReturnScene.list.FuncPopup;
	var IsInCall = ProcMgr.GetIsInCall();

    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_.DeleteButton;
	This_.DeleteButton.highlight();
	if(type == true) return;
	
	ProcMgr.StopHistoryVoicemail(this.CurHistoryIndex);	
	if(IsInCall){
		This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.DeleteButton;
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL_IN_HISTORY_LIST);
	}
	else{
		
		if(event.button == 2)
		{
			This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.POPUP_AND_SUB_LIST;
			StateMgr.Start_List_Tools_State(TOOL_MENU_LIST_TYPE.HISTORY_LIST);
		}
		else
		{
			
			This_.LastHighlight = HISTORY_BUTTON_HIGHLIGHT.DELETE_BUTTON;
			StateMgr.Start_Remove_State(This_.CurPosition);
		}
	}	
}



