
function FaceRecogItem () {
 
 	this.AvataLayerIndex        = -1;
 	this.AvataBorderLayerIndex        = -1;		//avata border layer
 	this.NameLayerIndex		= -1;
	
	this.eID	= null;	

	this.AvataStyle			= new Array(ITEM_STATE.MAX);
	this.AvataBorderStyle			= new Array(ITEM_STATE.MAX);
    this.NameStyle				= new Array(ITEM_STATE.MAX);   
		
    ListItem.call(this);
}

FaceRecogItem.prototype = new ListItem(); 


FaceRecogItem.prototype.Create = function(eName) {
    
    alert("FaceRecogItem.Create()");

    this.CreateBG(eName); 
    this.CreateAvata(eName);
    this.CreateAvataBorder(eName);
	this.CreateName(eName);	
	
	this.eID = eName;
	
	if(this.ItemID % 2 == 1){		
    	this.SetBgImage(ITEM_STATE.NORMAL,g_Image.IMAGE_FACE_RECOG_RESULT_BG_NORMAL);
    }else{
		this.SetBgImage(ITEM_STATE.NORMAL,' ');
    }
	this.SetBgImage(ITEM_STATE.HIGHLIGHT,g_Image.IMAGE_FACE_RECOG_RESULT_BG_HIGHLIGHT);	
	
	this.SetBgStyle(ITEM_STATE.NORMAL_UP, eName + "NormalUp");
	this.SetBgStyle(ITEM_STATE.NORMAL_DOWN, eName + "NormalDown");
	this.SetBgStyle(ITEM_STATE.HIGHLIGHT, eName + "Highlight");
		
	this.SetAvataStyle(ITEM_STATE.NORMAL,"rItem_Avata_Normal");	
	this.SetAvataStyle(ITEM_STATE.HIGHLIGHT,"rItem_Avata_Highlight");

	this.SetAvataBorderStyle(ITEM_STATE.NORMAL,"rItem_AvataBorder_Normal");	
	this.SetAvataBorderStyle(ITEM_STATE.HIGHLIGHT,"rItem_AvataBorder_Highlight");
	
	this.SetNameStyle(ITEM_STATE.NORMAL,"rItem_Name_Normal");	
	this.SetNameStyle(ITEM_STATE.HIGHLIGHT,'rItem_Name_Highlight')	;

}

FaceRecogItem.prototype.CreateAvata = function(eRootName) {

    var ElementStr = eRootName + "Avata";

    this.AvataLayerIndex = this.LayerArray.length;    
    this.AddJPGImageLayer(ElementStr);    
             
}
FaceRecogItem.prototype.CreateAvataBorder = function(eRootName) {

    var ElementStr = eRootName + "AvataBorder";

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

FaceRecogItem.prototype.CreateName = function(eRootName) {

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

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

FaceRecogItem.prototype.SetAvataBorderStyle = function(ItemStateIndex, Style){
    	
	this.AvataBorderStyle[ItemStateIndex] = Style;
    
}

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



FaceRecogItem.prototype.SetItem = function(DataObject) {
	
	alert("FaceRecogItem.SetItem()");

	var Name = DataObject.Name;	
	var AvataPath = DataObject.Avata;
	
	
	this.LayerArray[this.AvataLayerIndex].SetImage(AvataPath);
	this.LayerArray[this.AvataBorderLayerIndex].SetImage(g_Image.IMAGE_FACE_RECOG_RESULT_PHOTOLINE_NORMAL);
	if(Name==null){
		this.LayerArray[this.NameLayerIndex].SetText(TV_UNKNOWN_MSG);
	}else{
		this.LayerArray[this.NameLayerIndex].SetText(Name);
	}
	
	this.InputData = DataObject;
	
	this.ExistData = true;
}


FaceRecogItem.prototype.UpNormal = function() {
	alert("ContactItem.prototype.UpNormal");
	this.State = ITEM_STATE.NORMAL_UP;
	this.ChangeBG();
	this.ChangeLayerForNormal();
}
FaceRecogItem.prototype.DownNormal = function() {
	alert("FaceRecogItem.prototype.DownNormal");
    this.State = ITEM_STATE.NORMAL_DOWN;
	this.ChangeBG();
	this.ChangeLayerForNormal();
}
FaceRecogItem.prototype.ChangeLayerForNormal = function() {
	this.LayerArray[this.AvataLayerIndex].SetStyle("rItem_Avata_Normal");
    this.LayerArray[this.AvataBorderLayerIndex].SetImage(g_Image.IMAGE_FACE_RECOG_RESULT_PHOTOLINE_NORMAL);	
    this.LayerArray[this.AvataBorderLayerIndex].SetStyle("rItem_AvataBorder_Normal");	
    this.LayerArray[this.NameLayerIndex].SetStyle("rItem_Name_Normal");
    var layerId = this.LayerArray[this.NameLayerIndex].GetObjectId();
    var name = $("#"+layerId).text();
    if(name == TV_SELECT_TO_REGISTER_THIS_FACE_MSG){
    	this.LayerArray[this.NameLayerIndex].SetText(TV_UNKNOWN_MSG);
    }
}

FaceRecogItem.prototype.Highlight = function() {
	alert("FaceRecogItem.Highlight()");
	this.State = ITEM_STATE.HIGHLIGHT;
	this.ChangeBG();
	if(this.InputData.GetAvataIsNull==true){
		alert("this item not registed face!!");
		// this.LayerArray[this.AvataLayerIndex].SetImage
	}
	this.LayerArray[this.AvataLayerIndex].SetStyle("rItem_Avata_Highlight");
	this.LayerArray[this.AvataBorderLayerIndex].SetImage(g_Image.IMAGE_FACE_RECOG_RESULT_PHOTOLINE_HIGHLIGHT);
    this.LayerArray[this.AvataBorderLayerIndex].SetStyle("rItem_AvataBorder_Highlight");	
    this.LayerArray[this.NameLayerIndex].SetStyle("rItem_Name_Highlight");
    var layerId = this.LayerArray[this.NameLayerIndex].GetObjectId();
    var name = $("#"+layerId).text();
    if(name == TV_UNKNOWN_MSG){
    	this.LayerArray[this.NameLayerIndex].SetText(TV_SELECT_TO_REGISTER_THIS_FACE_MSG);
    }
    	
	
}
