/******************************************************************************
* dhtmllib.js                                                                 *
*                                                                             *
* Copyright 1999 by Mike Hall.                                                *
* Web address: http://www.brainjar.com                                        *
* Last update: November 30, 1999.                                             *
*                                                                             *
* Provides basic functions for DHTML positioned elements which will work on   *
* both Netscape Communicator and Internet Explorer browsers (version 4.0 and  *
* up).                                                                        *
******************************************************************************/

// Determine browser.

var isMinIE4 = 0;
var isMinIE5 = 0;
var isMinNS4 = 0;
var isMinNS6 = 0;

if (document.all) {
  isMinIE4 = 1;
  isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;
//alert("browser = Explorer");
}
else if (document.layers) {
  isMinNS4 = 1;
//alert("browser = Netscape 4");
}
else if (document.getElementById) {
  isMinNS6 = 1 ;
//alert("browser = Netscape 6 or 7");
}


/*
// Example tests that could be applied
N   = (document.layers) ? true:false;                 // netscape 4
I   = (document.all) ? true:false;                    // ie4+
DOM = ((document.getElementById)&&(!I))?true:false;   // ns6 etc.
*/



//-----------------------------------------------------------------------------
// Layer visibility.
//-----------------------------------------------------------------------------

function hideLayer(layer) {

  if (isMinNS4)
    layer.visibility = "hide";
  else if (isMinNS6)
    document.getElementById(layer).style.visibility = "hidden";
  else if (isMinIE4)
    layer.style.visibility = "hidden";
}

function showLayer(layer) {

  if (isMinNS4)
    layer.visibility = "show";
  else if (isMinNS6) {
    var elm = document.getElementById(layer);
    elm.style.visibility = "";
  } else if (isMinIE4)
    layer.style.visibility = "visible";
}

function isVisible(layer) {

  if (isMinNS4 && layer.visibility == "show")
    return(true);
  else if (isMinNS6 && layer.style.visibility == "visible")
    return(true);
  else if (isMinIE4 && layer.style.visibility == "visible")
    return(true);

  return(false);
}


//-----------------------------------------------------------------------------
// Layer utilities.
//-----------------------------------------------------------------------------

function getLayer(name) {

  if (isMinNS4) {
    return findLayer(name, document);
  } 
  if (isMinNS6) {
    return name;
  }
  if (isMinIE4) {
    return eval('document.all.' + name);
  }

  return null;
}


//-----------------------------------------------------------------------------
// Window and page properties.
//-----------------------------------------------------------------------------

function getWindowWidth() {

  if (isMinNS4 || isMinNS6)
    return(window.innerWidth);
  if (isMinIE4)
    return(document.body.clientWidth);
  return(-1);
}
