
function SceneToolList(options) {

	this.options	= options;
    
	//Object
	// this.ToolListDim	= null;
	this.ToolList		= null;
	this.TitleText		= null;	
	this.ToolHelpBar	= null;
	
	//flag
	this.MenuType		= TOOL_MENU_LIST_TYPE.NOTHING;		
	this.MimFocusMenuIndex		= 0;
	this.ShownSubList	= false;
	// this.ChangeTextFont	= false;
			
	//About property
	this.Identity		= null;
	this.Display		= null;	
	this.Index			= null;
	this.Availability	= null;
	this.IsUnblock		= false;	
	this.IsBuddy		= null;
	this.IsBlockedUser	= null;

	this.LightAdjustMenuIndex	= 0;
	this.LightAdjustMenuValue	= 0;

	
	//timer
    this.CloseTimer = false;

}

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

SceneToolList.prototype.handleShow = function () {
	alert("SceneToolList.handleShow()");
	
	// this.ToolListDim.show();
	
	this.SetMenu(); 
    this.ToolList.Show();
	
	this.startTimer();

}

SceneToolList.prototype.handleHide = function () {
	alert("SceneToolList.handleHide()");

    if (this.CloseTimer == true)
    {
        this.stopTimer();
    }
    
	if(this.ShownSubList ==  true)
	{
		sf.scene.hide('ToolListLightSeletor');	
		this.ShownSubList = false;
	}
	
	this.ToolList.Hide();	
	// this.ToolListDim.hide();

	// if(this.ChangeTextFont == true)
	// {
		// $("#ToolMenuListItem1Text").css('font-size','18px');
		// this.ChangeTextFont = false;
	// }
}

SceneToolList.prototype.handleFocus = function () {
	alert("SceneToolList.handleFocus()");

	// this.ToolListDim.show();		
	this.ListFocus();
	this.ToolHelpBar.visibleObj();	
	
}

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

	this.ToolList.blur();
	this.ToolHelpBar.hiddenObj();	
	
	this.ShownSubList	= false;
}

SceneToolList.prototype.handleKeyDown = function (keyCode) {
	
	alert("SceneToolList.handleKeyDown(" + keyCode + ")");
	
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	
	if(keyCode == sf.key.RETURN)
	{		
		this.processReturnKey();
		sf.key.preventDefault();
	}
	else if(keyCode == sf.key.EXIT){
		
		sf.key.preventDefault();
	}
	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);	
	}

}

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

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


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

	this.ToolList = new MenuList();
	this.ToolList.CreateBG("ToolMenuList");
	this.ToolList.SetBGImage(g_Image.IMAGE_LIST_MAIN_TOOL_LIST_NEW_BG);	
	this.ToolList.SetNumOfVisibleItem(7);
	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,"cToolMenuList_Text_Normal");
	this.ToolList.SetItemDefualtTextStyle(ITEM_STATE.HIGHLIGHT,"cToolMenuList_Text_Highlight");
	this.ToolList.SetItemDisableTextStyle("cToolMenuList_Text_Disable");
	this.ToolList.SetDataType(ITEM_DATA_TYPE.TEXT_ONLY);
	

	this.ToolList.SetItemPressedEventCallback(this.ProcessKeyEnter);
	
	//Text, Image, Diable
	var tempdata1 = ["1",null];
	var tempdata2 = ["2",null];
	var tempdata3 = ["3",null];
	var tempdata4 = ["4",null];
	var tempdata5 = ["5",null];
	var tempdata6 = ["6",null];
	var tempdata7 = ["7",null];
		
	this.ToolList.AddData(tempdata1);
	this.ToolList.AddData(tempdata2);
	this.ToolList.AddData(tempdata3);
	this.ToolList.AddData(tempdata4);
	this.ToolList.AddData(tempdata5);	
	this.ToolList.AddData(tempdata6);
	this.ToolList.AddData(tempdata7);

	this.ToolList.SetOnClickCallbackFunc(0,this.onClickEventFunc1);
	this.ToolList.SetOnClickCallbackFunc(1,this.onClickEventFunc2);
	this.ToolList.SetOnClickCallbackFunc(2,this.onClickEventFunc3);
	// this.ToolList.SetOnClickCallbackFunc(3,this.onClickEventFunc4);
	// this.ToolList.SetOnClickCallbackFunc(4,this.onClickEventFunc5);
	// this.ToolList.SetOnClickCallbackFunc(5,this.onClickEventFunc6);
	// this.ToolList.SetOnClickCallbackFunc(6,this.onClickEventFunc7);		
	this.ToolList.SetClickEventAvailable(WndMgr.MouseClickEnable);


	this.ToolList.ShowItem();
	
    this.ToolHelpBar = new HelpBar(HelpBarIndex.LIST_TOOL_MENU_IN_CALL_LIST, "ToolMenuList");
	
	var scene = sf.scene.get("ToolList");    
    this.ToolHelpBar.SetOnClickCallbackFunc(1, function(){scene.processReturnKey();});
    
}


