

var CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE = 9;

function SceneConferenceCall(options) {
	this.options = options;
    
    this.ConferenceCallView =null;

    this.CallDurationBgLabel	= null;
    this.CallDurationTextLabel	= null;
    this.CallDurationTimeLabel	= null;

    this.CallEndBtn		= null;
    this.MicMuteOnBtn	= null;
    this.MicMuteOffBtn	= null;
    
    this.CallMemberDisplay	= new Array(9);
	this.CallMemberInfo		= new Array();    

	this.CurrentCallmemberPage	= 0;
	this.MaxCallmemberPage		= 0;
    this.NumOfCallMember		= 0;
    this.CallMemberListOffset	= 0;
        
	this.CallMemberNumberLabel	= null;
	this.HostNmaeLabel			= null;
	this.LineImageLabel			= null;
	this.MyNameLabel			= null;

	this.TooltipTimer = null;
	this.flag_shown_tooltip = false;
	
	this.arrow_up	= null;
	this.arrow_down	= null;
	
	this.shownArrow = false;
	this.shownArrowUp = false;
	this.shownArrowDown = false;
}

SceneConferenceCall.prototype.initialize = function () {
	alert("SceneConferenceCall.initialize()");

	this.create();
}

SceneConferenceCall.prototype.handleShow = function () {
	alert("SceneConferenceCall.handleShow()");

	this.update();
}

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

	this.CurrentCallmemberPage = 1;
	this.initializeCallMemberDisplay();	
    this.initializeCallMemberInfo();
	this.updateCallDuration(' ');
    
	this.highlight(null);

	if(this.TooltipTimer)
	{
		clearTimeout(this.TooltipTimer);
		$('#conf_call_btn_tooltip').sfTooltip('hide');
		this.flag_shown_tooltip = false;		
	}
}

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

	this.highlight(this.CallEndBtn);

	var this_ = sf.scene.get("ConferenceCall");
	var returnCF =  function(){this_.processReturnKey();};
	WndMgr.SetReturnIconClickCallback(returnCF);
}

SceneConferenceCall.prototype.handleBlur = function () {
	alert("SceneConferenceCall.handleBlur()");
	
	this.highlight(null);
	WndMgr.SetReturnIconClickCallback(null);
}

SceneConferenceCall.prototype.handleKeyDown = function (keyCode) {
	alert("SceneConferenceCall.handleKeyDown(" + keyCode + ")");

	//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:
             this.processUpKey();
			break;
		case sf.key.DOWN:
            this.processDownKey();
			break;

		case sf.key.ENTER:
         this.processEnterKey();
			break;
            
        case sf.key.VOL_DOWN:
        case sf.key.PANEL_VOL_DOWN:
		case sf.key.VOL_UP:
        case sf.key.PANEL_VOL_UP:
             this.processVolumeKey();
            // sf.key.preventDefault();
			break;

        case sf.key.N1:
            ProcMgr.SendDTMF(0);
            break;        
        case sf.key.N2:
            ProcMgr.SendDTMF(1);
            break;        
        case sf.key.N3:
            ProcMgr.SendDTMF(2);
            break;        
        case sf.key.N4:
            ProcMgr.SendDTMF(3);        
            break;        
        case sf.key.N5:
            ProcMgr.SendDTMF(4);        
            break;        
        case sf.key.N6:
            ProcMgr.SendDTMF(5);        
            break;        
        case sf.key.N7:
            ProcMgr.SendDTMF(6);        
            break;        
        case sf.key.N8:
            ProcMgr.SendDTMF(7);        
            break;        
        case sf.key.N9:
            ProcMgr.SendDTMF(8);
            break;        
        case sf.key.N0:
            ProcMgr.SendDTMF(10);        
            break;            
        case 35:
		case 650: 			//ttx
            ProcMgr.SendDTMF(9);        
            break;        
        case 259:			//pre
            ProcMgr.SendDTMF(11);        
            break;
            
        case sf.key.RED:
			break;

		case sf.key.BLUE:
			break;	 
			
		case sf.key.YELLOW:
		case sf.key.GREEN:
            break;
            
		case sf.key.TOOLS:
            break;
			
       case sf.key.RETURN:
            this.processReturnKey();
            sf.key.preventDefault();
			break;
       
       case sf.key.EXIT:       
            this.processExitKey();
            sf.key.preventDefault();
			break;
			
        case sf.key.MUTE:
        	this.processMuteKey();
            break;			
            
		case 602:	//INFOLINK
		case 606:	//CONTENTS
		case 608:	//WISELINK
            ProcMgr.processInfolinkKeyInCall();
            sf.key.preventDefault();
			break;
            
         default:
            ProcMgr.processBlockKey(keyCode);
            break;  
	}
}

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

