// This script's main function allows to change the text in a DIV section and
// works for Netscape and IE (supposedly). Copied from a newsgroup.
var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;
var isBusy = false;

if (document.getElementById)
{
   isID = 1;
   isDHTML = 1;
}
else
{
    browserVersion = parseInt(navigator.appVersion);
    if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4))
    {
        isLayers = 1;
        isDHTML = 1;
    }
    else
    {
        if (document.all)
        {
            isAll = 1;
            isDHTML = 1;
        }
    }
}

function getObjNN4(obj, name)
{
    var x = obj.layers;

    for (var i = 0; i < x.length; i++)
    {
        if (x[i].id == name)
        {
            return x[i];
        }
        else if (x[i].layers.length)
        {
            var tmp = getObjNN4(x[i],name);
            if (tmp) return tmp;
        }
    }
    return null;
}

function findDOM(objectID, withStyle)
{
    if (withStyle == 1)
    {
        if (isID)
        {
            return (document.getElementById(objectID).style);
        }
        else
        {
            if (isAll)
            {
                return (document.all[objectID].style);
            }
            else
            {
                return getObjNN4(top.document,objectID);
            }
        }
    }
    else
    {
        if (isID)
        {
            return (document.getElementById(objectID));
        }
        else
        {
            if (isAll)
            {
                return (document.all[objectID]);
            }
            else
            {
                if (isLayers)
                {
                    return getObjNN4(top.document, objectID);
                }
            }
        }
    }
}

function changeText(id, text)
{
    // first we get a reference to the layer we want
    // to modify
    x = findDOM(id, 0);

    if (!x)
    {
        return;
    }
    if (isLayers)
    {
        // NS4 only allows you to have one output stream open at a time
        // so if we are already writing to one we will try this again in 250 ms.
        if (isBusy)
        {
            setTimeout("changeText( '" + id + "', '" + text + "' )", 250);
        }
        else
        {
            isBusy = true;

            // write does open for us
            x.document.write(text);
            x.document.close();
            isBusy = false;
        }
    }
    else
    {
        x.innerHTML = text;
    }
}


