function setVis(layerName, visMode){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  layerObj.visibility = visMode;
 }
 else if (isIE4 || isIE5 || isNS6) {
  layerObj.style.visibility = visMode;
 }
}

function getVis(layerName){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  return layerObj.visibility;
 }
 else if (isIE4 || isIE5 || isNS6) {
  return layerObj.style.visibility;
 }
}

function setLeft(layerName, leftPos){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  layerObj.left = leftPos;
 }
 else if (isIE4) {
  layerObj.style.pixelLeft = leftPos;
 }
 else if (isIE5 || isNS6) {
  layerObj.style.left = leftPos+"px";
 }
}

function setZIndex(layerName, z){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  layerObj.zIndex = z;
 }
 else if (isIE4 || isIE5 || isNS6) {
  layerObj.style.zIndex = z;
 }
}

function getLeft(layerName){
 var leftPos,layerObj;
 // WARNING : in many cases these values are blank unless explicitly set using javascript
 layerObj=getLayer(layerName);
 if (isNS4){
  leftPos = layerObj.left;
 } else if (isIE4) {
  leftPos = layerObj.style.pixelLeft;
 } else if (isIE5 || isNS6) {
  leftPos = layerObj.offsetLeft;  
 } /*else if (isNS6) {
  leftPos = layerObj.style.left
 }*/
 return parseInt(leftPos);
}

function setTop(layerName, topPos){
var layerObj;
layerObj=getLayer(layerName);
 if (isNS4){
  layerObj.top = topPos;
 }
 else if (isIE4) {
  layerObj.style.pixelTop = topPos;
 }
 else if (isIE5 || isNS6) {
  layerObj.style.top = topPos+"px";
 }
}

function getTop(layerName){
 var topPos,layerObj;
  // WARNING : in many cases these values are blank unless explicitly set using javascript
 layerObj=getLayer(layerName);
 if (isNS4){
  topPos=layerObj.top;
 } else if (isIE4) {
  topPos=layerObj.style.pixelTop;
 } else if (isIE5 || isNS6) {
  topPos=layerObj.offsetTop;
 }/* else if (isNS6) {
  topPos=layerObj.style.top.replace('px', '');
 }*/
 return parseInt(topPos);
}

function getLayerHeight(layerName){
 var theHeight,layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  theHeight = layerObj.clip.height;
 }
 else if (isIE4 || isIE5 || isNS6) {
  theHeight = layerObj.offsetHeight;
 }
 return theHeight;
}

function getLayerWidth (layerName){
 var theWidth,layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  theWidth = layerObj.clip.width;
 }
 else if (isIE4 || isIE5 || isNS6) {
  theWidth = layerObj.offsetWidth;
 }
 return theWidth;
}

function setLeftTopVis(layerName, leftPos, topPos, visMode){
 setLeft(layerName, leftPos);
 setTop(layerName, topPos);
 setVis(layerName, visMode);
}

function findNSLayer(layersObj,layerName) {
 var theLayer,undefined,layerObj;
 theLayer = eval('layersObj.'+layerName);
 if (theLayer==undefined) {
  for (layerObj in layersObj) {
   if ((theLayer==undefined) && (layerObj!='length')) {
    theLayer=findNSLayer(layersObj[layerObj].layers,layerName)
   } 
  } 
 }
 return theLayer;
}


function getLayer(layerName){
 var theLayer;
 if (layerName.indexOf('document')>=0) {
  theLayer=eval(layerName)
 } else {
  if (isNS4) {
   // search for layer, assumes no duplicate layer names
   theLayer=findNSLayer(document.layers,layerName);
  } else if (isIE4) {
   theLayer=eval('document.all.'+layerName)
  } else if (isIE5 || isNS6) {
   theLayer=document.getElementById(layerName);
  }
 }
 return theLayer;
}

function setHeight(layerName, newHeight){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  //eval('document.layers.'+layerName).clip.height=newHeight;
  layerObj.resizeTo(getLayerWidth (layerName),newHeight);
 }
 else if (isIE4) {
  layerObj.style.pixelHeight=newHeight;
 }
 else if (isIE5 || isNS6) {
  layerObj.style.height=newHeight
 }
}

function setWidth(layerName, newWidth){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  layerObj.resizeTo(newWidth,getLayerHeight(layerName));
  //layerObj.clip.width=newWidth;
 }
 else if (isIE4) {
  layerObj.style.pixelWidth=newWidth;
 }
 else if (isIE5 || isNS6) {
  layerObj.style.width=newWidth
 }
}

function setContents(layerName, newContents){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  layerObj.document.writeln(newContents);
  layerObj.document.close();
 }
 else if (isIE4 || isIE5 || isNS6) {
  layerObj.innerHTML=newContents;
 } 
}

/* Strictly speaking all the old functions should now use these new ones but I'm not confident of how cross-browser they are */
function setStyleProperty(layerName, property, value){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  eval('layerObj.'+property+' = value');
 }
 else if (isIE4 || isIE5 || isNS6) {
  eval('layerObj.style.'+property+' = value');
 }
}

function getStyleProperty(layerName, property){
 var layerObj;
 layerObj=getLayer(layerName);
 if (isNS4){
  return eval('layerObj.'+property);
 }
 else if (isIE4 || isIE5 || isNS6) {
  return eval('layerObj.style.'+property);
 }
}

