var browserKind = "unknown";
if (document.all) {       
  browserKind = "IE4";
  if (navigator.userAgent.indexOf("Opera")!=-1) { browserKind = "W3C"; }
}
else if (document.getElementById) { browserKind = "W3C"; }
else if (document.layers) { browserKind = "NS4"; }

function getObj(name) {
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
	  this.style = document.getElementById(name).style;
  }
  else if (document.all) {
  	this.obj = document.all[name];
  	this.style = document.all[name].style;
  }
  else if (document.layers) {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function getLayer(which) { 
  switch(browserKind) {  
    case "IE4":
        return document.all[which];
        break;
    case "W3C":
        return document.getElementById(which);
        break;
    case "NS4":
        return document.layers[which];
        break;
  }
}

function hideLayer(which) {  // approved
  switch(browserKind) {
    case "IE4":
        document.all[which].style.visibility = "hidden";
        break;
    case "W3C":
        document.getElementById(which).style.visibility = "hidden";
        break;
    case "NS4":
       document.layers[which].visibility = "hide";
        break;
  }
}

function showLayer(which) {  // approved
  switch(browserKind) {
    case "IE4":
        document.all[which].style.visibility = "visible";
        break;
    case "W3C":
        document.getElementById(which).style.visibility = "visible";
        break;
    case "NS4":
        document.layers[which].visibility = "show";
        break;
  } 
}      

function isLayerVisible(which) {
  res = false; 
  switch(browserKind) {
    case "IE4":
        if (document.all[which].style.visibility == "visible") res = true;
        break;
    case "W3C":
        if (document.getElementById(which).style.visibility == "visible") res = true;
        break;
    case "NS4":
        if (document.layers[which].visibility == "show") res = true;;
        break;
  } 
  return res;
} 

function resizeLayer(which,width,height) {
  setLayerWidth(which, width);
  setLayerHeight(which, height);
}

function setLayerWidth(which, width) {
  switch(browserKind) {
    case "IE4":
        document.all[which].style.width = width + "px";
        break;
    case "W3C":
        document.getElementById(which).style.width = width + "px";
        break;
    case "NS4":
        document.layers[which].width = width + "px";
        break;
  } 
}

function setLayerHeight(which, height) { 
  switch(browserKind) {
    case "IE4":
        document.all[which].style.height = height + "px";
        break;
    case "W3C":
        document.getElementById(which).style.height = height + "px";
        break;
    case "NS4":
        document.layers[which].height = height + "px";
        break;
  }
}

function getLayerWidth(which) {
  switch(browserKind) {
    case "IE4":
        return document.all[which].style.width;
        break;
    case "W3C":
        return document.getElementById(which).style.width;
        break;
    case "NS4":
        return document.layers[which].width;
        break;
  }
}

function getLayerHeight(which) {
  if (document.getElementById(which).offsetHeight != "undefined") {
    return document.getElementById(which).offsetHeight;
  }
}

function moveLayerTo(which, left, top) {
  switch(browserKind) {
    case "IE4":
        document.all[which].style.left = left + "px";
        document.all[which].style.top = top + "px";
        break;
    case "W3C":
        document.getElementById(which).style.left = left + "px";
        document.getElementById(which).style.top = top + "px";
        break;
    case "NS4":
        document.layers[which].left = left + "px";
        document.layers[which].top = top + "px";
        break;
  } 
}

function writeIntoLayer(which, what) {
   switch(browserKind) {
    case "IE4":
        x = document.all[which];
        x.innerHTML = what;
        break;
    case "W3C":
        x = document.getElementById(which);
        x.innerHTML = '';
        x.innerHTML = what;
        break;
    case "NS4":
        x = document.layers[which];
        x.document.open();
        x.document.write(what);
        x.document.close();
        break;
  }
}

function switchImageState(imgObject,newStateObject) {
  imgObject.src = newStateObject.src; 
}

var blinkTimeout;
var blinkState = true;

function blink(what) {
  window.clearTimeout(blinkTimeout);
  /*
  if (isLayerVisble(what)) { hideLayer(what); }
  else { showLayer(what); }
  */
  var o = new getObj(what);
  if (blinkState) {
    o.style.color = "#006600";
  }
  else {
    o.style.color = "#AFE0B3";
  }
  blinkState = !blinkState;
  blinkTimeout= window.setTimeout("blink('"+what+"')",400);
}


function getDocHeight() {
  var D = document;
  res = Math.max(
      Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
      Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
      Math.max(D.body.clientHeight, D.documentElement.clientHeight)
  );
  if (res == 0) res = 350;
  return res;
}

function getDocWidth() {
  var D = document;
  return Math.max(
      Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
      Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
      Math.max(D.body.clientWidth, D.documentElement.clientWidth)
  );
}

function getScrollY() {
  var scrOfX = 0, scrOfY = 0;

  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY;
}

function getViewportHeight() {
  // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
  if (typeof window.innerWidth != 'undefined') {
    viewportheight = window.innerHeight;
  }
  // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
    viewportheight = document.documentElement.clientHeight;
  }
  // older versions of IE
  else {
    viewportheight = document.getElementsByTagName('body')[0].clientHeight;
  }
  return viewportheight;
}

function getViewportWidth() {
  // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
  if (typeof window.innerWidth != 'undefined') {
    viewportwidth = window.innerWidth - getScrollerWidth();
  }
  // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
    viewportwidth = document.documentElement.clientWidth;
  }
  // older versions of IE
  else {
    viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
  }
  return viewportwidth;
}

function getScrollerWidth() {
  var scr = null;
  var inn = null;
  var wNoScroll = 0;
  var wScroll = 0;

  // Outer scrolling div
  scr = document.createElement('div');
  scr.style.position = 'absolute';
  scr.style.top = '-1000px';
  scr.style.left = '-1000px';
  scr.style.width = '100px';
  scr.style.height = '50px';
  // Start with no scrollbar
  scr.style.overflow = 'hidden';

  // Inner content div
  inn = document.createElement('div');
  inn.style.width = '100%';
  inn.style.height = '200px';

  // Put the inner div in the scrolling div
  scr.appendChild(inn);
  // Append the scrolling div to the doc
  document.body.appendChild(scr);

  // Width of the inner div sans scrollbar
  wNoScroll = inn.offsetWidth;
  // Add the scrollbar
  scr.style.overflow = 'auto';
  // Width of the inner div width scrollbar
  wScroll = inn.offsetWidth;

  // Remove the scrolling div from the doc
  document.body.removeChild(
      document.body.lastChild);

  // Pixel width of the scroller
  return (wNoScroll - wScroll);
  }