SceneToolList.prototype.SetMenuType = function(type){
	alert("SceneToolList.SetMenuType() ");
	
	this.MenuType = type;
}

SceneToolList.prototype.SetMenu = function(){
	alert("SceneToolList.SetMenu() ");
	
	this.MimFocusMenuIndex	= 6;	

	switch(this.MenuType) {

		case TOOL_MENU_LIST_TYPE.VIDEO_CALL:
			this.SetLightAdjustMenu(0);
			this.SetChangeViewMenu(1);
			this.SetContactListMenu(2);
			this.SetBlankMenu(3);
			this.SetBlankMenu(4);
			this.SetBlankMenu(5);
			this.SetBlankMenu(6);				
			break;			

		case TOOL_MENU_LIST_TYPE.VIDEO_CALL_WITH_EXT_CAM:
			this.SetChangeViewMenu(0);
			this.SetContactListMenu(1);
			this.SetBlankMenu(2);			
			this.SetBlankMenu(3);
			this.SetBlankMenu(4);
			this.SetBlankMenu(5);
			this.SetBlankMenu(6);				
			break;		

		case TOOL_MENU_LIST_TYPE.VOICE_CALL:
			this.SetContactListMenu(0);
			this.SetBlankMenu(1);
			this.SetBlankMenu(2);			
			this.SetBlankMenu(3);
			this.SetBlankMenu(4);
			this.SetBlankMenu(5);
			this.SetBlankMenu(6);				
			break;

		case TOOL_MENU_LIST_TYPE.VOICE_CALL_BUTTON:
			this.SetChangePhoneNumberMenu(0);
			this.SetSignOutMenu(1);
			this.SetAddContactMenu(2);
			this.SetBlankMenu(3);
			this.SetBlankMenu(4);
			this.SetBlankMenu(5);
			this.SetBlankMenu(6);
			break;
			
		default :
			this.SetBlankMenu(0);
			this.SetBlankMenu(1);
			this.SetBlankMenu(2);			
			this.SetBlankMenu(3);
			this.SetBlankMenu(4);
			this.SetBlankMenu(5);
			this.SetBlankMenu(6);						
			break;

	}

}


SceneToolList.prototype.ListFocus = function()
{
	alert("SceneToolList.ListFocus() ");
	
	if(this.MimFocusIndex > 0)
	{
		this.ToolList.SetHighlightForDataIndex(this.MimFocusIndex);	
	}
	else{
		this.ToolList.highlight();
	}

}


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

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

	switch(this_.MenuType) {

		case TOOL_MENU_LIST_TYPE.VIDEO_CALL:
			this_.ProcessEnterVidoeCallType(Index);
			break;			

		case TOOL_MENU_LIST_TYPE.VIDEO_CALL_WITH_EXT_CAM:
			this_.ProcessEnterVidoeCallExCamType(Index);
			break;			

		case TOOL_MENU_LIST_TYPE.VOICE_CALL:
			this_.ProcessEnterVocieCallType(Index);			
			break;

		case TOOL_MENU_LIST_TYPE.VOICE_CALL_BUTTON:
			this_.ProcessEnterVocieButtonType(Index);			
			break;
			
	}
}

