
function BlockItem () {
   
 	this.NameLayerIndex		= -1;
    this.BtnBgLayerIndex	= -1;	
	this.BtnTextLayerIndex	= -1;

	this.BtnBgUrl			= new Array(ITEM_STATE.MAX);
    this.BtnTextStyle		= new Array(ITEM_STATE.MAX);

	this.UnblockName = null;
	
    ListItem.call(this);
}

BlockItem.prototype = new ListItem(); 


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

    this.CreateBG(eName); 
	this.CreateName(eName);	
    this.CreateBtnBg(eName);	
    this.CreateBtnText(eName);		
   
	//this.SetBgImage(ITEM_STATE.NORMAL,' ');
 		
	this.SetBtnBgUrl(ITEM_STATE.NORMAL,g_Image.IMAGE_POPUP_BTN_NORMAL);
	this.SetBtnBgUrl(ITEM_STATE.HIGHLIGHT,g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);
	
	this.SetBtnTextStyle(ITEM_STATE.NORMAL, "popup_btn_text_normal_style");
	this.SetBtnTextStyle(ITEM_STATE.HIGHLIGHT, "popup_btn_text_focus_style");

	this.LayerArray[this.BtnTextLayerIndex].SetText(IDWS_MOIP_UNBLOCKED);

}

BlockItem.prototype.CreateName = function(eRootName) {

    var ElementStr = eRootName + "Name";
    
    this.NameLayerIndex = this.LayerArray.length;  
    this.AddTextLayer(ElementStr);
    this.LayerArray[this.NameLayerIndex].SetReverseDisable(true);
    this.LayerArray[this.NameLayerIndex].SetIsPlainText(true);
             
}

BlockItem.prototype.CreateBtnBg = function(eRootName) {

    var ElementStr = eRootName + "Btn";

    this.BtnBgLayerIndex = this.LayerArray.length;    
    this.AddImageLayer(ElementStr,20);    
  
}

BlockItem.prototype.CreateBtnText = function(eRootName) {

    var ElementStr = eRootName + "BtnText";
	
    this.BtnTextLayerIndex = this.LayerArray.length;    
    this.AddTextLayer(ElementStr);    
  
}


BlockItem.prototype.SetBtnBgUrl = function(ItemStateIndex, ImgPath){
    	
	this.BtnBgUrl[ItemStateIndex] = ImgPath;
	
	if(ItemStateIndex == ITEM_STATE.NORMAL){
		
		 this.SetImageLayer(this.BtnBgLayerIndex,ImgPath);
	}
    
}

BlockItem.prototype.SetBtnTextStyle = function(ItemStateIndex, Style){
    	
	this.BtnTextStyle[ItemStateIndex] = Style;

	if(ItemStateIndex == ITEM_STATE.NORMAL){
		
		this.LayerArray[this.BtnTextLayerIndex].SetStyle(Style);
	}    
}



BlockItem.prototype.GetUnblockName = function(){
    	
    return this.UnblockName;
}

BlockItem.prototype.Normal = function() {
	
    this.State = ITEM_STATE.NORMAL_UP;
	this.ChangeLayerForNormal();
}

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

BlockItem.prototype.ChangeLayerForHighlight = function() {

	alert("BlockItem.ChangeLayerForHighlight()");
	this.SetImageLayer(this.BtnBgLayerIndex,this.BtnBgUrl[ITEM_STATE.HIGHLIGHT]);
	this.SetStyle(this.BtnTextLayerIndex,this.BtnTextStyle[ITEM_STATE.HIGHLIGHT]);
	//this.LayerArray[this.BtnBgLayerIndex].SetImage();	
    //this.LayerArray[this.].SetStyle(this.[ITEM_STATE.HIGHLIGHT]); 		
}

BlockItem.prototype.ChangeLayerForNormal = function() {

    alert("BlockItem.ChangeLayerForNormal()");    
    this.SetImageLayer(this.BtnBgLayerIndex,this.BtnBgUrl[ITEM_STATE.NORMAL]);
	this.SetStyle(this.BtnTextLayerIndex,this.BtnTextStyle[ITEM_STATE.NORMAL]);
	// this.LayerArray[this.BtnBgLayerIndex].SetImage(this.BtnBgUrl[ITEM_STATE.NORMAL]);	
    // this.LayerArray[this.BtnTextLayerIndex].SetStyle(this.BtnTextStyle[ITEM_STATE.NORMAL]); 		

}


BlockItem.prototype.SetItem = function(BlockData) {
	
	alert("BlockItem.SetItem()");
	this.UnblockName = BlockData[0];
	var DisplayName = BlockData[1];
	var NameText;
	
	if(DisplayName && DisplayName.length > 0){
		NameText = DisplayName + " ( " + BlockData[0] + " ) ";
	} 
	else {
		NameText = BlockData[0];
	}

	this.LayerArray[this.NameLayerIndex].SetText(NameText);	
	
	this.ExistData = true;
}


