/*
    File: util.js
    Author: Clifford Hayashi
    Date: 22 June 2008
*/

      function createRequest() {
        try {
          request = new XMLHttpRequest();
        } catch (trymicrosoft) {
          try {
            request = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (othermicrosoft) {
            try {
              request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (failed) {
              request = null;
            }
          }
        }

        if (request == null)
          alert("Error creating request object!");
      }

      /*function getAbstract(abId,pId) {
        if (elId == "none" ) {
           elId = pId;
           createRequest();
           var url = "cgi-bin/getRC28Abstract.php?id="+abId;
           request.open("GET" ,url, true);
           request.onreadystatechange = updatePage;
           request.send(null);
        }
      }

      function updatePage() {
        if (request.readyState == 4) {
          if (request.status == 200) {
              var abstract = request.responseText;
              //alert(request.responseText);
              abEl = document.getElementById(elId);
              // no longer need elId; okay to get another abstract
              elId = "none";
              replaceText(abEl, abstract);
          } else {
            alert("Currently unable to get abstract!");
          }
        }
      }*/

      function replaceText(el, text) {
       if (el != null) {
        clearText(el);
        var newNode = document.createTextNode(text);
         el.appendChild(newNode);
       }
     }

     function clearText(el) {
       if (el != null) {
         if (el.childNodes) {
           for (var i = 0; i < el.childNodes.length; i++) {
             var childNode = el.childNodes[i];
             el.removeChild(childNode);
           }
         }
       }
     }

     function getText(el) {
       var text = "";
       if (el != null) {
         if (el.childNodes) {
           for (var i = 0; i < el.childNodes.length; i++) {
             var childNode = el.childNodes[i];
             if (childNode.nodeValue != null) {
               text = text + childNode.nodeValue;
             }
           }
         }
       }
       return text;
     }
