var webstandard = falsefunction makeRequest(url, targetSpan, doCount, expandAll) {//From w3schools - makes the proper request - after being modified for IE 7...		var design_request = false;		if (window.XMLHttpRequest) { // Mozilla, Safari, ... AND IE 7...		webstandard = true		design_request = new XMLHttpRequest();		if (design_request.overrideMimeType) {			design_request.overrideMimeType('text/xml');		}		if (!design_request) {			alert('Giving up :( Cannot create an XMLHTTP instance');			return false;		}	} else if (window.ActiveXObject) { // IE 6 and below		try {			design_request = new ActiveXObject("Msxml2.XMLHTTP");			if (!design_request) {				alert('Giving up :( Cannot create an XMLHTTP instance');				return false;			}		} catch (e) {			try {				design_request = new ActiveXObject("Microsoft.XMLHTTP");				if (!design_request) {					alert('Giving up :( Cannot create an XMLHTTP instance');					return false;				}			} catch (e) {			}		}	}	design_request.onreadystatechange = function() { processDesign(design_request, targetSpan, doCount, expandAll, url); };	design_request.open('GET', url + "?ReadDesign", true);	design_request.send(null);}function processDesign(design_request, targetSpan, doCount, expandAll, url) {/*	Charles F. Phillips	01/27/2007Once we're sure we have a valid design request, then we mae an entries request.*/	if (design_request.readyState == 4) {		if (design_request.status == 200) {			var entries_request = false;			if (window.XMLHttpRequest) { // Mozilla, Safari, ...				entries_request = new XMLHttpRequest();				if (entries_request.overrideMimeType) {					entries_request.overrideMimeType('text/xml');				}				if (!entries_request) {					alert('Giving up :( Cannot create an XMLHTTP instance');					return false;				}			} else if (window.ActiveXObject) { // IE				try {					entries_request = new ActiveXObject("Msxml2.XMLHTTP");					if (!entries_request) {						alert('Giving up :( Cannot create an XMLHTTP instance');						return false;					}				} catch (e) {					try {						entries_request = new ActiveXObject("Microsoft.XMLHTTP");						if (!entries_request) {							alert('Giving up :( Cannot create an XMLHTTP instance');							return false;						}					} catch (e) {					}				}			}			entries_request.onreadystatechange = function() { processEntries(design_request, entries_request, targetSpan, doCount, expandAll); };			entries_request.open('GET', url + "?ReadViewEntries&PreFormat&ExpandView&Count=-1", true);			entries_request.send(null);		} else {			alert('There was a problem with the entries request.');		}	}}function processEntries(design_request, entries_request, targetSpan, doCount, expandAll) {/*	Charles F. Phillips	01/27/2007	design_request, - is from the first request generated above	entries_request, - is from the second request generated above	targetSpan - allows us to name the spans dynaically so that we can have 		more than one view on the page and preserve the namespace	doCount - determines if we will post the child and descendants counts	expandAll - determines if we post the categories opened or closed*/	if (entries_request.readyState == 4) {		if (entries_request.status == 200) {			myView = document.getElementById(targetSpan)			if (myView) {								var XMLEntriesDoc = entries_request.responseXML				//Parsing the xml document returned from the Notes view, we get the viewentries				var root_entries = XMLEntriesDoc.getElementsByTagName("viewentries").item(0);				//If there is no node then set a status message and leave				if (!root_entries) {myView.innerHTML="No documents found"; return}								var XMLDesignDoc = design_request.responseXML				//Parsing the xml document returned from the Notes view, we get the view design				var root_design = XMLDesignDoc.getElementsByTagName("viewdesign").item(0);				//If there is no node then set a status message and leave				if (!root_design) {myView.innerHTML="No design found"; return}								//Build an array of table headers before we dive into the entries				var columns = root_design.getElementsByTagName("column")				var columnArray = new Array()				var noncategory = 0				for (i = 0; i < columns.length; i++){					if (!columns[i].getAttribute("sortcategorize")) {//skip over categories						columnArray[noncategory++] = columns[i].getAttribute("title")					}				}								//Grab the alternate row color if it exists				var altrowcolor = ""				if (root_design.getAttribute("altrowcolor")) {					altrowcolor = root_design.getAttribute("altrowcolor")				}								//Parse out the viewentry nodes - we will loop through the view entries to build our links				var entries = root_entries.getElementsByTagName("viewentry")				var sTemp = ""				var columnCurrent = 0				var columnPrevious = 0				var closeFlag = false				var expansion = "none"				var plusminus = "+"				if (expandAll) {expansion = "block"; plusminus = "-"}				for (i = 0; i < entries.length; i++){						//If there is a descendants attribute, then it is a category" and we want to handle that entry differently. 					if (entries[i].getAttribute("descendants")){												//Get the column number and determine what </span> tags we need						var grandchildren = entries[i].getElementsByTagName("entrydata")						columnCurrent = parseInt(grandchildren[0].getAttribute("columnnumber"))						//We ALWAYS close the span if the last loop filled it with documents						if (closeFlag) {sTemp += "</span>\n"; closeFlag = false}						//If current < previous, then we are also closing out a parent span						if (columnCurrent < columnPrevious) {sTemp += "</span>\n"}						columnPrevious = columnCurrent												//Generate the toggle and the column title						sTemp += "<span id=\"" + targetSpan + i + "Controller\" " 							+ "style=\"display:inline;\" class=\"plsminus\" "							+ "onClick=\"toggleDisplay('" + targetSpan + i + "')\">" + plusminus + "</span>&nbsp;"						sTemp += getText(entries[i])						//Determine if we want categories with document counts						if (doCount) {sTemp += " (" + entries[i].getAttribute("descendants") + ")"}						sTemp += "<br>\n"												//Create the span that will contain the current element's 						//children with an appropriate amount of padding						sTemp += "<span style=\"padding-left: " + ((columnCurrent + 1)  * 20) 							+ "px; display:" + expansion + ";\" id=\"" + targetSpan + i + "\">\n"					} else { //a Notes doc!						//First, we need to start a table for the documetns and fill in the headers						sTemp += "<table class=\"docTable\">\n"						sTemp += "<tr>\n"						for (a = 0; a < columnArray.length; a++){								sTemp += "<td class=\"docHeader\">" + columnArray[a] + "</td>\n"						}						sTemp += "</tr>\n"												var placeholder = 0						//the siblings attribute gives us the number of docs in the current 						//category and we want to handle them in a batch so they  can						//be put into the same span and use the same display property						for (doc = 0; doc < entries[i].getAttribute("siblings"); doc++){								placeholder = i + doc														//Apply altrowcolor (if any) to even rows							if (altrowcolor != "" && doc%2) {								sTemp += "<tr style=\"background-color:" + altrowcolor + "\">\n"							} else {								sTemp += "<tr>\n"							}														//Walk down the collection of column values, making the first one a hyperlink							var columnValues = entries[placeholder].getElementsByTagName("entrydata")							for (col = 0; col < columnArray.length; col++){								sTemp += "<td class=\"docData\">\n"								if (col == 0) {									sTemp += "<a href=\"" + location.href.substring(0, location.href.indexOf(".nsf")+4) 										+ "/0/" + entries[placeholder].getAttribute("unid") + "?OpenDocument\" title=\"Click here to open '" 										+ getText(columnValues[0]) + "'\">" + getText(columnValues[0]) + "</a>"								} else {									sTemp += getText(columnValues[col])								}								sTemp += "</td>\n"							}							sTemp += "</tr>\n"						} // end for						sTemp += "</table>\n"						//increment i by the value of g so that ther outer						//for loop picks up where the inner for loop left off.						i = placeholder						closeFlag = true					}				}				//Add the final closing tag before posting sTemp because				//we won't be looping anymore to generate it dynamically				sTemp += "</span>\n"				myView.innerHTML = sTemp							} else {				alert(targetSpan + " not found")			}		} else {			alert('There was a problem with the request.');		}	}}function getText(element) {/*	Charles F. Phillips	01/30/2007	This reduces a lot of redundancy in processResponse	Modified to handle IE7*/	var agt = navigator.userAgent.toLowerCase();	if (webstandard) { // Mozilla, Safari, ... AND IE7		if (agt.indexOf("msie 7.")!=-1) {			return element.text		} else {			return element.textContent		}	} else if (window.ActiveXObject) { // IE6 and below		return element.text	}}function toggleDisplay(targetSpan) {/*	Charles F. Phillips	01/27/2007	This not only toggles the display of thespan, but it changes + to - and back again*/	var theSpan = document.getElementById(targetSpan)	var theController = document.getElementById(targetSpan + "Controller")	if (theSpan) {		if (theSpan.style.display == "block") {			theSpan.style.display = "none"			theController.innerHTML = "+"		} else {			theSpan.style.display = "block"			theController.innerHTML = "-"		}	}}
