function SceneListMain(options) {
	this.options = options;
    
    this.ListMainView=null;
    this.ListMainLine=null;
    this.ListMainSkypeLogo=null;
    this.AvataFrameLabel=null;
    this.AvataImageLabel=null;
    this.OnlineStatusLabel=null;
    this.SkypeNameLabel=null;
    this.MoodMessageLabel=null;

	this.SkypeCreditValueBg=null;
	this.SkypeCreditValueLogo=null;
    this.SkypeCreditValueLabel=null;
    this.SkypeCreditZeroValueLabel=new Array(3);
    
    this.ListMainContactBtn=null;
    this.ListMainHistoryBtn=null;
    this.ListMainCallBtn=null;
    this.ListMainLiveCallBtn=null;
    this.ListMainProfileBtn=null;
    this.ListMainSettingBtn=null;

    this.ContactHelpBar =null;
    this.DefaultHelpBar =null;
    
    this.iCurrentSubScene = 0;
	this.ListMainIndex = 0;
    
    this.BtnList = new Array(5);
    
    this.destroyFlag = true;
    this.liveCallFlag = false;
    this.MouseOverFlag = false;
    this.flagFocus = false;
    
    this.HelpBarData = null;
    
	// Tooltip
	this.ToolTipBgId ="list_main_tooltip";
	this.ToolTipHTML="";
	this.isShownToolTip = false;
	this.TooltipTimer = null;
	this.ToolTipTxtWidth = 0;
}

SceneListMain.prototype.initialize = function () {
	alert("SceneListMain.initialize()");
	// this function will be called only once when the scene manager show this scene first time
	// initialize the scene controls and styles, and initialize your variables here 
	// scene HTML and CSS will be loaded before this function is called
   
    this.create();
}

SceneListMain.prototype.handleShow = function () {
	alert("SceneListMain.handleShow()");
	// this function will be called when the scene manager show this scene 
    this.initListMain();
}

SceneListMain.prototype.handleHide = function () {
	alert("SceneListMain.handleHide()");
	// this function will be called when the scene manager hide this scene  
    
    //sf.scene.hide(this.SubSceneId[this.iCurrentSubScene]);
    WndMgr.HideMainSub(this.iCurrentSubScene);    
    
	if(this.TooltipTimer)
		this.hideToolTip();
}

SceneListMain.prototype.handleFocus = function () {
	alert("SceneListMain.handleFocus()");
	// this function will be called when the scene manager focus this scene

     var a=0;
     for(a=0; a<this.BtnList.length; a++)
     {
         WndMgr.MainSubScene[a].flagSelect = false;
     }
    HelpBar.changeHelpBarItems(this.HelpBarData); 
    this.highlight(this.BtnList[this.iCurrentSubScene].obj, this.iCurrentSubScene);
    
    this.flagFocus = true;
}

