var IE = document.all?true:false;
if (!IE)
	document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;

var tempX = 0;
var tempY = 0;

function getMouseXY(e)
{
	if (IE)
	{
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else
	{
		tempX = e.pageX;
		tempY = e.pageY;
	} 

	if (tempX < 0)
		tempX = 0;
	if (tempY < 0)
		tempY = 0;

	return true;
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return {x:curleft, y:curtop};
}

var tTip = null;
var tTipTout;

function loadTooltip()
{
	toolTipArr = document.getElementsByTagName("img");
	
	oFrame = document.createElement("IFRAME");
	oFrame.frameBorder = 0;
	oFrame.scrolling = 'no';
	oFrame.id = 'ifr';
	oFrame.style.position = 'absolute';
	oFrame.style.display = 'none';
	oFrame.style.backgroundColor = 'transparent';
	document.body.appendChild(oFrame);
	
	for(i = 0; i < toolTipArr.length; i++)
	{
		if(toolTipArr[i].getAttribute("tooltip") != null)
		{
			toolTipArr[i].oDiv = document.createElement("DIV");
			toolTipArr[i].oDiv.className = 'tip-box';
			
			toolTipArr[i].oDiv.style.width = '300px';
			toolTipArr[i].oDiv.style.zIndex = 1000;
			
			if(toolTipArr[i].getAttribute("tooltip_width") != null)
			{
				toolTipArr[i].oDiv.style.width = toolTipArr[i].getAttribute("tooltip_width") + 'px';
			}
			toolTipArr[i].style.cursor = 'pointer';

			toolTipArr[i].oDiv.innerHTML = toolTipArr[i].getAttribute("tooltip");

			document.body.appendChild(toolTipArr[i].oDiv);

			toolTipArr[i].onmousemove = function()
			{
				this.oDiv.style.left = (tempX) + "px";
				if( (parseInt(this.oDiv.style.left) + parseInt(this.oDiv.style.width)) > document.body.clientWidth )
					this.oDiv.style.left = (tempX - parseInt(this.oDiv.style.width)) + 'px';
				if( parseInt(this.oDiv.style.left) < 0 )
					this.oDiv.style.left = '1px';
				this.oDiv.style.top = (tempY + this.offsetHeight + 13) + "px";
				this.oDiv.style.display = 'block';
				oFrame.style.left = this.oDiv.style.left;
				oFrame.style.top = this.oDiv.style.top;
				oFrame.style.width = this.oDiv.offsetWidth + 'px';
				oFrame.style.height = this.oDiv.offsetHeight + 'px';
				oFrame.style.zIndex = this.oDiv.style.zIndex - 1;
				oFrame.style.display = 'block';
			}
			
			toolTipArr[i].onmouseout = function()
			{
				this.oDiv.style.display = 'none';
				oFrame.style.display = 'none';
			}
		}
	}
}

function loadBubble()
{
	bubbleArr = document.getElementsByTagName("span");
	document.getElementById('bubble').style.display = 'none';
	document.getElementById('bubble').style.visibility = 'visible';
	
	for(i = 0; i < bubbleArr.length; i++)
	{
		if(bubbleArr[i].getAttribute("bubble") != null)
		{
			bubbleArr[i].style.cursor = 'default';
			
			bubbleArr[i].oY = -184;
			if(bubbleArr[i].getAttribute("bubbleSide") == 'left')
				bubbleArr[i].oX = bubbleArr[i].offsetWidth + 4;
			else
				bubbleArr[i].oX = -265;

			bubbleArr[i].onmouseover = function()
			{
				document.getElementById(this.getAttribute("bubbleKind")).style.display = 'block';
				if(this.getAttribute("bubbleSide") == 'left')
				{
					document.getElementById('leftSide__r').style.display = 'none';
					document.getElementById('rightSide__r').style.display = 'none';
					document.getElementById('topSide__r').style.display = 'none';
					document.getElementById('bottomSide__r').style.display = 'none';
					document.getElementById('leftSide__l').style.display = 'block';
					document.getElementById('rightSide__l').style.display = 'block';
					document.getElementById('topSide__l').style.display = 'block';
					document.getElementById('bottomSide__l').style.display = 'block';
				}
				else
				{
					document.getElementById('leftSide__l').style.display = 'none';
					document.getElementById('rightSide__l').style.display = 'none';
					document.getElementById('topSide__l').style.display = 'none';
					document.getElementById('bottomSide__l').style.display = 'none';
					document.getElementById('leftSide__r').style.display = 'block';
					document.getElementById('rightSide__r').style.display = 'block';
					document.getElementById('topSide__r').style.display = 'block';
					document.getElementById('bottomSide__r').style.display = 'block';
				}
				document.getElementById('bubble').style.left = (findPos(this).x + this.oX) + "px";
				document.getElementById('bubble').style.top = (findPos(this).y + this.oY) + "px";
				document.getElementById('bubble').style.display = 'block';
			}
			bubbleArr[i].onmouseout = function()
			{
				document.getElementById('bubble').style.display = 'none';
				document.getElementById(this.getAttribute("bubbleKind")).style.display = 'none';
			}
		}
	}
}