// Common include file for client side processing of tables and XML
function hiliteRow(theClassName,highlightcolor)
{
	source=event.srcElement
	while(source)
		{
		if(source.tagName =="TR" && source.className == theClassName)
			break;
		source = source.parentElement;
		}
	if(source)
		if (source.style.backgroundColor!=highlightcolor && source.id!="ignore" && source.style.backgroundColor != 'lightgreen') 
			source.style.backgroundColor = highlightcolor;
}

function unHiliteRow(originalcolor)
{
	source.style.backgroundColor=originalcolor
}

function sortOnThisField(theField,flag,sData)
{
	var workCell;
	var theField = delSortImg("../images/App/arrowUp.gif",flag) + theField;
	var xmlData;			//sData is used to remove the hard-coded SData inside the function -RMS//
	if (sData != null && sData != "undefined" && sData != "")
		xmlData = sData;
	else
		xmlData = SData;	
	generalSort.XMLDocument.selectSingleNode("//@order-by").text = theField;
	if (!xmlData.loadXML(xmlData.documentElement.transformNode(generalSort.XMLDocument)))
		xmlData.loadXML("<root></root>");
}

// handle column sorting for our data bound tables
function delSortImg(strSrc,flag)
{
	var theElem = window.event.srcElement;
	if (theElem.tagName.toUpperCase() == "IMG")
		theElem = theElem.parentElement;
	else
		if (theElem.tagName.toUpperCase() == "TD" && theElem.children.length>0)
			theElem = theElem.children[0];
	var theSpan = theElem;
	while (theElem.tagName.toUpperCase() != "TR")
		theElem = theElem.parentElement;
	clearSrtImg(theElem,theSpan);
	if (theSpan.children.length > 0)
		{
		if (theSpan.children[0].style.filter == "")
			{
			theSpan.children[0].style.filter = "flipV";
			return '-';
			}
		else
			{
			theSpan.children[0].style.filter = "";
			return '+';
			}
		}
	else
		{
		if (flag)
			{
			theSpan.innerHTML+='<img id="sort" src="'+strSrc+'" border="0" style="filter:">';
			return '+';
			}
		else
			{
			theSpan.innerHTML+='<img id="sort" src="'+strSrc+'" border="0" style="filter:flipV">';
			return '-';
			}
		}
}

function clearSrtImg(theElem,aElem)
{
	var theImgs = theElem.all.tags("IMG");
	var lng = theImgs.length;
	var j = 0;
	for (i = 0; i < lng; i++)
		{
		if (aElem == theImgs[j].parentElement)
			j++;
		else
			if (theImgs[j].id == 'sort')
				theImgs[j].removeNode();
		}
}

function addSrtImg(strSrc,theElem,theInd,flag)
{
	var theSpans = theElem.all.tags("SPAN");
	if (flag)
		theSpans[theInd].innerHTML += '<img id="sort" src="'+strSrc+'" border="0" style="filter:">';
	else
		theSpans[theInd].innerHTML += '<img id="sort" src="'+strSrc+'" border="0" style="filter:flipV">';
}

function checkErrors(obj)
{
	var errlist = obj.documentElement.selectNodes("//error");
	for(var i = 0; i < errlist.length; i++)
		alert(errlist[i].xml);
}

function setTrBgColor(oTR)
{
	var sBGColor = "white";
	var sBGColor2 = "whitesmoke";
	if (oTR.rowIndex%2 == 1)
		oTR.style.backgroundColor = sBGColor2;
	else
		oTR.style.backgroundColor = sBGColor;
}