SceneListMain.prototype.handleBlur = function () {
	alert("SceneListMain.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
    if(WndMgr.MainSubScene[this.iCurrentSubScene].flagSelect == false)
    {
        this.BtnList[this.iCurrentSubScene].obj.blur();
    }
    
    this.flagFocus = false;
  /*
    if(this.TooltipTimer)
          this.hideToolTip();*/
  
}

SceneListMain.prototype.handleKeyDown = function (keyCode) {
	alert("SceneListMain.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	/*
	if(this.TooltipTimer)
			this.hideToolTip();*/
	
	switch (keyCode) {
		case sf.key.LEFT:
			break;
		case sf.key.RIGHT:
			this.processRightKey();
			break;
		case sf.key.UP:
            this.processUpKey();
			break;
		case sf.key.DOWN:
            this.processDownKey();
			break;

		case sf.key.ENTER:
            this.processEnterKey();
			break;
            
       case sf.key.RED:
            this.processRedKey();
			break;
        
        case sf.key.YELLOW:
            this.processYellowKey();
			break;

    /*
        case sf.key.BLUE:
            this.processBlue();
                break;*/
    
			            
        case sf.key.RETURN:
            this.processReturnKey();
            //2013 modify by minseok
            sf.key.preventDefault();
			break;
            
        case sf.key.EXIT:
            this.processExitKey();
            //2013 modify by minseok
            sf.key.preventDefault();
			break;
        
        case 147:  //infolink
        case 261:  //contents
        case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
            
       default:
            ProcMgr.processBlockKey(keyCode);
            break;  
	}
}

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

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

	this.ListMainView = new View("ListMain");
    this.ListMainView.SetBgImage(g_Image.IMAGE_LIST_MAIN_BG);

    this.ListMainSkypeLogo= new Label("list_main_skype_logo", null);
    this.ListMainSkypeLogo.SetBgImage(g_Image.IMAGE_LIST_MAIN_SKYPE_LOGO);

    this.ListMainLine= new Label("list_main_line", null);
    this.ListMainLine.SetBgImage(g_Image.IMAGE_LIST_MAIN_LINE);
 
    this.AvataFrameLabel= new Label("list_main_avata_frame", null);
    this.AvataFrameLabel.SetBgImage(g_Image.IMAGE_LIST_MAIN_ONLY_MY_THUMBNAIL);
    this.AvataFrameLabel.AppendFgImage("list_main_avata_image","0px","0px","85px","85px");

    this.OnlineStatusLabel= new Label("list_main_online_status", null);

    this.SkypeNameLabel = new Label(null,"list_main_skype_name");
    this.SkypeNameLabel.SetTextStyle("list_main_skype_name_style");
    this.SkypeNameLabel.SetReverseDisable(true);
    this.SkypeNameLabel.SetIsPlainText(true);

    this.MoodMessageLabel = new Label(null,"list_main_mood_message");
    this.MoodMessageLabel.SetTextStyle("list_main_mood_message_style");
    this.MoodMessageLabel.SetReverseDisable(true);
    this.MoodMessageLabel.SetIsPlainText(true);
    
    this.SkypeCreditValueBg= new Label("list_main_skype_credit_value_bg", null);
    this.SkypeCreditValueBg.SetBgImage(g_Image.IMAGE_LIST_MAIN_CREDIT_BTN);

    this.SkypeCreditValueLogo= new Label("list_main_skype_credit_value_logo", null);
    this.SkypeCreditValueLogo.SetBgImage(g_Image.IMAGE_LIST_MAIN_CREDIT_LOGO);
 
    this.SkypeCreditValueLabel= new Label(null, "list_main_skype_credit_value");
    this.SkypeCreditValueLabel.SetTextStyle("list_main_skype_credit_value_style");
    this.SkypeCreditValueLabel.SetReverseDisable(true);
    
    this.SkypeCreditZeroValueLabel[0]= new Label(null, "list_main_skype_credit_zero_value_1");
    this.SkypeCreditZeroValueLabel[0].SetTextStyle("list_main_skype_credit_zero_value_style_1");
    this.SkypeCreditZeroValueLabel[0].SetText(TV_SID_SKYPE_CREDIT);
    
    this.SkypeCreditZeroValueLabel[1]= new Label(null, "list_main_skype_credit_zero_value_2");
    this.SkypeCreditZeroValueLabel[1].SetTextStyle("list_main_skype_credit_zero_value_style_2");
    this.SkypeCreditZeroValueLabel[1].SetText(":");
    
    this.SkypeCreditZeroValueLabel[2]= new Label(null, "list_main_skype_credit_zero_value_3");
    this.SkypeCreditZeroValueLabel[2].SetTextStyle("list_main_skype_credit_zero_value_style_3");
    this.SkypeCreditZeroValueLabel[2].SetText("0");

	var this_ = sf.scene.get('ListMain');
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	
    this.ListMainContactBtn = new Button();
    this.ListMainContactBtn.SetImageObjId("list_main_contact_btn");
//    this.ListMainContactBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, " ");
    this.ListMainContactBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_NORMALFOCUS);
	this.ListMainContactBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_SELECTED);
    this.ListMainContactBtn.SetIconObjId("list_main_contact_icon");
    this.ListMainContactBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_CONTACT_BTN_ICON);
    this.ListMainContactBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_FOCUS_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_CONTACT_BTN_ICON_SELECT);
	this.ListMainContactBtn.SetBgIcon(BtnIconIndex.BTN_SELECTED_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_CONTACT_BTN_ICON);
    this.ListMainContactBtn.SetTextObjId("list_main_contact_btn_text");
	this.ListMainContactBtn.SetIsTextInTable(true);
    this.ListMainContactBtn.SetText(TV_SID_VOICE_CONTACT);
    this.ListMainContactBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"list_main_category_btn_style_nor");
    this.ListMainContactBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"list_main_category_btn_style_focus"); 
    this.ListMainContactBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_SELECTED_STYLE,"list_main_category_btn_style_selected");  
	this.ListMainContactBtn.AppendFgImage("list_main_contact_btn_icon");
    this.ListMainContactBtn.SetFgImage(g_Image.IMAGE_LIST_MAIN_CATEGORY_CONTACT_BTN_ICON);		
	this.ListMainContactBtn.SetOnClickCallbackFunc(clickCF);

    this.ListMainHistoryBtn = new Button();
    this.ListMainHistoryBtn.SetImageObjId("list_main_history_btn");
//    this.ListMainHistoryBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, " ");
    this.ListMainHistoryBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_NORMALFOCUS);
	this.ListMainHistoryBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_SELECTED);
    this.ListMainHistoryBtn.SetIconObjId("list_main_history_icon");
    this.ListMainHistoryBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_HISTORY_BTN_ICON);
    this.ListMainHistoryBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_FOCUS_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_HISTORY_BTN_ICON_SELECT);
	this.ListMainHistoryBtn.SetBgIcon(BtnIconIndex.BTN_SELECTED_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_HISTORY_BTN_ICON);
    this.ListMainHistoryBtn.SetTextObjId("list_main_history_btn_text");
	this.ListMainHistoryBtn.SetIsTextInTable(true);
    this.ListMainHistoryBtn.SetText(TV_SID_VOICE_HISTORY);
    this.ListMainHistoryBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"list_main_category_btn_style_nor");
    this.ListMainHistoryBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"list_main_category_btn_style_focus");
    this.ListMainHistoryBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_SELECTED_STYLE,"list_main_category_btn_style_selected");
    this.ListMainHistoryBtn.AppendFgImage("list_main_history_btn_icon");
    this.ListMainHistoryBtn.SetFgImage(g_Image.IMAGE_LIST_MAIN_CATEGORY_HISTORY_BTN_ICON);	
	this.ListMainHistoryBtn.SetOnClickCallbackFunc(clickCF);

    this.ListMainCallBtn = new Button();
    this.ListMainCallBtn.SetImageObjId("list_main_call_btn");