SceneConferenceCall.prototype.create = function(){
    alert("SceneConferenceCall.create() ");
    this.ConferenceCallView = new View("ConferenceCall");
    //this.ConferenceCallView.SetBgImage(WndMgr.Bg_ConfCall.src);

    //this.LogoLabel= new Label("conf_call_skype_logo", null);
    //this.LogoLabel.SetBgImage(g_Image.IMAGE_CALL_SKYPE_LOGO);

    this.CallDurationBgLabel = new Label("conf_call_duration_bg",null);
	this.CallDurationBgLabel.SetBgImage(g_Image.IMAGE_CALL_DURATION_BG);
	
	this.CallDurationTextLabel = new Label(null,"conf_call_duration_text");	
	this.CallDurationTextLabel.SetText(IDWS_MOIP_SKYPE_CALL_DURATION); 
	
    this.CallDurationTimeLabel = new Label(null,"conf_call_duration_time");
    this.CallDurationTimeLabel.SetText("00:00:00");

	var CurLangID = ResMgr.GetCurLanguage();
	if(CurLangID == ENUM_TV_LANGUAGE.VIE || CurLangID == ENUM_TV_LANGUAGE.IND || CurLangID == ENUM_TV_LANGUAGE.KAZ || CurLangID == ENUM_TV_LANGUAGE.LIT ||
		CurLangID == ENUM_TV_LANGUAGE.MKD || CurLangID == ENUM_TV_LANGUAGE.MAY || CurLangID == ENUM_TV_LANGUAGE.POL || CurLangID == ENUM_TV_LANGUAGE.ALB ||
		CurLangID == ENUM_TV_LANGUAGE.TAM || CurLangID == ENUM_TV_LANGUAGE.XHO || CurLangID == ENUM_TV_LANGUAGE.ZUL)
	{
		$('#conf_call_duration_text').css('left','18px');
		$('#conf_call_duration_text').css('width','220px');
		
		$('#conf_call_duration_time').css('left','210px');
	}

    var this_ = sf.scene.get("ConferenceCall");
    var clickCF =  function(obj){this_.processClickEvent(obj);};

	this.MyThumbnail = new CompBase(); 
	this.MyThumbnail.CreateBG("conf_call_my_thumb");	
	this.MyThumbnail.AddJPGImageLayer("conf_call_my_thumb_avatar");

    this.MyNameLabel = new Label(null,"conf_call_my_name");
    this.MyNameLabel.SetIsPlainText(true);

	this.CallEndBtn = new Button();
    this.CallEndBtn.SetImageObjId("conf_call_end_btn");
    this.CallEndBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_END_BTN_NORMAL);
    this.CallEndBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_END_BTN_NORMALFOCUS);
    this.CallEndBtn.SetOnClickCallbackFunc(clickCF);
    $('#conf_call_end_btn').bind('mouseover',function(){this_.processCallEndBtnOver();});    
        
    this.MicMuteOnBtn = new Button();
    this.MicMuteOnBtn.SetImageObjId("conf_call_mute_on_btn");
    this.MicMuteOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_MIC_BTN_NORMAL);
    this.MicMuteOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_MIC_BTN_NORMALFOCUS);
    this.MicMuteOnBtn.SetOnClickCallbackFunc(clickCF);
    $('#conf_call_mute_on_btn').bind('mouseover',function(){this_.processMicMuteOnBtnOver();});
        
    this.MicMuteOffBtn = new Button();
    this.MicMuteOffBtn.SetImageObjId("conf_call_mute_off_btn");
    this.MicMuteOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_MIC_BLCOK_BTN_NORMAL);
    this.MicMuteOffBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_MIC_BLCOK_BTN_NORMALFOCUS);
    this.MicMuteOffBtn.SetOnClickCallbackFunc(clickCF);
    $('#conf_call_mute_off_btn').bind('mouseover',function(){this_.processMicMuteOffBtnOver();});

	this.CallMemberNumberLabel	= new Label(null,"conf_call_member_number");
	this.HostNmaeLabel			= new Label(null,"conf_call_host_name");

	$('#conf_call_scrollbar').sfScroll({'pages':2,'currentPage':0});
	
	this.LineImageLabel			= new Label("conf_call_line",null);
	this.LineImageLabel.SetBgImage(g_Image.IMAGE_CONFERENCE_CALL_LINE);


    var a=0;
	for( a=0; a< this.CallMemberDisplay.length; a++)
	{
        this.CallMemberDisplay[a] = new Object();  	
        this.CallMemberDisplay[a].ui = new CompBase();
        this.CallMemberDisplay[a].ui.CreateBG("conf_call_member_"+a);
        this.CallMemberDisplay[a].ui.AddJPGImageLayer("conf_call_member_"+a+"_avatar");
        this.CallMemberDisplay[a].ui.AddImageLayer("conf_call_member_"+a+"_online_status");
        this.CallMemberDisplay[a].ui.AddImageLayer("conf_call_member_"+a+"_status");        
        this.CallMemberDisplay[a].ui.AddTextLayer("conf_call_member_"+a+"_name");
        this.CallMemberDisplay[a].thumbObj = "conf_call_member_"+a+"_avatar";
		this.CallMemberDisplay[a].isShow = false;
    }
    
	$('#conf_call_btn_tooltip').sfTooltip({
		text : TV_SID_END_CALL,
		orientation : 'down'
	});
	this.flag_shown_tooltip = true;   

	$('#conf_call_member_bg_over').bind('mouseover',function(){this_.showArrowBtn();});	
	$('#conf_call_member_bg_over').bind('mouseout',function(){this_.hideArrowBtn();});

    this.arrow_up = new Label("conf_call_member_bg_arrow_up",null);
    this.arrow_up.SetBgImage(g_Image.IMAGE_LIST_MAIN_PROFILE_ARROW_UP);

    $('#conf_call_member_bg_arrow_up').bind('click',function(){this_.PrevCallMemberDisplayPage();});
    $('#conf_call_member_bg_arrow_up').bind('mouseover',function(){this_.arrow_up.SetBgImage(g_Image.IMAGE_LIST_MAIN_PROFILE_ARROW_UP_FOCUS);});
    $('#conf_call_member_bg_arrow_up').bind('mouseout',function(){this_.arrow_up.SetBgImage(g_Image.IMAGE_LIST_MAIN_PROFILE_ARROW_UP);});
   
	this.arrow_down	= new Label("conf_call_member_bg_arrow_down",null);
    this.arrow_down.SetBgImage(g_Image.IMAGE_LIST_MAIN_PROFILE_ARROW_DOWN);

    $('#conf_call_member_bg_arrow_down').bind('click',function(){this_.NextCallMemberDisplayPage();});
    $('#conf_call_member_bg_arrow_down').bind('mouseover',function(){this_.arrow_down.SetBgImage(g_Image.IMAGE_LIST_MAIN_PROFILE_ARROW_DOWN_FOCUS);});
    $('#conf_call_member_bg_arrow_down').bind('mouseout',function(){this_.arrow_down.SetBgImage(g_Image.IMAGE_LIST_MAIN_PROFILE_ARROW_DOWN);});	
	
}

