function CompBase() {

	this.Showstate = false;

	this.BGLayerIndex = -1;
	//배경 Layer index

	this.BGLayerObj = null;
	//2013 add by minseok
	this.BGLayerObj_left = null;
	this.BGLayerObj_right = null;
	this.BGLayerObj_center = null;
	this.BGLayer_left = null;
	this.BGLayer_right = null;
	this.BGLayer_center = null;

	this.divide_flag = null;

	this.LayerArray = [];

	this.clickCallbackFunc = null;
	this.onMouseOverCallbackFunc = null;
	this.onMouseOutCallbackFunc = null;

	//availity...
	this.flag_ClickEvent = false;
	this.flag_MouseMoveEvent = false;
	//prevent duplication
	this.flag_ClickinProgress = false;
	this.flag_MouseOverProgress = false;
	this.flag_MouseOutProgress = false;
	this.flag_EnableRightClick = false;
	//8.28 added
	this.Container_layer =null;
	this.image_divide = false;
}

CompBase.prototype.GetShowState = function() {

	//alert("CompBase.GetShowState = " + this.ShowState);
	return this.Showstate;

}

CompBase.prototype.GetLastLayerIndex = function() {

	return this.LayerArray.length - 1;

}

CompBase.prototype.InsertLayer = function(Layer) {

	this.LayerArray.push(Layer);

}

CompBase.prototype.AddTextLayer = function(eID) {

	//alert("CompBase.AddTextLayer(" + tID + ")");
	var textLayer = new TextLayer(eID);

	this.InsertLayer(textLayer);

}

CompBase.prototype.AddImageLayer = function(eID,divide) {

	
	if(divide){
		this.CreateBG(eID,divide);
		this.image_divide = true;
	}else{
		var imageLayer = new ImageLayer(eID);
		this.InsertLayer(imageLayer);	
	}

}

CompBase.prototype.AddJPGImageLayer = function(eID) {

	var imageLayer = new JPGImageLayer(eID);
	this.InsertLayer(imageLayer);

}

CompBase.prototype.CreateBG = function(eID, divide_option) {

	alert("CompBase.CreateBG(" + eID + ")");
	if(eID == null) {
		alert("CCompBase.CreateBG()  >>>   Param is null !!  ");
		return false;
	}

	//2013 add by minseok
	if(divide_option > 0) {
		
		
		this.divide_flag = divide_option;
		var temp_html = $("#"+eID).html();
		temp_html += "<div id=" + eID + "_left></div><div id=" + eID + "_center></div><div id=" + eID + "_right></div>";
		$("#"+eID).html(temp_html);

		this.BGLayerObj_left = eID + "_left";
		this.BGLayerObj_right = eID + "_right";
		this.BGLayerObj = eID;
		this.BGLayerObj_center = eID + "_center";

		this.BGLayer_center = new ImageLayer(eID + "_center");
		this.BGLayer_left = new ImageLayer(eID + "_left");
		this.BGLayer_right = new ImageLayer(eID + "_right");
		this.BGLayerIndex = this.LayerArray.length;
		
		var imageLayer = new ImageLayer(eID);
		this.InsertLayer(imageLayer);

		this.SetStyle();
	} else {
		this.Container_layer = eID;
		alert("normal ContainerId : "+this.Container_layer);
		var imageLayer = new ImageLayer(eID);

		this.BGLayerIndex = this.LayerArray.length;
		this.BGLayerObj = eID;

		this.InsertLayer(imageLayer);

		//this.Showstate  = false;
	}

}

CompBase.prototype.SetBGImage = function(ImageUrl) {

	//alert("CompBase.SetBGImage()");
	if(this.image_divide){
		if(ImageUrl != null) {
			var result = ImageUrl.indexOf('_center');
			var Url;
			if(result != -1) {
				Url = ImageUrl.substring(0, result);

			//	alert("Url : " + Url);
			}
			this.BGLayer_left.SetImage(Url + '_left.png');
			this.BGLayer_center.SetImage(Url + '_center.png');
			this.BGLayer_right.SetImage(Url + '_right.png');
		}
	}else{
		this.LayerArray[this.BGLayerIndex].SetImage(ImageUrl);
	}
}

CompBase.prototype.Update = function() {

	//

}