//    this.ListMainCallBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, " ");
    this.ListMainCallBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_NORMALFOCUS);
    this.ListMainCallBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_SELECTED);
    this.ListMainCallBtn.SetIconObjId("list_main_call_icon");
    this.ListMainCallBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_CALL_BTN_ICON);
    this.ListMainCallBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_FOCUS_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_CALL_BTN_ICON_SELECT);
	this.ListMainCallBtn.SetBgIcon(BtnIconIndex.BTN_SELECTED_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_CALL_BTN_ICON);
    this.ListMainCallBtn.SetTextObjId("list_main_call_btn_text");
	this.ListMainCallBtn.SetIsTextInTable(true);
    this.ListMainCallBtn.SetText(TV_SID_VOICE_CALL_PHONES);
    this.ListMainCallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"list_main_category_btn_style_nor");
    this.ListMainCallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"list_main_category_btn_style_focus");
    this.ListMainCallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_SELECTED_STYLE,"list_main_category_btn_style_selected");
    this.ListMainCallBtn.AppendFgImage("list_main_call_btn_icon");
    this.ListMainCallBtn.SetFgImage(g_Image.IMAGE_LIST_MAIN_CATEGORY_CALL_BTN_ICON);    
	this.ListMainCallBtn.SetOnClickCallbackFunc(clickCF);

    this.ListMainLiveCallBtn = new Button();
    this.ListMainLiveCallBtn.SetImageObjId("list_main_live_call_btn");
//    this.ListMainLiveCallBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, " ");
    this.ListMainLiveCallBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_NORMALFOCUS);
    this.ListMainLiveCallBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_SELECTED);
    this.ListMainLiveCallBtn.SetIconObjId("list_main_live_call_icon");
    this.ListMainLiveCallBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_LIVE_CALL_BTN_ICON);
    this.ListMainLiveCallBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_FOCUS_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_LIVE_CALL_BTN_ICON_SELECT);
	this.ListMainLiveCallBtn.SetBgIcon(BtnIconIndex.BTN_SELECTED_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_LIVE_CALL_BTN_ICON);
    this.ListMainLiveCallBtn.SetTextObjId("list_main_live_call_btn_text");
	this.ListMainLiveCallBtn.SetIsTextInTable(true);    
  //  this.ListMainLiveCallBtn.SetText(TV_SID_LIVE_CALL);
    this.ListMainLiveCallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"list_main_category_btn_style_nor");
    this.ListMainLiveCallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"list_main_category_btn_style_focus");
    this.ListMainLiveCallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_SELECTED_STYLE,"list_main_category_btn_style_selected");
    this.ListMainLiveCallBtn.AppendFgImage("list_main_live_call_btn_icon");
    this.ListMainLiveCallBtn.SetFgImage(g_Image.IMAGE_LIST_MAIN_CATEGORY_LIVE_CALL_BTN_ICON);       
	this.ListMainLiveCallBtn.SetOnClickCallbackFunc(clickCF);

    this.ListMainProfileBtn = new Button();
    this.ListMainProfileBtn.SetImageObjId("list_main_profile_btn");
//    this.ListMainProfileBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, " ");
    this.ListMainProfileBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_NORMALFOCUS);
    this.ListMainProfileBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_SELECTED);
    this.ListMainProfileBtn.SetIconObjId("list_main_profile_icon");
    this.ListMainProfileBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_PROFILE_BTN_ICON);
    this.ListMainProfileBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_FOCUS_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_PROFILE_BTN_ICON_SELECT);
	this.ListMainProfileBtn.SetBgIcon(BtnIconIndex.BTN_SELECTED_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_PROFILE_BTN_ICON);
    this.ListMainProfileBtn.SetTextObjId("list_main_profile_btn_text");
	this.ListMainProfileBtn.SetIsTextInTable(true);
    this.ListMainProfileBtn.SetText(TV_SID_VOICE_PROFILE);
    this.ListMainProfileBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"list_main_category_btn_style_nor");
    this.ListMainProfileBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"list_main_category_btn_style_focus");
    this.ListMainProfileBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_SELECTED_STYLE,"list_main_category_btn_style_selected");
    this.ListMainProfileBtn.AppendFgImage("list_main_profile_btn_icon");
    this.ListMainProfileBtn.SetFgImage(g_Image.IMAGE_LIST_MAIN_CATEGORY_PROFILE_BTN_ICON);        
	this.ListMainProfileBtn.SetOnClickCallbackFunc(clickCF);


    this.ListMainSettingBtn = new Button();
    this.ListMainSettingBtn.SetImageObjId("list_main_setting_btn");