SceneConferenceCall.prototype.update = function()
{  
    alert("SceneConferenceCall.update() ");	
	this.MyThumbnail.SetImageLayer(1,g_Data.GetMyAccountAvataImage());
	this.MyNameLabel.SetText(g_Data.GetMyAccountDisplayName());
	
	this.toggleMuteBtnEnable();	
	
	//get host name	
	var host_text = g_Data.CombinateStrings(TV_SID_MIX_HOST, PluginAPIMgr.GetCallMemberDisplayName(0));
	this.HostNmaeLabel.SetText(host_text);	
	
	this.CurrentCallmemberPage = 1;
	this.updateCallMember();
	
}


SceneConferenceCall.prototype.initializeCallMemberDisplay = function()
{    
	var a=0;
	for( a=0; a< this.CallMemberDisplay.length; a++)
	{
		this.clearCallMemberDisplay(a);
	}

}

SceneConferenceCall.prototype.clearCallMemberDisplay = function(index)
{	
    alert("SceneConferenceCall.clearCallMemberDisplay(" + index + ")");
    	    	
    if(this.CallMemberDisplay[index].isShow == true)
    {
    	alert("SceneConferenceCall.hideCallMemberDisplay(" + index + ")");    	

    	this.CallMemberDisplay[index].ui.Hide();
    	
    	if(this.CallMemberDisplay[index].isActivate == true)
    	{
			$('#'+this.CallMemberDisplay[index].thumbObj).removeClass('conf_call_member_avatar_active_style');
			$('#'+this.CallMemberDisplay[index].thumbObj).addClass('conf_call_member_avatar_style');
			this.CallMemberDisplay[index].isActivate = false;
    		
    	}    	
		this.CallMemberDisplay[index].ui.SetImageLayer(1," ");
		this.CallMemberDisplay[index].ui.SetImageLayer(2, " ");
		this.CallMemberDisplay[index].ui.SetImageLayer(3, " ");				
		this.CallMemberDisplay[index].ui.SetTextLayer(4, " ");
    	this.CallMemberDisplay[index].isShow = false;
    	
    }
    
}


