/*
| -------------------------------------------------------
| Author	: Feng Wu, http://come.to/feng, feng@ustc.edu
| -------------------------------------------------------
| Created	: 10/18/01
| Last Mod	: 2/15/2002 5:00PM
| -------------------------------------------------------
| Copyright © Feng Wu, 2001-2002
| -------------------------------------------------------
*/

isIE = isNS = 0
nSupported = 1
if (document.all)
	isIE = 1
else if (document.getElementById)
	isNS = 1
else
	nSupported = 0

var sOverTextColor	= "#FF00FF";
var sOverOffset		= "1px";
var sOutOffset		= "-1px";

// - 1 - border color (index)
function WF_BdColor_doChange(vEventSrc, sColorNew)
{
	vEventSrc.style.borderColor = sColorNew
}

function WF_BdColor(e, nIndex)
{
	if (nSupported)
	{
		var vEventSrc = (isIE) ? event.srcElement : e.target
		var sColor    = vColor[nIndex]
		var sOffset   = (nIndex) ? sOverOffset : sOutOffset

		if (vEventSrc.className == "cell")
			WF_BdColor_doChange(vEventSrc, sColor)
		else
		{
			while(vEventSrc.tagName != "TABLE")
			{
				vEventSrc = (isIE) ? vEventSrc.parentElement : vEventSrc.parentNode
				if (vEventSrc.className == "cell")
				{
					WF_BdColor_doChange(vEventSrc, sColor)

					vEventSrc.style.top      = sOffset;
					vEventSrc.style.left     = sOffset;
					vEventSrc.style.position = "relative";
				}
			}
		}
	}
}

// - 2 - background color (on / off) (! IE only)
function WF_BgColorOn(nIndex)
{
	if (isIE)
	{
		var sColor = vColor[nIndex]

		vEventSrc = event.srcElement
		if (vEventSrc.tagName == "TR" || vEventSrc.tagName == "TABLE")
		{	// nothing
		}
		else
		{
			while(vEventSrc.tagName != "TD")
				vEventSrc = vEventSrc.parentElement
			if (vEventSrc.id != "ignore")
			{
				vEventSrc.style.backgroundColor = sColor
				vEventSrc.style.color    = sOverTextColor;
			}
		}
	}
}

function WF_BgColorOff(nIndex)
{
	if (isIE)
	{
		sColor = vColor[nIndex]

		if (event.fromElement.contains(event.toElement)
//			|| vEventSrc.contains(event.toElement)
			|| vEventSrc.id == "ignore")
		{	// nothing
		}
		else
		{
//			if (event.toElement != vEventSrc)
			{
				vEventSrc.style.backgroundColor = sColor
				vEventSrc.style.color    = sOverTextColor;
			}
		}
	}
}