function ChangeColor(ctl)
{
	ctl.style.backgroundColor = "#dbffd1";
}

function DefaultColor(ctl)
{
	ctl.style.backgroundColor = "#fff";
}

function getQueryVariable(variable)
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++)
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable)
		{
			return pair[1];
		}
	}
}

function highlightword(node,word)
{
	if (node.hasChildNodes)
	{
		var hi_cn;
		for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++)
		{
			highlightword(node.childNodes[hi_cn],word);
		}
	}
	if (node.nodeType == 3)
	{
		tempNodeVal = node.nodeValue.toLowerCase();
		tempwordVal = word.toLowerCase();
		if (tempNodeVal.indexOf(tempwordVal)!= -1)
		{
			pn = node.parentNode;
			if (pn.className!= "searchword")
			{
				nv = node.nodeValue;
				ni = tempNodeVal.indexOf(tempwordVal);
				before = document.createTextNode(nv.substr(0,ni));
				docwordVal = nv.substr(ni,word.length);
				after = document.createTextNode(nv.substr(ni+word.length));
				hiwordtext = document.createTextNode(docwordVal);
				hiword = document.createElement("span");
				hiword.className = "searchword";
				hiword.appendChild(hiwordtext);
				pn.insertBefore(before,node);
				pn.insertBefore(hiword,node);
				pn.insertBefore(after,node);
				pn.removeChild(node);
			}
		}
	}
}

function Searchhighlight()
{
	if (!document.createElement)
		return;
	var sword = getQueryVariable('q');
	//ref = document.referrer;
	//highlightword(document.getElementsByTagName("body")[0],sword);
	if(sword && sword.length>1)
		highlightword(document.getElementById("searchResult"),sword);
}
