// JavaScript Document


function getRefToDiv(divID) {
    if( document.layers ) { //Netscape layers
        return document.layers[divID]; }
    if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
        return document.getElementById(divID); }
    if( document.all ) { //Proprietary DOM; IE4
        return document.all[divID]; }
    if( document[divID] ) { //Netscape alternative
        return document[divID]; }
    return false;
}


function getRefToDiv(divID,oDoc) {
    if( !oDoc ) { oDoc = document; }
    if( document.layers ) {
        if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
            //repeatedly run through all child layers
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
                //on success, return that layer, else return nothing
                y = getRefToDiv(divID,oDoc.layers[x].document); }
            return y; } }
    if( document.getElementById ) {
        return document.getElementById(divID); }
    if( document.all ) {
        return document.all[divID]; }
    return false;
}


function showDiv(divID_as_a_string) {
    //get a reference as above ...
    var myReference = getRefToDiv(divID_as_a_string);
    if( !myReference ) {
        window.alert('Nothing works in this browser');
        return false; //don't go any further
        //return anything would work,
        //but I am using false to show failure
    }
    //now we have a reference to it
    if( myReference.style ) { //DOM & proprietary DOM
        myReference.style.visibility = 'visible';
    } else {
        if( myReference.visibility ) { //Netscape
            myReference.visibility = 'show';
        } else {
            window.alert('Nothing works in this browser');
            return false; //don't go any further
        }
    }
    return true;
}


function changeDisplay( elementId, setTo ) {
    if( document.getElementById ) {
        //DOM
        var theElement = document.getElementById( elementId );
    } else {
        if( document.all ) {
            //Proprietary DOM
            var theElement = document.all[ elementId ];
        } else {
            //Create an object to prevent errors further on
            var theElement = new Object();
        }
    }
    if( !theElement ) {
        /* The page has not loaded or the browser claims to support
        document.getElementById or document.all but cannot actually
        use either */
        return;
    }
    //Reference the style ...
    if( theElement.style ) { theElement = theElement.style; }
    if( typeof( theElement.display ) == 'undefined' &&
    !( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) {
      //The browser does not allow us to change the display style
      //Alert something sensible (not what I have here ...)
      window.alert( 'Your browser does not support this' );
      return;
    }
    //Change the display style
    theElement.display = setTo;
}


