	<!--
		// Function which receives the arguments gotoPage and totalPages and 
		// uses their values to determine which page DIVs to hide and which to display
		var switchResults = function(gotoPage, totalPages) {
			
			for (i = 1; i < (totalPages + 1); i++) {
					
				// "Fix" the fact that the iterator runs one too many times (as it starts
				// at 1 instead of 0) and stop the following code from executing when it reaches
				// iterations which exceed the value of totalPages
				if (i <= totalPages) {
					// If the current index number's value is equal to the value of gotoPage, display that
					// page's DIV, otherwise, hide that page's DIV
					if (i == gotoPage) {
						document.getElementById('page' + i).className = 'showDiv';
					} else {
						document.getElementById('page' + i).className = 'hideDiv';
					}
				}
			}
		}
		
		// Function which retrieves the total number of results from the JSON output and
		// displays this in the associated DIV
		var showTotalResults = function(total) {
			if(total.iResults > 25) 
			{
				var totalRes = new Element('span', {
					'styles': {
						'font-style': 'italic'
					}
				}).setHTML('Er zijn 25 resultaten gevonden:<br />');
			}
			else
			{
				var totalRes = new Element('span', {
					'styles': {
						'font-style': 'italic'
					}
				}).setHTML('Er zijn ' + total.iResults + ' resultaten gevonden:<br />');				
			}
			totalRes.inject(document.getElementById('aantalres'));
		}
		
		// Function which retrieves all of the results contained in the JSON output and 
		// formats them for proper display on the page
		var showResults = function(results, sysInfo) {
			
			// Determine how many pages of results there are, by checking if 
			// the total number of results divided by the limit of results per 
			// page is a whole number or not
			if (sysInfo.iResults % 5 == 0) {
				var iTotalPages = sysInfo.iResults / 5;
			} else {
				var iTotalPages = Math.floor((sysInfo.iResults / 5) + 1);
			}
			if (iTotalPages > 5) iTotalPages = 5;
			
			// Initialize array to hold all of the result indici, enabling
			// the results to be called using the iterator index instead of 
			// not being able to iterate properly due to the irregular numbering
			testArray = new Array();
			
			// Iterate through the result objects held in "results" and
			// add each one to the array "testArray" for referencing later
			for (var i in results) {
				testArray.push(i);
			}
			
			// Initialize and set a counter variable for the pages
			var iCnt = 0;
			
			// Iterate through the number of "pages" generated and
			// execute the following code for each one
			for (k = 1; k < (iTotalPages + 1); k++) {

				// Create the DIVs which will represent each page and set the first page 
				// DIV to display upon loading the web page, hiding the rest
				if (iCnt == 0) {
					var page = new Element('div', {'id': 'page' + (iCnt + 1)});
					//document.write('new Element("div", {"id": "page' + (iCnt + 1) + '"})');
				} else {
					var page = new Element('div', {'id': 'page' + (iCnt + 1), 'class': 'hideDiv'});
				}

				// Insert each new page DIV into the main results DIV
				page.inject(document.getElementById('results'));

				// Initialize and set a counter variable for the results
				iCnt2 = 0;

				// Initialize and set the variable kk to "fix" the fact that this iteration doesn't
				// start at zero but at one, enabling use of the result stored in index 0 of the array
				kk = k - 1;

				// Iterate through the objects which are child nodes of the 
				// "results" node in the JSON output, stored in the array testArray
				// **********
				// i = (kk * 5) >>>> this will equal 0, 5, 10, 15, ...
				// i < ((kk + 1) * 5) >>>> this will equal 5, 10, 15, 20, ...
				for (i = (kk * 5); i < ((kk + 1) * 5); i++) {
					
					// "Fix" the fact that the iterator runs one too many times and stop the following code 
					// from executing when it reaches iterations which exceed the length of testArray
					if (i < testArray.length) {
						
						// Truncate "title" and the "category" strings if they're too long
						if (results[testArray[i]].title.length > 34) {
							results[testArray[i]].title = results[testArray[i]].title.substring(0, 34) + "...";
						}
						if (results[testArray[i]].subcategory.length > 13) {
							results[testArray[i]].subcategory = results[testArray[i]].subcategory.substring(0, 13) + "...";
						}

						// If the current page is 1, set the current result to result variable plus 1,
						// the first result to 1 and the last result to 5
						// **********
						// Otherwise, the following occurs:
						// ((iCnt2 + 1) + (k * 5)) >>>> this will equal to any number above 5
						// (k * 5) + 1 >>>> this will equal to adding 5 to the previous number each time
						// iFirst + 4 >>>> this will equal to the current first result plus 4
						if (k == 1) {
							var iCurr = (iCnt2 + 1);
							var iFirst = 1;
							var iLast = 5;
						} else {
							var iCurr = ((iCnt2 + 1) + (k * 5));
							var iFirst = (k * 5) + 1;
							var iLast = iFirst + 4;
						}

						// If iCurr's value isn't between the first and last result 
						// for the current page, don't create a DIV for this result
						if ((iCurr >= iFirst) && (iCurr <= iLast)) {
							var el = new Element('div', {'id': 'res' + (i + 1)}).injectInside(document.getElementById('page' + (iCnt + 1)));
							var dots = new Element('div', {'class': 'dots'}).injectInside(el);
							var img = new Element('img', {
								'src': results[testArray[i]].icon,
								'styles': {
									'float': 'right'
								}
							}).injectAfter(dots); 
							var link = new Element('a', {'href': 'stadskaart.html?deep=' + results[testArray[i]].mapURL}).injectAfter(img);

							// Use of the function appendChild which inserts text inside a hyperlink element
							link.appendChild(document.createTextNode(results[testArray[i]].title));

							var cat = new Element('span', {
								'id': 'catRes' + i,
								'styles': {
									'color': '#' + results[testArray[i]].colorcategory, 
									'font-size': '90%'
								}
							}).setHTML('<br />' + results[testArray[i]].category + ' &raquo; ' + results[testArray[i]].subcategory + '<br />').injectAfter(link);
							var desc = new Element('span').setHTML(results[testArray[i]].description + '<br />').injectAfter(cat);

							iCnt2++;
						}
					}
				}
				iCnt++;
			}

			pageLink = new Array();
			menuSpace = new Array();
			var pageMenu = new Element('div');
			
			// Iterate through the total number of pages, creating a hyperlink
			// for each page and add each one in behind the previous one
			for (n = 1; n < (iTotalPages + 1); n++) {
				if (n == 1) {
					var menuText = new Element('span').setHTML('Pagina: ').injectInside(pageMenu);
					//pageLink[n] = new Element('a', {'href': 'javascript:void(0);', 'onclick': 'switchResults("' + n + '", "' + iTotalPages + '")'}).injectAfter(menuText);
					pageLink[n] = new Element('a', {
						'href': 'javascript: switchResults('+n+', '+iTotalPages+');'
					});
					pageLink[n].injectAfter(menuText);
				} else {
					//pageLink[n] = new Element('a', {'href': 'javascript:void(0);', 'onclick': 'switchResults("' + n + '", "' + iTotalPages + '")'}).injectAfter(menuSpace[n-1]);
					pageLink[n] = new Element('a', {
						'href': 'javascript: switchResults('+n+', '+iTotalPages+');'
					});
					pageLink[n].injectAfter(menuSpace[n-1]);
				}
				menuSpace[n] = new Element('span').setHTML('&nbsp;').injectAfter(pageLink[n]);
				pageLink[n].appendChild(document.createTextNode(n));
			}
			pageMenu.inject(document.getElementById('pages'));
		}

		// Function which retrieves the error returned by the search page
		// in the JSON output and displays the cause of the error
		var showError = function(error) {
			var cause = new Element('span').setHTML(error.description);
			cause.inject(document.getElementById('aantalres'));
		}

		// After all of the page's elements are available, execute this
		// function which loads in the JSON output from an external page

	//-->
