/** locate the aligned document and highlight the link */
function performlink(name)
{
    var fi = getOtherFrameIndex();
    var obj,destObj,scrollY;
    var destWindow = window.parent.frames[fi].window;
    if ( navigator.appName != "Microsoft Internet Explorer" )
    {
        destObj = window.parent.frames[fi].window.document.anchors[name];
        obj = window.document.anchors[name];
        scrollY = window.scrollY;
    }
    else
    {
    	destObj = window.parent.frames[fi].window.document.all[name];
        obj = window.document.all[name];
        scrollY = document.body.scrollTop;
    }
    var scrollPos = destObj.offsetTop-(obj.offsetTop-scrollY);
    scrollPos = (scrollPos<0)?0:scrollPos;
    destWindow.scrollTo( 0, scrollPos );
    setHighlight( destObj, destWindow );
}
function setHighlight( destObj, destWindow )
{
    clearselection(destWindow);
    var spans = destObj.getElementsByTagName("span");
    if ( navigator.appName != "Microsoft Internet Explorer" )
    {
        destWindow.document.anchors[destObj.name].style.backgroundColor = "darkblue";
        destWindow.document.anchors[destObj.name].style.color="white";
    }
    else
    {
        destWindow.document.all[destObj.name].style.backgroundColor = "darkblue";
        destWindow.document.all[destObj.name].style.color="white";
    }
    for ( var i=0;i<spans.length;i++ )
    {
	    spans[i].style.color = "white";
    }
    destWindow.document.selectedanchor = destObj.name;
}
/* calculate the index of the frame */
function getOtherFrameIndex()
{
    var index = 0;
    for ( i=0;i<window.parent.frames.length;i++ )
    {
        if ( window.parent.frames[i].name == window.name )
        {
            index = i;
            break;
        }
    }
    return ( index == 1 ) ? 2 : 1;
}
/* clear the selected anchor in THIS document */
function clearselection(win)
{
    if (win.document.selectedanchor!=undefined)
    {
        var name = win.document.selectedanchor;
        if ( navigator.appName != "Microsoft Internet Explorer" )
	    anchor = win.document.anchors[name];
	else
	    anchor = win.document.all[name];
        var origAnchorBgColor = anchor.style.backgroundColor;
	anchor.style.backgroundColor = document.bgColor;
        anchor.style.color = "black";
        win.document.selectedanchor = undefined;
        var spans = anchor.getElementsByTagName("span");
	for ( var i=0;i<spans.length;i++ )
	{
            if ( document.spansColoured == undefined )
                spans[i].style.color = "black";
        }
    }
}
function clearselectionhere()
{
    clearselection(window);
}