SceneConferenceCall.prototype.initializeCallMemberInfo = function()
{
	var a=0;
	for( a=0; a< this.CallMemberInfo.length; a++)
	{
		this.clearCallMemberInfo(a);
	}
}

SceneConferenceCall.prototype.clearCallMemberInfo = function(index)
{
	if(this.CallMemberInfo[index])
	{
		this.CallMemberInfo[index].avatarImage	= null;
		this.CallMemberInfo[index].name			= null;
		this.CallMemberInfo[index].onlineState	= null;
		this.CallMemberInfo[index].callStatus	= null;
		this.CallMemberInfo[index].isActivate	= null;
	}
}


SceneConferenceCall.prototype.updateCallMember = function()
{
    alert("SceneConferenceCall.updateCallMember() ");

    var NumberOfCallMember = PluginAPIMgr.GetNumOfCallMembers(); 
     
	var callmember_text = g_Data.CombinateStrings(TV_SID_MIX_PEOPLE_ON_CALL, NumberOfCallMember);	
	this.CallMemberNumberLabel.SetText(callmember_text);     
     
	var i=0;
	for(i=0; i< NumberOfCallMember; i++)
	{
		if(this.CallMemberInfo[i] == null)
		{
			this.CallMemberInfo[i] = new Object();
			this.CallMemberInfo[i].name = null;
		}

		if(this.CallMemberInfo[i].name == null)
		{
			//ther is a data!!
			this.CallMemberInfo[i].avatarImage	= PluginAPIMgr.GetConferenceCallMemberAvataImage(i);
			this.CallMemberInfo[i].name			= PluginAPIMgr.GetCallMemberDisplayName(i);
			this.CallMemberInfo[i].onlineState	= PluginAPIMgr.GetConferenceCallMemberOnlineState(i);
			this.CallMemberInfo[i].callStatus	= PluginAPIMgr.ConferenceCallMemberStatus(i);
			this.CallMemberInfo[i].isActivate	= false;
						
			this.UpdateCallMemberDisplay(i,0);
		}
		else
		{
			var callStatus = PluginAPIMgr.ConferenceCallMemberStatus(i);
			
			if(this.CallMemberInfo[i].callStatus != callStatus)
			{
				this.CallMemberInfo[i].callStatus = callStatus;
				this.UpdateCallMemberDisplay(i,1);
			}
			
			var onlineState = PluginAPIMgr.GetConferenceCallMemberOnlineState(i);
			
			if(this.CallMemberInfo[i].onlineState != onlineState)
			{
				this.CallMemberInfo[i].onlineState = onlineState;
				this.UpdateCallMemberDisplay(i,2);
			}
		}
	}
	
	if(NumberOfCallMember < this.NumOfCallMember)
	{
		for(i=NumberOfCallMember; i< this.NumOfCallMember; i++)
		{
			//check... check... check....
			this.clearCallMemberInfo(i);
			//this.clearCallMemberDisplay(i);
		}
	}
		
	//set scroll
	var quotient = parseInt(NumberOfCallMember / CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE);	
	var rest = parseInt(NumberOfCallMember % CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE);
	
	if(rest > 0)
	{
		quotient++;
	}

	this.MaxCallmemberPage = quotient;
	alert('MaxCallmemberPage = ' + this.MaxCallmemberPage);
	
	if(this.MaxCallmemberPage > 1)
	{
		$('#conf_call_scrollbar').sfScroll('option','pages',this.MaxCallmemberPage);
		$('#conf_call_scrollbar').sfScroll('move',0);
		$('#conf_call_scrollbar').sfScroll('show');
	}
	else{
		$('#conf_call_scrollbar').sfScroll('hide');
	}    	    
	   
    this.NumOfCallMember = NumberOfCallMember;   
} 


