
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}

var http = getXMLHTTPRequest();

<!-- this function not used 2008 -->
function getData(someVarID) {
  var myurl = 'queryCode.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&refnum="+someVarID;
  http.open("GET", modurl, true);
  http.onreadystatechange = useHttpResponse;
  http.send(null);

}
<!-- this function not used 2008 -->
function useHttpResponse() {
   if (http.readyState == 4) {
    if(http.status == 200) {	
	 document.getElementById('responsediv').innerHTML = "<a href='javascript:hideInfoDiv()'>Show Map</a><br><br>"+http.responseText;	   
    }
  } else {
    document.getElementById('responsediv').innerHTML = 'Loading...';
  }
}

// GLOBALS
var catValue="#";
var catValue2="#";
var catValue3="#";
var catValue4="#";

// this is always the exact number of markers present in the system
var markerNumber=0;

// this is the number of items in any search array generated
var numInSearch=0;
var searchArray=new Array();

function prepareSearch(){
document.getElementById('catsdiv').style.visibility="hidden";
document.getElementById('searchDiv').style.visibility="visible";

// recentre on main area?
//document.getElementById('locationSelector').selectedIndex=0;
//map.setCenter(new GLatLng(52.220000, 0.975659), 8);

document.getElementById("cat21").selectedIndex=0;
document.getElementById("cat22").selectedIndex=0;
document.getElementById("cat23").selectedIndex=0;
document.getElementById("cat24").selectedIndex=0;
document.getElementById("cat3").selectedIndex=0;

// hide any infodiv
document.getElementById('responsediv').style.visibility="hidden";	


// hide of any existing markers
for (var Ai=1; Ai < numOfArrays; Ai++)
	 {
	// cycle all arrays in turn
	 var_name="thisArray";	 
	 eval (var_name+"=gArray"+Ai);		 
	 //window.alert(numOfArrays+" - "+thisArray);
	 // NEED TO SEE IF THIS CAT IS CURRENTLY ALIVE
	  // NOTE: it must be loaded if it is visible!
	 showStatus=thisArray[0][1];
	 if(showStatus==1)
	 	{
		var thisCBox="mType"+Ai;	
		document.getElementById(thisCBox).checked=false;
		
		// window.alert("ARRAY: "+thisArray);					
			for (var i=1; i < thisArray.length; i++)
			{			
			markerNum=thisArray[i][5];
			gmarkers[markerNum].hide();
			thisArray[0][1]=0;			
			//window.alert(checkString+" - "+markerNum);
			}
		}
	// we now have all markers turned off
	 }
	 
}

function doSearch(){
var searchterm=document.getElementById('searchBox').value;
// do not search for silly short strings
if(searchterm.length>2)
	{	
	// get rid of any existing search-generated markers	
	var startPoint=markerNumber-numInSearch;	
	// TEST
	//window.alert(markerNumber+" s"+numInSearch+" start"+startPoint);
		
	var deletedMarkers=0;
	// this will not remove anything if numInSearch is zero	
	for(i=markerNumber; i>startPoint; i--)
		{
		map.removeOverlay(gmarkers[i-1]);
		gmarkers.pop();
		deletedMarkers++;
		// TEST
		//window.alert(deletedMarkers);
		}
			
	markerNumber=markerNumber-deletedMarkers;
	//window.alert(markerNumber);
	numInSearch=0;
		
	document.getElementById('searchFrame').src="searchCode.php?searchterm="+searchterm;
	}
else
	{
	window.alert("Your searchterm must consist of at least 3 characters...");
	}
}

// temp function
function showSearch()
{

   function addSearchMarker(title, lng, lat, itemID, groupNum, thisArray, numInArray) {
   var point = new GLatLng(lng, lat);
   var icon = new GIcon(icon);
 	icon.image = "images/"+groupNum+".png";
	icon.iconSize = new GSize(10, 10);
	icon.iconAnchor = new GPoint(5, 5);
	icon.infoWindowAnchor = new GPoint(5, 1);
   var marker = new GMarker(point, icon);
   gmarkers.push(marker);
   marker.type = groupNum;
   
   //assign the marker array num to the main array
   thisArray[numInArray][5]=markerNumber;
   markerNumber++;
   
   GEvent.addListener(marker, "click", function () {
	  var text = "<div class=\"itemtext\"><div align=\"center\">"+title+"<br><br><a href='javascript:showInfoDiv("+itemID+")'>Contact Information</a></div></div>";
	  //var infoTabs = [
  //				new GInfoWindowTab("Office", text),
  //				new GInfoWindowTab("Address", "any old address"),
//				new GInfoWindowTab("Layer Demo", "<a href='javascript:showInfoDiv()'>Show Info</a>")
//					];
	  // use single marker
      marker.openInfoWindowHtml(text);
	  
	  // use multi-tab marker
	  //marker.openInfoWindowTabsHtml(infoTabs);	  
   }
   );
   
   map.addOverlay(marker); 
}   
   
	var searchTotal=searchArray.length;
	//window.alert("THIS FUNCTION WILL BE IMPLEMENTED SHORTLY : "+searchTotal+" M"+markerNumber);
	
	for(i=1; i<searchTotal; i++)
	{
	addSearchMarker(searchArray[i][0],searchArray[i][1],searchArray[i][2],searchArray[i][3],searchArray[i][4],searchArray,i);	 
	}
}



