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);
}

