
	/* 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 {


					if (BrowserName == "Netscape") {
						
					for ( x = 0; x < rootNode.childNodes.length; x++ ) 
					{
						
						sHTML += "<table style=\"border:1pt solid #eeeeee;\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
						// Insert the header (layerdoc name) to the table
						sHTML += "<tr>";				
						var docHeader = rootNode.childNodes.item(x).getAttribute("Name");
						if(docHeader == "BLP1999") 
						{ docHeader = "Borough Local Plan (1999)"; 	}	
						else if (docHeader == "CSSubmit")
						{ docHeader == "Core Strategy (Submission)" }
						else if (docHeader == "CSAdoption")
						{ docHeader == "Core Strategy (Adoption)" }												
						else if (docHeader == "HousingAllocationsDPDpreferred")
						{ docHeader = "Housing Allocations DPD (Preferred Options)"; }
						else if (docHeader == "HousingAllocationsDPDSubmission")
						{ docHeader = "Housing Allocations DPD (Submission)";	}						
						else if (docHeader == "Housing AllocationDPDAdoption")
						{ docHeader = "Housing Allocations DPD (Adoption)";	}
						else if (docHeader == "CEEDPDOptions")
						{ docHeader = "Community, Environment And Economy DPD (Options)";	}						
						else if (docHeader == "CEEDPDSubmission")
						{ docHeader = "Community, Environment And Economy DPD (Submission)";	}	
						else if (docHeader == "CEEDPDAdoption")
						{ docHeader = "Community, Environment And Economy DPD (Adoption)";	}
						else if (docHeader == "OtherRelevantDes")
						{ docHeader = "Other Relevant Designations";	}
						else if (docHeader == "Grid_10K")
						{ docHeader = "Grid Navigator";	}
						else if (docHeader == "Districts")
						{ docHeader = "Districts - UD";	}						
						else
						{ docHeader = "Undefined - UD"; }
							
						
						sHTML += "<td width=\"98%\"><span class=\"bold\">" + docHeader + "</span>";

						// ie= rootNode.childNodes.item(0).childNodes.item(0).childNodes.item(0).firstChild.nodeValue;
						for ( f = 0; f < rootNode.childNodes.item(x).childNodes.length; f++ )
						{
							
						  if(docHeader != "Grid Navigator")
						  {
							var tProjectId = "";
							tProjectId = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(0).firstChild.nodeValue;
							var tSectionId = "";
							tSectionId = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(1).firstChild.nodeValue;
							var tContentId = "";
							tContentId = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(2).firstChild.nodeValue;
							var tDbRetUrl =  "" ;
							var tNoUrl = "";
							if(((tProjectId == "") && (tSectionId == "") && (tContentId == "")))
							{ tNoUrl = "none";	}
							else 
							{  tNoUrl = "in";	}
							
							var tFPUrl = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(3).firstChild.nodeValue;						
							var tFPUrl2 = "";
							if (( tFPUrl.substring(0,12) != 'http://scarb' ) && (tNoUrl == "in"))
							{
								tFPUrl2 = "<a href='" + tFPUrl + "' target='_blank'>View Related Website</a>";

							}
							else if (( tFPUrl.substring(0,5) == 'http:' ) && (tNoUrl == "in"))
							{
								tFPUrl2 = "<a href='" + tFPUrl + "pointId=" + tSectionId + "#" + tContentId + "' target='_blank'>View More Information</a>";

							}
							else if (( tFPUrl.substring(0,5) == 'http:' ) && (tNoUrl == "none"))
							{
								tFPUrl2 = "<a href='" + tFPUrl + "' target='_blank'>View Related Website</a>";
							}
							else
							{
								tFPUrl2 = "None";
							}
	
							var tFPImNo = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(4).firstChild.nodeValue;
							tFPImNo2 = "images/key-items/" + tFPImNo + ".gif";
							var tFPDescription = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(5).firstChild.nodeValue;
							var tFPName = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(6).firstChild.nodeValue;			
							if(tFPDescription.search(/Proposed Housing Site/i) != -1)
							{
								var tChkColor = "ldftableblu";
								var tTrChkColor = "trAltBlu";
							}
							else if(tFPDescription.search(/Allocated Site/i) != -1)
							{
								var tChkColor = "ldftablegrn";
								var tTrChkColor = "trAltGrn";
							}
							else if(tFPDescription.search(/Dismissed Site/i) != -1)
							{
								var tChkColor = "ldftablered";
								var tTrChkColor = "trAltRed";
							}				
							else { var tChkColor = "ldftable"; var tTrChkColor = "trAlt";  }
							
							var tFPInfoText = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(7).firstChild.nodeValue;
							var tFPSiteRef = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(8).firstChild.nodeValue;
							if (tFPSiteRef == "")
							{
								tFPSiteRef = "None";
							}

							sHTML += "<table class=" + tChkColor + ">"; 			
							sHTML += "<tr class=" + tTrChkColor + ">";
							sHTML += "<td width=\"100%\" colspan=\"4\"><img src='"+tFPImNo2+"' alt='" + tFPDescription + "' /> " + tFPDescription;
							sHTML += "</tr>";			
							sHTML += "<tr class=\"trldf\">";
							sHTML += "<td width=\"27%\">Designation</td><td width=\"26%\">Site Id / Policy Ref</td><td width=\"26%\">Additional Info</td><td width=\"18%\">Website link</td>" ;
							sHTML += "</tr>";
							sHTML += "<tr>";
							sHTML += "<td>" + tFPName + "</td><td>" + tFPSiteRef + "</td><td>" + tFPInfoText + "</td><td>" + tFPUrl2 + "</td>" ;
							sHTML += "</tr></table>";

						  }
						  else
						  {
							  
						if (Zoom > 50000)
						{
							var tGridKeyImage =  "";
							tGridKeyImage = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(5).firstChild.nodeValue;
							tGridKeyImage2 = "images/key-items/" + tGridKeyImage + ".gif";							
							var tGridItem = "";
							tGridItem = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(5).firstChild.nodeValue;
							tGIUrl = "";
							tGIUrl = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(3).firstChild.nodeValue;
							tGIUrl2 = "<a href='" + tGIUrl + "' target='_parent'>center on Map Grid " +tGridItem+"</a>";

							sHTML += "<table class=" + tChkColor + ">"; 			
							sHTML += "<tr class=" + tTrChkColor + ">";
							sHTML += "<td width=\"100%\" colspan=\"4\"><img src='"+tGridKeyImage2+"' /> " + "Redraw the page to: " +  tGIUrl2;
							sHTML += "</tr>";			
							sHTML += "</table>";							  
			  						  
						    sHTML += "<br /><span class=\"uline\" onClick=\"javascript:ZoomExtents()\">Show the full map</span>";
						}
						else
						{
							   sHTML += "<br /><span class=\"uline\" onClick=\"javascript:ZoomExtents()\">Show the full map</span>";
						}
								
						  }						  
						}			
						sHTML += "</td></tr><br />";
					}
					sHTML += "</tr></table>";

				//	}  // End for	
				

				QueryTitle.innerHTML = "Information and links for the point you selected:";
			    largemenu('QueryDivHolder');
				containerDiv.innerHTML = sHTML;
					
    		//} // End If	
		//} // this closes the if deciding if all the func is in IE or Netscape	

























					}
					else
					{




					for ( x = 0; x < rootNode.childNodes.length; x++ ) 
					{
						
						sHTML += "<table style=\"border:1pt solid #eeeeee;\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";

						// Insert the header (layerdoc name) to the table
						sHTML += "<tr>";
						var docHeader = rootNode.childNodes.item(x).getAttribute("Name");
						// alert(docHeader);
						if(docHeader == "BLP1999") 
						{ docHeader = "Borough Local Plan (1999)"; 	}
						
						else if (docHeader == "CSSubmit")
						{ docHeader == "Core Strategy (Submission)" }
						else if (docHeader == "CSAdoption")
						{ docHeader == "Core Strategy (Adoption)" }						
						
						else if (docHeader == "HousingAllocationsDPDpreferred")
						{ docHeader = "Housing Allocations DPD (Preferred Options)"; }
						else if (docHeader == "HousingAllocationsDPDSubmission")
						{ docHeader = "Housing Allocations DPD (Submission)";	}						
						else if (docHeader == "Housing AllocationDPDAdoption")
						{ docHeader = "Housing Allocations DPD (Adoption)";	}
						else if (docHeader == "CEEDPDOptions")
						{ docHeader = "Community, Environment And Economy DPD (Options)";	}						
						else if (docHeader == "CEEDPDSubmission")
						{ docHeader = "Community, Environment And Economy DPD (Submission)";	}	
						else if (docHeader == "CEEDPDAdoption")
						{ docHeader = "Community, Environment And Economy DPD (Adoption)";	}
						else if (docHeader == "OtherRelevantDes")
						{ docHeader = "Other Relevant Designations";	}
						else if (docHeader == "Grid_10K")
						{ docHeader = "Grid Navigator";	}
						else if (docHeader == "Districts")
						{ docHeader = "Districts - UD";	}						
						else
						{ docHeader = "Undefined - UD"; }
							
						
						sHTML += "<td width=\"98%\"><span class=\"bold\">" + docHeader + "</span>";


						for ( f = 0; f < rootNode.childNodes.item(x).childNodes.length; f++ )
						{
							
						  if(docHeader != "Grid Navigator")
						  {
							var tProjectId = "";
							tProjectId = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(0).text;
							var tSectionId = "";
							tSectionId = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(1).text;
							var tContentId = "";
							tContentId = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(2).text;
							var tDbRetUrl =  "" ;
							var tNoUrl = "";
							if(((tProjectId == "") && (tSectionId == "") && (tContentId == "")))
							{ tNoUrl = "none";	}
							else 
							{  tNoUrl = "in";	}
							
							var tFPUrl = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(3).text;						
							var tFPUrl2 = "";
							if (( tFPUrl.substring(0,12) != 'http://scarb' ) && (tNoUrl == "in"))
							{
								tFPUrl2 = "<a href='" + tFPUrl + "' target='_blank'>View Related Website</a>";

							}
							else if (( tFPUrl.substring(0,5) == 'http:' ) && (tNoUrl == "in"))
							{
								tFPUrl2 = "<a href='" + tFPUrl + "pointId=" + tSectionId + "#" + tContentId + "' target='_blank'>View More Information</a>";

							}
							else if (( tFPUrl.substring(0,5) == 'http:' ) && (tNoUrl == "none"))
							{
								tFPUrl2 = "<a href='" + tFPUrl + "' target='_blank'>View Related Website</a>";
							}
							else
							{
								tFPUrl2 = "None";
							}
	
							var tFPImNo = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(4).text;
							tFPImNo2 = "images/key-items/" + tFPImNo + ".gif";
							var tFPDescription = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(5).text;
							var tFPName = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(6).text;			
							if(tFPDescription.search(/Proposed Housing Site/i) != -1)
							{
								var tChkColor = "ldftableblu";
								var tTrChkColor = "trAltBlu";
							}
							else if(tFPDescription.search(/Allocated Site/i) != -1)
							{
								var tChkColor = "ldftablegrn";
								var tTrChkColor = "trAltGrn";
							}
							else if(tFPDescription.search(/Dismissed Site/i) != -1)
							{
								var tChkColor = "ldftablered";
								var tTrChkColor = "trAltRed";
							}				
							else { var tChkColor = "ldftable"; var tTrChkColor = "trAlt";  }
							
							var tFPInfoText = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(7).text;
							var tFPSiteRef = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(8).text;
							if (tFPSiteRef == "")
							{
								tFPSiteRef = "None";
							}

							sHTML += "<table class=" + tChkColor + ">"; 			
							sHTML += "<tr class=" + tTrChkColor + ">";
							sHTML += "<td width=\"100%\" colspan=\"4\"><img src='"+tFPImNo2+"' alt='" + tFPDescription + "' /> " + tFPDescription;
							sHTML += "</tr>";			
							sHTML += "<tr class=\"trldf\">";
							sHTML += "<td width=\"27%\">Designation</td><td width=\"26%\">Site Id / Policy Ref</td><td width=\"26%\">Additional Info</td><td width=\"18%\">Website link</td>" ;
							sHTML += "</tr>";
							sHTML += "<tr>";
							sHTML += "<td>" + tFPName + "</td><td>" + tFPSiteRef + "</td><td>" + tFPInfoText + "</td><td>" + tFPUrl2 + "</td>" ;
							sHTML += "</tr></table>";

						  }
						  else
						  {
							  
						if (Zoom > 50000)
						{
							var tGridKeyImage =  "";
							tGridKeyImage = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(5).text;
							tGridKeyImage2 = "images/key-items/" + tGridKeyImage + ".gif";							
							var tGridItem = "";
							tGridItem = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(5).text;
							tGIUrl = "";
							tGIUrl = rootNode.childNodes.item(x).childNodes.item(f).childNodes.item(3).text;
							tGIUrl2 = "<a href='" + tGIUrl + "' target='_parent'>center on Map Grid " +tGridItem+"</a>";

							sHTML += "<table class=" + tChkColor + ">"; 			
							sHTML += "<tr class=" + tTrChkColor + ">";
							sHTML += "<td width=\"100%\" colspan=\"4\"><img src='"+tGridKeyImage2+"' /> " + "Redraw the page to: " +  tGIUrl2;
							sHTML += "</tr>";			
							sHTML += "</table>";							  
			  						  
						    sHTML += "<br /><span class=\"uline\" onClick=\"javascript:ZoomExtents()\">Show the full map</span>";
						}
						else
						{
							   sHTML += "<br /><span class=\"uline\" onClick=\"javascript:ZoomExtents()\">Show the full map</span>";
						}
								
						  }						  
						}			
						sHTML += "</td></tr><br />";
					}
					sHTML += "</tr></table>";

					}  // End for	
				

				QueryTitle.innerHTML = "Information and links for the point you selected:";
			    largemenu('QueryDivHolder');
				containerDiv.innerHTML = sHTML;
					
    		} // End If	
		} // this closes the if deciding if all the func is in IE or Netscape				
		}
	}