SceneConferenceCall.prototype.updateActiveMemberInfo = function(callmemberIndex,loudness)
{
    alert("SceneConferenceCall.updateActiveMemberInfo() : "+ callmemberIndex);
    
	if(callmemberIndex > this.NumOfCallMember || callmemberIndex < 0)
	{
		alert("callmemberIndex error!!!")
		return;
	}
	else	
	{
		alert("callmemberIndex=" + callmemberIndex + " loudness="+loudness);
	}
	
	if(loudness > 0)
	{
		this.CallMemberInfo[callmemberIndex].isActivate = true;
	}
	else
	{
		this.CallMemberInfo[callmemberIndex].isActivate = false;
	}
	
	this.UpdateCallMemberDisplay(callmemberIndex,3);	
}

SceneConferenceCall.prototype.GetOnlineStatusImage = function(state)
{
	alert('SceneConferenceCall.GetOnlineStatusImage');
	var OnlineStatusImg = null;
	
    switch(state)
    {
        case ENUM_CONTACT_AVAILABILITY.ONLINE:
        case ENUM_CONTACT_AVAILABILITY.ONLINE_FROM_MOBILE:
            OnlineStatusImg = 'images/720p/Status/icon_status_online.png';
            break;

        case ENUM_CONTACT_AVAILABILITY.OFFLINE:
        case ENUM_CONTACT_AVAILABILITY.NOT_AVAILABLE_FROM_MOBILE:
            OnlineStatusImg = 'images/720p/Status/icon_status_signout_select.png';   
            break;

        case ENUM_CONTACT_AVAILABILITY.AWAY :
        case ENUM_CONTACT_AVAILABILITY.AWAY_FROM_MOBILE:
            OnlineStatusImg = 'images/720p/Status/icon_status_away.png';   
            break;

        case ENUM_CONTACT_AVAILABILITY.DO_NOT_DISTURB :
        case ENUM_CONTACT_AVAILABILITY.DO_NOT_DISTURB_FROM_MOBILE:
            OnlineStatusImg = 'images/720p/Status/icon_status_donotdisturb.png';   
            break;

        case ENUM_CONTACT_AVAILABILITY.OFFLINE_BUT_CF_ABLE :
        case ENUM_CONTACT_AVAILABILITY.OFFLINE_BUT_VM_ABLE:
            OnlineStatusImg = 'images/720p/Status/icon_status_signout_select.png';   
            break;

        case ENUM_CONTACT_AVAILABILITY.PENDINGAUTH  :
        case ENUM_CONTACT_AVAILABILITY.UNKNOWN:
            OnlineStatusImg = 'images/720p/Status/icon_status_signout_select.png';   
            break;

        case ENUM_CONTACT_AVAILABILITY.BLOCKED  :
        case ENUM_CONTACT_AVAILABILITY.BLOCKED_SKYPEOUT:
            OnlineStatusImg = 'images/720p/Status/icon_status_presenceblocked.png';   
            break;

        case ENUM_CONTACT_AVAILABILITY.SKYPE_ME :
            OnlineStatusImg = 'images/720p/Status/icon_status_online.png';   
            break;

        default:
            OnlineStatusImg = 'images/720p/Status/icon_status_signout_select.png'; 
            break;      
    }
	
	return OnlineStatusImg;

	
}


/*
 *  function name	: UpdateCallMemberDisplay
 * 	param [index]	:  0~8 display id
 *  param [type]	: 	0 - change all components 
 * 						1 - 
 * 						2 - change online status
 * 
 */

