function SceneListMainLiveCall(options) {
	this.options = options;
    
    this.ListMainLiveCallView =null;
    
    this.CallDurationTextLabel =null;
    this.CallDurationTimeLabel =null;   
    
    this.CallMemberThumbnailLabel=null;
    this.CallMemberNameLabel=null;
    this.CallMemberOnlineStatusLabel=null;
    this.CallMemberMoodMsgLabel=null;
    
    this.GoCallBtn=null;
    this.CallEndBtn=null;
    
    this.destroyFlag= true;
    
    this.HelpBar =null;
    
    this.FlagFocus = false;
}

SceneListMainLiveCall.prototype.initialize = function () {
	alert("SceneListMainLiveCall.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();
}

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

SceneListMainLiveCall.prototype.handleHide = function () {
	alert("SceneListMainLiveCall.handleHide()");
	// this function will be called when the scene manager hide this scene  
}

SceneListMainLiveCall.prototype.handleFocus = function () {
	alert("SceneListMainLiveCall.handleFocus()");
	// this function will be called when the scene manager focus this scene
	this.FlagFocus = true;
	
	var currentHighlight =  this.ListMainLiveCallView.getCurrentHighlight();

    if(currentHighlight == null)
    {
    	this.highlight(this.GoCallBtn);
    }
    else
    {
        this.highlight(currentHighlight);
    }
    
}

SceneListMainLiveCall.prototype.handleBlur = function () {
	alert("SceneListMainLiveCall.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
    this.FlagFocus = false;
    
	var currentHighlight =  this.ListMainLiveCallView.getCurrentHighlight();
	currentHighlight.blur();


}

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

			break;
		case sf.key.DOWN:

			break;

		case sf.key.ENTER:
            this.processEnterKey();
			break;
            
       case sf.key.RED:
            this.processRedKey();
			break;
            
        case sf.key.RETURN:
            this.processReturnKey();
            sf.key.block(event);
			break;
            
         case sf.key.EXIT:
            this.processExitKey();
            sf.key.block(event);
			break;
            
         case 147:  //infolink
         case 261:  //contents
         case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
            
         default:
            ProcMgr.processBlockKey(keyCode);
            break;  
	}
}

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

SceneListMainLiveCall.prototype.create = function(){
    alert("SceneListMainLiveCall.create() ");
    this.ListMainLiveCallView = new View("ListMainLiveCall");
    
      this.CallDurationTextLabel = new Label(null,"live_call_duration_text");
    this.CallDurationTextLabel.SetTextStyle("live_call_duration_text_style");
    this.CallDurationTextLabel.SetText(IDWS_MOIP_SKYPE_CALL_DURATION);

    this.CallDurationTimeLabel = new Label(null,"live_call_duration_time");
    this.CallDurationTimeLabel.SetTextStyle("live_call_duration_time_style");
    this.CallDurationTimeLabel.SetText("00:00:00");

    this.CallMemberThumbnailLabel= new Label("live_call_member_thumbnail", null);
    this.CallMemberThumbnailLabel.SetBgImage(g_Image.IMAGE_VOICE_CALL_THUMBNAIL);
    this.CallMemberThumbnailLabel.AppendFgImage("live_call_member_thumbnail_avata","3px","3px","143px","140px");
    this.CallMemberThumbnailLabel.SetFgImage(g_Image.IMAGE_LIST_MAIN_VIEW_DEFAULT_AVATA);

    this.CallMemberNameLabel = new Label(null,"live_call_member_name");
    this.CallMemberNameLabel.SetTextStyle("live_call_member_name_style");
    
    this.CallMemberOnlineStatusLabel= new Label("live_call_member_online_status", null);
 
    this.CallMemberMoodMsgLabel = new Label(null,"live_call_member_mood_message");
    this.CallMemberMoodMsgLabel.SetTextStyle("live_call_member_mood_message_style");
    
    var this_ = sf.scene.get('ListMainLiveCall');
    var clickCF =  function(obj){this_.processClickEvent(obj);};

    this.GoCallBtn = new Button();
    this.GoCallBtn.SetImageObjId("live_call_go_btn");
    this.GoCallBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_LIVE_CALL_GO_BTN_NORMAL);
    this.GoCallBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIVE_CALL_GO_BTN_NORMALFOCUS);	
    this.GoCallBtn.SetTextObjId("live_call_go_btn_text");
    this.GoCallBtn.SetText(TV_SID_GO_CALL);
    this.GoCallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"common_btn_text_f17_normal_style");
	this.GoCallBtn.SetOnClickCallbackFunc(clickCF);
	
    this.CallEndBtn = new Button();
    this.CallEndBtn.SetImageObjId("live_call_end_btn");
    this.CallEndBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_LIVE_CALL_END_BTN_NORMAL);
    this.CallEndBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIVE_CALL_END_BTN_NORMALFOCUS);	
    this.CallEndBtn.SetTextObjId("live_call_end_btn_text");
    this.CallEndBtn.SetText(TV_SID_END_CALL);
    this.CallEndBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"common_btn_text_f17_normal_style");
	this.CallEndBtn.SetOnClickCallbackFunc(clickCF);
	
    this.HelpBar = new HelpBar(HelpBarIndex.LIST_MAIN_LIVE_CALL_PAGE,"SceneListMain");
    this.HelpBar.SetOnClickCallbackFunc(1, function(){this_.processRedKey();});
    this.HelpBar.SetOnClickCallbackFunc(2, function(){this_.processReturnKey();});

    this.GoCallBtn.registHelpBar( this.HelpBar);
    this.CallEndBtn.registHelpBar( this.HelpBar);
}

