var webstandard = false;var plusSign = "<img src='/img/icon-plus.png' border='0' />";var minusSign = "<img src='/img/icon-minus.png' border='0' />";var testDisplay = true;function getXMLHTTP() {	var xmlHttp;	try {  		xmlHttp=new XMLHttpRequest();		webstandard = true;		if (xmlHttp.overrideMimeType)  xmlHttp.overrideMimeType('text/xml')			} catch (e) {		try {			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");		} catch (e) {			try {				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");			} catch (e) {				alert( "Unable to continue - Your browser does not support AJAX." );				return false;			}		}		}	return xmlHttp;}function makeRequest(url, targetSpan, doCount, expandAll, restrictToState) {//From w3schools - makes the proper request - after being modified for IE 7...	var design_request = getXMLHTTP();	if( typeof design_request == "boolean" )  return false		design_request.onreadystatechange = function() { processDesign(design_request, targetSpan, doCount, expandAll, url, restrictToState); };	design_request.open('GET', url + "?ReadDesign", true);	design_request.send(null);}function processDesign(design_request, targetSpan, doCount, expandAll, url, restrictToState) {/*	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 = getXMLHTTP();			if( typeof entries_request == "boolean" )  return false							entries_request.onreadystatechange = function() { processEntries(design_request, entries_request, targetSpan, doCount, expandAll); };			entries_request.open('GET', url + "?ReadViewEntries&PreFormat&ExpandView&RestrictToCategory=" + restrictToState + "&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 = plusSign				if (expandAll) {expansion = "block"; plusminus = minusSign }				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\" "							+ "onClick=\"toggleDisplay('" + targetSpan + i + "')\">" + plusminus + "</span>&nbsp;"														if( testDisplay ) {								//alert( entries[i] )								//alert( entries[i].getElementsByTagName("text")[0] )								//alert( entries[i].text )								//alert( entries[i].textContent )								testDisplay = false;							}						sTemp += "<span class=\"select-region\">" + getText(entries[i]);											//Add document counts if required						if (doCount) {sTemp += " (" + entries[i].getAttribute("descendants") + ")"}						sTemp += "</span><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 documents and fill in the headers						sTemp += "<table class=\"adviserLine\">\n"						sTemp += "<tr>\n"						for (a = 0; a < columnArray.length; a++){								sTemp += "<td>" + 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")							var target = ""							for (col = 0; col < columnArray.length -1; col++){								if (col == 0) {									sTemp += "<td class=\"adviserLink\">\n"									if (getText(columnValues[2]).indexOf(".htm") > 0) {										target = "target='_top'"									}									else {										target = ""									}									sTemp += "<a " + target + " href=\"" + location.href.substring(0, location.href.indexOf(".au")+3) + "/"	+ getText(columnValues[2]) + "\">" + getText(columnValues[0]) + "</a>";								} else {									sTemp += "<td class=\"adviserName\">\n"																	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/IE8		if (agt.indexOf("msie 7.")!=-1 || agt.indexOf("msie 8.")!=-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 = plusSign		} else {			theSpan.style.display = "block"			theController.innerHTML = minusSign		}	}}