SceneToolList.prototype.ProcessEnterVidoeCallType = function(Index){

	switch(Index) {
		
		case 0:
			this.enterLightAdjustMenu();
			break;
		case 1:
			this.enterChangeViewMenu();
			break;				
		case 2:
			this.enterContactListMenu();
			break;	
	}		
	
}

SceneToolList.prototype.ProcessEnterVidoeCallExCamType = function(Index){

	switch(Index) {
		
		case 0:
			this.enterChangeViewMenu();
			break;
		case 1:
			this.enterContactListMenu();
			break;
	}		
	
}


SceneToolList.prototype.ProcessEnterVocieCallType = function(Index){

	this.enterContactListMenu();
}

SceneToolList.prototype.ProcessEnterVocieButtonType = function(Index){

	// alert("SceneToolList.ProcessEnterVocieButtonType()");
	
	switch(Index) {
		
		case 0:
			this.enterChangePhoneNumberMenu();
			break;
		case 1:
			this.enterSignOutMenu();
			break;				
		case 2:
			this.enterAddContactMenu();
			break;	
	}
}

SceneToolList.prototype.enterLightAdjustMenu = function(){
	alert("SceneToolList.enterLightAdjustMenu()");

	// this.ToolListDim.hide();	
	this.ShowSublList();
}

SceneToolList.prototype.enterChangeViewMenu = function(){
	alert("SceneToolList.enterChangeViewMenu()");

	StateMgr.Stop_List_Tools_State(true);
	WndMgr.ChangeVideoCallScreen();      	
}

SceneToolList.prototype.enterContactListMenu = function(){
	alert("SceneToolList.enterContactListMenu()");

	if(ProcMgr.isGenoaS == false)
	{
		StateMgr.Start_Live_Contact_List_State();
	}
}


SceneToolList.prototype.enterChangePhoneNumberMenu = function(){
	alert("SceneToolList.enterChangePhoneNumberMenu()");
}

SceneToolList.prototype.enterSignOutMenu = function(){
	alert("SceneToolList.enterSignOutMenu()");
}

SceneToolList.prototype.enterAddContactMenu = function(){
	alert("SceneToolList.enterAddContactMenu()");
}