//    this.ListMainSettingBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, " ");
    this.ListMainSettingBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_NORMALFOCUS);
	this.ListMainSettingBtn.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_SELECTED);
    this.ListMainSettingBtn.SetIconObjId("list_main_setting_icon");
    this.ListMainSettingBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_SETTINGS_BTN_ICON);
    this.ListMainSettingBtn.SetBgIcon(BtnIconIndex.BTN_NORMAL_FOCUS_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_SETTINGS_BTN_ICON_SELECT);
	this.ListMainSettingBtn.SetBgIcon(BtnIconIndex.BTN_SELECTED_ICON, g_Image.IMAGE_LIST_MAIN_CATEGORY_SETTINGS_BTN_ICON);
    this.ListMainSettingBtn.SetTextObjId("list_main_setting_btn_text");
	this.ListMainSettingBtn.SetIsTextInTable(true);
    this.ListMainSettingBtn.SetText(SID_SETTINGS);
    this.ListMainSettingBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"list_main_category_btn_style_nor");
    this.ListMainSettingBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"list_main_category_btn_style_focus");
    this.ListMainSettingBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_SELECTED_STYLE,"list_main_category_btn_style_selected");
    this.ListMainSettingBtn.AppendFgImage("list_main_setting_btn_icon");
    this.ListMainSettingBtn.SetFgImage(g_Image.IMAGE_LIST_MAIN_CATEGORY_SETTINGS_BTN_ICON);    
	this.ListMainSettingBtn.SetOnClickCallbackFunc(clickCF);


	this.ListMainContactBtn.SetOnMouseOverCallbackFunc(function(obj) {this_.processMouseOver(obj);});
	this.ListMainHistoryBtn.SetOnMouseOverCallbackFunc(function(obj) {this_.processMouseOver(obj);});
	this.ListMainCallBtn.SetOnMouseOverCallbackFunc(function(obj) {this_.processMouseOver(obj);});
	this.ListMainProfileBtn.SetOnMouseOverCallbackFunc(function(obj) {this_.processMouseOver(obj);});
	this.ListMainSettingBtn.SetOnMouseOverCallbackFunc(function(obj) {this_.processMouseOver(obj);});

	this.ListMainContactBtn.SetOnMouseOutCallbackFunc(function(obj) {this_.processMouseOut(obj);});
	this.ListMainHistoryBtn.SetOnMouseOutCallbackFunc(function(obj) {this_.processMouseOut(obj);});
	this.ListMainCallBtn.SetOnMouseOutCallbackFunc(function(obj) {this_.processMouseOut(obj);});
	this.ListMainProfileBtn.SetOnMouseOutCallbackFunc(function(obj) {this_.processMouseOut(obj);});
	this.ListMainSettingBtn.SetOnMouseOutCallbackFunc(function(obj) {this_.processMouseOut(obj);});

	//helpbar
	HelpBar.createHelpBar("SceneListMain");
	this.HelpBarData  = {
		'red': IDWS_MOIP_POPUP_EXIT_SIGN_OUT,
		'yellow':IDWS_MOIP_SKYPE_ADD_A_CONTACT,
		'tools' : SID_TOOLS,
		'return' : SID_RETURN
	};
	HelpBar.setHelpBarItems(this.HelpBarData);
	
	for(var a=0; a<this.BtnList.length; a++)
	{
	    this.BtnList[a]=new Object();
	}
	
	this.ToolTipHTML = this.getToolTipHTML();
	$("#ListMain").append(this.ToolTipHTML);

}

SceneListMain.prototype.setDestroyFlag= function(destroy_flag){
     this.destroyFlag = destroy_flag;
}

SceneListMain.prototype.setLiveCallFlag= function(live_call_flag){
     this.liveCallFlag = live_call_flag;
}

SceneListMain.prototype.initListMain=function()
{
    alert("SceneListMain.initListMain()");
    
    this.update();
    
    if(this.destroyFlag==true)
    {
	    alert("initListMain() --> destroyFlag == true");
        this.iCurrentSubScene = 0;
        for(var a=0; a<this.BtnList.length; a++)
        {
            WndMgr.MainSubScene[a].flagSelect = false;
        }

        this.BtnList[0].obj =  this.ListMainContactBtn; 
        this.BtnList[1].obj =  this.ListMainHistoryBtn;
        this.BtnList[2].obj =  this.ListMainCallBtn;
        this.BtnList[3].obj =  this.ListMainProfileBtn;
        this.BtnList[4].obj =  this.ListMainSettingBtn;
        
        //2013 add by minseok
        this.BtnList[0].helpbarData =  {
        	'red': IDWS_MOIP_POPUP_EXIT_SIGN_OUT,
			'yellow':IDWS_MOIP_SKYPE_ADD_A_CONTACT,
			'return' : SID_RETURN
        } 
        this.BtnList[1].helpbarData =  {
        	'red': IDWS_MOIP_POPUP_EXIT_SIGN_OUT,
			'return' : SID_RETURN
        }
        this.BtnList[2].helpbarData =  {
        	'red': IDWS_MOIP_POPUP_EXIT_SIGN_OUT,
			'return' : SID_RETURN
        }
        this.BtnList[3].helpbarData =  {
        	'red': IDWS_MOIP_POPUP_EXIT_SIGN_OUT,
			'return' : SID_RETURN
        }
        this.BtnList[4].helpbarData =  {
        	'red': IDWS_MOIP_POPUP_EXIT_SIGN_OUT,
			'return' : SID_RETURN
        }
        
        this.ListMainCallBtn.visibleObj();
        this.ListMainLiveCallBtn.hiddenObj();
		if(this.isShownToolTip == false) {
			this.showToolTip();
			this.isShownToolTip = true;
		}
		this.initGoContactList();	
        this.destroyFlag = false;
    }
    
    if( this.liveCallFlag==true)
    {
        this.ListMainCallBtn.hiddenObj();
        this.BtnList[2].obj =  this.ListMainLiveCallBtn;
        this.ListMainLiveCallBtn.visibleObj();
    }
    else
    {
        this.ListMainLiveCallBtn.hiddenObj();
        this.BtnList[2].obj =  this.ListMainCallBtn;
        this.ListMainCallBtn.visibleObj();
    }
    
    if(WndMgr.MainSubScene[2].flagSelect ==true)
    {
         this.BtnList[2].obj.select();
    }
	
}

