isNS4 = (document.layers) ? 1 : 0;
isIE4 = (document.all) ? 1 : 0;
isW3C = (document.getElementById && !document.all) ? 1 : 0;
var cssp;

function getCalculatedProperty(objName, property) {
//alert('getCalc called');
     // thanks to Ian Grant, http://www.faqts.com/knowledge_base/view.phtml/aid/7157

     if (isW3C) {
     //alert('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;
          }
//alert(property);
          //cssp = document.defaultView.getComputedStyle(docObj, "").getPropertyValue(property);
          cssp = window.document.defaultView.getComputedStyle(docObj, "").getPropertyValue(property);
//alert(cssp);
          return (cssp == "") ? "unknown" : cssp;
    }

    // ***** Netscape Navigator 4+ DOM *****

    if (isNS4) {
    //alert('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 (isIE4) {
    //alert('isIE4');
          if (property == "width") return eval(objName + ".offsetWidth") + "px";
          if (property == "height") return eval(objName + ".offsetHeight") + "px";
          if (property == "top") return eval(objName + ".offsetTop") + 'px';
          if (property == "left") return eval(objName + ".offsetLeft") + 'px';
          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);
    }
}
