
function SceneVoiceCallToolList(options) {

	this.options	= options;
    
	//Object
	// this.ToolListDim	= null;
	this.ToolList		= null;
	this.MenuText		= null;	
	this.ToolHelpBar	= null;
	
	this.SubSceneType	= null;
	
	//check
	this.Identity		= null;
	this.Display		= null;	
	this.Index			= null;
	this.Availability	= null;

	//timer
    this.CloseTimer = false;

}

SceneVoiceCallToolList.prototype.initialize = function () {
	alert("SceneVoiceCallToolList.initialize()");
	this.create();
}

SceneVoiceCallToolList.prototype.handleShow = function () {
	alert("SceneVoiceCallToolList.handleShow()");
	
	// this.ToolListDim.show();

    this.ToolList.Show();
	
	this.startTimer();

}

SceneVoiceCallToolList.prototype.handleHide = function () {
	alert("SceneVoiceCallToolList.handleHide()");
		
	// this.ToolListDim.hide();


    if (this.CloseTimer == true)
    {
        this.stopTimer();
    }

}

SceneVoiceCallToolList.prototype.handleFocus = function () {
	alert("SceneVoiceCallToolList.handleFocus()");
	
	this.SetMenuItem();
	
	// this.ToolList.highlight();
	this.ToolHelpBar.visibleObj();	
	
}

SceneVoiceCallToolList.prototype.handleBlur = function () {
	alert("SceneVoiceCallToolList.handleBlur()");
	

	this.ToolList.blur();
	this.ToolHelpBar.hiddenObj();	
}

SceneVoiceCallToolList.prototype.handleKeyDown = function (keyCode) {
	
	alert("SceneVoiceCallToolList.handleKeyDown(" + keyCode + ")");
	
PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	if(keyCode == sf.key.RETURN)
	{		
		this.processReturnKey();
		sf.key.block(event);
	}
	else if(keyCode == sf.key.EXIT){
		this.processReturnKey();
		sf.key.block(event);
	}
	else if( keyCode == 147 || keyCode == 261  || keyCode == 115  )   //infolink ,contents, wiselink
	{
		ProcMgr.processInfolinkKey(); 
	}	
	else {
		
		if(keyCode == sf.key.DOWN || keyCode == sf.key.UP)
		{
			this.resetTimer();	
		}
			
		this.ToolList.KeyProcess(keyCode);	
	}

}

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

SceneVoiceCallToolList.prototype.create = function(){
    alert("SceneVoiceCallToolList.create() ");


    this.MenuText = new Label(null,"VCtoolListMenuText");    
    this.MenuText.SetText(SID_TOOLS);

	this.ToolList = new MenuList();
	this.ToolList.CreateBG("VCtoolList");
	this.ToolList.SetBGImage(g_Image.IMAGE_LIST_MAIN_TOOL_LIST_NEW_BG);	
	this.ToolList.SetNumOfVisibleItem(3);
	this.ToolList.SetStartDataIndex(0);
	this.ToolList.SetItemClass(MenuListItem);
	this.ToolList.SetItemBgImage(ITEM_STATE.NORMAL," ");
	this.ToolList.SetItemBgImage(ITEM_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_TOOL_LIST_ITEM_NEW_HIGHLIGHT);
	this.ToolList.SetItemDefualtTextStyle(ITEM_STATE.NORMAL,"cToolList_Text_Normal");
	this.ToolList.SetItemDefualtTextStyle(ITEM_STATE.HIGHLIGHT,"cToolList_Text_Highlight");
	this.ToolList.SetItemDisableTextStyle("cToolList_Text_Disable");
	this.ToolList.SetDataType(ITEM_DATA_TYPE.TEXT_ONLY);
	
	var scene = sf.scene.get("VoiceCallToolList");
	this.ToolList.SetItemPressedEventCallback(scene.ProcessKeyEnter);
	
	// this.ToolListDim = new DimBg("VoiceCallToolListDim", "VoiceCallToolList"); 

	//Text, Image, Diable
	var tempdata1 = [TV_CHANGE_PHONE_NUMBER,null];
	var tempdata2 = [IDWS_MOIP_POPUP_EXIT_SIGN_OUT,null];
	var tempdata3 = [IDWS_MOIP_SKYPE_ADD_A_CONTACT,null];
		
	this.ToolList.AddData(tempdata1);
	this.ToolList.AddData(tempdata2);
	this.ToolList.AddData(tempdata3);

	this.ToolList.SetOnClickCallbackFunc(0,this.onClickEventFunc1);
	this.ToolList.SetOnClickCallbackFunc(1,this.onClickEventFunc2);
	this.ToolList.SetOnClickCallbackFunc(2,this.onClickEventFunc3);
	this.ToolList.SetClickEventAvailable(WndMgr.MouseClickEnable);

	this.ToolList.ShowItem();
	
    this.ToolHelpBar = new HelpBar(HelpBarIndex.LIST_TOOL_MENU_VOICE_CALL_LIST, "VCtoolList");
    this.ToolHelpBar.SetOnClickCallbackFunc(1, function(){scene.processReturnKey();});
}

