function Hide(id) {
   //alert(id);
   document.getElementById(id).style.visibility="hidden";
}

function UnHide(id) {
   //alert(id);
   document.getElementById(id).style.visibility="visible";
}

function parseGetVars() {
   //Pulls out value of parameters of "GET" string in an html address
   //If we have www.a.com?fubar=123 then getVars[fubar] will be 123
   //Usage is "getVars=parseGetVars()"
   
   var getVars = new Array();
   var qString = unescape(top.location.search.substring(1));
   var pairs = qString.split(/\&/);
   for (var i in pairs) {
      var nameVal = pairs[i].split(/\=/);
      getVars[nameVal[0]] = nameVal[1];
   }
   return getVars;
}

function LinkOpened(LinkId) {
   // Records that a link in the page was followed (in order to allow assessment
   // of which are most useful links)
   
   //[insert section that opens a file for input/output]
   file = fopen(LinksData.txt)
   length = flength(file);         // Get the length of the file
   str = fread(file, length);     // Read in the entire file
   fclose(file);
   write(str);
   //[add line with date/time + LinkId + carriage return]
   //[Close file]
   
}

function getHTTPObject() {
   // Function for AJAX. Creates the XMLHTTPRequest that is used to interface with the server.
   
   if (typeof XMLHttpRequest != 'undefined') { return new XMLHttpRequest();
      } try { return new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) { try { return new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {} } return false;
}

function updateData(http, myurl, param1, param2) {
   // Function for AJAX. Accesses a back-end script (specified in the first line)
   // using GET method.
   // "param" is the list of parameters to send to the backend script
   // "myurl" is the address of the backend script
   
   http.open("GET", myurl + "?p1=" + escape(param1)+ "?p2=" + escape(param2), false);
   http.onreadystatechange = useHttpResponse; // This last is a function defined below.
   http.send(null);
}

function useHttpResponse() {
   // Function for AJAX. Makes use of data retrieved from back-end. Called from within updateData function
   
   if (http.readyState == 4) {
      var textout = http.responseText;
   }
}

function RecordLink(Destination) {
   // When the user clicks on a link, records the event, specifying origin and destination pages.
   // (Will not work with page addresses that contain '?')
   // Uses AJAX
   
   http = getHTTPObject();
   
   // In case of modification of the below, the backend script must be modified accordingly
   // to correctly label the parameters
   updateData(http, "/cgi-bin/links_analysis_cgi.pl", location.href, Destination)
   
   // http.setRequestHeader("Connection", "close");
   
}