
function LiveCallItem () {
            
    this.NameLayerIndex         = -1;
    this.BoxLayerIndex			= -1;	
    this.AvataLayerIndex        = -1;
    this.StatusLayerIndex  		= -1;  			//1:1 call or conference call
    this.DurationLayerIndex		= -1;

	this.AvataType		= null;
	this.IdentityName	= null;
   
	this.NameStyle			= new Array(ITEM_STATE.MAX);   
    this.BoxStyle			= new Array(ITEM_STATE.MAX);   
    this.AvataStyle			= new Array(ITEM_STATE.MAX);	
    this.StatusStyle		= new Array(ITEM_STATE.MAX);
    this.DurationStyle		= new Array(ITEM_STATE.MAX);
	
    ListItem.call(this);
}

LiveCallItem.prototype = new ListItem(); 

LiveCallItem.prototype.Create = function(eName) {
    
    alert("LiveCallItem.Create()");
            
    this.CreateBG(eName);         	
    this.CreateBox(eName);		
    this.CreateAvata(eName);
	this.CreateName(eName);
    this.CreateStatus(eName);
	this.CreateDuration(eName);	
    
    this.SetBgImage(ITEM_STATE.NORMAL,' ');
	this.SetBgImage(ITEM_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_HIGHLIGHT_BG);	
	
	this.SetBgStyle(ITEM_STATE.NORMAL_UP, eName + "NormalUp");
	this.SetBgStyle(ITEM_STATE.NORMAL_DOWN, eName + "NormalDown");
	this.SetBgStyle(ITEM_STATE.HIGHLIGHT, eName + "Highlight");
		
	this.SetBoxStyle(ITEM_STATE.NORMAL, "pItem_Box_Normal");
	this.SetBoxStyle(ITEM_STATE.HIGHLIGHT, "pItem_Box_Highlight");
		
	this.SetAvataStyle(ITEM_STATE.NORMAL, "pItem_Avatar_Normal");
	this.SetAvataStyle(ITEM_STATE.HIGHLIGHT, "pItem_Avatar_Highlight");
			
	this.SetNameStyle(ITEM_STATE.NORMAL, "pItem_Name_Normal");
	this.SetNameStyle(ITEM_STATE.HIGHLIGHT, "pItem_Name_Highlight");

	this.SetStatusStyle(ITEM_STATE.NORMAL, "cItem_Status_Normal");
	this.SetStatusStyle(ITEM_STATE.HIGHLIGHT, "cItem_Status_Highlight");
	
	this.SetDurationStyle(ITEM_STATE.NORMAL, "cItem_Duration_Normal");
	this.SetDurationStyle(ITEM_STATE.HIGHLIGHT, "cItem_Duration_Highlight");	
	
}

LiveCallItem.prototype.CreateBox = function(eRootName) {

    var ElementStr = eRootName + "Box";

    this.BoxLayerIndex = this.LayerArray.length;    
    this.AddJPGImageLayer(ElementStr);
	              
}

LiveCallItem.prototype.CreateAvata = function(eRootName) {

    var ElementStr = eRootName + "Avata";

    this.AvataLayerIndex = this.LayerArray.length;    
    this.AddJPGImageLayer(ElementStr);    
             
}

LiveCallItem.prototype.CreateName = function(eRootName) {

    var ElementStr = eRootName + "Name";
    
    this.NameLayerIndex = this.LayerArray.length;
    this.AddTextLayer(ElementStr);
             
}

LiveCallItem.prototype.CreateStatus = function(eRootName) {

    var ElementStr = eRootName + "Status";

    this.StatusLayerIndex = this.LayerArray.length;    
    this.AddImageLayer(ElementStr);    
             
}

LiveCallItem.prototype.CreateDuration = function(eRootName) {

    var ElementStr = eRootName + "Duration";

    this.DurationLayerIndex = this.LayerArray.length;    
    this.AddTextLayer(ElementStr);    
  
}

LiveCallItem.prototype.SetStatusStyle = function(ItemStateIndex, Style){
    	
	this.StatusStyle[ItemStateIndex] = Style;
    
}

LiveCallItem.prototype.SetBoxStyle = function(ItemStateIndex, Style){
    	
	this.BoxStyle[ItemStateIndex] = Style;
    
}


LiveCallItem.prototype.SetAvataStyle = function(ItemStateIndex, Style){
    	
	this.AvataStyle[ItemStateIndex] = Style;
    
}

LiveCallItem.prototype.SetNameStyle = function(ItemStateIndex, Style){
    	
	this.NameStyle[ItemStateIndex] = Style;
    
}

LiveCallItem.prototype.SetDurationStyle = function(ItemStateIndex,Style){
    	
	this.DurationStyle[ItemStateIndex] = Style;    
}

LiveCallItem.prototype.UpNormal = function() {
	
    this.State = ITEM_STATE.NORMAL_UP;
	this.ChangeBG();
	this.ChangeLayerForNormal();
}

LiveCallItem.prototype.DownNormal = function() {
	
    this.State = ITEM_STATE.NORMAL_DOWN;
	this.ChangeBG();
	this.ChangeLayerForNormal();
}

LiveCallItem.prototype.Highlight = function() {
	
	this.State = ITEM_STATE.HIGHLIGHT;
	this.ChangeBG();
	this.ChangeLayerForHighlight();
	
}