SceneListMain.prototype.initGoContactList=function(){
		
	if(PluginAPIMgr.GetNumberOfContacts() > 0 && this.iCurrentSubScene == 0) {
		
	    alert("initGoContactList : GetNumberOfContacts > 0");
		this.ListMainView.setCurrenHighlight(this.BtnList[this.iCurrentSubScene].obj);
		WndMgr.ShowMainSub(this.iCurrentSubScene);
		this.ListMainView.setCurrentSelect(this.BtnList[this.iCurrentSubScene].obj);
		WndMgr.SelectMainSub(this.iCurrentSubScene);
	} 
}

SceneListMain.prototype.showToolTip=function()
{
	var YellowBtn = $("#SceneListMain_helpbar .sf-ui-keyhelp-icon-yellow").offset();
    alert("********** YellowBtn = Left("+YellowBtn.left+"), Top("+YellowBtn.top+")");
	
	if(YellowBtn.left) {
		$('#list_main_tooltip_arrow').css('left', (YellowBtn.left)+'px');
		$("#"+this.ToolTipBgId).css("display","block");
		
		var _This = sf.scene.get('ListMain');
		this.TooltipTimer = setTimeout("CloseTimerCF()", 7000);	
		CloseTimerCF = function(){
			alert("HelpBar -> tooltip time out");
			_This.hideToolTip();
		} 
	}
}

SceneListMain.prototype.hideToolTip=function()
{
	alert("SceneListMain.prototype.hideToolTip");

	$("#"+this.ToolTipBgId).css("display","none");
	
	clearTimeout(this.TooltipTimer);
	this.TooltipTimer=null;
}
   
SceneListMain.prototype.getToolTipHTML = function()
{
	alert("SceneListMain.prototype.getToolTipHTML");
	
	var wrapHTML = "";
	wrapHTML += "<div id ='"+this.ToolTipBgId+"'>"
	wrapHTML += "<table cellpadding='0px' cellspacing='0px' align='right' style='table-layout:fixed; height:80px;'>";
	wrapHTML += "<tr valign='middle'>";
	wrapHTML += "<td style='width: 20px; background-image :url(images/720p/tooltip/tooltip_left.png); background-repeat: no-repeat;'></td>";
	wrapHTML += "<td style='background-image :url(images/720p/tooltip/tooltip_center.png); background-repeat: repeat-x;'>";
	wrapHTML += "<div id ='list_main_tooltip_text' style='padding-bottom:20px; line-height:24px; height:24px;' class='tooltip_style_default'>"+TV_SELECT_ADD_A_CONTACT_MSG+"</div>";
	wrapHTML += "</td>"
	wrapHTML += "<td style='width: 20px; background-image :url(images/720p/tooltip/tooltip_right.png); background-repeat: no-repeat;'></td>";
	wrapHTML += "<td style='width: 100px;'></td>";
	wrapHTML += "</tr>";
	wrapHTML += "</table>";
	wrapHTML += "<div id='list_main_tooltip_arrow' style='position:absolute; top:58px; width:25px; height:22px; background-image :url(images/720p/tooltip/tooltip_point_bottom.png);'></div>";
	wrapHTML += "</div>";
	
	return wrapHTML;
}

SceneListMain.prototype.toggleCameraOffBtnEnable=function()
{
    alert("SceneListMain.toggleCameraOffBtnEnable() ");
    
    var camera_state = PluginAPIMgr.GetCameraState();
    
    if(camera_state == ENUM_CAM_STATE.CAM_STATE_DISCONNECTED || camera_state == ENUM_CAM_STATE.CAM_STATE_CONNECTING)
    {
        alert("SceneListMain.toggleCameraOffBtnEnable() Dim : true ->  camera_state : "+ camera_state );
    }
    else
    {
        alert("SceneListMain.toggleCameraOffBtnEnable() Dim :  false ");
        if(PluginAPIMgr.IsInCall()==1)
		{
			PluginAPIMgr.StartRecord();
		}
    }    
}

SceneListMain.prototype.update=function()
{
    alert("SceneListMain.update()");
    this.updateAvata();
    this.updateOnlineStatus();
    this.updateSkypeName();
    this.updateMoodMessage();
    this.updateCredit();
}

SceneListMain.prototype.updateAvata = function()
{	
    this.AvataFrameLabel.SetFgImage(PluginAPIMgr.GetMyAvataImageForMain());	
}

SceneListMain.prototype.updateOnlineStatus= function()
{
    this.OnlineStatusLabel.SetBgImage(PluginAPIMgr.GetMyOnlineStateImage());
}

SceneListMain.prototype.updateSkypeName = function()
{
     this.SkypeNameLabel.SetText(PluginAPIMgr.GetMyDisplayName());
}

SceneListMain.prototype.updateMoodMessage= function()
{
    this.MoodMessageLabel.SetText(PluginAPIMgr.GetMyMoodMsg());
}