CompBase.prototype.SetTextLayer = function(ArrayIndex, Text) {

	if(ArrayIndex == null|| Text == null) {
		alert("[CompBase.SetTextLayer()] Param is null !!");
		return false;
	}

	this.LayerArray[ArrayIndex].SetText(Text);

}

CompBase.prototype.SetImageLayer = function(ArrayIndex, ImageUrl) {

	if(ArrayIndex == null || ImageUrl == null) {
		alert("[CompBase.SetImageLayer()] Param is null !!");
		return false;
	}
	if(this.image_divide){
		this.SetBGImage(ImageUrl);
	}else
		this.LayerArray[ArrayIndex].SetImage(ImageUrl);

}

CompBase.prototype.SetStyle = function(ArrayIndex, style) {

	alert("CompBase.SetStyle ()");

	//2013 add by minseok
	if(this.divide_flag > 0) {
		var OrginWidth = $("#" + this.BGLayerObj).css('width');
		var OrginHeight = $("#" + this.BGLayerObj).css('height');

		var WidthLen = OrginWidth.indexOf("px");
		var HeightLen = OrginHeight.indexOf("px");

		var w_int = parseInt(OrginWidth.substring(0, WidthLen));
		var h_int = parseInt(OrginHeight.substring(0, HeightLen));

		$("#" +this.BGLayerObj_left).addClass("cListItemWithTreeObject");
		$("#" +this.BGLayerObj_left).css('left', '0');
		$("#" +this.BGLayerObj_left).css('width', this.divide_flag);
		$("#" +this.BGLayerObj_left).css('height', h_int);

		$("#" +this.BGLayerObj_center).addClass("cListItemWithTreeObject");
		$("#" +this.BGLayerObj_center).css('left', this.divide_flag);
		$("#" +this.BGLayerObj_center).css('width', w_int - (this.divide_flag * 2));
		$("#" +this.BGLayerObj_center).css('height', h_int);

		$("#" +this.BGLayerObj_right).addClass("cListItemWithTreeObject");
		$("#" +this.BGLayerObj_right).css('left', w_int - this.divide_flag);
		$("#" +this.BGLayerObj_right).css('width', this.divide_flag);
		$("#" +this.BGLayerObj_right).css('height', h_int);

		this.BGLayerObj_left = this.BGLayerObj + "_left";
		this.BGLayerObj_right = this.BGLayerObj + "_right";
		this.BGLayerObj_center = this.BGLayerObj + "_center";

	} else {
		this.LayerArray[ArrayIndex].SetStyle(style);
	}

}

CompBase.prototype.Show = function() {
	alert("compbase.show() id = "+this.Container_layer);
	this.Showstate = true;

	if(this.flag_ClickEvent == true) {
		this.SetClickEvent();
	}

	if(this.flag_MouseMoveEvent == true) {
		this.SetMouseOverEvent();
		this.SetMouseOutEvent();
	}
	if(this.Container_layer)
		$("#" + this.Container_layer).css('display', 'block');
	else
		$("#" + this.LayerArray[this.BGLayerIndex].Obj).css('display', 'block');
}

CompBase.prototype.Hide = function() {
	alert("compbase.Hide() id = "+this.Container_layer);
	this.Showstate = false;
	if(this.flag_ClickEvent == true) {
		this.ResetClickEvent();
	}

	if(this.flag_MouseMoveEvent == true) {
		this.ResetMouseOverEvent();
		this.ResetMouseOutEvent();
	}
	if(this.Container_layer)
		$("#" + this.Container_layer).css('display', 'none');
	else
	$("#" + this.LayerArray[this.BGLayerIndex].Obj).css('display', 'none');
	
}

CompBase.prototype.GetBGLayer = function() {

	return this.LayerArray[this.BGLayerIndex];
}
//Public
CompBase.prototype.SetOnClickCallbackFunc = function(func, rightClick) {

	if(WndMgr.MouseClickEnable == false) {
		return;
	}
	if(rightClick) {
		alert(">>>>> rightClick <<<<<");
		this.flag_EnableRightClick = rightClick;
	}

	if(func != null) {
		alert("CompBase.SetOnClickCallbackFunc()");
		this.clickCallbackFunc = func;
		this.SetClickEvent();
		this.flag_ClickEvent = true;
	}

}

