

   //' Used to toggle on or off a Div.
   function toggleDiv(element, showDiv)
   {
      var e = document.getElementById(element); 
      var s;

      if (showDiv == null || showDiv == 'undefined') // if showDiv is not specified, toggle the div from it's current state.
         s = (e.style.display == 'block') ? 'none' : 'block';
      else if (Boolean(showDiv))
         s = 'block';
      else
         s = 'none';

      e.style.display = s;
   }

   //'
   //' Set a panel on a form to the value of another panel
   //' The target is called "panel" by default.
   //' panelChange("FooBar"); sets the <Div ID=FooBar> to an empty area
   //' panelChange("Somewhere","FooBar"); sets <Div ID=Somewhere> to the value of <Div ID=FooBar>
   //'
   function panelChange(panelChangeDestination,panelChangeSource) {
      if (panelChangeSource != null && panelChangeSource != undefined) {
         document.getElementById(panelChangeDestination).innerHTML=document.getElementById(panelChangeSource).innerHTML;
         }
      else {
         //' If no source specified, then empty the destination
         document.getElementById(panelChangeDestination).innerHTML="";
         }
      }

   //'
   //' AJAX POST
   //' POST type transactions have the distinct advantage that they are not limited by the number of characters sent to server.
   //' POST transactions are not cached within the browser, while GET transactions are.
   //' However, POST transactions are ever so slightly less efficient and are larger.
   //'
   //<script src="/CommonLibrary/commonLibrary.js"></script>
   //'
   var http_request = false;
   //'
   function commonLibraryAJAXPostHTML(url, parameters, divId, waitMessage, visibilityAuto) {
      //PARAMETERS EXAMPLES:
      //   url:        'Debugger/DebuggerAjax.htm' // The URL to make the Ajax Request to
      //   parameters: 'Debugger.Command=' + encodeURI( document.getElementById('TextAreaID').value ) // data to send to the Ajax page handler
      //   divID:      'The section that the result is to be stuffed into
      //   visivilityAuto: 'If true, the divId is made visible when the result comes in.
      //Use encodeURI() anything that could contain special characters
      var element = document.getElementById(divId);
      http_request = false;
      if (window.XMLHttpRequest) {
         // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
            }
         }
      else if (window.ActiveXObject) {
         // IE versions prior to 7
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
            }
         catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
               }
            catch (e) {
               }
            }
         }
      if (!http_request) {
         element.innerHTML= 'Cannot create XMLHTTP instance';
         if (visibilityAuto) {
            element.style.visibility = 'visible';
            }
         }

      http_request.onreadystatechange = function() {
         if (http_request.readyState == 4) {
            element = document.getElementById(divId);
            if (http_request.status == 200) {
               try {
                  element.innerHTML = http_request.responseText;
                  } 
               catch (e) {
                  var tn = element.tagName;
                  if(tn=='TBODY' || tn=='TR' || tn=='TD') {
                     var tempDiv = document.createElement("div");
                     tempDiv.innerHTML = '<table id="tempTable" style="display: none">' + http_request.responseText + '</table>';
                     element.parentNode.replaceChild(tempDiv.getElementsByTagName(tn).item(0), element);
                     }
                  else throw e;
                  }
               }
            else {
               element.innerHTML= 'There was a problem with the AJAX request.';
               }
            if (visibilityAuto) {
               element.style.visibility = 'visible';
               }
            }
         };
      http_request.open('POST', url, true);
      if (waitMessage != '') {
         try {
            element.innerHTML = waitMessage;
            } 
         catch (e) {
            var tn = element.tagName;
            if(tn=='TBODY' || tn=='TR' || tn=='TD') {
               var tempDiv = document.createElement("div");
               tempDiv.innerHTML = '<table id="tempTable" style="display: none">' + waitMessage + '</table>';
               element.parentNode.replaceChild(tempDiv.getElementsByTagName(tn).item(0), element);
               }
            else throw e;
            }
         }
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
      }

   function commonLibraryAJAXPostEval(url, parameters) {
      //PARAMETERS EXAMPLES:
      //   url:        'Debugger/DebuggerAjax.htm' // The URL to make the Ajax Request to
      //   parameters: 'Debugger.Command=' + encodeURI( document.getElementById('TextAreaID').value ) // data to send to the Ajax page handler
      //Use encodeURI() anything that could contain special characters
      http_request = false;
      if (window.XMLHttpRequest) {
         // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
            }
         }
      else if (window.ActiveXObject) {
         // IE versions prior to 7
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
            }
         catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
               }
            catch (e) {
               }
            }
         }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         }

      http_request.onreadystatechange = function() {
         if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               eval(http_request.responseText);
               }
            else {
               alert('There was a problem with the AJAX request.');
               }
            }
         };
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
      }
