
function cHoverBox(content, className, showAt, targetId, hideIfEmpty) {

	this.Target = getE(targetId);
	if (!this.Target) return;

	this.ClassName = className;
	this.ShowAt = showAt;
	this.Content = content;
	this.HideIfEmpty = ((hideIfEmpty == undefined) ? false : hideIfEmpty);

	var me = this;

	this.targetMouseOver = function(evt) {
		var e = new cEvent(evt);
		me.build();
		me.BoxContent.innerHTML = me.Content;
		me.Box.style.display = "block";
		me.position(e.Target);
	}

	this.targetMouseOut = function(evt) {
		me.Box.style.display = "none";
	}

	if (this.Content.length == 0 && this.HideIfEmpty) {
		this.Target.style.display = "none";
	}
	else if (this.Content.length > 0) {
		appendEventHandler(this.Target, "mouseover", this.targetMouseOver);
		appendEventHandler(this.Target, "mouseout", this.targetMouseOut);
	}

}

cHoverBox.prototype.build = function() {
	// Pokud uz elementy boxu existuji, pak pryc
	if (getE("id_" + this.ClassName)) {
		this.Box = getE("id_" + this.ClassName);
		this.BoxContent = getE("id_" + this.ClassName + "C");
		return;
	}

	this.Box = document.createElement("div");
	this.Box.id = "id_" + this.ClassName;
	this.Box.className = this.ClassName;

	var temp = document.createElement("div");
	temp.className = this.ClassName + "T";
	this.Box.appendChild(temp);

	this.BoxContent = document.createElement("div");
	this.BoxContent.id = "id_" + this.ClassName + "C";
	this.BoxContent.className = this.ClassName + "C hbContent";
	this.Box.appendChild(this.BoxContent);

	var temp = document.createElement("div");
	temp.className = this.ClassName + "B";
	this.Box.appendChild(temp);

	document.body.appendChild(this.Box);
}

cHoverBox.prototype.position = function(elTarget) {
	var pos = getPosition(elTarget);
	switch (this.ShowAt) {
	case 1:
		this.Box.style.left = (pos.x - this.Box.offsetWidth - 6) + "px";
		this.Box.style.top = (pos.y - this.Box.offsetHeight - 6) + "px";
		break;
	case 2:
		this.Box.style.left = (pos.x - 5) + "px";
		this.Box.style.top = (pos.y - this.Box.offsetHeight) + "px";
		break;
	case 3:
		this.Box.style.left = (pos.x + 16) + "px";
		this.Box.style.top = (pos.y + 16) + "px";
		break;
	case 4:
		this.Box.style.left = (pos.x - this.Box.offsetWidth - 6) + "px";
		this.Box.style.top = (pos.y + 16) + "px";
		break;
	}
}


