
	/* Info Search Class */
	
	function InfoPointSearch() { // Class
	
		// Private storage
		var containerDiv;
		
		// Public functions
		this.SetContainer = SetDivContainer;
		this.SearchAtPoint = FetchInfoData;
		
		// Get the name of the Div container in which the results will be written into
		function SetDivContainer( container ) {
			containerDiv = container;
		}
	
		// Do a Info Point Search
		function FetchInfoData( mouseX, mouseY ) {

			var xmlDoc;
			
			if (document.implementation && document.implementation.createDocument) {
				xmlDoc = document.implementation.createDocument("", "", null);
			}
			else if (window.ActiveXObject) {
				xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			}
			
			var sURL = "http://" + Domain  + "/" + Virtual;
			sURL += "/dialogbox_InfoPointViewer.asp?infomode=xml&theme=" + theme + "&easting=" + Easting + "&northing=" + Northing + "&pixelx=" + mouseX + "&pixely=" + mouseY + "&MapWidth=" + Zoom + "&imagewidth=" + MapWidth + "&imageheight=" + MapHeight;
			
			// Excluded the unvisible layers
			sURL += "&layers=" + ReturnExcludedLayers();
			
			xmlDoc.async = false; // Tell the Xml document to wait until the document has been complete read
			xmlDoc.load( sURL );
			
			createInfoTable(xmlDoc);
			
			xmlDoc = null;
			
		}

		// Populate the results into the set container
		function createInfoTable(xmlDoc) {
	
			var sHTML = "";
			var x = 0;
			var l = 0;

			rootNode = xmlDoc.documentElement;

			// Only if there are info records
			if ( rootNode.childNodes.length > 0 ) {
				
				sHTML = "";

				if ( rootNode.nodeName.toLowerCase() == "planaccesserror" ) {
					if (BrowserName == "Netscape") {
						sHTML = rootNode.childNodes.item(0).childNodes.item(1).firstChild.nodeValue;
					} else {
						sHTML = rootNode.childNodes.item(0).childNodes.item(1).text;
					}
				} else {

					for ( x = 0; x < rootNode.childNodes.length; x++ ) {

						// Get the number of columns in the XML document
						var dataRows = rootNode.childNodes.item(x).childNodes.item(0).childNodes.length;

						sHTML += "<p><table border=\"1\" bordercolor=\"#ffffff\" style=\"border:1pt solid #9EBFE0;\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";

						// Insert the header to the table
						sHTML += "<tr>";
						sHTML += "<td width=\"10%\">" + rootNode.childNodes.item(x).getAttribute("Name") + "</td>";
						sHTML += "<td width=\"90%\" colspan=" + dataRows + ">&nbsp;</td>";
						sHTML += "</tr>";

						for ( f = 0; f < rootNode.childNodes.item(x).childNodes.length; f++ ) {
							
							sHTML += "<tr>";
							
							var LayerNode = rootNode.childNodes.item(x).childNodes.item(0).childNodes.item(l)

							if ( l == 0 ) {

								// Check the child node has data associated with it
								for ( ll = 0; ll < dataRows; ll++ ) {
									sHTML += "<td bgcolor=\"#9EBFE0\" width='" + Math.round(100 / dataRows) + "%'>" + rootNode.childNodes.item(x).childNodes.item(0).childNodes.item(ll).nodeName + "</td>";
								}

								sHTML += "</tr><tr>";

							}
								
							var dataRows = rootNode.childNodes.item(x).childNodes.item(f).childNodes.length;
							
							// Loop around all the fields in the feature
							for ( l = 0; l < dataRows; l++ ) {

								

								// Capture the field info
								if (BrowserName == "Netscape") {
								
									if ( rootNode.childNodes.item(x).childNodes.item(0).childNodes.item(l).childNodes.length == 1 ) {
										var LayerText = rootNode.childNodes.item(x).childNodes.item(0).childNodes.item(l).firstChild.nodeValue;
									} else {
										var LayerText = "&nbsp;";
									}

								} else {  // Internet Explorer

									var LayerText = rootNode.childNodes.item(x).childNodes.item(0).childNodes.item(l).text;

								}

								if ( LayerText.substring(0,5) == 'http:' ) {
									sHTML += "<td bgcolor=\"#9EBFE0\" width='" + Math.round(100 / dataRows) + "%'><a href='" + LayerText + "' target='_blank'><img src='images/paweb.gif' title='" + LayerText + "'></a></td>";
								} else if ( LayerText.substring(0,5) == 'https:' ) {
									sHTML += "<td bgcolor=\"#9EBFE0\" width='" + Math.round(100 / dataRows) + "%'><a href='" + LayerText + "' target='_blank'><img src='images/paweb.gif' title='" + LayerText + "'></a></td>";
								} else if ( LayerText.substring(0,5) == 'mailto:' ) {
									sHTML += "<td bgcolor=\"#9EBFE0\" width='" + Math.round(100 / dataRows) + "%'><a href='" + LayerText + "' target='_blank'><img src='images/pamail.gif' title='" + LayerText + "'></a></td>";
								} else {
									sHTML += "<td bgcolor=\"#9EBFE0\" width='" + Math.round(100 / dataRows) + "%'>" + LayerText + "</td>"
								}

							} // End For
						
							sHTML += "</tr>";
							
						} // End For
						
						
						sHTML += "</table></p>";

					}  // End for

				}

				containerDiv.innerHTML = sHTML;

			} // End If		

		}
	
	}
