//	Filename:	hotips.js
//	Author:		Ming-Cheng Hsu <noty@wildlook.com / noty@webmaster.com.tw>
//	Created on:	11/07/2000
//	Last Modified:	11/15/2000 - NC support
//
//	Note: this script 'must be' call from the BODY section.

// Initiation
var	_ua = document.all ? "ie" : (document.layers ? "nc" : "foo");

if (_ua != "foo") {
	if (typeof(_doc) == "undefined" || _doc == null) _doc = document;
	var	_tip;
	var	_tipx;
	var	_tipy;
	var	_tipOX = 10;
	var	_tipOY = 10;
	var	_tipWidth;
	if (_ua == "nc") {
		_tip = document.layers["NCTIP_"];
		_doc.captureEvents(Event.MOUSEMOVE);
	} else if (_doc.all['_IETIP_'] == null) {
		_doc.write('<DIV ID="_IETIP_" STYLE="position:absolute;visibility:hidden;z-index:100"></DIV>');
		_tip = _doc.all['_IETIP_'].style;
	}
	_doc.onmousemove = mMov_;
}

// main functions
function tips(sMsg, sTitle, iWidth, iBorder, sTFC, sTBC, sMFC, sMBC, sBRC, sSBC, iSOX, iSOY, sAlpha) {
	if (_ua == "foo" || _tip == null) return;
	_tipWidth = (iWidth != null) ? iWidth : 200;	// global
	_tipBorder = (iBorder != null) ? iBorder : 1;	// border width
	_tipTFC = (sTFC != null) ? sTFC : "white";	// title fg color
	_tipTBC = (sTBC != null) ? sTBC : "darkgreen";	// title bg color
	_tipMFC = (sMFC != null) ? sMFC : "black";	// msg fg color
	_tipMBC = (sMBC != null) ? sMBC : "#eeeeee";	// msg bg color
	_tipBRC = (sBRC != null) ? sBRC : _tipTBC;	// border color
	_tipSBC = (sSBC != null && sSBC != true) ? sSBC : "darkslategray";	// shadow color
	_tipSOX = (iSOX != null) ? iSOX : 5;		// shadow offset X
	_tipSOY = (iSOY != null) ? iSOY : 5;		// shadow offset Y
	// Alpha properties
	_tipAlpha = (sAlpha == null || _ua == "nc") ? "" : ((sAlpha != true) ? (";filter:alpha("+sAlpha+")") : (";filter:alpha(opacity=85,finishopacity=65,startx=0,starty=0,finishx=100,finishy=100,style=1))"));

	tmp  = '<TABLE CELLPADDING="'+_tipBorder+'" CELLSPACING="0" WIDTH="'+_tipWidth+'" BORDER="0" BGCOLOR="'+_tipBRC+'" STYLE="position:absolute;top:0;left:0;z-index:102'+_tipAlpha+'"><TR><TD STYLE="padding-top:2pt">';
	tmp += ((sTitle != null) ? '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="'+_tipWidth+'" BGCOLOR="'+_tipTBC+'" BORDER="0"><TR><TD align=center height=12><FONT STYLE="font:8pt Verdana,Tahoma;color:'+_tipTFC+'">'+sTitle+'</FONT></TD></TR></TABLE>' : '');
	tmp += '<TABLE CELLPADDING="2" CELLSPACING="0" WIDTH="'+_tipWidth+'" BORDER="0" BGCOLOR="'+_tipMBC+'"><TR><TD align=center><FONT STYLE="color:'+_tipMFC+';font:normal 8pt Arial,Verdana,Tahoma">'+sMsg+'</FONT></TD></TR></TABLE></TD></TR></TABLE>';
	tmp += ((sSBC != null && _ua == "ie") ? ('<TABLE CELLPADDING="'+_tipBorder+'" CELLSPACING="0" WIDTH="'+_tipWidth+'" BORDER="0" BGCOLOR="'+_tipSBC+'" STYLE="position:absolute;top:'+_tipSOY+'px;left:'+_tipSOX+'px;z-index:101'+_tipAlpha+'"><TR><TD>' + ((sTitle != null) ? '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0"><TR><TD STYLE="font:bold 8pt Verdana,Tahoma;color:'+_tipSBC+'">'+sTitle+'</TD></TR></TABLE>' : '') + '<TABLE CELLPADDING="2" CELLSPACING="0" WIDTH="100%" BORDER="0" BGCOLOR="'+_tipSBC+'"><TR><TD STYLE="color:'+_tipSBC+';font:normal 8pt Verdana,Tahoma">'+sMsg+'</TD></TR></TABLE></TD></TR></TABLE>') : '');

	if (_ua == "nc") {
		_tip.document.write(tmp);
		_tip.document.close();
		mMov_();
		_tip.visibility = "show";
	} else {
		_doc.all['_IETIP_'].innerHTML = tmp;
		mMov_();
		_tip.visibility = "visible";
	}
}

function stip() {
	if (_ua == "foo" || _tip == null) return;
	_tip.visibility = (_ua == "nc") ? "hide" : "hidden";
}

// sub functions
function mMov_(ev) {
	if (_ua == "foo" || _tip == null) return;
	if (_ua == "ie") {
		_tipx = (event.clientX + _tipOX + _tipWidth <= _doc.body.clientWidth) ? (event.clientX + _doc.body.scrollLeft + _tipOX) : (event.clientX + _doc.body.scrollLeft - _tipWidth - 8);
		_tipy = event.clientY + _doc.body.scrollTop + _tipOY;
		tipMov_();
	} else if (_ua == "nc" && _tip.visibility == "show") {
		_tipx = ev.pageX + _tipOX;
		_tipy = ev.pageY + _tipOY;
		tipMov_();
	}

}

function tipMov_() {
	if (_ua == "foo" || _tip == null) return;
	if (_ua == "ie") {
		_tip.pixelLeft = _tipx;
		_tip.pixelTop = _tipy;
	} else if (_ua == "nc") {
		_tip.left = _tipx;
		_tip.top = _tipy;
	}
}