SceneConferenceCall.prototype.UpdateCallMemberDisplay = function(infoIndex,type)
{
    alert("SceneConferenceCall.UpdateCallMemberDisplay(" + infoIndex + ")");

	var InfoPage;	
	var displayIndex;	
		
	if(infoIndex < CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE)
	{
		InfoPage = 1;	
		displayIndex = infoIndex;		
	}
	else
	{		
		var quotient = parseInt(infoIndex / CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE);	
		var rest = parseInt(infoIndex % CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE);
    
		InfoPage = quotient + 1;	
		displayIndex = rest;	
		
		alert("quotient = " + quotient + " , rest = " + displayIndex );
	}

		
	if(InfoPage != this.CurrentCallmemberPage)
	{
		alert("InfoPage : " + InfoPage + "  // CurrentCallmemberPage : " + this.CurrentCallmemberPage);
		return;
	}
    
	if(type == 0)
	{
		this.CallMemberDisplay[displayIndex].ui.SetImageLayer(1,this.CallMemberInfo[infoIndex].avatarImage);		
		this.CallMemberDisplay[displayIndex].ui.SetImageLayer(2,this.GetOnlineStatusImage(this.CallMemberInfo[infoIndex].onlineState));		
		this.CallMemberDisplay[displayIndex].ui.SetTextLayer(4,this.CallMemberInfo[infoIndex].name);		
		this.UpdateStatus(displayIndex,this.CallMemberInfo[infoIndex].callStatus);		

	}
	//display status
	else if(type == 1)
	{
		this.UpdateStatus(displayIndex,this.CallMemberInfo[infoIndex].callStatus);
	
	}
	//online status
	else if (type == 2){
		this.CallMemberDisplay[displayIndex].ui.SetImageLayer(2,this.GetOnlineStatusImage(this.CallMemberInfo[infoIndex].onlineState));	
	}	
	else if (type == 3){

		if(this.CallMemberDisplay[displayIndex].isActivate == true)
		{
			if(this.CallMemberInfo[infoIndex].isActivate == false)
			{
				alert("Deactive!!!");
				$('#'+this.CallMemberDisplay[displayIndex].thumbObj).removeClass('conf_call_member_avatar_active_style');
				$('#'+this.CallMemberDisplay[displayIndex].thumbObj).addClass('conf_call_member_avatar_style');
				this.CallMemberDisplay[displayIndex].isActivate = false;
			}
		}
		else
		{
			if(this.CallMemberInfo[infoIndex].isActivate == true)
			{
				alert("Active!!");
				$('#'+this.CallMemberDisplay[displayIndex].thumbObj).removeClass('conf_call_member_avatar_style');
				$('#'+this.CallMemberDisplay[displayIndex].thumbObj).addClass('conf_call_member_avatar_active_style');
				this.CallMemberDisplay[displayIndex].isActivate = true;
			}
		}
	}
	else{		
    	alert("error");
		return;
	}

	//check check check
	if(this.CallMemberDisplay[displayIndex].isShow == false)
	{		
		this.CallMemberDisplay[displayIndex].ui.Show();
		this.CallMemberDisplay[displayIndex].isShow = true;
	}
       
}

SceneConferenceCall.prototype.UpdateStatus = function(displayIndex,callStatus)
{
	alert('SceneConferenceCall.UpdateStatus');
	
	var StatusImg;
			
	switch(callStatus)
	{
		case ENUM_CALL_MEMBER_STATUS.ROUTING:
		case ENUM_CALL_MEMBER_STATUS.EARLYMEDIA:
		case ENUM_CALL_MEMBER_STATUS.RINGING_OUT:
		case ENUM_CALL_MEMBER_STATUS.RINGING_IN:
			StatusImg = g_Image.IMAGE_CONFERENCE_CALL_CALLING_ICON;
			break;
			
		case ENUM_CALL_MEMBER_STATUS.FINISHED:
		case ENUM_CALL_MEMBER_STATUS.CANCELLED:
		case ENUM_CALL_MEMBER_STATUS.FAILED:
		case ENUM_CALL_MEMBER_STATUS.MISSED:
		case ENUM_CALL_MEMBER_STATUS.REFUSED:
		case ENUM_CALL_MEMBER_STATUS.BUSY:
		case ENUM_CALL_MEMBER_STATUS.DROPPED:			
			StatusImg = g_Image.IMAGE_CONFERENCE_CALL_END_ICON;
			break;

		case ENUM_CALL_MEMBER_STATUS.LOCALHOLD:
		case ENUM_CALL_MEMBER_STATUS.REMOTEHOLD:		
			StatusImg = g_Image.IMAGE_CONFERENCE_CALL_HOLD_ICON;
			break;
			
		default:
			StatusImg = ' ';
	}
	alert('StatusImg='+StatusImg);
	this.CallMemberDisplay[displayIndex].ui.SetImageLayer(3,StatusImg);			
		
}	

SceneConferenceCall.prototype.NextCallMemberDisplayPage = function()
{
    alert("SceneConferenceCall.NextCallMemberDisplayPage");
    	
	if(this.MaxCallmemberPage == this.CurrentCallmemberPage)
	{
		return;
	}
	
	//Increase page number
	this.CurrentCallmemberPage++;
	
	var maxNum = this.CurrentCallmemberPage * CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE;
	var startIndex = (this.CurrentCallmemberPage-1)*CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE;
	var curPageItemNum = 0;
	
	if(this.MaxCallmemberPage == this.CurrentCallmemberPage)
	{
		curPageItemNum = this.NumOfCallMember - startIndex;
	}	
	else
	{
		curPageItemNum = CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE;
	}
		
	var i=0;
	for(i = 0; i < curPageItemNum; i++)
	{		
		this.UpdateCallMemberDisplay(startIndex+i,0);
	}
	
	for(i = curPageItemNum; i < CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE; i++)
	{		
		this.clearCallMemberDisplay(i);
	}
	
	$('#conf_call_scrollbar').sfScroll('move',this.CurrentCallmemberPage-1);
	this.updateArrowBtn();
}