SceneListMain.prototype.updateCredit = function(){
	
	if(PluginAPIMgr.GetMyBalance() > 0 )
	{
		this.SkypeCreditValueLabel.SetText(PluginAPIMgr.GetMyCredit());
		this.SkypeCreditValueLabel.visibleObj();
		this.SkypeCreditZeroValueLabel[0].hiddenObj();
		this.SkypeCreditZeroValueLabel[1].hiddenObj();
		this.SkypeCreditZeroValueLabel[2].hiddenObj();
	}
	else 
	{
		//this.SkypeCreditValueLabel.SetText(TV_SID_SKYPE_CREDIT+" : "+"0");
		this.SkypeCreditValueLabel.hiddenObj();
		this.SkypeCreditZeroValueLabel[0].visibleObj();
		this.SkypeCreditZeroValueLabel[1].visibleObj();
		this.SkypeCreditZeroValueLabel[2].visibleObj();
	}	
}


SceneListMain.prototype.highlight=function(obj, index)
{
	alert("SceneListMain.highlight()");
	
    this.ListMainView.setCurrenHighlight(obj);

    if(index != this.iCurrentSubScene)
    {
       WndMgr.HideMainSub(this.iCurrentSubScene);
        this.iCurrentSubScene = index;
    }
 
    WndMgr.ShowMainSub(this.iCurrentSubScene);
	HelpBar.setHelpBarItems(this.BtnList[this.iCurrentSubScene].helpbarData);
	if(this.iCurrentSubScene!=0){
		if(this.TooltipTimer)
			this.hideToolTip();
	}else{
		if(this.TooltipTimer&&this.iCurrentSubScene==0){
		    var YellowBtn = $("#SceneListMain_helpbar .sf-ui-keyhelp-icon-yellow").offset();
			if(YellowBtn.left) {
				$('#list_main_tooltip_arrow').css('left', (YellowBtn.left)+'px');
			}
		}
	}
}

SceneListMain.prototype.select=function(obj)
{
	alert("SceneListMain.select()");
	if( WndMgr.CheckMoveSubToMain(this.iCurrentSubScene) == false || sf.scene.get(WndMgr.MainSubScene[this.iCurrentSubScene].Id).IsShownObj==false){
		return;
	}
		
	this.ListMainView.setCurrentSelect(obj);     
	WndMgr.SelectMainSub(this.iCurrentSubScene);
	
	if(this.TooltipTimer&&this.iCurrentSubScene==0){
	    var YellowBtn = $("#SceneListMain_helpbar .sf-ui-keyhelp-icon-yellow").offset();
		if(YellowBtn.left) {
			$('#list_main_tooltip_arrow').css('left', (YellowBtn.left)+'px');
		}
	}
}

SceneListMain.prototype.selectOnCurrHighlight=function()
{
	alert("SceneListMain.selectOnCurrHighlight()");
	var currentHighlight =  this.ListMainView.getCurrentHighlight();
	if(currentHighlight!=null)
	{
		this.select(currentHighlight);
	}	
}

SceneListMain.prototype.processDownKey = function(){
    alert("SceneListMain.processDownKey() ");
    var currentHighlight =  this.ListMainView.getCurrentHighlight();
    
    var a =0;
    for(a=0; a<this.BtnList.length; a++)
    {
        if(this.BtnList[a].obj == currentHighlight )
        {
            var b = a+1;
            if(b >= this.BtnList.length) { 
				b = this.BtnList.length-1;
			} else {
			this.ListMainIndex = b;
            this.highlight(this.BtnList[b].obj, b);
            //change helpbar - by minseok
            this.HelpBarData = this.BtnList[b].helpbarData;
            HelpBar.changeHelpBarItems(this.HelpBarData);
            
            RecogMgr.ChangeVoiceHelpbar();
        }
     }
}
}

SceneListMain.prototype.processUpKey = function(){
    alert("SceneListMain.processUpKey() ");
    
    var currentHighlight =  this.ListMainView.getCurrentHighlight();
    
    var a =0;
    for(a=0; a<this.BtnList.length; a++)
    {
        if(this.BtnList[a].obj == currentHighlight )
        {
            var b = a-1;
            if( b < 0 ) {
				b = 0;
			} else {
			this.ListMainIndex = b;
            this.highlight(this.BtnList[b].obj, b);
            //change helpbar - by minseok
            this.HelpBarData = this.BtnList[b].helpbarData;
            HelpBar.changeHelpBarItems(this.HelpBarData);
            
            RecogMgr.ChangeVoiceHelpbar();
        }
     }
}
}

SceneListMain.prototype.processRightKey = function(){
    
	alert("SceneListMain.processRightKey() ");
   
   this.processEnterKey();
}



SceneListMain.prototype.processEnterKey = function(){
    alert("SceneListMain.processEnterKey() ");
	
    var currentHighlight =  this.ListMainView.getCurrentHighlight();
    
	this.ListMainIndex = this.BtnList.length+1;
    this.select(currentHighlight);
       
}

SceneListMain.prototype.processYellowKey = function(){
    alert("SceneListMain.processYellowKey() ");
    
    var currentHighlight =  this.ListMainView.getCurrentHighlight();
    
   if(currentHighlight == this.ListMainContactBtn)
   {
		var IsInCall = ProcMgr.GetIsInCall();
		
		if(IsInCall){
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.NOT_AVAILABLE_DURING_CALL);
		}
		else
		{
			StateMgr.Start_Add_Contact_State();
		}       
   }      
}

SceneListMain.prototype.processRedKey = function(){
    alert("SceneListMain.processRedKey() ");
    
    StateMgr.Start_Signout_State();     
}

