//2.1.7	- Added support for Column Totals - Thanks to Jonathan Roberts for code submission//		- CSS definition for columnTotal, and isCategory, CategoryTotal, CategoryTotalEmptyCell//		- Added Adjacent[ HTML | Text | Element ] support for firefox - Thanks to Peter Kempf// 		- Robusted up saveState to included expanded/collapsed entries, selectedPosition and start position//		- Added resetState() function to clear the view's current state//		- Added 'extendLastColumn' property - defaults to true to mimic 2.1.6 & previous releases, but if set//		  to false, the last column does not extend the width of the view, helpful for right aligned last columns//AUTHOR: Jason Thomas w/ 2.1.7 updates by Jeremy Hodge//dependant on jsUtility//todo// Resizable columns// fix search problem related to response hierarchy views/***********************************************************************This library contains a class definition for NotesView2. Basically, this allows external code to create a NotesView2 object relatedto a Domino view and display it on a web browser. Capable of displaying any View or Folder.IMPORTANT: this script must have access to a "sleep" agent (included in the sample database), this script assumes its located in this database, to		 override the location of the agent, set the property sleepPath to the location of the agent (omit the name of the agent 'sleep' .. see example belowIMPORTANT: If you are going to use the search functionality, you must add agtSearchView and agtIsDBIndexed agents to your database********************************************************************//********************NotesView2 object*****************************TO CREATE:var o = new NotesView2(<dbname>, <viewname>);TO ADJUST:Be sure to use these adjustments BEFORE calling the render methodo.hideSelectionMargin = <true or false>; //defaults to trueo.linesToShow = <number of document rows to display at once>; //defaults to 12o.linesToGet = <number of documents to fetch from server at a time, MUST be greater than linesToShow>; //defaults to 20o.queryBuilder = <url of webpage that contains popup form for helping the user create complex search querys, form must return a query to calling code using the window.returnValue property>; //defaults to "", if added, a Query Builder button is added to search bar//note the queryBuilder is currently only supported in IE because it uses the showModalDialog function o.addAction(<String, title of action>, <Function, javascript function>, <String, url of action button icon>); //repeat as necessary, if no actions are added, the action bar is not showno.actionButtonDisplay = <1 - icon+button, 2 - icon only, 3 text only>; //defaults to 1o.preventCaching = <true or false>; //defaults to trueo.restrictToCategory = <String, category to restrict to>; //defaults to blank - call resetState() before reloading the window if you change this after calling rendero.useViewStyles = <true or false>; //defaults to false, when set to true, the column and header formatting from each view column will be applied as styles (overriding any css)TO POINT TO A DIFFERENT LOCATION FOR THE SLEEP AGENT:o.sleepPath='/folder/subfolder/database.nsf/'; // you can omit the trailing slash, agent must exist as 'sleep' in that databaseTO IMPLEMENT THE ONCLICK:o.openDocument = function(viewEntry){	//implement code to run when user clicks document	//this function is passed a single parameter: a NotesViewEntry2 object containing the document that was clicked	//this function is called when a user:			//clicks on the link for this document (the first column value's text)			//presses the enter key when the link for this document has focus			//double clicks on the row containing this document};TO DISPLAY:o.render(<html container object>);TO MANIPULATE AFTER DISPLAY:- use o.navigator.selected to get an array of selected NotesViewEntry2 objects- use o.refresh(), o.expandAllEntries(), o.collaspseAllEntries(), o.jumpTo(), o.toggleSearchBar() to manipulate view with external action buttons- see NotesViewEntry2 at bottom for usage of that object***************************************************************************//**************************NotesViewEntry2 object**************************When a user is interacting with the view on the page, they can select a document by clicking on it or tabbing to it.If the .hideSelectionMargin property of the NotesView2 object is set to false, they can select multiple documentsusing checkboxes on the left hand margin.To get a javascript handle to the selected documents, use the NotesView2.navigator.selected property.This returns an array of all selected documents as NotesViewEntry2 objects.The NotesViewEntry2 class is documented here:properties (these are all READ ONLY):	.unid //the unid of this entry's notes document	.position //String, the position of this entry in the view, ex: 1.2.3.1	.noteId //String, the note id of this entry	.children //String, the number of children of this entry in the view	.descendants //String, the number of descendants of this entry in the view	.siblings //String,the number of siblings of this entry in the view	.isResponse //String, indicates if this is a response document or not	.indent //the indent level of this document in the view, use getLevel() function for more accurate results	.columnValues //a hash of all column values for this entry, access using column number as a string (0 based) ex: var columnThreeValue = entry.columnValues['2']		.isCategory //Boolean, a flag that indicates if this entry is a category or not	.view //a handle to the NotesView2 object this entry is a part of	.isExpanded //Boolean, a flag that indicates if this entry is currently expandedfunctions:	getLevel() //Number, returns the indent level of this document in the view***********************************************************************/function NotesView2(db,name){	this.version = "1.6"; //version number of this code	//constants	this.images = new Object(); //a hash object of image urls to be used by this code	this.images["dblsort"] = "/icons/dblsort.gif";	this.images["dblasc"] = "/icons/dblasc.gif";	this.images["dbldesc"] = "/icons/dbldesc.gif";	this.images["ascsort"] = "/icons/ascsort.gif";	this.images["descsort"] = "/icons/descsort.gif";	this.images["altasc"] = "/icons/altasc.gif";	this.images["altdesc"] = "/icons/altdesc.gif";	this.images["pagedown"] = "/icons/descsort.gif";	this.images["pageup"] = "/icons/ascsort.gif";	this.images["scrolldown"] = "/icons/descsort.gif";	this.images["scrollup"] = "/icons/ascsort.gif";	this.images["refresh"] = "/icons/viewsort.gif";	this.images["opentwistie"] = db + "/EXPANDED%20TWISTIE?OPENIMAGERESOURCE";	this.images["closedtwistie"] = db + "/COLLAPSED%20TWISTIE?OPENIMAGERESOURCE";	this.images["columnresize"] = db + "/col-resize.gif";	this.hideSelectionMargin = true; //boolean flag to hide or show the selection margin in the view	this.id = Math.random();	this.db = db;	this.name = name;	this.sleepPath = db;	this.linesToShow = 11;	this.linesToGet = 20;	this.queryBuilder = "";	this.actionButtonDisplay = 1; // 1 - icon+button, 2 - icon only, 3 text only	this.actions = new Array();	this.preventCaching = true;	this.restrictToCategory = "";	this.useViewStyles = false;	this.stateTimeout = {years: 0, months: 0, days: 0, hours: 0, mins: 15, secs: 0 };		// time to save state before reseting	this.lang = (window['NotesView2Lang']) ? NotesView2Lang : {		status_ready : "Ready",		status_loading_data : "Retrieving data...",		status_selected_documents : "$ document(s) selected",		status_jumpto_fail : "Could not find '$'",		status_jumpto_success : "Found '$'",			tooltip_remove_sort : "Remove Sort",		tooltip_sort_ascending : "Sort Ascending",		tooltip_sort_descending : "Sort Descending",		tooltip_expand_category : "Expand Entry",		tooltip_collapse_category : "Collapse Entry",		tooltip_page_up : "Page Up",		tooltip_page_down : "Page Down",		tooltip_scroll_up : "Scroll Up",		tooltip_scroll_down : "Scroll Down",			prompt_jumpto : "Enter the text to jump to:",		prompt_search_input : "Search for: ",		prompt_clear_search : "Clear Results",		prompt_search_go : "Go",		prompt_query_builder : "Query Builder",			msg_search_results : "$ result(s) found",		msg_db_not_indexed : "Database is not full-text indexed (search may be slow)",		msg_db_is_indexed : "Database is full-text indexed",		msg_index_test_failed : "Cannot determine status of full-text index",		msg_startkey_and_restricttocategory_error : "A start key cannot be set when the view is restricted to a single category"	};		//state variables	this.resortAscending = -1;	this.resortDescending = -1;	this.expandAll = false;	this.selectedEntryPosition = "";	this.allExpanded = "";		//programmatic control variables	this.searchQuery = "";	this.start = "";	this.startKey = "";	this.disabled = true;	this.waitingForData = false;	this.previousStarts = new Array();	this.container = null;	this.tbody = null;	this.actionBar;	this.columns = new Array();	this.navigator = null;	this.statusBar = null;	this.searchBar = null;	this.searchResultCount = "";	this.statusMessage = this.lang['status_ready'];	this.visibleColumns = 0;	this.responseColumn = -1;	this.stateReloaded = false;	this.extendLastColumn = true;			this.openDocument = function(viewEntry){};	/**************refresh()**********************/	this.refresh = function(){		this.statusMessage = this.lang['status_ready'];		this.changeState("selectedEntryPosition","");		this.reset();	};	/*************changeState()****************/	this.changeState = function(parameterName, parameterValue){		this[parameterName] = parameterValue;		this.saveState();	};	/**************saveState******************/	this.saveState = function(){		var cookieName = escape(this.db + "!" + this.name).toLowerCase();		var cookieValue = escape(this.resortDescending + "|" + this.resortAscending + "|" + this.expandAll + "|" + this.selectedEntryPosition + "|" + this.start);		var kill_time = new Date();		kill_time.adjust(this.stateTimeout['years'], this.stateTimeout['months'], this.stateTimeout['days'], this.stateTimeout['hours'], this.stateTimeout['mins'], this.stateTimeout['secs']);		document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + kill_time.toGMTString();		document.cookie = cookieName + '!previousStarts=' + escape(this.previousStarts.join(',')) + ";path=/;expires=" + kill_time.toGMTString();		document.cookie = cookieName + '!replayHistory=' + escape(this.navigator.replayHistory.join('^')) + ";path=/;expires=" + kill_time.toGMTString();		document.cookie = cookieName + '!allExpanded=' + escape(this.allExpanded) + ";path=/;expires=" + kill_time.toGMTString();	};	/***************loadState*********************/	this.loadState = function(){		var a = document.cookie.split(";");				var key = escape(this.db + "!" + this.name).toLowerCase();		for(var i = 0 ; i < a.length ; i++){			if(a[i].indexOf("=") != -1){				var cookieName = a[i].left("=").trim();				if(cookieName == key){					var cookieValues = unescape(a[i].right("=")).trim().split("|");					this.resortDescending = parseInt(cookieValues[0]);					this.resortAscending = parseInt(cookieValues[1]);					this.expandAll = (cookieValues[2]=="true") ? true : false;					this.selectedEntryPosition = cookieValues[3];					this.start = cookieValues[4];				} else if (cookieName == key + "!allExpanded") {					this.allExpanded = unescape(a[i].right('=')).trim();				} else if (cookieName == key + '!previousStarts') {					this.previousStarts = unescape(a[i].right('=')).trim();					this.previousStarts = this.previousStarts.split(',');				} else if (cookieName == key + '!replayHistory') {					this.navigator.replayHistory = unescape(a[i]).right('=').trim().split('^');					var s = this.db + "/" + this.name + "?readviewentries&preformat&count=";					for (var x=0; x < this.navigator.replayHistory.length; x++) {						var categoryEntry = {};						url = this.navigator.replayHistory[x];						this.navigator.loadDataFromCache(s + url, null);					}				}			}		}				var expEntries = this.allExpanded.split('@').join('');		expEntries = expEntries.split(',');		expEntries = expEntries.splice(0, expEntries.length - 1);		expEntries.sort();		sleep(1); // sleep for 1 sec to make sure we've finsihed loading data from replay above ... this is a hack that should				// be cleaned up eventually with some sort of cache manager that can reload the cache and then notify when its				// done so we can expand the entries. requires sleep agent to be in database...		for (x=0; x < expEntries.length; x++) {		// expand (or collapse) the entries that were expanded (or collapsed)			if (!this.expandAll) {				this.expand(expEntries[x]);			} else {				this.collapse(expEntries[x]);			};		}; 	};	/**************resetState**************/	this.resetState = function() {		var cookieName = escape(this.db + "!" + this.name).toLowerCase();		var kill_time = new Date();		kill_time.adjust(-1,0,0,0,0,0);		document.cookie = cookieName + "=;path=/;expires=" + kill_time.toGMTString();		document.cookie = cookieName + '!previousStarts=;path=/;expires=' + kill_time.toGMTString();		document.cookie = cookieName + '!allExpanded=;path=/;expires=' + kill_time.toGMTString();		document.cookie = cookieName + '!replayHistory=;path=/;expires=' + kill_time.toGMTString();	}	/**************toggleSearchBar**************/	this.toggleSearchBar = function(){		if(this.searchBar.style.display == "none"){			this.searchBar.style.display = "block";			document.getElementById(this.id + "-searchbox").select();		}else{			this.searchBar.style.display = "none";			if(this.searchQuery){				this.clearSearch();			}		}	};	/****************refreshStatus()***************/	this.refreshStatus = function(){		var s = this.statusMessage;		if(this.waitingForData){			s = this.lang['status_loading_data'];		}else if(this.navigator.selected.length > 0 && !this.hideSelectionMargin){			s = this.lang['status_selected_documents'].split("$").join(this.navigator.selected.length+"");		}		this.statusBar.childNodes[0].nodeValue = s;	};	/***************reset()*********************/	this.reset = function(){		if(this.disabled || this.waitingForData) return;		this.disabled = true;		this.previousStarts = new Array();		this.navigator = null;		this.navigator = new NotesViewNavigator2(this);				var tbody = this.tbody;		var row = tbody.rows[2];		while(row.notesViewEntry){			tbody.removeChild(row);			var tr = tbody.appendChild(document.createElement("tr"));			var td = tr.appendChild(document.createElement("td"));			td.className = "dataCell";			td.colSpan = this.visibleColumns + ((this.hideSelectionMargin) ? 0 : 1)  + ((this.extendLastColumn) ? 0 : 1);			td.innerHTML = "&nbsp;";			row = tbody.rows[2];		}				this.loadState();		this.navigator.onbeforedataload = function(){			this.view.waitingForData = true;			this.view.refreshStatus();			this.view.refreshScrollBar();		};			this.navigator.ondataload = function(firstPosition,toplevelcount){			if(this.view.searchQuery){				document.getElementById(this.view.id + "-searchcount").childNodes[0].nodeValue = this.view.lang['msg_search_results'].split('$').join(toplevelcount + "");			}			if(this.view.startKey){				var s = this.view.startKey;				this.view.startKey = "";				var i = this.childCollection.length;				if(i==0){					this.view.statusMessage = this.view.lang['status_jumpto_fail'].split('$').join(s);					this.view.waitingForData = false;					this.view.disabled = false;					this.view.reset();					return;				}else{					this.view.statusMessage = this.view.lang['status_jumpto_success'].split('$').join(s);					this.view.start = firstPosition;				}			}			if(this.view.start == ""){				this.view.start = firstPosition;			}						this.view.drawRows();			this.view.waitingForData = false;			this.view.refreshStatus();			this.view.refreshScrollBar();		};				for(var i = 0 ; i < this.columns.length ; i++){			var col = this.columns[i];			if(!col.response){				if(col.sortImg){					col.sortImg.style.display = ((this.searchQuery || this.restrictToCategory) ? "none" : "");				}				if(col.resortAscending && col.resortDescending){					if(this.resortAscending == i){						col.sortImg.src = this.images["dblasc"];						col.sortImg.title = this.lang['tooltip_remove_sort'];					}else if(this.resortDescending == i){						col.sortImg.src = this.images["dbldesc"];						col.sortImg.title = this.lang['tooltip_sort_ascending'];					}else{						col.sortImg.src = this.images["dblsort"];						col.sortImg.title = this.lang['tooltip_sort_descending'];					}				}else if(col.resortAscending){					if(this.resortAscending == i){						col.sortImg.src = this.images["altasc"];						col.sortImg.title = this.lang['tooltip_remove_sort'];					}else{						col.sortImg.src = this.images["ascsort"];						col.sortImg.title = this.lang['tooltip_sort_ascending'];					}				}else if(col.resortDescending){					if(this.resortDescending == i){						col.sortImg.src = this.images["altdesc"];						col.sortImg.title = this.lang['tooltip_remove_sort'];					}else{						col.sortImg.src = this.images["descsort"];						col.sortImg.title = this.lang['tooltip_sort_descending'];					}				}				}		}					if(this.startKey){			this.navigator.loadRowsAt(this.startKey);		}else if(this.searchQuery){			this.navigator.loadRows("1");			this.start = "1";		}else if(this.start == ""){  //1.7 this.selectedEntryPosition == ""			this.navigator.loadRows("1");		}else			this.navigator.loadRows(this.start);			this.disabled = false;	};	/**************toggleEntry()*************/	this.toggleEntry = function(entry){		if(this.disabled || this.waitingForData){			return;		}		if(entry.hasChildren){			this.disabled = true;			if(entry.isExpanded){				this.collapse(entry.position);			}else{				this.expand(entry.position);			}			this.disabled = false;		}		this.selectEntry(entry);	};	/****************selectEntry()*************/	this.selectEntry = function(entry){		var currentHighlighted = this.navigator.getEntryByPosition(this.selectedEntryPosition);		if(currentHighlighted){			currentHighlighted.isHighlighted = false;			var row = currentHighlighted.tableRow;			if(row){				row.className = ((row.rowIndex%2==0) ? "alternateRowB" : "alternateRowA");			}		}		if(!this.searchQuery){			this.changeState("selectedEntryPosition",entry.position);		}else{			this.selectedEntryPosition = entry.position;		}		entry.isHighlighted = true;		if(this.hideSelectionMargin){			this.navigator.selected = ((entry.unid) ? new Array(entry) : new Array());		}		entry.tableRow.className = "highlightedRow";	};	/***************openEntry()****************/	this.openEntry = function(entry){		if(this.disabled || this.waitingForData){			return;		}		if(entry.unid){			this.disabled = true;			this.openDocument(entry);			this.disabled = false;		}else{			this.toggleEntry(entry);		}	};	/***************render()********************/	this.render = function(container){		this.container = container;		var nv = this;		var s = this.db+"/"+this.name+"?readdesign";		if(this.preventCaching){			s += "&cache=" + Math.random();		}		loadXMLRequest(s,function(xmldoc){			nv.loadDesign(xmldoc);		});	};	/***************loadDesign()********************/	this.loadDesign = function(xml){		if(xml){			var design = xmlToObject(xml,true,true);			var c = design.viewdesign[0].column;			var offSet = (this.restrictToCategory) ? 1 : 0;			for(var i = offSet ; i < c.length ;i++){				this.columns[i-offSet] = new NotesViewColumn2(c[i]);				if(!this.columns[i-offSet].response){					this.visibleColumns++;				}else if(this.responseColumn==-1){					this.responseColumn = i-offSet;				}			}			this.drawView();		}	};	/**************collapse()********************/	this.collapse = function(position){		var entry = this.navigator.getEntryByPosition(position);		var next = this.navigator.getNextSiblingOrAncestor(entry);		entry.isExpanded = false;		if (!this.expandAll)			this.allExpanded = ((this.allExpanded).split('@' + position + ',').join(''))		else			this.allExpanded = ((this.allExpanded).split('@' + position + ',').join('')) + '@' + position + ',';		entry.twistie.childNodes[0].src = this.images["closedtwistie"];		entry.twistie.title = this.lang['tooltip_expand_category'];		if(!next){			var n = (position.indexOf(".") == -1) ? (new String(parseInt(position) + 1)) : (position.leftBack(".") + "." + (parseInt(position.rightBack("."))+1));			this.navigator.loadRows(n,true);		}else{			this.drawRows();		}	};	/***************expand()*********************/	this.expand = function(position){		var entry = this.navigator.getEntryByPosition(position);		entry.isExpanded = true;		if (this.expandAll)			this.allExpanded = ((this.allExpanded).split('@' + position + ',').join(''))		else			this.allExpanded = ((this.allExpanded).split('@' + position + ',').join('')) + '@' + position + ',';		try {			entry.twistie.childNodes[0].src = this.images["opentwistie"];			entry.twistie.title = this.lang['tooltip_collapse_category'];		} catch(err) {			// If we havent drawn it yet, we haven't established 'twistie' yet, so just ignore ... 		}		this.navigator.loadChildren(position,"1");	};	/***************expandAllEntries()*************************/	this.expandAllEntries = function(){		if(!this.searchQuery){			this.allExpanded = '';			this.changeState("expandAll", true);			this.reset();		}	};	/***************collapseAllEntries()*************************/	this.collapseAllEntries = function(){		if(!this.searchQuery){			this.allExpanded = '';			this.changeState("expandAll", false);			if(this.selectedEntryPosition.indexOf(".") != -1){				this.changeState("selectedEntryPosition", this.selectedEntryPosition.left("."));			}			this.reset();		}	};	/**************jumpTo()**********************/	this.jumpTo = function(){		if(!this.searchQuery){			var s = prompt(this.lang['prompt_jumpto'],"");			if(s){				this.startKey = s;				this.reset();			}		}	};	/***************sort()*************************/	this.sort = function(columnNumber){		//descending, then ascending, then none		var col = this.columns[columnNumber];		if(!col.resortAscending && !col.resortDescending)return;		var desc = (this.resortDescending != columnNumber) ? -1 : this.resortDescending;		var asc = (this.resortAscending != columnNumber) ? -1 : this.resortAscending;		if(col.resortDescending && col.resortAscending){			if(desc == -1 && asc == -1){				desc = columnNumber;			}else if(desc == columnNumber){				desc = -1;				asc = columnNumber;			}else{				asc = -1;				desc = -1;			}		}else if(col.resortAscending){			desc = -1;			if(asc == -1){				asc = columnNumber;			}else{				asc = -1;			}		}else{			asc = -1;			if(desc == -1){				desc = columnNumber;			}else{				desc = -1;			}		}		this.changeState("resortAscending",asc);		this.changeState("resortDescending", desc);		this.changeState("selectedEntryPosition","1");		this.reset();	};	/**************addAction()****************************/	this.addAction = function(title,func,img){		this.actions.push({title:title, func:func, img:img});	};	/***************addActionButton()*********************/	this.addActionButton = function(img, title, func){		var btn = document.createElement("button");		btn.notesView = this;		btn.onclick = function(){			func.call(this,this.notesView);			return false;		};		if(this.actionButtonDisplay == 1 || this.actionButtonDisplay == 2){			btn.appendChild(document.createElement("img")).src = img;		}		if(this.actionButtonDisplay == 1){			btn.appendChild(document.createTextNode(" "));		}		if(this.actionButtonDisplay == 1 || this.actionButtonDisplay == 3){			btn.appendChild(document.createTextNode(title));		}		btn.title = title;		this.actionBar.appendChild(btn);	};	/****************searchView()****************/	this.searchView = function(query){		if(query){			this.changeState("selectedEntryPosition","1");			this.searchQuery = query;			this.reset();		}	};	/**************clearSearch()*********************/	this.clearSearch = function(){		if(this.searchQuery){			this.changeState("selectedEntryPosition","1");			this.searchQuery = "";			document.getElementById(this.id + "-searchcount").childNodes[0].nodeValue = "";			this.reset();		}	};	/***************drawView()*********************/	this.drawView = function(){		if(this.actions.length>0){			this.actionBar = this.container.appendChild(document.createElement("div"));			this.actionBar.className = "actionBar";			for(var i = 0 ; i < this.actions.length ; i++){				this.addActionButton(this.actions[i].img, this.actions[i].title, this.actions[i].func);			}		}		var nv = this;		this.searchBar = this.container.appendChild(document.createElement("div"));		this.searchBar.className = "searchBar";		this.searchBar.style.display = "none";		this.searchBar.appendChild(document.createTextNode(this.lang['prompt_search_input']));		var inp = document.createElement("input");		inp.id = this.id + "-searchbox";		inp.type = "text";		inp.onkeypress = function(e){			var ev = (e) ? e : event;			if(ev.keyCode==13){				nv.searchView(this.value);				return false;			}		};		this.searchBar.appendChild(inp);		var btn = this.searchBar.appendChild(document.createElement("button"));		btn.appendChild(document.createTextNode(this.lang['prompt_search_go']));		btn.onclick = function(){nv.searchView(inp.value);return false;};		var btn = this.searchBar.appendChild(document.createElement("button"));		btn.appendChild(document.createTextNode(this.lang['prompt_clear_search']));		btn.onclick = function(){nv.clearSearch();return false;};		if(this.queryBuilder && window['showModalDialog']){			var btn = this.searchBar.appendChild(document.createElement("button"));			btn.appendChild(document.createTextNode(this.lang['prompt_query_builder']));			btn.onclick = function(){				var q = window.showModalDialog(nv.queryBuilder);				if(q){					document.getElementById(this.id + "-searchbox").value = q;				}				return false;			};		}		this.searchBar.appendChild(document.createElement("br"));		var indexStatus = this.searchBar.appendChild(document.createElement("span"));		indexStatus.style.fontSize = "xx-small";		indexStatus.style.color = "red";		indexStatus.appendChild(document.createTextNode(" " + this.lang['msg_db_not_indexed']));		loadXMLRequest(this.db + "/agtIsDBIndexed?Openagent&db=" + escape(this.db),function(xmldoc){			var s = "", c = "red";			try{				var o = xmldoc.getElementsByTagName("isIndexed");				if(o.length ==1 && o[0].childNodes[0].nodeValue == "true"){					s = this.lang['msg_db_is_indexed'];					c= "green";				}else{					s = this.lang['msg_db_not_indexed'];				}			}catch(e){				s = this.lang['msg_index_test_failed'];			}			indexStatus.style.color = c;			indexStatus.innerHTML = s;		},this);				var resultCount = this.searchBar.appendChild(document.createElement("span"));		resultCount.style.fontWeight = "bold";		resultCount.id = this.id + "-searchcount";		resultCount.appendChild(document.createTextNode(" "));		var div = this.container.appendChild(document.createElement("div"));		div.style.overflow = "hidden";		this.viewDiv = div;		var table = div.appendChild(document.createElement("table"));		table.style.width = "100%";		table.className = "viewTable";		table.cellPadding = 0;		table.cellSpacing = 0;		table.appendChild(document.createElement("thead"));		table.appendChild(document.createElement("tfoot"));		var tbody = table.appendChild(document.createElement("tbody"));		this.tbody = tbody;		var tr = tbody.appendChild(document.createElement("tr"));		if(!this.hideSelectionMargin){			var th = tr.appendChild(document.createElement("td"));			th.appendChild(document.createTextNode(" "));			th.innerHTML = "&nbsp;";			th.className = "header";			th.style.width="13px";		}		for(var i = 0 ; i < this.columns.length ; i++){			var col = this.columns[i];			if(!col.response){				var th = tr.appendChild(document.createElement("td"));				col.tableCell = th;				th.className = "header";				if(this.useViewStyles){					for(var styleName in col.headFont){						th.style[styleName] = col.headFont[styleName];					}				}				th.appendChild(document.createTextNode((col.title)?" "+col.title:" "));				if(col.resortAscending || col.resortDescending){					var a = th.appendChild(document.createElement("a"));					a.href = "javascript:void(0)";					a.notesView = this;					a.notesViewColumnNumber = col.columnNumber;					a.onclick = function(){						this.notesView.sort(parseInt(this.notesViewColumnNumber));						return false;					};					var img = a.appendChild(document.createElement("img"));					img.className = "colSort";					img.width = "16";					img.height = "16";					if(col.resortAscending && col.resortDescending){						img.src = this.images["dblsort"];					}else if(col.resortAscending){						img.src = this.images["ascsort"];					}else{						img.src = this.images["descsort"];					}					img.border = 0;					col.sortImg = img;				}				if(col.width && i < this.columns.length-1){					th.style.width = col.width;				}			}		}			if (!this.extendLastColumn) {			var th = tr.appendChild(document.createElement("td"));			th.appendChild(document.createTextNode(" "));			th.innerHTML = "&nbsp;";			th.className = "header";		}						var th = tr.appendChild(document.createElement("td"));		th.className = "header";		th.innerHTML = "&nbsp;";		var tr = tbody.appendChild(document.createElement("tr"));		var td = tr.appendChild(document.createElement("td"));		td.colSpan = this.visibleColumns + ((this.hideSelectionMargin) ? 0 : 1) + ((this.extendLastColumn) ? 0 : 1);		td.style.overflow = "hidden";		td.style.height = "0px";				var th = tr.appendChild(document.createElement("td"));		th.rowSpan = this.linesToShow+1;		th.className = "scrollBar";		th.style.width="20px";		th.style.verticalAlign = "top";		var btn = th.appendChild(document.createElement("button"));		btn.title = this.lang['tooltip_page_up'];		btn.style.width = "20px";		btn.style.height = "20px";		btn.notesView = this;		btn.onclick = function(){			this.notesView.pageUp();			return false;		};		var btnImg = btn.appendChild(document.createElement("img"));		btnImg.src = this.images["pageup"];		this.pageUpButton = btn;				th.appendChild(document.createElement("br"));				var btn = th.appendChild(document.createElement("button"));		btn.style.width = "20px";		btn.style.height = "20px";		btn.title = this.lang['tooltip_scroll_up'];		btn.notesView = this;		btn.onclick = function(){			return false;		};		btn.onmousedown = function(){			this.notesView.scrollUp();			window.NOTESVIEWTOSCROLL = this.notesView;			this.notesView.scrollingUp=setTimeout("NOTESVIEWTOSCROLL.holdScroll(-1)",800);			return false;		};		btn.onmouseout = function(){			clearTimeout(this.notesView.scrollingUp);			return false;		};		btn.onmouseup = function(){			clearTimeout(this.notesView.scrollingUp);			return false;		};		var btnImg = btn.appendChild(document.createElement("img"));		btnImg.src = this.images["scrollup"];		this.scrollUpButton = btn;										var bar = th.appendChild(document.createElement("div"));		var barBlockPusher = bar.appendChild(document.createElement("div"));		barBlockPusher.innerHTML = "&nbsp;";		barBlockPusher.style.width = "10px";		barBlockPusher.style.overflow = "hidden";		barBlockPusher.style.height = "1px";		this.scrollbarblockpusher = barBlockPusher;		var barBlock = bar.appendChild(document.createElement("div"));		barBlock.align="center";		barBlock.innerHTML = "&nbsp;";		barBlock.className = "scrollBarBlock";		barBlock.style.width = "100%";		barBlock.style.height = "50px";		this.scrollbarblock = barBlock;		bar.style.width = "20px";		bar.style.textAlign = "center";		this.scrollbar = bar;		var btn = th.appendChild(document.createElement("button"));		btn.style.width = "20px";		btn.style.height = "20px";		btn.title = this.lang['tooltip_scroll_down'];		btn.notesView = this;		btn.onclick = function(){			return false;		};		btn.onmousedown = function(){			this.notesView.scrollDown();			window.NOTESVIEWTOSCROLL = this.notesView;			this.notesView.scrollingDown=setTimeout("NOTESVIEWTOSCROLL.holdScroll(1)",800);			return false;		};		btn.onmouseout = function(){			clearTimeout(this.notesView.scrollingDown);			return false;		};		btn.onmouseup = function(){			clearTimeout(this.notesView.scrollingDown);			return false;		};		var btnImg = btn.appendChild(document.createElement("img"));		btnImg.src = this.images["scrolldown"];		this.scrollDownButton = btn;				th.appendChild(document.createElement("br"));				var btn = th.appendChild(document.createElement("button"));				btn.title = this.lang['tooltip_page_down'];		btn.style.width = "20px";		btn.style.height = "20px";		btn.notesView = this;		btn.onclick = function(){			this.notesView.pageDown();			return false;		};		var btnImg = btn.appendChild(document.createElement("img"));		btnImg.src = this.images["pagedown"];		this.pageDownButton = btn;				this.padView();		this.statusBar = this.container.appendChild(document.createElement("div"));		this.statusBar.className = "statusBar";		this.statusBar.appendChild(document.createTextNode(this.lang['status_ready']));		this.disabled = false;		this.reset();	};	/**************holdScroll****************/	this.holdScroll = function(x){		if(x>0){			this.scrollDown();			if(this.scrollingDown){				clearTimeout(this.scrollingUp);				this.scrollingDown = setTimeout("NOTESVIEWTOSCROLL.holdScroll(1)",100);			}		}else if(x<0){			this.scrollUp();			if(this.scrollingUp){				clearTimeout(this.scrollingDown);				this.scrollingUp = setTimeout("NOTESVIEWTOSCROLL.holdScroll(-1)",100);			}		}	};	/**************padView()*******************/	this.padView = function(){		var tbody = this.tbody;		while(tbody.rows.length < this.linesToShow + 2){			var tr = tbody.appendChild(document.createElement("tr"));			var td = tr.appendChild(document.createElement("td"));			td.className = "dataCell";			td.colSpan = this.visibleColumns+((this.hideSelectionMargin) ? 0 : 1)+((this.extendLastColumn) ? 0 : 1);			td.innerHTML = "&nbsp;";		}	};	/**************refreshScrollBar*************/	this.refreshScrollBar = function(){//		this.scrollUpButton.disabled = (this.waitingForData || this.start == "1");//		this.pageUpButton.disabled = this.scrollUpButton.disabled;//		if(this.scrollUpButton.disabled)clearTimeout(this.scrollingUp);		var tbody = this.tbody;//		this.scrollDownButton.disabled = (this.waitingForData || !tbody.rows[3].notesViewEntry);//		this.pageDownButton.disabled = this.scrollDownButton.disabled;//		if(this.scrollDownButton.disabled){//			clearTimeout(this.scrollingDown);//		}		if(!this.scrollbar.style.height){			var total = -1 * (this.scrollUpButton.offsetHeight + this.pageUpButton.offsetHeight + this.pageDownButton.offsetHeight + this.scrollDownButton.offsetHeight);			total += this.tbody.rows[1].cells[1].offsetHeight;			this.scrollbar.style.height = total+"px";			this.viewDiv.style.height = this.tbody.offsetHeight;		}		total = parseInt(this.scrollbar.style.height);				if(!this.scrollDownButton.disabled){			var pad = this.previousStarts.length*2;			var blockHeight = parseInt(this.scrollbarblock.style.height);			if((blockHeight + pad) > (total*0.95)){				pad = Math.round(total * 0.95) - blockHeight;			}			if(pad<1){				pad = 1;			}			if(pad==1 && this.start != "1"){				pad = 20;			}			this.scrollbarblock.style.display = "";			this.scrollbarblockpusher.style.height = pad+"px";		}else if(!this.waitingForData){			if(this.start=="1"){				this.scrollbarblock.style.display = "none";			}else{				var blockHeight = parseInt(this.scrollbarblock.style.height);				this.scrollbarblock.style.display = "";				this.scrollbarblockpusher.style.height = (total - blockHeight) + "px";			}		}			};	/**************moveUp()*****************/	this.moveUp = function(upCount){		this.previousStarts = new Array();		if(this.start.indexOf(".") == -1){			for(var x = parseInt(this.start) - 1; x > 0 && this.previousStarts.length < this.linesToGet ; x--){				this.previousStarts.push(new String(x));			}		}else{			var pos = this.start;			while(this.previousStarts.length < this.linesToGet && pos != "1"){				if(pos.indexOf(".") != -1){					var last = parseInt(pos.rightBack("."));					if(last > 1){						pos = pos.leftBack(".") + "." + (last - 1);					}else{						pos = pos.leftBack(".");					}				}else{					pos = new String(parseInt(pos) -1);				}				this.previousStarts.push(pos);			}		}		this.previousStarts.reverse();		var s = this.start;		for(var x = 0 ; x < upCount && this.previousStarts.length > 0; x++){			this.start = this.previousStarts.pop();		}		var startAt = (this.previousStarts.length==0) ? this.start : this.previousStarts[0];		if(s.indexOf(".") == -1){			this.navigator.loadRows(startAt,false);		}else{			this.navigator.loadChildren(s.leftBack("."),null,startAt);		}	};	/**************scrollUp()********************/	this.scrollUp = function(){		if(!this.waitingForData && this.start != "1" && !this.disabled){			this.disabled = true;			if(this.previousStarts.length==0){				this.disabled = false;				this.refresh();			}else{				this.start = this.previousStarts.pop();				this.drawRows();			}			this.disabled = false;		}	};	/**************scrollDown()***************/	this.scrollDown = function(){		var tbody = this.tbody;		var notAtEnd = (tbody.rows[3].notesViewEntry);		if(!this.waitingForData && notAtEnd && !this.disabled){			this.disabled = true;			var entry = this.navigator.getEntryByPosition(this.start);			var firstRow = entry.tableRow;			tbody.removeChild(firstRow);			entry.tableRow = null;			if(entry.isExpanded){				var next = this.navigator.getNextEntry(entry);			}else{				var next = this.navigator.getNextSiblingOrAncestor(entry);			}			this.previousStarts.push(this.start);			this.start = next.position;			this.drawRows();			this.disabled = false;		}	};	/****************pageUp()*********************/	this.pageUp = function(){		var tbody = this.tbody;		if(!this.waitingForData && !this.disabled && this.start != "1"){			this.disabled = true;			if(this.previousStarts.length == 0 || (this.previousStarts.length < this.linesToShow && this.previousStarts[0] != "1")){				this.disabled = false;				this.refresh();			}else{				for(var i = 0 ; i < this.linesToShow && this.previousStarts.length > 0 ; i++){					var nextPos = this.previousStarts.pop();				}				this.start = nextPos;				this.drawRows();			}			this.disabled = false;		}	};	/****************pageDown()******************/	this.pageDown = function(){		var tbody = this.tbody;		var notAtEnd = (tbody.rows[3].notesViewEntry);		if(notAtEnd && !this.waitingForData && !this.disabled){			this.disabled = true;			for(var i = 2 ; i < tbody.rows.length -1 && tbody.rows[i+1].notesViewEntry ; i++){				this.previousStarts.push(tbody.rows[i].notesViewEntry.position);			}			var next = tbody.rows[i].notesViewEntry;			tbody.removeChild(tbody.rows[i]);			next.tableRow = null;			this.start = next.position;			this.drawRows();			this.disabled = false;		}	};	/***************drawRows()********************/	this.drawRows = function(){		var tbody = this.tbody;		var entry = this.navigator.getEntryByPosition(this.start);		for(var i = 0 ; i < this.linesToShow && entry ; i++){			if(!entry.tableRow){				var tr = this.getRow(entry);				entry.tableRow = tr;				var row = tbody.rows[i+2];				if(row){					tbody.insertBefore(tr,row);				}else{					tbody.appendChild(tr);				}			}			var row = tbody.rows[i+2];			if(entry.isHighlighted){				row.className = "highlightedRow";			}else{				row.className = (i%2==0) ? "alternateRowB" : "alternateRowA";			}			if(entry.hasChildren){				if(entry.isExpanded){					entry = this.navigator.getNextEntry(entry);				}else{					this.removeChildRows(entry, tbody);					entry = this.navigator.getNextSiblingOrAncestor(entry);				}			}else{				entry = this.navigator.getNextEntry(entry);			}			if(tbody.rows.length > this.linesToShow + 2){				var rowToRemove = tbody.rows[tbody.rows.length-1];				if(rowToRemove.notesViewEntry)rowToRemove.notesViewEntry.tableRow = null;				tbody.removeChild(rowToRemove);			}			if(!entry || entry.getMoreChildren || entry.getMoreRows){				for(var x = i+1 ; x < this.linesToShow ; x++){					var row = tbody.rows[i+3];					if(row && row.notesViewEntry){						row.notesViewEntry.tableRow = null;						tbody.removeChild(row);						var tr = tbody.appendChild(document.createElement("tr"));						var td = tr.appendChild(document.createElement("td"));						td.className = "dataCell";						td.innerHTML = "&nbsp;";						td.colSpan = this.visibleColumns+((this.hideSelectionMargin) ? 0 : 1)+((this.extendLastColumn) ? 0 : 1);					}				}			}			if(entry && entry.getMoreRows){				this.padView();				this.navigator.loadRows(entry.position);				return;			}else if(entry && entry.getMoreChildren){				this.padView();				this.navigator.loadChildren(entry.position.leftBack("."), entry.position.rightBack("."));				return;			}		}		this.padView();		this.refreshScrollBar();	};	/********************removeChildRows********************/	this.removeChildRows = function(entry,tbody){		for(var index = 1 ; index < entry.childCollection.length ; index++){			if(typeof entry.childCollection[index] != "undefined"){				var childEntry = entry.childCollection[index];				if(childEntry.hasChildren){					childEntry.isExpanded = false;					this.removeChildRows(childEntry,tbody);				}				if(childEntry.tableRow){					tbody.removeChild(childEntry.tableRow);					childEntry.tableRow = null;				}			}		}	};	/**************getRow*********************/	this.getRow = function(entry){		var entryLevel = entry.getLevel();		var tr = document.createElement("tr");		tr.id = entry.position + "-" + this.id;		tr.notesViewEntry = entry;		tr.onclick = function(){			this.notesViewEntry.view.selectEntry(this.notesViewEntry);		};		tr.ondblclick = function(){			this.notesViewEntry.view.openEntry(this.notesViewEntry);		};		if(!this.hideSelectionMargin){			var td = tr.appendChild(document.createElement("td"));			td.style.width = "13px";			td.className = "selectionMargin";			if(entry.unid){				var ch = (entry.isSelected) ? " checked" : "";				var inp = document.createElement("<input" + ch + ">");				inp.style.height = "13px";				inp.style.width = "13px";				inp.type = "checkbox";				inp.notesViewEntry = entry;				inp.onclick = function(){					if(this.checked){						this.notesViewEntry.isSelected = true;						this.notesViewEntry.view.navigator.selected.push(this.notesViewEntry);					}else{						this.notesViewEntry.isSelected = false;						var c = this.notesViewEntry.view.navigator.selected;						var x = -1;						for(var i = 0 ; i < c.length ; i++){							if(c[i].position == this.notesViewEntry.position){								x = i;								i = c.length+1;							}						}						if(x > -1){							this.notesViewEntry.view.navigator.selected.splice(x,1);						}					}					this.notesViewEntry.view.refreshStatus();				};				td.appendChild(inp);			}else{				td.innerHTML = "&nbsp;";			}		}		var firstColLink = null, firstColInserted = false;		var twistieSwitch = false;		for(var x = 0 ; x < this.columns.length ; x++){			var val = entry.columnDisplayValues[new String(x)];			if(this.columns[x].icon){				if(val==""){					val = '[&lt;img border="0" src="/icons/ecblank.gif" alt=""/&gt;]';				}else if(val.indexOf("/") != -1){					val = '[&lt;img border="0" src="' + val + '" alt=""/&gt;]';				}else{					val = parseInt(val);					val = ("00" + val).right(3);					val = '[&lt;img border="0" src="/icons/vwicn' + val + '.gif" alt=""/&gt;]';				}			}						if (entry.isCategoryTotal)				firstColInserted = true;							if(firstColLink == null && val){				firstColLink = document.createElement("a");				firstColLink.onfocus = function(){this.parentNode.parentNode.onclick();return false;};				firstColLink.onclick = function(){this.parentNode.parentNode.ondblclick();return false;};				try{					firstColLink.innerHTML = this.processPassThruHTML(val);				}catch(e){					firstColLink.innerHTML = val;				}				firstColLink.href = "javascript:void(0)";				firstColLink.className = "RowLink";				if(this.useViewStyles){					for(var styleName in this.columns[x].textFont){						firstColLink.style[styleName] = this.columns[x].textFont[styleName];					}				}			}						if(!this.columns[x].response){				if(!val){					var td = tr.appendChild(document.createElement("td"));					if (entry.isCategoryTotal)						td.className = 'categoryTotalEmptyCell'					else						td.className = "dataCell";					td.innerHTML = "&nbsp;";					if(x < this.columns.length - 1)td.style.width = this.columns[x].width;				}else if(entry.isCategory || (entry.hasChildren && this.responseColumn == x-1)){									var td = tr.appendChild(document.createElement("td"));					td.className = "dataCell";					if(this.useViewStyles){						for(var styleName in this.columns[x].textFont){							td.style[styleName] = this.columns[x].textFont[styleName];						}					}										var idex = 0;										if(entry.isCategory){						if (!twistieSwitch) {							idex = this.findSpanLength(entry,x);							if(idex > 0) td.colSpan = idex + 1							else if(idex == -1) td.colSpan = this.columns.length - x;						}						if (twistieSwitch) td.className = td.className + ' columnTotal'; else td.className = td.className + ' isCategory';					}										if(!twistieSwitch){						if(entry.indent)td.style.paddingLeft = (parseInt(entry.indent) * 15) + "px";						var a = this.getTwistieImg(entry);						td.appendChild(a);												if(firstColInserted){							a.insertAdjacentHTML("afterEnd",this.processPassThruHTML(val));						}else{							td.appendChild(firstColLink);							firstColInserted = true;						}							if(entry.isCategory && idex == -1 ) 							x = this.columns.length;						else	if(entry.isCategory) x = x + idex						else if(x < this.columns.length - 1) td.style.width = this.columns[x].width;												twistieSwitch = true;																		} else {							td.style.textAlign = this.columns[x].styleAlign;						td.innerHTML = this.processPassThruHTML(val);					}				}else{					var td = tr.appendChild(document.createElement("td"));					if (entry.isCategoryTotal)						td.className = 'categoryTotal'					else						td.className = "dataCell";					if(this.useViewStyles){						for(var styleName in this.columns[x].textFont){							td.style[styleName] = this.columns[x].textFont[styleName];						}					}					td.style.textAlign = this.columns[x].styleAlign;					if(firstColInserted){						td.innerHTML = this.processPassThruHTML(val);										}else{						td.appendChild(firstColLink);						firstColInserted = true;					}					if(x < this.columns.length - 1){						td.style.width = this.columns[x].width;					}				}			}else if(this.searchQuery){			}else if(val){				var td = tr.appendChild(document.createElement("td"));				td.className = "dataCell";				if(this.useViewStyles){					for(var styleName in this.columns[x].textFont){						td.style[styleName] = this.columns[x].textFont[styleName];					}				}				td.colSpan = this.visibleColumns - x;				td.style.paddingLeft = (parseInt(entry.indent) * 15) + "px";				if(entry.hasChildren){					var a = this.getTwistieImg(entry);					td.appendChild(a);					if(firstColInserted){						a.insertAdjacentHTML("afterEnd",this.processPassThruHTML(val));					}else{						td.appendChild(firstColLink);						firstColInserted = true;					}				}else{					if(firstColInserted){						td.innerHTML = this.processPassThruHTML(val);					}else{						td.appendChild(firstColLink);						firstColInserted = true;					}				}				x = this.columns.length;			}		}				if(!this.extendLastColumn){			var td = tr.appendChild(document.createElement("td"));			td.className = "dataCell";			td.innerHTML = "&nbsp;";			td.style.width = '50%';		}		return tr;	};	/**********************findSpanLength*****************/		this.findSpanLength = function(entry, idex){		var T1;		var T2=0;		for(var g = idex+1 ; g < this.visibleColumns ; g++){			T1 = entry.columnValues[g];			if(T1!=null && T1!="")return T2;			T2 = T2+1;		}		return -1;	}	/**********************getTwistieImg*****************/	this.getTwistieImg = function(entry){		var a = document.createElement("a");		entry.twistie = a;		a.title = (entry.isExpanded) ? this.lang['tooltip_collapse_category'] : this.lang['tooltip_expand_category'];		a.href = "javascript:void(0)";		a._NOTESVIEW = this;		a._VIEWENTRY = entry;		a.onclick = function(){			if(this._NOTESVIEW.disabled || this._NOTESVIEW.waitingForData){				return false;			}			this._NOTESVIEW.toggleEntry(this._VIEWENTRY);			return false;		};		a.onfocus = function(){this.parentNode.parentNode.onclick();return false;};		var img = a.appendChild(document.createElement("img"));		img.border = 0;		img.style.margin = "0px 2px 0px 1px";		img.align = "absmiddle";		img.src = (entry.isExpanded) ? this.images["opentwistie"] : this.images["closedtwistie"];		return a;	};	/***************escapeHTML****************/	this.processPassThruHTML = function(s){		var sNew = "";		s = s.split("<").join("&lt;").split(">").join("&gt;");		var a = s.split("[&lt;");		for(var i = 0 ; i < a.length ; i++){			if(i == 0){				sNew += a[i];			}else{				sNew += "<";				if(a[i].indexOf("&gt;]") == -1){					sNew += a[i].split("&lt;").join("<").split("&gt;").join(">");				}else{					sNew += a[i].left("&gt;]").split("&lt;").join("<").split("&gt;").join(">") + ">";					sNew += a[i].right("&gt;]");				}			}		}		return sNew;};}function NotesViewNavigator2(view){	this.view = view; //the parent NotesView	this.childCollection = new Array(); //collection of all entries	this.selected = new Array(); //array of the currently selected documents in the view	this.expandAll = view.expandAll; //convienience property	this.replayHistory = new Array(); // array of all load XML calls we make so we can replay from cache on loadstate()	/*****************addEntry***************************/	this.addEntry = function(entry){		var pos = entry.position;		var parent = (pos.indexOf(".") == -1) ? this : this.getEntryByPosition(pos.leftBack("."));		if(parent == null){			var n = new NotesViewEntry2(null,this.view);			n.position = pos.leftBack(".");			this.addEntry(n);			parent = this.getEntryByPosition(pos.leftBack("."));		}		pos = "." + pos;		parent.childCollection[parseInt(pos.rightBack("."))] = entry;	};	/****************getNextSiblingOrAncestor********************/	this.getNextSiblingOrAncestor = function(entry){		var pos = entry.position;		var parent = (pos.indexOf(".") == -1) ? this : this.getEntryByPosition(pos.leftBack("."));		var next = null;		for(var i = parseInt(("." + pos).rightBack("."))+1 ; i < parent.childCollection.length ; i++){			if(typeof parent.childCollection[i] != "undefined"){				next = parent.childCollection[i];				i = parent.childCollection.length;			}		}		if(next){			return next;		}else if(pos.indexOf(".") == -1){			return null;		}else{			return this.getNextSiblingOrAncestor(parent);		}	};	/*******************getNextEntry**********************************/	this.getNextEntry = function(entry){		var next = null;		if(entry.childCollection.length > 0){			for(var i = 1 ; i < entry.childCollection.length ; i++){				if(typeof entry.childCollection[i] != "undefined"){					next = entry.childCollection[i];					i = entry.childCollection.length;				}			}		}		if(next == null){			next = this.getNextSiblingOrAncestor(entry);		}		return next;	};	/**********************getFirstEntry*******************************/	this.getFirstEntry = function(){		return this.getEntryByPosition("1");	};	/************************getEntryByPosition******************/	this.getEntryByPosition = function(position){		var pos = position;		var parent = this;		while(pos.indexOf(".") != -1 && parent){			parent = parent.childCollection[parseInt(pos.left("."))];			pos = pos.right(".");		}		var r = (parent) ? parent.childCollection[parseInt(pos)] : null;		return (r) ? r : null;	};	/***********************load**********************************/	this.load = function(xml, categoryEntry){		var entries = xml.getElementsByTagName("viewentry");		var entry, firstPos="";		for(var i = 0 ; i < entries.length ; i++){			var pos = entries[i].getAttribute("position");			if(i==0){				firstPos=pos;				if(this.view.selectedEntryPosition == ""){					this.view.selectedEntryPosition = pos;				}			}			entry = this.getEntryByPosition(pos);			if(entry){				entry.refreshFromXML(entries[i]);			}else{				entry = new NotesViewEntry2(entries[i],this.view);				this.addEntry(entry);			}			if(entry.position == this.view.selectedEntryPosition){				entry.isHighlighted = true;				if(this.view.hideSelectionMargin){					this.selected = (entry.unid) ? new Array(entry) : new Array();				}			}			var test = entry.position + ".";			if(categoryEntry && (categoryEntry.position.left(test.length) == test || categoryEntry.position == entry.position)){					entry.isExpanded = true;			}			if(!categoryEntry && this.expandAll && entry.hasChildren){				entry.isExpanded = true;			}			entry.getMoreChildren = false;			entry.getMoreRows = false;						if(entry.position.indexOf(".") != -1){				var parent = this.getEntryByPosition(entry.position.leftBack("."));				for(x in parent.columnValues){					if(typeof entry.columnValues[x] == "undefined"){						entry.columnValues[x] = parent.columnValues[x];					}				}			}						}		if(this.view.linesToGet == entries.length){			if(categoryEntry){				if(entry.position.leftBack(".") == categoryEntry.position){					entry.getMoreChildren = true;				}else{					entry.getMoreRows = true;				}						}else{				entry.getMoreRows = true;			}		}		var total = xml.getElementsByTagName("viewentries")[0].getAttribute("toplevelentries");		this.ondataload(firstPos,total);	};	/******************navigator data loading events*****************************/	this.ondataload = function(){};	this.onbeforedataload = function(){};	/********************loadChildren*************************************/	this.loadChildren = function(position,startAt, startAtPosition){		this.onbeforedataload();		if(startAt){			var entry = this.getEntryByPosition(position + "." + startAt);			if(entry){				entry.getMoreChildren = false;				entry.getMoreRows = false;			}		}		var entry = this.getEntryByPosition(position);		if(!entry){			entry = {position:position};		}		count = this.view.linesToGet;		var s = this.view.db + "/" + this.view.name + "?readviewentries&preformat&count=" + count;		if(this.view.preventCaching){			s += "&cache=" + Math.random();		}		if(this.view.restrictToCategory){			s += "&restricttocategory=" + this.view.restrictToCategory;		}else{			if(this.view.resortDescending > -1){				s += "&resortdescending=" + this.view.resortDescending;			}else if(this.view.resortAscending > -1){				s += "&resortascending=" + this.view.resortAscending;			}		}		s += "&expand=" + position;		s += "&start=";		s += (startAtPosition) ? startAtPosition : position + "." + startAt;		this.expandAll = this.view.expandAll;		this.loadData(s,entry);	};  	/********************loadRowsAt*******************************/	this.loadRowsAt = function(startKey){		if(this.view.restrictToCategory){			alert(this.view.lang['msg_startkey_and_restricttocategory_error']);		}		this.onbeforedataload();		var s = this.view.db + "/" + this.view.name + "?readviewentries&preformat&count=" + this.view.linesToGet;		if(this.view.preventCaching){			s += "&cache=" + Math.random();		}			if(this.view.restrictToCategory){			s += "&restricttocategory=" + this.view.restrictToCategory;		}else{			s += "&startkey=" + escape(startKey);			if(this.view.resortDescending > -1){				s += "&resortdescending=" + this.view.resortDescending;			}else if(this.view.resortAscending > -1){				s += "&resortascending=" + this.view.resortAscending;			}		}		s += (this.view.expandAll) ? "&expandview" : "&collapseview";		this.expandAll = this.view.expandAll;		this.loadData(s);	};	/*************************loadRows******************************/	this.loadRows = function(startAt,expandAllOverride){		this.onbeforedataload();		var entry = this.getEntryByPosition(startAt);		if(entry){			entry.getMoreChildren = false;			entry.getMoreRows = false;		}		var s= "";		if(this.view.searchQuery){			s = this.view.db + "/agtSearchView?openagent";			s += "&db=" + escape(this.view.db);			s += "&vw=" + escape(this.view.name);			s += "&query=" + escape(this.view.searchQuery);			s += "&count=" + this.view.linesToGet;			s += "&start=" + startAt;			if(this.view.preventCaching){				s += "&cache=" + Math.random();			}		}else{			s = this.view.db + "/" + this.view.name + "?readviewentries&preformat&count=" + this.view.linesToGet;			s += "&start=" + startAt;			if(this.view.preventCaching){				s += "&cache=" + Math.random();			}				if(this.view.restrictToCategory){				s += "&restricttocategory=" + this.view.restrictToCategory;			}else{				if(this.view.resortDescending > -1){					s += "&resortdescending=" + this.view.resortDescending;				}else if(this.view.resortAscending > -1){					s += "&resortascending=" + this.view.resortAscending;				}			}			if(expandAllOverride != null){				s += (expandAllOverride) ? "&expandview" : "&collapseview";				this.expandAll = expandAllOverride;			}else{				s += (this.view.expandAll) ? "&expandview" : "&collapseview";				this.expandAll = this.view.expandAll;			}		}		this.loadData(s);	};	/************************loadData**********************************/	this.loadData = function(url, categoryEntry){		var nav = this;		this.replayHistory.push(url.right('&count='));		loadXMLRequest(url, function(xmldoc){			nav.load(xmldoc,categoryEntry);		});	};	/************************loadDataFromCache**********************************/	this.loadDataFromCache = function(url, categoryEntry){		var nav = this;		var pos = url.rightBack('&start=');		var pos = pos.left('&');		if (pos.indexOf('.') == -1)			categoryEntry = null		else			categoruEntry = this.getEntryByPosition(pos);		loadXMLRequest(url, function(xmldoc){			nav.load(xmldoc, categoryEntry);		});	};}/*****************************************************This object gives access to the properties of a given entry in a NotesView2 object.A lot of the properties correspond exactly to the attributes in the ?ReadViewEntries xml output for notes views.External code will usually only need the unid property and maybe the columnValues property and isCategory property*******************************************************/function NotesViewEntry2(xml, view){	this.position = null; //the position of this entry in the view, ex: 1.2.3.1	this.noteId = null; //the note id of this entry	this.children = null; //the number of children of this entry in the view	this.descendants = null; //the number of descendants of this entry in the view	this.siblings = null; //the number of siblings of this entry in the view	this.isResponse = null; //flag indicates if this is a response document or not	this.isCategoryTotal = null; //flag indicates if this is the total line for a view with column totals	this.unid = null; //the unid of this entry's notes document	this.indent = null; //the indent level of this document in the view, use getLevel() function for more accurate results	this.columnValues = new Object(); //a hash of all column values for this entry, access using column number as a string ex: var s = o.columnValues['2']		this.isCategory = false; //a flag that indicates if this entry is a category or not	this.view = view; //a handle to the NotesView2 object this entry is a part of	this.isExpanded = false; //a flag that indicates if this entry is currently expanded		//the rest of this class is private and not for external code use	this.columnDisplayValues = new Object(); //a hash of all column values for this entry that are actually drawn to the screen, not for external use	this.isSelected = false;	this.isHighlighted = false;	this.areChildrenLoaded = false;	this.childCollection = new Array();	this.tableRow = null;	this.getMore = false;	this.getMoreChildren = false;	this.getMoreRows = false;	this.firstColumnNumber = view.columns.length;	this.twistie = null;		//this refreshes the values of this entry from the given xml node	this.refreshFromXML = function(xml){		this.position = xml.getAttribute("position");		this.noteId = xml.getAttribute("noteid");		this.children = xml.getAttribute("children");		if(this.children && parseInt(this.children) > 0){			this.hasChildren = true;		}		this.descendants = xml.getAttribute("descendants");		this.isResponse = xml.getAttribute("response");		this.isCategoryTotal = xml.getAttribute("categorytotal")			this.siblings = xml.getAttribute("siblings");		this.unid = xml.getAttribute("unid");		this.isCategory = false;		var values = xml.getElementsByTagName("entrydata");		for(var i = 0 ; i < values.length ; i++){			var isCat = values[i].getAttribute("category");			if(isCat){				this.isCategory = true;			}			var oEntryData = xmlToObject(values[i],true);			var s = "";			if(oEntryData['text']){				s = oEntryData.text[0]._text;			}else if(oEntryData['textlist'] && oEntryData.textlist[0]['text']){				s = oEntryData.textlist[0].text[0]._text;			}			var colNum = values[i].getAttribute("columnnumber");			var ind = values[i].getAttribute("indent");			if(ind){				this.indent = ind;				this.firstColumnNumber = parseInt(ind);			}else{				this.firstColumnNumber = Math.min(this.firstColumnNumber, parseInt(values[i].getAttribute("columnnumber")));			}			this.columnValues[colNum] = s;			this.columnDisplayValues[colNum] = s;		}	};	this.getLevel = function(){		var level1 = this.firstColumnNumber + 1;		return level1;	};	if(xml){		this.refreshFromXML(xml);	}}//this is for internal use only, by the NotesView2 objectfunction NotesViewColumn2(col){	this.columnNumber = (!col._attributes['columnnumber']) ? null : col._attributes['columnnumber'];	this.resortAscending = (!col._attributes['resortascending']) ? false : col._attributes['resortascending'];	this.resortDescending = (!col._attributes['resortdescending']) ? false : col._attributes['resortdescending'];	this.width = (!col._attributes['width']) ? null : col._attributes['width'];	this.name = (!col._attributes['name']) ? null : col._attributes['name'];	this.title = (!col._attributes['title']) ? null : col._attributes['title'];	this.sort = (!col._attributes['sort']) ? null : col._attributes['sort'];	this.sortCategorize = (!col._attributes['sortcategorize']) ? null : col._attributes['sortcategorize'];	this.format = (!col._attributes['format']) ? null : col._attributes['format'];	this.twistie =(!col._attributes['twistie']) ? null : col._attributes['twistie'];	this.response = (!col._attributes['response']) ? null : col._attributes['response'];	this.icon = (!col._attributes['icon']) ? false : col._attributes['icon'];		this.align = (!col._attributes['align']) ? "" : col._attributes['align'];	this.styleAlign = (this.align=="1") ? "right" : (this.align=="2") ? "center" : "left";	this.sortImg = null;	this.textFont = 	{fontSize:col.cfont[0]._attributes['size']+'pt',							color:col.cfont[0]._attributes['color'],							fontFamily:col.cfont[0]._attributes['face'],							fontWeight:(col.cfont[0]._attributes['style'].indexOf('b')!=-1)?"bold":"normal",							fontStyle:(col.cfont[0]._attributes['style'].indexOf('i')!=-1)?"italic":"normal"};	this.headFont = 	{fontSize:col.hfont[0]._attributes['size']+'pt',							color:col.hfont[0]._attributes['color'],							fontFamily:col.hfont[0]._attributes['face'],							fontWeight:(col.hfont[0]._attributes['style'].indexOf('b')!=-1)?"bold":"normal",							fontStyle:(col.hfont[0]._attributes['style'].indexOf('i')!=-1)?"italic":"normal"};}