LiveCallItem.prototype.ChangeLayerForHighlight = function() {
	
	alert("CallingLiveItem.ResizeLayerNormal()");

	this.LayerArray[this.BoxLayerIndex].SetStyle(this.BoxStyle[ITEM_STATE.HIGHLIGHT]);
	this.LayerArray[this.BoxLayerIndex].SetImage(g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_HIGHLIGHT_THUMBNALE_BOX);
	this.LayerArray[this.AvataLayerIndex].SetStyle(this.AvataStyle[ITEM_STATE.HIGHLIGHT]);		
    this.SetBigAvata();
    this.LayerArray[this.NameLayerIndex].SetStyle(this.NameStyle[ITEM_STATE.HIGHLIGHT]);	
    this.LayerArray[this.StatusLayerIndex].SetStyle(this.StatusStyle[ITEM_STATE.HIGHLIGHT]);		
	this.LayerArray[this.DurationLayerIndex].SetStyle(this.DurationStyle[ITEM_STATE.HIGHLIGHT]);
		
}


LiveCallItem.prototype.ChangeLayerForNormal = function() {

    alert("CallingLiveItem.ResizeLayerNormal()");    
	
	this.LayerArray[this.BoxLayerIndex].SetStyle(this.BoxStyle[ITEM_STATE.NORMAL]);	
	this.LayerArray[this.BoxLayerIndex].SetImage(g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_NORMAL_THUMBNALE_BOX);
	this.LayerArray[this.AvataLayerIndex].SetStyle(this.AvataStyle[ITEM_STATE.NORMAL]);
	this.SetSmallAvata();
    this.LayerArray[this.NameLayerIndex].SetStyle(this.NameStyle[ITEM_STATE.NORMAL]);	
    this.LayerArray[this.StatusLayerIndex].SetStyle(this.StatusStyle[ITEM_STATE.NORMAL]);		
	this.LayerArray[this.DurationLayerIndex].SetStyle(this.DurationStyle[ITEM_STATE.NORMAL]);	
}


LiveCallItem.prototype.SetItem = function() {
	
	alert("CallingLiveItem.SetItem()");

	//Set Name
	var Name = PluginAPIMgr.GetCallMemberDisplayName();		
	this.IdentityName = PluginAPIMgr.GetCallMemberID();
	
	//alert("Name = " + Name);
	this.LayerArray[this.NameLayerIndex].SetText(Name);
	
	//Set avatar
	var Avatar = PluginAPIMgr.GetAvatarPath(this.IdentityName);
	this.AvatarType = PluginAPIMgr.GetAvatarType(this.IdentityName);

	//alert("AvataType = " + this.AvataType);
	this.LayerArray[this.AvataLayerIndex].SetImage(Avatar);
		
	//Set Status
	var Status = g_Image.IMAGE_ONLINE_STATUS_PRESENCE_CALLING;	
	this.LayerArray[this.StatusLayerIndex].SetImage(Status);
	
	//Set Duration Time
	var Time = IDWS_MOIP_SKYPE_CALL_DURATION + " : ";
	//alert("Time = " + Time);
	this.LayerArray[this.DurationLayerIndex].SetText(Time);
	
	this.ExistData = true;
}

LiveCallItem.prototype.GetIdentity = function(){

    return this.IdentityName;
}


LiveCallItem.prototype.SetDuration = function(strTime){

	var DurationTime = IDWS_MOIP_SKYPE_CALL_DURATION + " : "+ strTime;
	this.LayerArray[this.DurationLayerIndex].SetText(DurationTime);
}


LiveCallItem.prototype.SetSmallAvata = function() {
	
	
	if(this.AvataType == ENUM_CONTACT_AVATA_TYPE.ONES_IMAGE){
		return;
	}
	
	var Avata;
	
	switch(this.AvataType) {

		case ENUM_CONTACT_AVATA_TYPE.PSTN:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_PSTN;	
			break;
		
		case ENUM_CONTACT_AVATA_TYPE.MALE:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_MALE;	
			break;

		case ENUM_CONTACT_AVATA_TYPE.FEMALE:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_FEMALE;	
			break;
		
		case ENUM_CONTACT_AVATA_TYPE.MYSELF:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_MYSELF;	
			break;
			
		case ENUM_CONTACT_AVATA_TYPE.TEST_CALL:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_TEST_CALL;	
			break;			

		case ENUM_CONTACT_AVATA_TYPE.NO_GENDER:			
		default :
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_NO_GENDER;	
			break;	
			
	}
	
	this.LayerArray[this.AvataLayerIndex].SetImage(Avata);
	
}

LiveCallItem.prototype.SetBigAvata = function() {
	
	if(this.AvataType == ENUM_CONTACT_AVATA_TYPE.ONES_IMAGE){
		return;
	}
	
	var Avata;
	
	switch(this.AvataType) {

		case ENUM_CONTACT_AVATA_TYPE.PSTN:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_PSTN_BIG;	
			break;
		
		case ENUM_CONTACT_AVATA_TYPE.MALE:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_MALE_BIG;	
			break;

		case ENUM_CONTACT_AVATA_TYPE.FEMALE:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_FEMALE_BIG;	
			break;
		
		case ENUM_CONTACT_AVATA_TYPE.MYSELF:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_MYSELF_BIG;	
			break;
			
		case ENUM_CONTACT_AVATA_TYPE.TEST_CALL:
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_TEST_CALL_BIG;	
			break;			

		case ENUM_CONTACT_AVATA_TYPE.NO_GENDER:		
		default :
			Avata = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_NO_GENDER_BIG;	
			break;	
			
	}
	
	this.LayerArray[this.AvataLayerIndex].SetImage(Avata);
	
}