SceneListMain.prototype.processReturnKey = function(){
    alert("SceneListMain.processReturnKey() ");
   
  StateMgr.Start_Exit_State(true);
}

SceneListMain.prototype.processExitKey = function(){
    alert("SceneListMain.processExitKey() ");
   
   StateMgr.Start_Exit_State(false);
}

SceneListMain.prototype.processBlue = function(){
    alert("SceneListMain.processBlue() ");
    
	if(PluginAPIMgr.GetMySkyeName() == 'young477'){

		sf.scene.show('TestPopupForText');
	    sf.scene.focus('TestPopupForText');       				
	}
}

SceneListMain.prototype.gotoAndSelectCatecory = function(category_index,item_index,missed_call)
{
	alert("SceneListMain.gotoAndSelectCatecory(CurrentSubScene : "+this.iCurrentSubScene+" )");
    
    alert("category_index = "+category_index+",   item_index = "+item_index);
    
    var category_scene = null;
    
    if(category_index==0 || category_index==1) //Contact, history
    {
	   	category_scene = sf.scene.get(WndMgr.MainSubScene[category_index].Id);

		if((category_scene.CheckValidList() == true) || (category_index==1 && item_index==0 && missed_call == true)) {
	    	category_scene.SetJumpState(item_index);
		}
		else {
			if(this.iCurrentSubScene != category_index) {
			    alert("Contact & History Date == 0 or null");
				if(this.iCurrentSubScene == 0 || this.iCurrentSubScene == 1) {
			   		sf.scene.get(WndMgr.GetMainSubSceneID()).processReturnKey();
				} else if(this.iCurrentSubScene == 2) {
			   		sf.scene.get(WndMgr.GetMainSubSceneID()).ReturnToMain();
				} else {
					WndMgr.ReturnSubToMain();
				}
		    	this.highlight(this.BtnList[category_index].obj, category_index);
		        this.HelpBarData = this.BtnList[category_index].helpbarData;
		        HelpBar.changeHelpBarItems(this.HelpBarData);
		        RecogMgr.ChangeVoiceHelpbar();
				return;
			}
		}
    }

	//Show sub Main win
    if(this.iCurrentSubScene != category_index)
    {
    	this.ListMainView.setCurrenHighlight(this.BtnList[category_index].obj);
    	 
		WndMgr.HideMainSub(this.iCurrentSubScene);
		
		this.iCurrentSubScene = category_index;
		WndMgr.ShowMainSub(category_index);		
    }
    else
    {
    	if(category_scene != null)
    	{
    		if( category_index==0 || category_index==1) //contact, history
	    	{
	    		if(category_scene.IsShownObj == false)
	    		{
	    			WndMgr.ShowMainSub(category_index);
	    		}
	    		if( WndMgr.MainSubScene[category_index].flagSelect == true){
					sf.scene.focus(WndMgr.MainSubScene[category_index].Id);    
	    		}
	    		
	    		category_scene.Refresh();
	    	}
    	}
    }
 
 	//Select focus..
	if(WndMgr.MainSubScene[category_index].flagSelect == false)
    {
    	this.ListMainView.setCurrentSelect(this.BtnList[category_index].obj);
    	WndMgr.SelectMainSub(category_index);
    }	
}


SceneListMain.prototype.gotoContact = function()
{
	alert("SceneListMain.gotoContact()");
    
    alert("CurrentSubScene = " + this.iCurrentSubScene);

	//Show sub Main win
    if(this.iCurrentSubScene != 0)
    {
    	this.ListMainView.setCurrenHighlight(this.BtnList[0].obj);
    	 
		WndMgr.HideMainSub(this.iCurrentSubScene);
		
		this.iCurrentSubScene = 0;
		WndMgr.ShowMainSub(0);		
    }
 
 	//Select focus..
    if(WndMgr.MainSubScene[0].flagSelect == false)
    {
    	this.ListMainView.setCurrentSelect(this.BtnList[0].obj);
    	WndMgr.SelectMainSub(0);
    }	
}

SceneListMain.prototype.gotoHistory = function()
{
	alert("SceneListMain.gotoHistory()");
    
    alert("CurrentSubScene = " + this.iCurrentSubScene);

	//Show sub Main win
    if(this.iCurrentSubScene != 1)
    {
    	this.ListMainView.setCurrenHighlight(this.BtnList[1].obj);
    	 
		WndMgr.HideMainSub(this.iCurrentSubScene);
		
		this.iCurrentSubScene = 1;
		WndMgr.ShowMainSub(1);		
    }
 
 	//Select focus..
    if(WndMgr.MainSubScene[1].flagSelect == false)
    {
    	this.ListMainView.setCurrentSelect(this.BtnList[1].obj);
    	WndMgr.SelectMainSub(1);
    }	
}

///////// Processing Click evnet  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SceneListMain.prototype.InitMouseOver = function() {

	if(this.MouseOverFlag == true) 
	{
		alert("SceneListMain.InitMouseOver() : iCurrentSubScene = " + this.iCurrentSubScene);
	    for(var a=0; a<this.BtnList.length; a++)
	    {
			if(this.iCurrentSubScene != a)
			{
				this.BtnList[a].obj.GetBGLayer().SetBgImage("");
			}
	    }
		this.MouseOverFlag = false;
	}
}

