function showMarkers( showType, showKind, show, pict ) {
	var XMLfile = GXmlHttp.create();
	XMLfile.onreadystatechange = function() {
		if ( XMLfile.readyState == 4 ) {
			var xmlDoc = XMLfile.responseXML;
			var markers = xmlDoc.documentElement.getElementsByTagName( 'marker' );
			var points = xmlDoc.documentElement.getElementsByTagName( 'point' );
			var fullNames = xmlDoc.documentElement.getElementsByTagName( 'name' );
			var cities = xmlDoc.documentElement.getElementsByTagName( 'city' );
			var types = xmlDoc.documentElement.getElementsByTagName( 'type' );
			var kinds = xmlDoc.documentElement.getElementsByTagName( 'kind' );
			for ( var i = 0; i < markers.length; i++ ) {
				var markerType = "";if ( types[i].firstChild ) { markerType = types[i].firstChild.nodeValue; }
				var markerKind = "";if ( kinds[i].firstChild ) { markerKind = kinds[i].firstChild.nodeValue; }
				if ( showType == markerType && (showKind == markerKind || showKind == "") ) {
					var point = new GPoint( parseFloat( points[i].getAttribute( 'lon' ) ), parseFloat( points[i].getAttribute( 'lat' ) ) );
					var markerID = markers[i].getAttribute( 'ID' );
					var city = "";if ( cities[i].firstChild ) { city = cities[i].firstChild.nodeValue; }
					var markerHTML = "<div class=itemName>" + fullNames[i].firstChild.nodeValue + "</div><div class=itemCity>" + city + "</div><a class=moreInfoLink href='moreInfo.php?ID=" + markerID + "' target='popup' onClick='popUp(\"moreInfo.php?ID=" + markerID + "\")' onMouseOver='self.status=\"More info\";return true;'>More info</a>";					
					if (!show && showKind == "")	// Remove Markers
						map.removeOverlay( typeMarkerArr[i] );
					if (!show && showKind != "")	// Remove Markers
						map.removeOverlay( kindMarkerArr[i] );
					if (show)
					{		// Add Markers
						if (showKind == "") {				// if no kind is specified, show type icon
							var icon = new GIcon( baseIcon );
							icon.image = 'images/' + markerType + '.png';
							typeMarkerArr[i] = new GMarker( point, icon );
							addPopUp( typeMarkerArr[i], point, markerType, markerHTML );
							map.addOverlay( typeMarkerArr[i] );
						}
						else {								// if there is a kind, show kind icon
							var icon = new GIcon( kindIcon );
							icon.image = 'images/dots/' + pict + '.png';
							kindMarkerArr[i] = new GMarker( point, icon );
							addPopUp( kindMarkerArr[i], point, markerKind, markerHTML );
							map.addOverlay( kindMarkerArr[i] );
						}
 					}
				}
			}
		}
	}
	XMLfile.open( 'GET', 'getMapPoints.php', true );
	XMLfile.send(null);
}

// Add the marker listener
// This has to be in a separate function because of scoping
function addPopUp( marker, point, markerType, markerHTML ) {
	GEvent.addListener( marker, 'click', function(){ marker.openInfoWindowHtml( markerHTML ); showCircles( marker, point ); } );
}

// Geocoder: Pass an address to show on the map
function showAddress(address) {
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  alert(address + " not found");
		} else {
		  map.setCenter(point, 13);
		  var marker = new GMarker(point);
		  map.addOverlay(marker);
		  //marker.openInfoWindowHtml(address);
		}
	  }
	);
  }
}

// Add circles and refresh the table
function showCircles( marker, point ) {
  if ( point ) {

  	// Remove previous circles
	if (circle2) {
		map.removeOverlay( circle2 );
		map.removeOverlay( circle5 );
		map.removeOverlay( circle10 );
   	}
   	
  	var centerX = point.x;
    var centerY = point.y;
    // Get the circle vertices
		var pts2 = [];
    var pts5 = [];
    var pts10 = [];
    var angle;
    for ( var i=0; i<37; i++ ) {
      angle = 10 * i;
      pts2.push( getVertex( centerX, centerY, 2, angle ) );
      pts5.push( getVertex( centerX, centerY, 5, angle ) );
      pts10.push( getVertex( centerX, centerY, 10, angle ) );
    }
  	// Show the circles
    circle2 = new GPolyline( pts2, "#FF0000", 6, 0.6 );
    map.addOverlay( circle2 );
    circle5 = new GPolyline( pts5, "#FFA500", 5, 0.6 );
    map.addOverlay( circle5 );
    circle10 = new GPolyline( pts10, "#EEEE00", 4, 0.6 );
    map.addOverlay( circle10 );
    // Update the report and nearest businesses tables
		document.getElementById('report').innerHTML = "<iframe ID=reportFrame allowtransparency=true frameborder=no scrolling=auto src='getReport.php?lon=" + centerX + "&lat=" + centerY + "'></iframe><div class=reportHeader>Nearby businesses:</div><iframe ID=nearestFrame allowtransparency=true frameborder=no scrolling=auto src='getNearest.php?lon=" + centerX + "&lat=" + centerY + "'></iframe>";
		// Add lat, lon info to debug area
		//document.getElementById('debug').innerHTML = "Debugging info: lon = " + centerX + ", lan = " + centerY;
  }
}

// Get the coordinates of each vertex of a "circle"
function getVertex( x, y, radius, angle ) {
  var vx = 0;
  var vy = 0;
  var term1 = (90 - angle) * 0.0174533;
  vx = x + radius * Math.cos( term1 ) / 69.04545 / Math.cos( y * 0.0174533 );
  vy = y + radius * Math.sin( term1 ) / 69.04545;
  return new GPoint( vx, vy );
}

// Show help in the report box
function showHelp() {
	document.getElementById('report').innerHTML = helpText;
	void 0;
}

function popUp(popupURL) {
  myPopUpWindow = window.open(popupURL,'popup','top=40,left=80,toolbar=no,location=no,directories=no,menubar=no,scrollbars,resizable,width=500,height=300')
}