function releaseSearch(){
document.getElementById('searchDiv').style.visibility="hidden";
document.getElementById('catsdiv').style.visibility="visible";
// get rid of any existing search-generated markers
	var startPoint=markerNumber-numInSearch;	
	// TEST
	//window.alert(markerNumber+" s"+numInSearch+" start"+startPoint);
		
	var deletedMarkers=0;
	// this will not remove anything if numInSearch is zero	
	for(i=markerNumber; i>startPoint; i--)
		{
		map.removeOverlay(gmarkers[i-1]);
		gmarkers.pop();
		deletedMarkers++;
		// TEST
		//window.alert(deletedMarkers);
		}
			
	markerNumber=markerNumber-deletedMarkers;
	//window.alert(markerNumber);
	searchArray.length=0;
	numInSearch=0;
}



function showInfoDiv(someVarID){
doInfo=document.getElementById('responsediv');
doInfo.style.visibility="visible";
document.getElementById('infoFrame').src='showinfo.php?refnum='+someVarID+'&z=z';
}

function hideInfoDiv(){
doInfo=document.getElementById('responsediv');
doInfo.style.visibility="hidden";
}

function showDiv(divID){
doInfo=document.getElementById(divID);
if(doInfo.style.visibility=="visible")
	{doInfo.style.visibility="hidden"}
else{doInfo.style.visibility="visible"}
}

function doLocations(){
var newIndex = document.getElementById('locationSelector').selectedIndex;
var newValue = document.getElementById('locationSelector').options[newIndex].value;
LocActionArray=newValue.split("#");
newX=eval(LocActionArray[0]);
newY=eval(LocActionArray[1]);
newZoom=eval(LocActionArray[2]);
map.setCenter(new GLatLng(newX, newY), newZoom);
}

// START OF GOOGLE CODE

var gmarkers=[];
var map;


// EITHER hard code a viewport here or take out the values and let the data decide
var centreLeft=52.220000;
var centreRight=0.975659;
var startZoomLevel = 8;

if(!centreLeft && !centreRight)
{
// get the initial centre of the map
var minLeft=999999; var maxLeft=0; var minRight=999999; var maxRight=0;
	for (var i=1; i < gArray1.length; i++)
	 {	         
     var Left = gArray1[i][1];
	 if(Left<minLeft){minLeft=Left;}
	 if(Left>maxLeft){maxLeft=Left;}
	 var Right = gArray1[i][2];
	 if(Right<minRight){minRight=Right;}
	 if(Right>maxRight){maxRight=Right;}
      }
	 centreLeft=minLeft+((maxLeft-minLeft)/2);
	 centreRight=minRight+((maxRight-minRight)/2);
}
// *******************************************************************8	  

function switchMarkers(thisType)
{
map.closeInfoWindow();	

var thisCBox="mType"+thisType;
var newValue = document.getElementById(thisCBox).checked;

var_name="thisArray";	 
eval (var_name+"=gArray"+thisType);	

eval(loadedStatus=thisArray[0][0]);

//window.alert(thisArray+" L-"+loadedStatus);

if(loadedStatus==0)
{
//window.alert(loadedStatus);
//divLoader=document.getElementById('catsDivLoader');
//divLoader.style.visibility="visible";
}

   for (var i=1; i<thisArray.length; i++)
    {	
	markerNum=thisArray[i][5];
	//window.alert(markerNum+" - "+loadedStatus);
	// IF DATASET NOT YET LOADED, LOAD IT
	if(loadedStatus==0)
		{		
		// this does the one-off load + makes it visible
		map.addOverlay(gmarkers[markerNum]);
		// inform control vars of status
		//THIS ONE MEANS LOADED
		thisArray[0][0]=1;
		//THIS ONE MEANS DISPLAYED
		thisArray[0][1]=1;		
		}
	else
	// data is ALREADY loaded, do normal show/hide stuff!
		{
	
		 if(newValue) 
				{
				thisArray[0][1]=1;
			    gmarkers[markerNum].show();
				}
		  else
			   {
			   gmarkers[markerNum].hide();
			   thisArray[0][1]=0;
			   }
		}
	}
	
	//switchCat2();
	//document.getElementById('catsDivLoader').style.visibility="hidden";
}