SceneConferenceCall.prototype.PrevCallMemberDisplayPage = function()
{	
	if(this.CurrentCallmemberPage == 1)
	{
		return;
	}
	
	this.CurrentCallmemberPage--;
	
	var startIndex = (this.CurrentCallmemberPage-1) * CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE;

	var i=0;
	for(i = 0; i < CONFERENCE_CALL_MAX_MEMBER_NUM_IN_PAGE; i++)
	{		
		this.UpdateCallMemberDisplay(startIndex+i,0);
	}
	
	$('#conf_call_scrollbar').sfScroll('move',this.CurrentCallmemberPage-1);
	this.updateArrowBtn();
} 


SceneConferenceCall.prototype.highlight=function(obj)
{
    this.ConferenceCallView.setCurrenHighlight(obj);
    
    if(obj)
    {
    	this.ShowTooltip(obj);
    }
}


SceneConferenceCall.prototype.processEnterKey = function(){
    alert("SceneConferenceCall.processEnterKey() ");
    
    var currentHighlight =  this.ConferenceCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.MicMuteOffBtn:
        case this.MicMuteOnBtn:        
			this.changeMuteBtn();
			break;

		case this.CallEndBtn:
			ProcMgr.DisconnectCall();
    }
}

SceneConferenceCall.prototype.processRightKey = function(){
    alert("SceneConferenceCall.processRightKey() ");
    
    var currentHighlight =  this.ConferenceCallView.getCurrentHighlight();
    
    if(currentHighlight == this.MicMuteOnBtn || currentHighlight == this.MicMuteOffBtn)
    {
    	this.highlight(this.CallEndBtn);
    } 	
}

SceneConferenceCall.prototype.processLeftKey = function(){
    alert("SceneConferenceCall.processLeftKey() ");
    
    var currentHighlight =  this.ConferenceCallView.getCurrentHighlight();

    if(currentHighlight == this.CallEndBtn)
    {
		if( this.MicMuteOffBtn.GetFlagVisible() == true)
		{
			this.highlight(this.MicMuteOffBtn);
		}
		else
		{
			this.highlight(this.MicMuteOnBtn);
		}
	}
}

SceneConferenceCall.prototype.processUpKey = function(){
    alert("SceneConferenceCall.processUpKey() ");
    
	this.PrevCallMemberDisplayPage();
}

SceneConferenceCall.prototype.processDownKey = function(){
    alert("SceneConferenceCall.processDownKey() ");
    
	this.NextCallMemberDisplayPage();
}

SceneConferenceCall.prototype.processVolumeKey=function()
{
    alert("SceneConferenceCall.processVolumeKey() ");
	
	//unmute
	if(ProcMgr.CallInfo.IsSpeakerMute == true)
	{
	    ProcMgr.processVolumeMute(false);
	}
    
    StateMgr.Start_Volume_Speaker_State(VOLUME_MODE.MASTER);
}

SceneConferenceCall.prototype.processClickEvent = function(obj){
	alert("SceneConferenceCall.processClickEvent() ");
		
	this.processEnterKey();
}

SceneConferenceCall.prototype.changeMuteBtn = function()
{
    alert("SceneVideoCall.changeMuteBtn() ");
    
	if( this.MicMuteOnBtn.GetFlagVisible() == true)
	{
		alert("show MicMuteOffBtn");

		this.MicMuteOnBtn.hiddenObj();
		this.MicMuteOnBtn.blur();
		this.highlight(this.MicMuteOffBtn);	
		this.MicMuteOffBtn.visibleObj();
		this.ShowTooltip(this.MicMuteOffBtn);
		PluginAPIMgr.MuteMic(true);		
	}
	else
	{
		alert("show MicMuteOnBtn");
		
		this.MicMuteOffBtn.hiddenObj();
		this.MicMuteOffBtn.blur();
		this.highlight(this.MicMuteOnBtn);
		this.MicMuteOnBtn.visibleObj();		
		this.ShowTooltip(this.MicMuteOnBtn);
		PluginAPIMgr.MuteMic(false);
	}
}

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

SceneConferenceCall.prototype.processReturnKey = function(){
    alert("SceneConferenceCall.processReturnKey() ");
        
	if(g_Data.WIDGET_PARAM.start == true)
	{
		ProcMgr.GoOutWithSignIn(false);
	}
	else
	{
		StateMgr.Start_Main_State();
	}
}

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


