var hState = 0;

function getElementsByClassName(oElm, strTagName, strClassName)
{
	var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++)
	{
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className))
		{
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function switchHighlight()
{
	if(hState == 0)
	{
		highlight();
		highlightForm.highlightButton.value = "Turn Off Highlight";
		hState = 1;
	} else
	{
		unhighlight();
		highlightForm.highlightButton.value = "Turn On Highlight";
		hState = 0;
	}
}

function highlight()
{
	redSpans = getElementsByClassName(document, "span", "Red");
	yellowSpans = getElementsByClassName(document, "span", "Yellow");
	greenSpans = getElementsByClassName(document, "span", "Green");
	for (i=0; i<redSpans.length; i++)
	{
		redSpans[i].style.backgroundColor = "#FFB2B2";
	}
	for (i=0; i<yellowSpans.length; i++)
	{
		yellowSpans[i].style.backgroundColor = "#FFFF90";
	}
	for (i=0; i<greenSpans.length; i++)
	{
		greenSpans[i].style.backgroundColor = "#B2FFB2";
	}
}

function unhighlight()
{
	redSpans = getElementsByClassName(document, "span", "Red");
	yellowSpans = getElementsByClassName(document, "span", "Yellow");
	greenSpans = getElementsByClassName(document, "span", "Green");
	for (i=0; i<redSpans.length; i++)
	{
		redSpans[i].style.backgroundColor = "transparent";
	}
	for (i=0; i<yellowSpans.length; i++)
	{
		yellowSpans[i].style.backgroundColor = "transparent";
	}
	for (i=0; i<greenSpans.length; i++)
	{
		greenSpans[i].style.backgroundColor = "transparent";
	}

}