SceneToolList.prototype.processReturnKey = function(){

	alert("SceneToolList.processReturnKey()");

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


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

SceneToolList.prototype.resetTimer = function()
{
    alert("SceneToolList.resetTimer() ");

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

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

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


SceneToolList.prototype.SetLightAdjustMenu = function(Index){
	
	alert("SceneToolList.SetLightAdjustMenu -- " + Index);
	
	// $("#ToolMenuListItem1Text").css('font-size','16px');
	// this.ChangeTextFont = true;
		
	this.LightAdjustMenuIndex = Index;
	this.SetLightAdjustValueText()
	this.ToolList.SetEnableItem(Index);
	
	//Set index ...... it is possible to focus
	if(Index < this.MimFocusMenuIndex)
	{
		this.MimFocusMenuIndex = Index;
	}


	var CurLangID = ResMgr.GetCurLanguage();

 	if(CurLangID == ENUM_TV_LANGUAGE.MKD || CurLangID == ENUM_TV_LANGUAGE.POL || CurLangID == ENUM_TV_LANGUAGE.POR || CurLangID == ENUM_TV_LANGUAGE.ROM || 
 		CurLangID == ENUM_TV_LANGUAGE.RUS || CurLangID == ENUM_TV_LANGUAGE.SPA || CurLangID == ENUM_TV_LANGUAGE.ZUL)
 	{
		$("#ToolMenuListItem1Text").css('font-size', "15px" );
   	}
   	else if(CurLangID == ENUM_TV_LANGUAGE.TAM)
   	{
   		$("#ToolMenuListItem1Text").css('font-size', "14px" );
   	}
}

SceneToolList.prototype.SetLightAdjustValueText = function(){
	
	
	var value =	PluginAPIMgr.GetCameraLightMode();
	alert("SceneToolList.SetLightAdjustValueTextvalueText >> mode : " + value);	
		
	var valueText = null;
	
	if(value == 1)
	{
		valueText = SID_LOW_KR_VOL;
	}
	else if(value == 2)
	{
		valueText = COM_SID_MEDIUM;	
	}
	else if(value == 3)
	{
		valueText = SID_HIGH_KR_VOL;
	}
	else
	{
		valueText = SID_OFF_KR_DEACT;		
	}
		
	alert("valueText == " + valueText);	
	
	//Camera Light Adjustment
	var tempdata;

	var CurLangID = ResMgr.GetCurLanguage();

 	if(CurLangID == ENUM_TV_LANGUAGE.TAM)
 	{
		tempdata = [TV_CAMERA_LIGHT_ADJUSTMENT + ":" + valueText ,null];
   	}
   	else{
		tempdata = [TV_CAMERA_LIGHT_ADJUSTMENT + " : " + valueText ,null];
   	}



	
	var this_ = sf.scene.get("ToolList");
	
	this_.LightAdjustMenuValue = value;
	this_.ToolList.ChangeData(this_.LightAdjustMenuIndex,tempdata);
	
	
	this_.startTimer();
}

SceneToolList.prototype.SetChangeViewMenu = function(Index){

	alert("SceneToolList.SetChangeViewMenu -- " + Index);
		
	var tempdata;
	
 	if(WndMgr.isShowVideoCallNormal == true)
 	{
 		tempdata = [TV_SID_LARGE_SCREEN ,null];
 	}
 	else if(WndMgr.isShowVideoCallSD == true)
 	{
 		tempdata = [SID_FULL_SCREEN ,null];
 	}
 	else if(WndMgr.isShowVideoCallHD == true)
 	{
 		tempdata = [TV_SID_NORMAL_SCREEN ,null];
 	}
 	
	this.ToolList.ChangeData(Index,tempdata);
	this.ToolList.SetEnableItem(Index);

	//Set index ...... it is possible to focus
	if(Index < this.MimFocusMenuIndex)
	{
		this.MimFocusMenuIndex = Index;
	}	
	
}

SceneToolList.prototype.SetContactListMenu = function(Index){

	alert("SceneToolList.SetContactListMenu -- " + Index);
	var tempdata = [TV_SID_CONTACK_LIST ,null];
	this.ToolList.ChangeData(Index,tempdata);
	this.ToolList.SetEnableItem(Index);

	//Set index ...... it is possible to focus
	if(Index < this.MimFocusMenuIndex)
	{
		this.MimFocusMenuIndex = Index;
	}	
	
}


SceneToolList.prototype.SetChangePhoneNumberMenu = function(Index){

	alert("SceneToolList.SetChangePhoneNumberMenu -- " + Index);
	var tempdata = [TV_CHANGE_PHONE_NUMBER,null];
	this.ToolList.ChangeData(Index,tempdata);
	this.ToolList.SetEnableItem(Index);

	if(Index < this.MimFocusMenuIndex)
	{
		this.MimFocusMenuIndex = Index;
	}	
	
}

SceneToolList.prototype.SetSignOutMenu = function(Index){

	alert("SceneToolList.SetSignOutMenu -- " + Index);
	var tempdata = [IDWS_MOIP_POPUP_EXIT_SIGN_OUT,null];
	this.ToolList.ChangeData(Index,tempdata);
	this.ToolList.SetEnableItem(Index);

	if(Index < this.MimFocusMenuIndex)
	{
		this.MimFocusMenuIndex = Index;
	}	
	
}


SceneToolList.prototype.SetAddContactMenu = function(Index){

	alert("SceneToolList.SetAddContactMenu -- " + Index);
	var tempdata = [IDWS_MOIP_SKYPE_ADD_A_CONTACT,null];
	this.ToolList.ChangeData(Index,tempdata);
	this.ToolList.SetEnableItem(Index);

	if(Index < this.MimFocusMenuIndex)
	{
		this.MimFocusMenuIndex = Index;
	}	
	
}


SceneToolList.prototype.SetBlankMenu = function(Index){

	alert("SceneToolList.SetBlankMenu -- " + Index);
	var tempdata = [" " ,null];
	this.ToolList.ChangeData(Index,tempdata);
	this.ToolList.SetDisableItem(Index);
	
}


SceneToolList.prototype.ShowSublList = function(){

    alert("SceneToolList.ShowSublList() ");

	alert(">>>>" + this.LightAdjustMenuValue);
	
	this.stopTimer();
	
	sf.scene.get('ToolListLightSeletor').Init(this.LightAdjustMenuValue,this.SetLightAdjustValueText);
	sf.scene.show('ToolListLightSeletor');
	sf.scene.focus('ToolListLightSeletor');
	
	this.ShownSubList = true;

}

/*
SceneToolList.prototype.ShowAddAssignedPhoneNumberPopup = function()
{
	StateMgr.Start_Add_Phone_Number_State();
}

SceneToolList.prototype.ShowSignOutPopup = function()
{
	//reset g_data
	g_Data.SetAssignedPhoneNumberInfo(null,-1,-1,null,false);
	
	StateMgr.Start_Signout_State();

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

SceneToolList.prototype.ShowAddContactPopup = function()
{
	//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();	
	
}

*/


SceneToolList.prototype.processClickEvent = function(Index){
		
	switch(this.MenuType)
	{
		case TOOL_MENU_LIST_TYPE.VIDEO_CALL:
			this.ProcessEnterVidoeCallType(Index);
			break;			

		case TOOL_MENU_LIST_TYPE.VIDEO_CALL_WITH_EXT_CAM:
			this.ProcessEnterVidoeCallExCamType(Index);
			break;			

		case TOOL_MENU_LIST_TYPE.VOICE_CALL:
			this.ProcessEnterVocieCallType(Index);			
			break;

		case TOOL_MENU_LIST_TYPE.VOICE_CALL_BUTTON:
			this.ProcessEnterVocieButtonType(Index);			
			break;			
	}
}


SceneToolList.prototype.onClickEventFunc1 = function(){
		
	var This_ = sf.scene.get("ToolList");
	This_.processClickEvent(0);
}

SceneToolList.prototype.onClickEventFunc2 = function(){

	var This_ = sf.scene.get("ToolList");
	This_.processClickEvent(1);
}

SceneToolList.prototype.onClickEventFunc3 = function(){
	
	var This_ = sf.scene.get("ToolList");
	This_.processClickEvent(2);
}
/*
SceneToolList.prototype.onClickEventFunc4 = function(){
	
	var This_ = sf.scene.get("ToolList");
	This_.processClickEvent(3);	
}

SceneToolList.prototype.onClickEventFunc5 = function(){

	var This_ = sf.scene.get("ToolList");
	This_.processClickEvent(4);	
}

SceneToolList.prototype.onClickEventFunc6 = function(){
	
	var This_ = sf.scene.get("ToolList");
	This_.processClickEvent(5);	
}

SceneToolList.prototype.onClickEventFunc7 = function(){
	
	var This_ = sf.scene.get("ToolList");
	This_.processClickEvent(6);	
	
}
*/