var req; // object for making XMLHttpRequest callvar resultColXML= new Array() // holds results.  If column is an array, i.e. multiple columns, this will be an array of arraysvar AJAXuserFunction; // user function called once resultColXML is populatedvar AJAXcolumn; // column number required from viewvar AJAXcolumns; // if column is an array, i.e. multiple columns are returnedvar columnIsArray; function trim(aStr) { return aStr.replace(/^\s+/g, "").replace(/\s+$/g, "") }function isArray(obj) {   return (obj.constructor.toString().indexOf("Array") != -1)}/*--------------------------- Dbcolumn function start here -------------------*/function dbColumn(path,view,column, updFunction, async, URLargs) {  if(dbColumn.arguments.length>=5) {	thisAsync=async  } else {  	thisAsync = true  }  if(dbColumn.arguments.length>=6) {   addToURL = URLargs  } else {   addToURL = ""  }  AJAXuserFunction = updFunction; // for use in function processReqChange_lookup  columnIsArray = isArray(column);  if (columnIsArray) {   AJAXcolumns = column  } else {   AJAXcolumn = column // for use in function parseXMLdblookup, N.B. starts at 1 and Categorised column is not counted  }  var pos=0;  currURL = (document.location.href).toLowerCase();   pos = currURL.indexOf('://');   pos += 3;  pos = currURL.indexOf('/', pos);  if( trim(path) == "" ) {   if( pos > 0 ) {    newPos = currURL.indexOf('.nsf',pos);    if (newPos > 0) {     path = currURL.substring(pos+1,newPos+4)    }   }  }  vurl = "/"+trim(path)+"/"+view+"?Readviewentries&count=9999&collapseview"   //checking whether browser is Mozilla or Netscape   if (window.XMLHttpRequest)  {        req = new XMLHttpRequest();//        req.overrideMimeType('text/xml');        if(thisAsync) req.onreadystatechange = processReqChange_lookup;        req.open("GET", vurl , thisAsync);        req.send(null);        if(!thisAsync) processReqChange_lookup();      }        //checking whether browser is IE  else if (window.ActiveXObject)  {         req = new ActiveXObject("Microsoft.XMLHTTP");        if (req)   {               if(thisAsync) req.onreadystatechange = processReqChange_lookup;               req.open("GET", vurl, thisAsync);             req.send();               if(!thisAsync) processReqChange_lookup();           }        }}/*--------------------------- writing in combo function start here -------------------*/function writeInCombo(data,fldCombo){ fldCombo.length=0//   fldCombo.length +=1//   fldCombo[fldCombo.length-1].text = " - Select - "; for(iCount=0;iCount<data.length;iCount++) {  fldCombo.length +=1  strText=data[iCount]    if (strText !=undefined && strText != null)  {    fldCombo[fldCombo.length-1].text = trim(strText)   } } }function writeInComboValue(data,fldCombo) // this one splits the XML data on "~~~" to get text and value{ fldCombo.length=0//   fldCombo.length +=1//   fldCombo[fldCombo.length-1].text = " - Select - "; for(iCount=0;iCount<data.length;iCount++) {  fldCombo.length +=1  var strText=data[iCount]    if (strText !=undefined && strText != null)  {    var textText = strText.substr(0, strText.indexOf("~~~") );   var valueText = strText.substr(strText.indexOf("~~~")+3 );   fldCombo[fldCombo.length-1].text = trim(textText);   fldCombo[fldCombo.length-1].value = trim(valueText);  } } }/*--------------------------- Dblookup function start here -------------------*/function dbLookup(path,view,key,column, updFunction, async){   if(dbLookup.arguments.length==6) {	thisAsync=async  } else {  	thisAsync = true  } AJAXuserFunction = updFunction; // for use in function processReqChange_lookup columnIsArray = isArray(column); if (columnIsArray) {  AJAXcolumns = column } else {  AJAXcolumn = column // for use in function parseXMLdblookup, N.B. starts at 1 and Categorised column is not counted } var pos=0; currURL = (document.location.href).toLowerCase();   pos = currURL.indexOf('://');    pos += 3;   pos = currURL.indexOf('/', pos);  if( trim(path) == "" )  {   if( pos > 0 )   {    newPos = currURL.indexOf('.nsf',pos);    if (newPos > 0)    {     path = currURL.substring(pos+1,newPos+4)    }   }    }    vurl = "/"+trim(path)+"/"+view+"?Readviewentries&restricttocategory="+key+"&count=9999&rand=" + rand();       //checking whether browser is mozila or Netscape   if (window.XMLHttpRequest)  {        req = new XMLHttpRequest();//        req.overrideMimeType('text/xml');        if(thisAsync) req.onreadystatechange = processReqChange_lookup;        req.open("GET", vurl , thisAsync);        req.send(null);        if(!thisAsync) processReqChange_lookup();      }         //checking whether browser is IE  else if (window.ActiveXObject)  {         req = new ActiveXObject("Microsoft.XMLHTTP");        if (req)   {            if(thisAsync) req.onreadystatechange = processReqChange_lookup;            req.open("GET", vurl, thisAsync);            req.send();            if(!thisAsync) processReqChange_lookup();           }        } }/* Function used to check whether xml file loaded completely or not */function processReqChange_lookup() {    if (req.readyState == 4)              /*Only process if xml file is loaded completely:4="Complete" */  {         if (req.status == 200)            /*Only process if everything is ok*/    {             response  = req.responseXML.documentElement;             // find out in total, how many items are in the "view"		 //  var vEntries = response.getElementsByTagName("viewentries") 		   //resultColXML.totalAvail = vEntries[0].getAttribute("toplevelentries") 		   resultColXML.totalAvail = response.getAttribute("toplevelentries") 		 //  response  = req.responseXML.documentElement;             if(columnIsArray) {                 for(i=0; i<AJAXcolumns.length; i++) {                  resultColXML[""+AJAXcolumns[i]] = parseXMLdblookup(response, AJAXcolumns[i])                }             // get the start and stop item numbers from the returned array                resultColXML.startItemNum = resultColXML[""+AJAXcolumns[0]].startItemNum             resultColXML.stopItemNum = resultColXML[""+AJAXcolumns[0]].stopItemNum              } else {                // don't bother getting the start and stop numbers, because they are already there from the parseXMLdbLookup stuff.                resultColXML = parseXMLdblookup(response, AJAXcolumn);              }              AJAXuserFunction();        }    else    {             alert("There was a problem retrieving the XML data:n" + req.statusText);          }       }}/* Function used to extract value one by one from xml file */function parseXMLdblookup(responseXML, column){ var colEntry = new Array(0)  viewEntries = responseXML.getElementsByTagName("viewentry")  for(var i=0; i<viewEntries.length; i++) {   // if(i==0) {colEntry.startItemNum = viewEntries[i].getAttribute("position")}  // if(i==viewEntries.length -1) { colEntry.stopItemNum = viewEntries[i].getAttribute("position") }      entryData = viewEntries[i].getElementsByTagName("entrydata");   for (var ie=0; ie < entryData.length; ie++) {         if (entryData[ie].getAttribute("columnnumber") == (column - 1)) {            entryText = entryData[ie].getElementsByTagName("text")            for (var it=0; it < entryText.length; it++) {               if( entryText[it].firstChild){                 	colEntry.push(entryText[it].firstChild.nodeValue)               } else {                    colEntry.push("")               }            }         }    } }  return colEntry}/* random number to defeat caching */var thisDate = new Date();var seed = thisDate.getTime() % 0xffffffff;function rand() {  seed = (0x015a4e35 * seed ) %0x7ffffffff;  return (seed >> 16);}/*--------------------------- ajaxCall function start here -------------------*/function ajaxCall(url, updFunction, async){   if(ajaxCall.arguments.length==3) {	thisAsync=async	//alert("setting async to " + async)  } else {  	thisAsync = true  	//	alert("setting async to default")  }   //checking whether browser is mozila or Netscape   if (window.XMLHttpRequest)  {        req = new XMLHttpRequest();//        req.overrideMimeType('text/xml');        if(thisAsync) req.onreadystatechange = updFunction;        req.open("GET", url , thisAsync);        req.send(null);        if(!thisAsync) updFunction();      }         //checking whether browser is IE  else if (window.ActiveXObject)  {        req = new ActiveXObject("Microsoft.XMLHTTP");        if (req)   {            if(thisAsync) req.onreadystatechange = updFunction;            req.open("GET", url, thisAsync);            req.send();            if(!thisAsync) updFunction();           }        } }/*--------------------------- ajaxDBPublished function start here -------------------*/function ajaxLookup(url, column, start, count, updFunction, async){ // this could REALY be used as a basis of all of the other lookup stuff.// load the defaults. 	if (url == null){     	currURL = (document.location.href).toLowerCase(); 	} else { 		currURL = url 	} 	if (start == null)	{    		start = 1;	}  	if(count == null)	{		count = 30;	}         if (async == null)     {     	async = true     }         AJAXuserFunction = updFunction; // for use in function processReqChange_lookup columnIsArray = isArray(column); if (columnIsArray) {  AJAXcolumns = column } else {  AJAXcolumn = column // for use in function parseXMLdblookup, N.B. starts at 1 and Categorised column is not counted }   //checking whether browser is mozila or Netscape   if (window.XMLHttpRequest)  {        req = new XMLHttpRequest();//        req.overrideMimeType('text/xml');        if(async) req.onreadystatechange = processReqChange_lookup;        req.open("GET", url , async);        req.send(null);        if(!async) processReqChange_lookup();      }         //checking whether browser is IE  else if (window.ActiveXObject)  {         req = new ActiveXObject("Microsoft.XMLHTTP");        if (req)   {            if(async) req.onreadystatechange = processReqChange_lookup;            req.open("GET", url, async);            req.send();            if(!async) processReqChange_lookup();           }        } }