/* //:::::::::::   POPUP TIP   :::::::::::\\
                 by Micah Goulart

	This script can be used as long as this
	disclaimer is left untouched.
	For bug reports or custom scripts, email me at:
	micahgoulart@mailbr.com.br
	
	IMPORTANT ::
		This script requires the dynlayer.js source file.
		Download it at members.xoom.com/micahgoulart/dhtml
		
	LAST UPDATE :: 26.11.1999
	
   //:::::::::::   copyright 1999   :::::::::::\\ */
	
function popUpTip()
{	var arg = arguments
	
	this.w = arg[0]
		
	this.ID = this.cssID = "popUpTip" + (popUpTip.count++)
	this.ref = this.ID + "Ref"
	eval(this.ref + " = this")
	
	this.border = 2
	this.borderColor = "Gray"
	this.captionBgColor = "Gray"
	this.textBgColor = "DodgerBlue"
	
	this.align = "right"
	this.checkAlignment = true
	
	this.isHidden = true
	this.isStick = false
	
	this.offsetX = 15
	this.offsetY = 15	}

x = false
popUpTip.count = 0
popUpTip.current = null

popUpTip.prototype.build = popUpTipBuild
popUpTip.prototype.activate = popUpTipActivate
popUpTip.prototype.show = popUpTipShow
popUpTip.prototype.hide = popUpTipHide
popUpTip.prototype.check = popUpTipCheck
popUpTip.prototype.stick = popUpTipStick



function popUpTipBuild()
{	this.css = css(this.ID, -this.w, -500, this.w, 300, null, "hidden")
	
	this.div = "\n<DIV ID=" + this.ID + ">&nbsp;</DIV>\n"
	writeCSS(this.css)	}
	
function popUpTipActivate()
{	this.obj = new DynLayer(this.ID)

	popUpTip.current = this
	
	popUpTip.avWidth = (is.ns) ? self.innerWidth : document.body.clientWidth;	}


function _startMouseTrack()
{	if (is.ns) document.captureEvents(Event.MOUSEMOVE || Event.MOUSEUP)
	document.onmousemove = mouseMove;
	document.onmouseup = mouseUp;		}
	
function _stopMouseTrack()
{	if (is.ns) document.releaseEvents(Event.MOUSEMOVE || Event.MOUSEUP);
	document.onmousemove = new Function ("return true");	}
	


//::::::::::: hides the PopUp tip box after if stick is true :::::::::::\\
function mouseUp()
{	for (var i = 0; i < popUpTip.count; i++)
	{	var which = eval("popUpTip" + i + "Ref")
		if (which.isStick) which.hide(1) }
			}

//::::::::::: tracks the mouseMove and positions the popUp Tip :::::::::::\\
function mouseMove(e)
{	x = (is.ns) ? e.layerX : event.x + document.body.scrollLeft
	y = (is.ns) ? e.layerY : event.y + document.body.scrollTop
	
	if (!popUpTip.current.isStick)
		popUpTip.current.check()

	if (popUpTip.current.align == "left") xPos = x - popUpTip.current.w
	if (popUpTip.current.align == "center")
		xPos = x - (popUpTip.current.w/2) + (popUpTip.current.offsetX/2)
	if (popUpTip.current.align == "right") xPos = x + popUpTip.current.offsetX
	
	if (!popUpTip.current.isStick)
		popUpTip.current.obj.moveTo(xPos, y + popUpTip.current.offsetY)
		
			}


//::::::::::: builds the PopUp Tip then shows it :::::::::::\\
function popUpTipShow(caption, text)
{	popUpTip.current = this	

	_startMouseTrack()

	if (is.ie && this.isHidden) mouseMove()

	this.check()
	
	str = 
		"<TABLE BORDER=0 CELLSPACING="+this.border+" CELLPADDING=0 WIDTH="+this.w+ 
			" BGCOLOR='"+this.borderColor+"'>" +
		"<TR>" +
			"<TD BGCOLOR='"+this.captionBgColor+"'>" +
				"<DIV CLASS="+this.cssID+"Caption>"+caption+"</DIV></TD>" +
		"</TR>";

	if (text)
	str +=
		"<TR>" +
			"<TD BGCOLOR='"+this.textBgColor+"'>" +
				"<DIV CLASS="+this.cssID+"Text>"+text+"</DIV></TD>" +
		"</TR>"
	
	str += "</TABLE>"
	
	this.obj.write(str)
	
	this.obj.show()
	this.isHidden = this.isStick = false	 }
	

//::::::::::: hides PopUp Tip :::::::::::\\
function popUpTipHide(toggle)
{	if (!this.isStick || toggle) this.obj.hide()	
	_stopMouseTrack()
	this.isHidden = true
	if (toggle)
		this.isStick = false	}


//::::::::::: sticks the PopUp Tip :::::::::::\\
function popUpTipStick(caption, text)
{	if (caption) this.show(caption, text)
	this.isStick = true; }


//::::::::::: checks the PopUp's position :::::::::::\\
function popUpTipCheck()
{	if (!this.checkAlignment || !x) return;

	var _totalWidth = popUpTip.avWidth - this.offsetX;
	
	var _align = this.align
	
	if (_align == "left" && x < this.w) _align = "center"
	if (_align == "center" && x < this.w/2) _align = "right"
	if (_align == "center" && x > (_totalWidth-20) - (this.w/2)) _align = "left"
	if (_align == "right" && x > (_totalWidth-20) - this.w) _align = "center"
	this.align = _align	}

