// Extremely simple use of the extremely simple AJAX JavaScript interface

function loadViewInfo(vid, rid, h, w) {}
function loadContext(base, section, page, element, desc) {
   window.base    = base;
   window.section = section;
   window.page    = page;
   window.element = element;
   window.desc    = desc;
}

function loadElement(element) {

   window.element = element;

   // Figure out if we need to use ActiveX (IE6/5)
   // or standard XML (for everything else)

   if(window.XMLHttpRequest) {
      xmlhttp1 = new XMLHttpRequest(); 
      xmlhttp2 = new XMLHttpRequest(); 
   }
   else {
      xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
      xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
   }

   // Setup the AJAX request interrupt for the tag

   xmlhttp1.onreadystatechange = 

      function() {
         if(xmlhttp1.readyState==4 && xmlhttp1.status==200) 
            document.getElementById("tag").innerHTML = 
                                 xmlhttp1.responseText;
         else
            document.getElementById("tag").innerHTML = 
                                                 "???";
      }

   // Setup the AJAX request interrupt for the description

   xmlhttp2.onreadystatechange =
  
      function() {
         if(xmlhttp2.readyState==4 && xmlhttp2.status==200) 
            document.getElementById(window.desc).innerHTML = 
                                        xmlhttp2.responseText;
         else
            document.getElementById(window.desc).innerHTML =
                                      "Please wait";
      }

   // Make the requests

   xmlhttp1.open("GET", 
           window.base + "/getTag.php?s=" + window.section + 
                        "&p=" + window.page + 
                        "&e=" + window.element, 
            true);
   xmlhttp2.open("GET", 
           window.base + "/getDesc.php?s=" + window.section + 
                        "&p=" + window.page + 
                        "&e=" + window.element, 
            true);

   xmlhttp1.send();
   xmlhttp2.send();
}

