function Balloon()
{
	this.id = "balloon_default"	
	
	var theString = '<STYLE TYPE="text/css">#'+this.id+'{width:150; visibility:hidden;}</STYLE>';
	theString += '<DIV id="anchor' + this.id + '" style="visibility:hidden"><DIV CLASS="hlpdiv" id="'+this.id+'"></DIV></DIV>';
	document.write(theString);
	this.divElm = document.getElementById(this.id);
	this.divAnchorElm = document.getElementById("anchor" + this.id);
	if (navigator.appName!="Netscape")
	{
		this.divElm.attachEvent("onmouseover", this._setMouseOver);
		this.divElm.attachEvent("onmouseout", this._setMouseOut);
	}
	else
	{
		this.divElm.setAttribute("onmouseover", "this.setAttribute('mouse', 'over')");
		this.divElm.setAttribute("onmouseout", "this.setAttribute('mouse', 'out')");
	}
}

Balloon.prototype.SetWidth = function Balloon_SetWidth(width)
{
	document.getElementById(this.id).style.width = width; 
}

Balloon.prototype.GetWidth = function Balloon_GetWidth()
{
	return document.getElementById(this.id).clientWidth + 2;
}

Balloon.prototype.Show = function Balloon_Show(obj, innerHtml)
{
	var dx, dy, elm;
	elm = obj;
	
	var pos = this._findObjPos(obj)
	
	dx = pos.x - 20;	
	if (dx + this.GetWidth()> document.body.clientWidth) dx = document.body.clientWidth - this.GetWidth();
	if (dx < 0) dx = 1;	
	
	dy = pos.y;
	if (dy > 17) dy += 17

	this.divElm.innerHTML = innerHtml;
	
	if (navigator.appName=="Microsoft Internet Explorer")
	{
		this.divElm.style.left = dx;
		this.divElm.style.top = dy;
	}
	else
	{
		this.divElm.parentNode.removeChild(this.divElm);
		obj.appendChild(this.divElm);
//		this.divElm.style.left = dx-20;
//		this.divElm.style.top = dy+1;
	}
	this.divElm.style.visibility = "visible";	
}

Balloon.prototype.Hide = function Balloon_Hide()
{
	this.divElm.style.visibility = "hidden";
	if (navigator.appName!="Microsoft Internet Explorer")
	{
		this.divElm.parentNode.removeChild(this.divElm);
		this.divAnchorElm.appendChild(this.divElm);
	}	
}

Balloon.prototype.IsMouseOver = function Balloon_IsMouseOver()
{
	return this.divElm.getAttribute('mouse') == "over";
}
/******************************************************************************/
Balloon.prototype._setMouseOver = function Balloon_setMouseOver()
{
	document.getElementById("balloon_default").setAttribute("mouse", "over"); //this - window
}
Balloon.prototype._setMouseOut = function Balloon_setMouseOut()
{
	document.getElementById("balloon_default").setAttribute("mouse", "out"); //this - window
}
Balloon.prototype._findObjPos = function Balloon_findAPosX(obj)
{
	if (!obj) return -1;
	var curLeft = 0;
	var	curTop = 0;
	
	if (obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			curLeft += obj.offsetLeft;
			curTop += obj.offsetTop;
			obj	= obj.offsetParent;
			if (obj.tagName == "DIV")
			{
				if (obj.scrollLeft) curLeft -= obj.scrollLeft;
				if (obj.scrollTop) curTop -= obj.scrollTop;
			}
		}
	} 
	else
	{
		curLeft	+= obj.x;
		curTop += obj.y;
		if (obj.tagName == "DIV")
		{
			curLeft -= obj.scrollLeft;
			curTop -= obj.scrollTop;
		}
	}
	return	{x:curLeft,y:curTop};
}

