
var DEFAULT_SEARCH_DATA = { 
 
    SkypName		:   " ",
    FullName		:   " ",
    Country			:   " ",
    AvatarPath		:   " "
}



function CountryItem () {
 
 	this.NameLayerIndex		= -1;
    this.PrefixLayerIndex		= -1;	
	this.FlagLayerIndex		= -1;
	//2013 add by minseok
	this.CheckLayerIndex = -1;
	this.Name = null;
	
	this.eID	= null;	

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

CountryItem.prototype = new ListItem(); 


CountryItem.prototype.Create = function(eName, divide_option) {
    
    alert("CountryItem.Create()");

    this.CreateBG(eName, divide_option); 
	this.CreateName(eName);	
    this.CreatePrefix(eName);	
    this.CreateFlag(eName);		
    //2013 add by minseok
    this.CreateCheck(eName);	
	
	this.eID = eName;
	
	this.SetBgImage(ITEM_STATE.NORMAL,' ');
	//this.SetBgImage(ITEM_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CALL_COUNTR_FLAG_LIST_ITEM_HIGHLIGHT_BG);	
		
	this.NameStyle[ITEM_STATE.NORMAL] = "cFlagList_Name_Text_Normal";
	this.NameStyle[ITEM_STATE.HIGHLIGHT] = "cFlagList_Name_Text_Highlight";	

	this.PrefixStyle[ITEM_STATE.NORMAL] = "cFlagList_Prefix_Text_Normal";
	this.PrefixStyle[ITEM_STATE.HIGHLIGHT] = "cFlagList_Prefix_Text_Highlight";	

}

CountryItem.prototype.CreateName = function(eRootName) {

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

CountryItem.prototype.CreatePrefix = function(eRootName) {

    var ElementStr = eRootName + "Prefix";

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

CountryItem.prototype.CreateFlag = function(eRootName) {

    var ElementStr = eRootName + "Flag";
	
    this.FlagLayerIndex = this.LayerArray.length;    
    this.AddImageLayer(ElementStr);    
  
}

CountryItem.prototype.CreateCheck = function(eRootName){
	var ElementStr = eRootName + "Check";
	
    this.CheckLayerIndex = this.LayerArray.length;    
    this.AddImageLayer(ElementStr);
}

CountryItem.prototype.SetContainerStyle = function(type){
 
 	var Scene;
	var LeftPostionOfPrefix;
	var FlagStyle;
	
	switch(type) {
		
		case FLAG_LIST_TYPE.LIST_MAIN_CALL:
			Scene = "_ListMainCall";
			LeftPostionOfPrefix = "434px";
			FlagStyle = "cFlagList_Flag_ListMainCall";
			break;
			
		default:
			Scene = "_AddPhoneNumber";
			LeftPostionOfPrefix = "160px";
			FlagStyle = "cFlagList_Flag_AddPhoneNumber";			
			break;
			
	}
	
	this.LayerArray[this.BGLayerIndex].SetStyle(this.eID + Scene);	
	this.LayerArray[this.FlagLayerIndex].SetStyle(FlagStyle);
	$("#"+this.LayerArray[this.PrefixLayerIndex].Obj).css('left', LeftPostionOfPrefix);

}


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

	this.Name = DataObject.Name;	
	var Prefix = DataObject.Prefix;
	var Flag = DataObject.FlagImg;
	//2013 add by minseok
	var Check = DataObject.FlagCheck;
	
	this.LayerArray[this.NameLayerIndex].SetText(this.Name);	
	this.LayerArray[this.PrefixLayerIndex].SetText(Prefix);
	this.LayerArray[this.FlagLayerIndex].SetImage(Flag);
	//2013 add by minseok
	if(Check){
		this.LayerArray[this.CheckLayerIndex].SetImage(g_Image.IMAGE_ONLINE_STATUS_BTN_CHK);
	}else{
		this.LayerArray[this.CheckLayerIndex].SetImage(' ');
	}
	
	this.ExistData = true;
}


CountryItem.prototype.Normal = function() {
	
    this.State = ITEM_STATE.NORMAL;
	this.ChangeBG();
    this.LayerArray[this.NameLayerIndex].SetStyle(this.NameStyle[ITEM_STATE.NORMAL]);
    this.LayerArray[this.PrefixLayerIndex].SetStyle(this.PrefixStyle[ITEM_STATE.NORMAL]);	
}

CountryItem.prototype.Highlight = function() {
	
	this.State = ITEM_STATE.HIGHLIGHT;
	this.ChangeBG();
	this.LayerArray[this.PrefixLayerIndex].SetStyle(this.PrefixStyle[ITEM_STATE.HIGHLIGHT]);
	if(this.CheckMarquee(this.Name)>173){
		this.LayerArray[this.NameLayerIndex].SetStyle("cFlagList_Name_Text_Highlight_Marquee");
	}else{
		this.LayerArray[this.NameLayerIndex].SetStyle(this.NameStyle[ITEM_STATE.HIGHLIGHT]);	
	}
	this.CheckMarquee(this.Name);
}
CountryItem.prototype.CheckMarquee = function(name) {
	var tempHTML = "<div id='checkmarquee' style='position:absolute'></div>";
	$("#"+this.eID).append(tempHTML);
	$("#checkmarquee").removeClass();
	$("#checkmarquee").html(name);
	var width = $("#checkmarquee").css('width');
	var len= width.indexOf("px");
	var curr_w_int = parseInt(width.substring(0,len));
	alert(name+" : " + width); 
	$("#checkmarquee").remove();
	return curr_w_int;
	
}