SceneListMainLiveCall.prototype.update = function()
{
    this.CallMemberNameLabel.SetText( PluginAPIMgr.GetCallMemberDisplayName());
    this.CallMemberThumbnailLabel.SetFgImage(PluginAPIMgr.GetCallMemberAvataImage());
    this.CallMemberOnlineStatusLabel.SetBgImage(PluginAPIMgr.GetCallMemberOnlineStateImage());
    this.CallMemberMoodMsgLabel.SetText(PluginAPIMgr.GetCallMemberMoodMsg());
    
      if(g_Data.GetCallLocalHold() == true)
     {
        this.LocalHold();
     }
     else if(g_Data.GetCallRemoteHold() == true)
     {
        this.RemoteHold();
     }
     else
     {
        this.Resume();
     }
}

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

SceneListMainLiveCall.prototype.highlight=function(obj)
{
    this.ListMainLiveCallView.setCurrenHighlight(obj);
}

SceneListMainLiveCall.prototype.processLeftKey=function()
{
    alert("SceneListMainLiveCall.processLeftKey() ");
    var currentHighlight =  this.ListMainLiveCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.GoCallBtn:
                WndMgr.ReturnSubToMain();
                this.highlight(null);
            break;
         case this.CallEndBtn:
            this.highlight(this.GoCallBtn);
            break;            
    }
}

SceneListMainLiveCall.prototype.processRightKey=function()
{
    alert("SceneListMainLiveCall.processRightKey() ");
    var currentHighlight =  this.ListMainLiveCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.GoCallBtn:
            this.highlight(this.CallEndBtn);
            break;
         case this.CallEndBtn:
            this.highlight(this.GoCallBtn);
            break;            
           
    }
}

SceneListMainLiveCall.prototype.processEnterKey=function()
{
    alert("SceneListMainLiveCall.processEnterKey() ");
    var currentHighlight =  this.ListMainLiveCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.GoCallBtn:
        	alert("==============================> GoCallBtn");
			ProcMgr.GoCall();
            break;
         case this.CallEndBtn:
			alert("==============================> CallEndBtn");
            ProcMgr.DisconnectCall();
            break;            
    }
}

SceneListMainLiveCall.prototype.updateCallDuration = function(time)
{
     this.CallDurationTimeLabel.SetText(time);
}

SceneListMainLiveCall.prototype.updateCallMemberInfo = function()
{
	 alert("SceneListMainLiveCall.updateCallMemberInfo() ");
	 
	this.CallMemberNameLabel.SetText( PluginAPIMgr.GetCallMemberDisplayName());
    this.CallMemberThumbnailLabel.SetFgImage(PluginAPIMgr.GetCallMemberAvataImage());
    this.CallMemberOnlineStatusLabel.SetBgImage(PluginAPIMgr.GetCallMemberOnlineStateImage());
    this.CallMemberMoodMsgLabel.SetText(PluginAPIMgr.GetCallMemberMoodMsg());	
}

SceneListMainLiveCall.prototype.processRedKey = function(){
    alert("SceneListMainLiveCall.processRedKey() ");

    StateMgr.Start_Signout_State();       
}

SceneListMainLiveCall.prototype.processReturnKey = function(){
    alert("SceneListMainLiveCall.processReturnKey() ");
    WndMgr.ReturnSubToMain();
    this.highlight(null);
}

SceneListMainLiveCall.prototype.processExitKey = function(){
    alert("SceneListMainLiveCall.processExitKey() ");

   StateMgr.Start_Exit_State(false);
}


SceneListMainLiveCall.prototype.LocalHold=function()
{
    alert("SceneListMainLiveCall.LocalHold() ");   
    
    this.CallDurationTextLabel.SetText(IDWS_MOIP_CALL_ON_HOLD);    
}

SceneListMainLiveCall.prototype.RemoteHold=function()
{
    alert("SceneListMainLiveCall.RemoteHold() ");  
    
    this.CallDurationTextLabel.SetText(TV_SID_YOU_ARE_ON_HOLD); 
}

SceneListMainLiveCall.prototype.Resume=function()
{
    alert("SceneListMainLiveCall.Resume() ");  
    
    this.CallDurationTextLabel.SetText(IDWS_MOIP_SKYPE_CALL_DURATION); 
}

///////// Processing Click evnet  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////

SceneListMainLiveCall.prototype.processClickEvent = function(obj){
	alert("SceneListMainLiveCall.processClickEvent() ");
	
	var currentHighlight =  this.ListMainLiveCallView.getCurrentHighlight();

	if(currentHighlight != obj)
    {
    	alert("111111111111111111111111111111111");
    	
    	if(obj == this.CallEndBtn)
    	{
    		alert(" >>>>>>>>>>>   obj == this.CallEndBtn");
    	}
    	else if(obj == this.GoCallBtn)
    	{
    		alert(">>>>>>>>>>>>  obj == this.GoCallBtn");
    	}
    	else{
    		alert(">>>>>>>>>>>>>> Obj is another....");
    	}
    	
    	this.highlight(obj);
    }
    
    if(this.FlagFocus==false)
	{
		alert("2222222222222222222222222222222222");
		sf.scene.get('ListMain').selectOnCurrHighlight();
	}

	alert("333333333333333333333333");
    this.processEnterKey();	
}