SceneListMain.prototype.processMouseOver = function(obj) {
	alert("SceneListMain.processMouseOver() = " + obj);

    for(var a=0; a<this.BtnList.length; a++)
    {
		if(this.iCurrentSubScene == a)
		{
	    	if(WndMgr.MainSubScene[this.iCurrentSubScene].flagSelect==true)
	    	{
	    	    if(WndMgr.GetMainSubSceneID()=="ListMainCall"||WndMgr.GetMainSubSceneID()=="ListMainSetting"||WndMgr.GetMainSubSceneID()=="ListMainProfile")
	    	      sf.scene.get(WndMgr.GetMainSubSceneID()).ReturnToMain();
	    	    else
	    		sf.scene.get(WndMgr.GetMainSubSceneID()).processReturnKey();
	    	}
		}
		else
		{
			if(this.BtnList[a].obj == obj) {
				this.MouseOverFlag = true;
				this.BtnList[a].obj.GetBGLayer().SetBgImage(g_Image.IMAGE_LIST_MAIN_CATEGORY_BTN_OVER);
			}
			else {
				this.BtnList[a].obj.GetBGLayer().SetBgImage("");
			}
		}
    }
}

SceneListMain.prototype.processMouseOut = function(obj) {

	if(this.MouseOverFlag == true) 
	{
		alert("SceneListMain.processMouseOut() : iCurrentSubScene = " + this.iCurrentSubScene);
	    for(var a=0; a<this.BtnList.length; a++)
	    {
			if(this.iCurrentSubScene != a)
			{
				this.BtnList[a].obj.GetBGLayer().SetBgImage("");
			}
	    }
		this.MouseOverFlag = false;
	}
}

SceneListMain.prototype.processClickEvent = function(obj){
	alert("SceneListMain.processClickEvent() ");
	
	var index =0;

    for(var a=0; a<this.BtnList.length; a++)
    {
        if(this.BtnList[a].obj == obj)
        {
        	index=a;
        	break;
        }
    }
    
    if(index==this.iCurrentSubScene)
    {
    	if(WndMgr.MainSubScene[this.iCurrentSubScene].flagSelect==true)
    	{
    		sf.scene.get(WndMgr.GetMainSubSceneID()).processReturnKey();
    	}
    	else
    	{
    		this.processEnterKey();
    	}
    }
    else
    {
    	if(WndMgr.MainSubScene[this.iCurrentSubScene].flagSelect==true)
    	{
    		sf.scene.get(WndMgr.GetMainSubSceneID()).processReturnKey();
    	}
    	
    	this.highlight(obj, index);
    	//change helpbar - by minseok
        this.HelpBarData = this.BtnList[index].helpbarData;
        HelpBar.changeHelpBarItems(this.HelpBarData);
        
        RecogMgr.ChangeVoiceHelpbar();
    }
}
SceneListMain.prototype.AdjustBtnText = function(){
	
	var CurLangID = ResMgr.GetCurLanguage();
 	if(CurLangID == ENUM_TV_LANGUAGE.XHO)
 	{
 		$("#list_main_contact_btn_text").css('left', "119px" );
 		$("#list_main_history_btn_text").css('left', "119px" );
 		$("#list_main_call_btn_text").css('left', "119px" );  		 	
 		$("#list_main_live_call_btn_text").css('left', "119px" ); 		
 		$("#list_main_profile_btn_text").css('left', "119px" ); 		
 		$("#list_main_setting_btn_text").css('left', "119px" );  		
	
 		this.ListMainContactBtn.AppendFgImage("list_main_contact_btn_icon","33px","0px","76px","76px");
	    this.ListMainHistoryBtn.AppendFgImage("list_main_history_btn_icon","33px","0px","76px","76px");
	    this.ListMainCallBtn.AppendFgImage("list_main_call_btn_icon","33px","0px","76px","76px");
	    this.ListMainLiveCallBtn.AppendFgImage("list_main_live_call_btn_icon","33px","0px","76px","76px");
	    this.ListMainProfileBtn.AppendFgImage("list_main_profile_btn_icon","33px","0px","76px","76px");
	    this.ListMainSettingBtn.AppendFgImage("list_main_setting_btn_icon","33px","0px","76px","76px");
   	}
   	else
   	{
 		this.ListMainContactBtn.AppendFgImage("list_main_contact_btn_icon","33px","0px","76px","76px");
	    this.ListMainHistoryBtn.AppendFgImage("list_main_history_btn_icon","33px","0px","76px","76px");
	    this.ListMainCallBtn.AppendFgImage("list_main_call_btn_icon","33px","0px","76px","76px");
	    this.ListMainLiveCallBtn.AppendFgImage("list_main_live_call_btn_icon","33px","0px","76px","76px");
	    this.ListMainProfileBtn.AppendFgImage("list_main_profile_btn_icon","33px","0px","76px","76px");
	    this.ListMainSettingBtn.AppendFgImage("list_main_setting_btn_icon","33px","0px","76px","76px");
   	}
	
}	


//for Voice Recognition 
SceneListMain.prototype.MoveHighlight = function(index){
	alert("SceneListMain.MoveHighlight() : " + index);
    
	if(WndMgr.MainSubScene[this.iCurrentSubScene].flagSelect==true)
	{
		sf.scene.get(WndMgr.GetMainSubSceneID()).processReturnKey();
	}
	
	this.highlight(this.BtnList[index].obj, index);
    this.HelpBarData = this.BtnList[index].helpbarData;
    HelpBar.changeHelpBarItems(this.HelpBarData);
}