CompBase.prototype.ResetOnClickCallbackFunc = function() {

	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	alert("CompBase.ResetOnClickCallbackFunc()");
	this.clickCallbackFunc = null;
	this.ResetClickEvent();
	this.flag_ClickEvent = false;
}

CompBase.prototype.SetOnMouseOverCallbackFunc = function(func) {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(func != null) {
		alert("CompBase.SetOnMouseOverCallbackFunc()");
		this.onMouseOverCallbackFunc = func;
		this.SetMouseOverEvent();
		this.flag_MouseMoveEvent = true;
	}
}

CompBase.prototype.SetOnMouseOutCallbackFunc = function(func) {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(func != null) {
		alert("CompBase.SetOnMouseOutCallbackFunc()");
		this.onMouseOutCallbackFunc = func;
		this.SetMouseOutEvent();
		this.flag_MouseMoveEvent = true;
	}
}

CompBase.prototype.ResetOnMouseOverCallbackFunc = function() {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	alert("CompBase.ResetOnMouseOverCallbackFunc()");
	this.onMouseOverCallbackFunc = null;
	this.ResetMouseOverEvent();
	this.flag_MouseMoveEvent = false;

}

CompBase.prototype.ResetOnMouseOutCallbackFunc = function() {
	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	alert("CompBase.ResetOnMouseOutCallbackFunc()");
	this.onMouseOutCallbackFunc = null;
	this.ReetMouseOutEvent();
	this.flag_MouseMoveEvent = false;

}
//Private
CompBase.prototype.SetClickEvent = function() {

	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	var this_ = this;
	if(this.flag_ClickinProgress == false) {
		alert("CompBase.SetClickEvent()");

		if(this.flag_EnableRightClick == false) {
			document.getElementById(this.BGLayerObj).onclick = function() {this_.clickCallbackFunc(this_);};
		} else {
			document.getElementById(this.BGLayerObj).onmousedown = function() {this_.clickCallbackFunc(this_);};
		}

		$("#" + this.BGLayerObj).css({
			'cursor' : 'pointer'
		});
		this.flag_ClickinProgress = true;
	} else {
		alert("CompBase.SetClickEvent()  ===> flag_ClickEvent is true");
	}
}

CompBase.prototype.ResetClickEvent = function() {

	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(this.flag_ClickinProgress == true) {
		alert("CompBase.ResetClickEvent()");
		document.getElementById(this.BGLayerObj).onclick = null;
		$("#" + this.BGLayerObj).css({
			'cursor' : ''
		});
		this.flag_ClickinProgress = false;
	}
}
//mouse move...
CompBase.prototype.SetMouseOverEvent = function() {

	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	var this_ = this;

	if(this.flag_MouseOverProgress == false) {
		alert("CompBase.SetMouseOverEvent()");
		document.getElementById(this.BGLayerObj).onmouseover = function(){ this_.onMouseOverCallbackFunc(this_);};
		this.flag_MouseOverProgress = true;
	} else {
		alert("CompBase.SetMouseOverEvent()  ===> flag_MouseOverProgress is true");
	}

}

CompBase.prototype.ResetMouseOverEvent = function() {

	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(this.flag_MouseOverProgress == true) {
		alert("CompBase.ResetClickEvent()");
		document.getElementById(this.BGLayerObj).onmouseover = null;

		this.flag_MouseOverProgress = false;
	}
}

CompBase.prototype.SetMouseOutEvent = function() {

	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	var this_ = this;

	if(this.flag_MouseOutProgress == false) {
		alert("CompBase.SetMouseOutEvent()");
		document.getElementById(this.BGLayerObj).onmouseout = function(){ this_.onMouseOutCallbackFunc(this_);};
		this.flag_MouseOutProgress = true;
	} else {
		alert("CompBase.SetMouseOutEvent()  ===> flag_MouseOutProgress is true");
	}
}

CompBase.prototype.ResetMouseOutEvent = function() {

	if(WndMgr.MouseClickEnable == false) {
		return;
	}

	if(this.flag_MouseOutProgress == true) {
		alert("CompBase.ResetClickEvent()");
		document.getElementById(this.BGLayerObj).onmouseout = null;
		this.flag_MouseOutProgress = false;
	}
}