var lastUpdate = 0;var userToken = null;function ajaxSetToken(inToken){    userToken = inToken;}/* * Returns a new XMLHttpRequest object, or false if this browser * doesn't support it */function newXMLHttpRequest() {  var xmlreq = false;  if (window.XMLHttpRequest) {    // Create XMLHttpRequest object in non-Microsoft browsers    xmlreq = new XMLHttpRequest();  } else if (window.ActiveXObject) {    // Create XMLHttpRequest via MS ActiveX    try {      // Try to create XMLHttpRequest in later versions      // of Internet Explorer      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");    } catch (e1) {      // Failed to create required ActiveXObject      try {        // Try version supported by older versions        // of Internet Explorer        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");      } catch (e2) {        // Unable to create an XMLHttpRequest with ActiveX      }    }  }  return xmlreq;}/* * Returns a function that waits for the specified XMLHttpRequest * to complete, then passes its XML response * to the given handler function. * req - The XMLHttpRequest whose state is changing * responseXmlHandler - Function to pass the XML response to */function getReadyStateHandler(req, responseXmlHandler) {  // Return an anonymous function that listens to the  // XMLHttpRequest instance  return function () {    // If the request's status is "complete"    if (req.readyState == 4) {      // Check that a successful server response was received      if (req.status == 200) {        // Pass the XML payload of the response to the        // handler function        responseXmlHandler(req.responseXML);      } else {        // An HTTP problem has occurred        alert("HTTP error: "+req.status);      }    }  }}function updateList(listXML) { // Get the root "xmlresponse" element from the document var responseElement = listXML.getElementsByTagName("xmlresponse")[0]; // Check that a more recent response document hasn't been processed // already var generated = responseElement.getAttribute("generated"); if (generated > lastUpdate) {   lastUpdate = generated;   // Clear the list used to display the cart contents   var destlistid = responseElement.getAttribute("destlist");   var destlist = document.getElementById(destlistid);   destlist.innerHTML = "";   // Loop over the items in the cart   var items = responseElement.getElementsByTagName("item");   for (var I = 0 ; I < items.length ; I++) {     var item = items[I];     // Extract the text nodes from the name and quantity elements     var name = item.getAttribute("name");     var value = item.getAttribute("value");     if (value == null || value == "") {        value = name;     }     // Create and add an option item HTML element for this cart item     var li = document.createElement("option");     li.value = value;     li.appendChild(document.createTextNode(name));     destlist.appendChild(li);   } }}function ajaxListRemoval(inListID){    var req = newXMLHttpRequest();    var listObject = document.getElementById(inListID);    var selectedObject = listObject.options[listObject.selectedIndex];    var selectedValue = selectedObject.value;    var handlerFunction = getReadyStateHandler(req, updateList);    req.onreadystatechange = handlerFunction;    req.open("POST", "/spotme/EditTagList.mrk", true);    req.setRequestHeader("Content-Type",                       "application/x-www-form-urlencoded");    // Send form encoded data stating that I want to add the    // specified item to the cart.    req.send("generic(action)=remove&generic(destlist)="+inListID+"&generic(item)="+selectedValue);}/* */function ajaxListSelection(inSourceList, inDestinationList, inAction) {  // Obtain an XMLHttpRequest instance  var req = newXMLHttpRequest();  // Get the selection from the list  var srcIndex = inSourceList.selectedIndex  var srcObject = inSourceList.options[srcIndex];  var srcObjectID = srcObject.value;  // Set the handler function to receive callback notifications  // from the request object  var handlerFunction = getReadyStateHandler(req, updateList);  req.onreadystatechange = handlerFunction;  // Open an HTTP POST connection to the spot list action.  // Third parameter specifies request is asynchronous.  req.open("POST", inAction, true);  // Specify that the body of the request contains form data  req.setRequestHeader("Content-Type",                       "application/x-www-form-urlencoded");  // Send form encoded data stating that I want to add the  // specified item to the cart.  req.send("generic(action)=add&generic(destlist)="+inDestinationList+"&generic(item)="+srcObjectID);}function ajaxPostKeysAndValues(inAction, inKeys, inValues, inUpdate){  // Obtain an XMLHttpRequest instance  var req = newXMLHttpRequest();  // Set the handler function to receive callback notifications  // from the request object  var handlerFunction = getReadyStateHandler(req, inUpdate);  req.onreadystatechange = handlerFunction;  // Open an HTTP POST connection to the spot list action.  // Third parameter specifies request is asynchronous.  req.open("POST", inAction, true);  // Specify that the body of the request contains form data  req.setRequestHeader("Content-Type",                       "application/x-www-form-urlencoded");  var posting = "";  for (var i = 0; i < inKeys.length; i++) {      posting += inKeys[i] + "=" + inValues[i] + "&";  }  req.send(posting.replace(/\&$/g, ""));}function isArray(obj) {   if (obj.constructor.toString().indexOf("Array") == -1)      return false;   else      return true;}function ajaxPost(inAction, inValue, inUpdate){    var keys = new Array(1);    keys[0] = "data";    var values = new Array(1);    values[0] = inValue;    ajaxPostMultiple(inAction, keys, values, inUpdate)}function ajaxPostMultiple(inAction, inKeys, inValues, inUpdate){  // Obtain an XMLHttpRequest instance  var req = newXMLHttpRequest();  // Set the handler function to receive callback notifications  // from the request object  var handlerFunction = getReadyStateHandler(req, inUpdate);  req.onreadystatechange = handlerFunction;  // Open an HTTP POST connection to the spot list action.  // Third parameter specifies request is asynchronous.  req.open("POST", inAction, true);  // Specify that the body of the request contains form data  req.setRequestHeader("Content-Type",                       "application/x-www-form-urlencoded");  // Send form encoded data stating that I want to add the  // specified item to the cart.  var sendString = "";  if (userToken != null) {      sendString += "g(userToken)=" + userToken + "&";  }  for (var i = 0; i < inKeys.length; i++) {      sendString += "g(" + inKeys[i] + ")=" + inValues[i] + "&";  }  // remove trailing '&'  sendString = sendString.substring(0, sendString.length - 1);  req.send(sendString);}function showElement(inID) {    document.getElementById(inID).style.display = "inline";}function hideElement(inID) {    document.getElementById(inID).style.display = "none";}function toggleDiv(inDivID){	var theDiv = document.getElementById(inDivID);	if (theDiv) {		if (theDiv.style.display == "none") {			theDiv.style.display = "inline";		} else {			theDiv.style.display = "none";		}	}}