SceneConferenceCall.prototype.ShowTooltip = function(btn_obj)
{		
	var tooltip_text;
	var tooltip_left;
	
	//1st. show
	if(this.flag_shown_tooltip == false)
	{
		$('#conf_call_btn_tooltip').sfTooltip('show');
		this.flag_shown_tooltip = true;
	}	
	
	if(btn_obj == this.MicMuteOffBtn)
	{
		tooltip_text = IDWS_MOIP_SKYPE_UNMUTE_MIC;
		tooltip_left = '917px';
	}
	if(btn_obj == this.MicMuteOnBtn)
	{
		tooltip_text = IDWS_MOIP_SKYPE_MUTE_MIC;
		tooltip_left = '917px';
	}	
	else if(btn_obj == this.CallEndBtn)
	{
		tooltip_text = TV_SID_END_CALL;
		tooltip_left = '1021px';
	}

	$('#conf_call_btn_tooltip').sfTooltip('setText',tooltip_text);
	$('#conf_call_btn_tooltip').css('left',tooltip_left);
	
	if(this.TooltipTimer)
	{
		clearTimeout(this.TooltipTimer);
	}
    
	this.TooltipTimer = setTimeout("HideToolTipCallBack()", 6000);
	
	HideToolTipCallBack = function(){
		$('#conf_call_btn_tooltip').sfTooltip('hide');
		sf.scene.get('ConferenceCall').flag_shown_tooltip = false;
    }
}

SceneConferenceCall.prototype.toggleMuteBtnEnable=function()
{
    alert("SceneConferenceCall.toggleMuteBtnEnable() ");
    
    //get mute state 
    this.is_mic_mute = ProcMgr.CallInfo.IsMicMute;
	
	var currentHighlight =  this.ConferenceCallView.getCurrentHighlight();

	if(this.is_mic_mute == true)
	{	
		this.MicMuteOffBtn.visibleObj();
		this.MicMuteOnBtn.hiddenObj();
	}
	else{
		
		this.MicMuteOffBtn.hiddenObj();
		this.MicMuteOnBtn.visibleObj();
	}
}

SceneConferenceCall.prototype.processBtnOver = function(obj){
	
	var currentHighlight =  this.ConferenceCallView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }
}

SceneConferenceCall.prototype.processCallEndBtnOver = function(){
	this.processBtnOver(this.CallEndBtn);
}

SceneConferenceCall.prototype.processMicMuteOnBtnOver = function(){
    this.processBtnOver(this.MicMuteOnBtn);
}

SceneConferenceCall.prototype.processMicMuteOffBtnOver = function(){
    this.processBtnOver(this.MicMuteOffBtn);
}

SceneConferenceCall.prototype.showArrowBtn = function()
{	
	alert('SceneConferenceCall.showArrowBtn');
	if(this.MaxCallmemberPage < 2)
	{
		return;
	}
	this.shownArrow = true;
	this.updateArrowBtn();
}

SceneConferenceCall.prototype.hideArrowBtn = function()
{	
	alert('SceneConferenceCall.hideArrowBtn');
	
	if(this.shownArrowUp == true)
	{
		this.arrow_up.hiddenObj();
	}
	if(this.shownArrowDown == true)
	{
		this.arrow_down.hiddenObj();
	}
	
	this.shownArrow = false;
}


SceneConferenceCall.prototype.updateArrowBtn = function()
{
	alert('SceneConferenceCall.updateArrowBtn');	
	
	if(this.shownArrow == false)
	{
		return;
	}
	
	if(this.CurrentCallmemberPage > 1)
	{
		this.arrow_up.visibleObj();
		this.shownArrowUp = true;
	}
	else
	{
		this.arrow_up.hiddenObj();
		this.shownArrowUp = false;
	}
	
	if(this.CurrentCallmemberPage == this.MaxCallmemberPage)
	{
		this.arrow_down.hiddenObj();
		this.shownArrowDown = false;
	}
	else
	{
		this.arrow_down.visibleObj();
		this.shownArrowDown = true;
	}
}

SceneConferenceCall.prototype.processMuteKey = function()
{
	alert("SceneConferenceCall.processMuteKey()");

	if(ProcMgr.CallInfo.IsSpeakerMute == false)
	{
	    ProcMgr.processVolumeMute(true);
	    StateMgr.Start_Volume_Speaker_State(VOLUME_MODE.MASTER_MUTE);
	}
	else
	{
		ProcMgr.processVolumeMute(false);
    	StateMgr.Start_Volume_Speaker_State(VOLUME_MODE.MASTER);
	}
}
