isNS4 = (document.layers) ? 1 : 0; 
isIE = (document.all) ? 1 : 0;
isW3C = (document.getElementById && !document.all) ? 1 : 0;

function setStyle(objName, property, val) {

   if (isIE) {
         var layer = document.all[objName];
       layer.style[property] = val;
         return;
   }
   if (isW3C) {
         var obj = document.getElementById( objName );
       if (obj != null) {
           var s = obj.style;
           s[ property ] = val;
              return;
         }
          return;
   }
   if (isNav4) {
         document[objName][property] = val;
         return;
   }
}

function getSpecifiedProperty(objName, property) {

    if (isIE) {
         str = eval("document.all."+objName+".currentStyle."+property);
         return str;
    }
}

function getCalculatedProperty(objName, property) {
    // thanks to Ian Grant, http://www.faqts.com/knowledge_base/view.phtml/aid/7157

    if (isW3C) {
       docObj = document.getElementById(objName);
         
       if (property == "visibility") {
             cssp = docObj.style.visibility;
              return (cssp == "") ? "inherit" : cssp;
         }

         if (property == "clip") {
             cssp = docObj.style.clip;

                if (cssp == "") {
                   cssStr = "rect(0px "; 
                    cssStr += getCalculatedProperty(objName, "width") + " ";
                   cssStr += getCalculatedProperty(objName, "height") + " ";
                   cssStr += "0px)";
                   return cssStr;
             }
             return cssp;
         }

         if (property == "zIndex") {
             cssp = docObj.style.zIndex;
             return (cssp == "") ? "inherit" : cssp;
         }

         cssp = document.defaultView.getComputedStyle(docObj, "").getPropertyValue(property);

         return (cssp == "") ? "unknown" : cssp;
   }

   // ***** Netscape Navigator 4+ DOM *****

   if (isNS4) {
         docObj = document.layers[objName];

         if (property == "visibility") {
             cssp = docObj.visibility;
             return (cssp == "hide") ? "hidden" : (cssp == "show") ? "visible" : "inherit";
         }
         if (property == "clip") {
                 cssStr = "rect(" + docObj.clip.top + "px ";
             cssStr += docObj.clip.right + "px ";
             cssStr += docObj.clip.bottom + "px ";
             cssStr += docObj.clip.left + "px)";
             return cssStr;
         }
         if ((property == "width") || (property == "height")) {
                  return eval("docObj.clip." + property) + "px";
         }
         if (property == "top") property = "pageY";
         if (property == "left") property = "pageX";
         
         cssp = eval("docObj." + property);
         if (property != "zIndex") cssp += "px";
         return cssp;
   }

   // ***** Internet Explorer 4+ DOM *****

   if (isIE) {
         if (property == "width") return eval(objName + ".offsetWidth");
         if (property == "height") return eval(objName + ".offsetHeight");
         if (property == "top") return eval(objName + ".offsetTop");
         if (property == "left") return eval(objName + ".offsetLeft");
         if (property == "clip") {
               cssp = eval(objName + ".style.clip");
             if (cssp == "") {
                   cssStr = "rect(0px ";
                   cssStr += getCalculatedProperty(objName, "width") + " ";
                   cssStr += getCalculatedProperty(objName, "height") + " ";
                   cssStr += "0px)";
                   return cssStr;
             }
             return cssp;
         }
         return eval(objName + ".currentStyle." + property);
   }
}


function pxval(valAsStr) {
    if ((i = valAsStr.indexOf("px")) != -1) { 
          val = parseInt(valAsStr.substring(0,i)); 
     }
    else { 
          val = 0; 
          alert("problem parsing valAsStr:"+valAsStr);
    }
    return val;
}