function switchCat2()
{
	
// CALLED WHEN USER MAKES A SELECTION IN THE CAT2 FILTERS
//window.alert(thisCat2);
map.closeInfoWindow();

// its different if there is a search in progress!
if(numInSearch>0)
	{
	//window.alert("Search in progress...");	
			
			for(i=1; i<numInSearch; i++)
			{
			checkString=searchArray[i][6];
			filter1String=searchArray[i][7];			
			markerNum=searchArray[i][5];
			displayMe=1;			
			//window.alert(checkString+" - "+markerNum);
			//GET ROLE			
								
			
			// filtering *************************************
			if (displayMe==1
				&& filter1String.indexOf(filter1Value) > -1)	  
					  { }
			  
		   else
			  {
			  displayMe=0;
			  gmarkers[markerNum].hide();
			  }
			// **********************************************8						
										 
	 		if(displayMe==1)
				{
				gmarkers[markerNum].show();
				}
			}



	}


else
	{

//window.alert(catValue+" - "+catValue2+" - "+catValue3+" - "+catValue4);

// NOW THOSE GLOBAL VARS HAVE THE CORRECT VALUES
for (var Ai=1; Ai < numOfArrays; Ai++)
	 {
	// cycle all arrays in turn
	 var_name="thisArray";	 
	 eval (var_name+"=gArray"+Ai);		 
	 //window.alert(numOfArrays+" - "+thisArray);
	 // NEED TO SEE IF THIS CAT IS CURRENTLY ALIVE
	  // NOTE: it must be loaded if it is visible!
	 showStatus=thisArray[0][1];
	 if(showStatus==1)
	 	{
		// window.alert("ARRAY: "+thisArray);					
			for (var i=1; i < thisArray.length; i++)
			{
			// which bit of the array is this?
			checkString=thisArray[i][6];
			filter1String=thisArray[i][7];
			
			markerNum=thisArray[i][5];
			displayMe=1;			
			//window.alert(checkString+" - "+markerNum);
			
			

			
			// filtering *************************************
			if (displayMe==1
				&& filter1String.indexOf(filter1Value) > -1)	  
					  { }
			  
		   else
			  {
			  displayMe=0;
			  gmarkers[markerNum].hide();
			  }
			// **********************************************8						
					
														 
					 
	 		if(displayMe==1)
				{
				gmarkers[markerNum].show();
				}
		    } // end of cycle individual array
		   
		} // end of DISPLAYED=1
	 
	
	 } // end of cycle all arrays

	//document.getElementById('catsDivLoader').style.visibility="hidden";
	
	}// end else - not a search
}

function analyseMap()
{
theseBounds=map.getBounds();
nePoint=theseBounds.getNorthEast();
sePoint=theseBounds.getSouthWest();

maxlon=nePoint.lng();
minlon=sePoint.lng();
maxlat=nePoint.lat();
minlat=sePoint.lat();

//window.alert(minlon+"-"+maxlon+" "+minlat+"-"+maxlat);

document.getElementById('responsediv').style.visibility="visible";
document.getElementById('infoFrame').src="analyse.php?minlon="+minlon+"&maxlon="+maxlon+"&minlat="+minlat+"&maxlat="+maxlat;
}



    //<![CDATA[

  function load()
  {
      if (GBrowserIsCompatible())
	   {
	   
// **********************************************************

// *****************************************************************************************************************
	  	  	  
        map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());		
        map.setCenter(new GLatLng(centreLeft, centreRight), startZoomLevel);
		
		

   function addMarker(title, lng, lat, itemID, groupNum, thisArray, numInArray) {
   var point = new GLatLng(lng, lat);
   var icon = new GIcon(icon);
 	icon.image = "images/"+groupNum+".png";
	icon.iconSize = new GSize(10, 10);
	icon.iconAnchor = new GPoint(5, 5);
	icon.infoWindowAnchor = new GPoint(5, 1);
   var marker = new GMarker(point, icon);
   gmarkers.push(marker);
   marker.type = groupNum;
   
   //assign the marker array num to the main array
   thisArray[numInArray][5]=markerNumber;
   markerNumber++;
   
   GEvent.addListener(marker, "click", function () {
      // FF 1.5 fix
	  var text = "<div class=\"itemtext\"><div align=\"center\">"+title+"<br><br><a href='javascript:showInfoDiv("+itemID+")'>Contact Information</a></div></div>";
	  //var infoTabs = [
  //				new GInfoWindowTab("Office", text),
  //				new GInfoWindowTab("Address", "any old address"),
//				new GInfoWindowTab("Layer Demo", "<a href='javascript:showInfoDiv()'>Show Info</a>")
//					];
	  // use single marker
      marker.openInfoWindowHtml(text);
	  
	  // use multi-tab marker
	  //marker.openInfoWindowTabsHtml(infoTabs);
	  
   }
   );
   
   //map.addOverlay(marker); 
   //marker.hide();
   
}



	for (var Ai=1; Ai < numOfArrays; Ai++)
	 {		 
	 var_name="thisArray";	 
	 eval (var_name+"=gArray"+Ai);		 
	 //window.alert(numOfArrays+" - "+thisArray);	
	  
	 for (var i=1; i < thisArray.length; i++)
		 { 
		 len=thisArray.length;
		// window.alert(len);	
		 
		  addMarker(thisArray[i][0],thisArray[i][1],thisArray[i][2],thisArray[i][3],thisArray[i][4],thisArray,i);	  
		  }
     
      }

// ******************************************************************************************************************		
	  
	  }
else {alert("Sorry, the Google Maps API is not compatible with this browser");}
    }
    //]]>
	
