<body onload="highlightOnLoad();">
<a href="..." onclick="highlightOnClick(href);">
var currentDiv, currentHash, access = document.createElement("_"), shared = document.createTextNode(null);
access.appendChild(shared);
function highlightMessage(newHash, hashTrusted)
{
if (newHash != currentHash)
{
var exclusive;
try
{
access.removeChild(shared);
exclusive = true;
}
catch (exception) { }
if (exclusive)
{
if (currentDiv)
{
currentDiv.className = "msg";
}
var newDiv = document.getElementById(newHash);
if (hashTrusted || newDiv && newDiv.className == "msg")
{
newDiv.className = "msg highlighted";
currentDiv = newDiv;
}
else
{
currentDiv = null;
}
currentHash = newHash;
access.appendChild(shared);
}
}
}
function highlightOnLoad()
{
highlightMessage(location.hash.substr(1));
setTimeout(highlightOnLoad, 1000);
}
function highlightOnClick(newUrl)
{
var newParts = newUrl.split("#");
if (newParts[0] == location.href.split("#")[0])
{
highlightMessage(newParts[1], true);
}
}