function kbRemoveFormatting(el_pv)
{
	for (var i = 0; i < el_pv.childNodes.length; i++)
	{
		var curEl = el_pv.childNodes[i];
		
		if (curEl.nodeName.substr(0, 1) != "#")
		{
			// Because of the way that KC nests lists, we don't want
			// to remove the style from list items.
			if (curEl.nodeName.toLowerCase() != "li")
			{
				curEl.removeAttribute("style", 0);
			}
			kbRemoveFormatting(curEl);
			if (curEl.nodeName.toLowerCase() == "font")
			{
				var newEl = document.createElement("span");
				for (var j = 0; j < curEl.childNodes.length; j++)
				{
					newEl.appendChild(curEl.childNodes[j].cloneNode(true));
				}
				el_pv.replaceChild(newEl, curEl);
			}
		}
	}
}
function fixKbLinks( )
{
	var kbMainBody = document.getElementById("kbMainBody");
	if (kbMainBody != null)
	{
		kbRemoveFormatting(kbMainBody);
	}
	var idx = 0;
	////////////////////
	// The typical pattern for a primus link is "primus://:xxx", where xxx is the
	// solution ID.  Obviously this is not a recognized protocol by most browsers.
	var primusLinkPattern = /primus:\/\/:([\d\w]+)/;

	// Pattern for non-breaking spaces
	var spacePattern = /&nbsp;/gi;

	for (var i = 0; i < document.links.length; i++)
	{
		idx = document.links[i].href.indexOf("/attachments/");
		if (idx >= 0)
		{
			// This is an attachments link.  Point it to the local attachments directory.
			document.links[i].href = "/answers/attachments/" + document.links[i].href.substr(idx + 13);
		}
		else if (primusLinkPattern.test(document.links[i].href))
		{
			// This is a Primus link.  See above.
			var lnkVals = primusLinkPattern.exec(document.links[i].href);
			document.links[i].href = "/answers/documentDisplay.do?docProp=%24solution_id&docPropValue=" + lnkVals[1] +
				"&directSolutionLink=1&docType=1006&clusterName=DefaultCluster&resultType=5002&groupId=1&lang=english";
		}
		// Get rid of non-breaking spaces.
		if (document.links[i].innerHTML)
		{
			document.links[i].innerHTML = document.links[i].innerHTML.replace(spacePattern, " ");
		}
	}
	// Now for the images.
	for (var i = 0; i < document.images.length; i++)
	{
		idx = document.images[i].src.indexOf("/attachments/");
		if (idx >= 0)
		{
			document.images[i].src = "/answers/attachments/" + document.images[i].src.substr(idx + 13);
		}
	}
}
if (window.addEventListener)
{
	window.addEventListener("load", fixKbLinks, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", fixKbLinks);
}
document.write("<script type=\"text/javascript\" src=\"/javascript/jquery-1.2.6.js\"></script>");