// Added by Nimal R. 9/9/2001

var isDOM       = (document.getElementById) ? true : false;
var isNS4       = (document.layers) ? true : false;
var isIE        = (document.all) ? true : false;
var isIE4       = isIE && !isDOM;
var isMac       = (navigator.appVersion.indexOf("Mac") != -1);
var isIE4M      = isIE4 && isMac;
var isOpera     = (navigator.userAgent.indexOf("Opera")!=-1);
var isKonqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);
var isIE5M      = isIE && isMac;
var isIE5W      = isIE && !isMac;
var isNS6       = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
var isIEpos     = isIE || (isNS6 && parseInt(navigator.productSub)>=20010710);
var isIEDTD     = (isIE && document.doctype) ? document.doctype.name.indexOf(".dtd")!=-1 : false;
var isIEnoDTD   = isIE && !isIEDTD;

// Temporary fixes
var isIE5       = isIE && (isIE5W || isIE5M);
//if (isIE5) {
//   isIE4 =1;
//}
// End of temporary fixes

var isMenu = !isOpera && !isKonqueror && !isIE4M && (isDOM || isNS4 || isIE4);
var BrowserString = isNS4 ? "NS4" : isDOM ? "DOM" : "IE4";

/*
if (isDOM) {
  document.write("isDOM ");
}
if (isNS4) {
  document.write("isNS4 ");
}
if (isIE) {
  document.write("isIE ");
}
if (isIE4) {
  document.write("isIE4 ");
}
if (isIE5W) {
  document.write("isIE5W ");
}
if (isIE5) {
  document.write("isIE5 ");
}
if (isNS6) {
  document.write("isNS6 ");
}
if (isOpera) {
  document.write("isOpera ");
}
*/


function hideLayer(layer) {

  if (isNS4)
    layer.visibility = "hidden"; // "hide";
  if (isIE4 || isDOM)
    layer.style.visibility = "hidden";
  /* if (isDOM)
    layer.style.display = "none"; */
}

function hideLayerWithId(id) {
  layer = getLayer(id);
  hideLayer(layer);
}

function showLayer(layer) {

  if (isNS4)
    layer.visibility = "visible"; // "show";
  if (isIE4 || isDOM)
    layer.style.visibility = "visible";
  /* if (isDOM)
    layer.style.display = "none"; */
}

function showLayerWithId(id) {
  layer = getLayer(id);
  showLayer(layer);
}

function moveLayerTo(layer, x, y) {

  if (isNS4)
    layer.moveTo(x, y);
  else if (isIE4) {
    layer.style.left = x;
    layer.style.top  = y;
  }
  else if (isDOM) {
    layer.style.left = x;
    layer.style.top  = y;
  }
}

function clipLayer(layer, clipleft, cliptop, clipright, clipbottom) {
  if (isNS4) {
    layer.clip.left   = clipleft;
    layer.clip.top    = cliptop;
    layer.clip.right  = clipright;
    layer.clip.bottom = clipbottom;
  }
  if (isIE4 || isDOM)
    layer.style.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
}

function getHeight(layer) {

  if (isNS4) {
    if (layer.document.height)
      return(layer.document.height);
    else
      return(layer.clip.bottom - layer.clip.top);
  }
  if (isIE4) {
    if (false && layer.style.pixelHeight)
      return(layer.style.pixelHeight);
    else
      return(layer.clientHeight);
  }
  if (isDOM) {
    if (layer.offsetHeight)
      return(layer.offsetHeight);
    else 
      return(layer.clientHeight - layer.clientHeight); 
  }
  return(-1);
}

function getLayer(name, doc) {

  if (isNS4)
    return findLayer(name, document)
  if (isIE4)
    return eval('document.all.' + name);
  if (isDOM) 
    return eval('document.getElementById\("' + name +'")');

  return null;
}

function findLayer(name, doc) {

  var i, layer;

  for (i = 0; i < doc.layers.length; i++) {
    layer = doc.layers[i];
    if (layer.name == name)
      return layer;
    if (layer.document.layers.length > 0) {
      layer = findLayer(name, layer.document);
      if (layer != null)
        return layer;
    }
  }

  return null;
}

function getWindowWidth() {

  if (isNS4)
    return(window.innerWidth);
  if (isIE4 || isDOM)
    return(document.body.clientWidth);
  return(-1);
}

function getWindowHeight() {

  if (isNS4)
    return(window.innerHeight);
  if (isIE4 || isDOM)
    return(document.body.clientHeight);
  return(-1);
}

function getPageScrollX() {

  if (isNS4)
    return(window.pageXOffset);
  if (isIE4)
    return(document.body.scrollLeft);
  return(-1);
}

function getPageScrollY() {

  if (isNS4)
    return(window.pageYOffset);
  if (isIE4)
    return(document.body.scrollTop);
  return(-1);
}

function getPageWidth() {

  if (isNS4)
    return(document.width);
  if (isIE4)
    return(document.body.scrollWidth);
  return(-1);
}

function getPageHeight() {

  if (isNS4)
    return(document.height);
  if (isIE4)
    return(document.body.scrollHeight);
  return(-1);
}

function setBgColor(layer, color) {
  if (isNS4) layer.bgColor               = color;
  if (isIE4) layer.style.backgroundColor = color;
}