SceneVoiceCallToolList.prototype.SetMenuItem = function(){
	alert("SceneVoiceCallToolList.SetMenuItem() ");

	alert("GetAssignedPhoneNumberIndex = " + g_Data.GetAssignedPhoneNumberIndex());

	if(g_Data.GetAssignedPhoneNumberIndex() > 3)
	{		
		this.ToolList.SetDisableItem(0);
		this.ToolList.SetHighlightForDataIndex(1);	
	}
	else
	{
		this.ToolList.SetEnableItem(0);
		this.ToolList.highlight();
	}	
}

SceneVoiceCallToolList.prototype.ProcessKeyEnter = function(){
	alert("SceneVoiceCallToolList.ProcessKeyEnter() ");

	var scene = sf.scene.get("VoiceCallToolList");
	var Index = scene.ToolList.GetCurrentItem();

	switch(Index) {

		case 0:
			scene.ShowAddAssignedPhoneNumberPopup();
			break;
		case 1:
			scene.ShowSignOutPopup();
			break;				
		case 2:
			scene.ShowAddContactPopup();
			break;	
	}		
}


SceneVoiceCallToolList.prototype.processReturnKey = function(){

	alert("SceneVoiceCallToolList.processReturnKey()");

	var Scene = sf.scene.get(WndMgr.GetMainSubSceneID());	
	Scene.Activation();
	    	 
	StateMgr.Stop_List_Tools_State(true);
	
	g_Data.SetAssignedPhoneNumberInfo(null,-1,-1,null,false);	
	
}

SceneVoiceCallToolList.prototype.startTimer = function()
{
    alert("SceneListMainToolList.startTimer() ");
	
	this.CloseTimer = true;
	PluginAPIMgr.StartOSDTimer("60000" , function() { sf.scene.get('VoiceCallToolList').popupTimerCallback();}, ENUM_TIMER_TYPE.POPUP_WND);
}

SceneVoiceCallToolList.prototype.resetTimer = function()
{
    alert("SceneListMainToolList.resetTimer() ");

	if(this.CloseTimer == true)
	{
		PluginAPIMgr.RestartOSDTimer("60000" ,ENUM_TIMER_TYPE.POPUP_WND);
	}
}

SceneVoiceCallToolList.prototype.stopTimer = function()
{
    alert("SceneListMainToolList.stopTimer() ");
	
	this.CloseTimer = false;
	PluginAPIMgr.StopOSDTimer(ENUM_TIMER_TYPE.POPUP_WND);
}

SceneVoiceCallToolList.prototype.popupTimerCallback = function()
{
	alert("SceneVoiceCallToolList.popupTimerCallback() ");
	
	if(this.CloseTimer==false)
	{
		return
	}
	
   this.CloseTimer = false;
   
   this.processReturnKey();
}

SceneVoiceCallToolList.prototype.ShowAddAssignedPhoneNumberPopup = function()
{
	StateMgr.Start_Add_Phone_Number_State();
}

SceneVoiceCallToolList.prototype.ShowSignOutPopup = function()
{

	alert("SceneVoiceCallToolList.ShowSignOutPopup() ");

	//reset g_data
	g_Data.SetAssignedPhoneNumberInfo(null,-1,-1,null,false);	
	
	StateMgr.Start_Signout_State();

	var Scene = sf.scene.get(WndMgr.GetMainSubSceneID());	
	Scene.Activation();	
	
}

SceneVoiceCallToolList.prototype.ShowAddContactPopup = function()
{

	alert("SceneVoiceCallToolList.ShowAddContactPopup() ");

	//reset g_data
	g_Data.SetAssignedPhoneNumberInfo(null,-1,-1,null,false);	

	StateMgr.Start_Add_Contact_State();

	var Scene = sf.scene.get(WndMgr.GetMainSubSceneID());	
	Scene.Activation();	
	
}

SceneVoiceCallToolList.prototype.onClickEventFunc1 = function(){
	
	alert("SceneVoiceCallToolList.onClickEventFunc1() ");

	var This_ = sf.scene.get("VoiceCallToolList");
	This_.ShowAddAssignedPhoneNumberPopup();
}

SceneVoiceCallToolList.prototype.onClickEventFunc2 = function(){

	alert("SceneVoiceCallToolList.onClickEventFunc2() ");
	
	var This_ = sf.scene.get("VoiceCallToolList");
	This_.ShowSignOutPopup();
}

SceneVoiceCallToolList.prototype.onClickEventFunc3 = function(){
	
	alert("SceneVoiceCallToolList.onClickEventFunc3() ");	

	var This_ = sf.scene.get("VoiceCallToolList");	
	This_.ShowAddContactPopup();
	
}
