    var iconBlue = new GIcon(); 
    iconBlue.image = 'http://4114openhouses.com/images/411-flag-blue.png';
    iconBlue.shadow = 'http://4114openhouses.com/images/411-flag-shadow.png';
    iconBlue.iconSize = new GSize(27, 28);
    iconBlue.shadowSize = new GSize(40, 38);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

    var iconRed = new GIcon(); 
    iconRed.image = 'http://4114openhouses.com/images/411-flag-red.png';
    iconRed.shadow = 'http://4114openhouses.com/images/411-flag-shadow.png';
    iconRed.iconSize = new GSize(27, 28);
    iconRed.shadowSize = new GSize(40, 38);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);

    var iconGreen = new GIcon(); 
    iconGreen.image = 'http://4114openhouses.com/images/411-flag-green.png';
    iconGreen.shadow = 'http://4114openhouses.com/images/411-flag-shadow.png';
    iconGreen.iconSize = new GSize(27, 28);
    iconGreen.shadowSize = new GSize(40, 38);
    iconGreen.iconAnchor = new GPoint(6, 20);
    iconGreen.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["ACTIVE"] = iconBlue;
	customIcons["NEW"] = iconGreen;
	customIcons["BACK ON MARKET"] = iconGreen;
    customIcons["OPEN"] = iconRed;

	var map;

	var markers;
		
	function computeBounds(data) {
          var xml = GXml.parse(data);
          markers = xml.documentElement.getElementsByTagName("marker");
          var centerFound = false;
		  for (var i = 0; i < markers.length; i++) {		
			if(markers[i].getAttribute("lat") != 0.0) {
             	var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                	                    parseFloat(markers[i].getAttribute("lng")));
				if(!centerFound) {
					centerFound = true;
					bounds = new GLatLngBounds(point, point);
				} else {
					bounds.expand(point);
				}
			}
		  }
	}

    function load(data, zoomLevel, computeBounds) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("mapresults"));
//        map.addControl(new GSmallMapControl());
		map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
		var bounds = null;
		//Initially the center is set to downtown Omaha, but this will likely change in the upcoming for loop
	    map.setCenter(new GLatLng(41.263305, -96.052976), zoomLevel);
		var centerFound = false;
		
//        GDownloadUrl(mapPage, function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
		  	//If the lat or lng is 0, no need putting a marker on the map
			if(markers[i].getAttribute("lat") == 0.0 || markers[i].getAttribute("lng") == 0.0) {
				continue;
			}

            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
   		                            parseFloat(markers[i].getAttribute("lng")));

		  	//If the zoomLevel is 13, we are on the results.php page, so we center on the first property
/*			if(computeBounds == true && centerFound == false) {
				map.setCenter(point, zoomLevel);
				centerFound = true;			
			}
*/
			//If searchAny is false, we are on the results page and we are ccomputing the bounding area of the map
			//so we compute the bounds of all homes for sale in the results

			if(computeBounds == true) {
				if(!centerFound) {
					centerFound = true;
					bounds = new GLatLngBounds(point, point);
				} else {
					bounds.extend(point);
				}		
			}
			if(computeBounds == true && i == markers.length - 1) {
				//we are at the end of the loop, so set the bounds
				map.setCenter(bounds.getCenter()); 
				var boundszoom = map.getBoundsZoomLevel(bounds, map.getSize()); 
				map.setZoom(boundszoom); 				
			}
							  
            var mls_num = markers[i].getAttribute("mls_num");
            var addr_num = markers[i].getAttribute("addr_num");
		//	var open_date_begin = markers[i].getAttribute("open_date_begin");
			var addr_dir = markers[i].getAttribute("addr_dir");
			var addr_st = markers[i].getAttribute("addr_st");
			//var address = markers[i].getAttribute("addr_st");
            var status = markers[i].getAttribute("status");
			var list_price = markers[i].getAttribute("list_price");
			var bed = markers[i].getAttribute("bed");
			var bath = markers[i].getAttribute("bath");
			var garage = markers[i].getAttribute("garage");
			var icon = markers[i].getAttribute("icon");
			var area = markers[i].getAttribute("area");
			//var sqft = markers[i].getAttribute("sqft");
		//	var im_location = markers[i].getAttribute("im_location");
			var open_date = markers[i].getAttribute("open_date");
			var open_time = markers[i].getAttribute("open_time");
            var marker = createMarker(point, mls_num, addr_num, addr_dir, addr_st, status, list_price, bed, bath, garage, icon, open_date, open_time, area);
            map.addOverlay(marker);
          }
  //      });
      }
    }

	// Add Commas function
	function addCommas(nStr)
	{
			nStr += '';
			x = nStr.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
					x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			return x1 + x2;
	}

	function createMarker(point, mls_num, addr_num, addr_dir, addr_st, status, list_price, bed, bath, garage, icon, open_date, open_time, area) {
		  var marker = new GMarker(point, customIcons[icon]);
		  var html = '<table style="font-size: 11px;" width="225" border="0" cellspacing="2" cellpadding="2"><tr><td><a href="details.php?recordID=' 
					+ mls_num + '"><img src="../mls_photos/OABRMLS' + mls_num + '.jpg" width="90" height="80" border="0" /></a></td>'
					+ '<td>MLS #: ' + mls_num  + '<br/>' + addr_num + '&nbsp;' + addr_dir + '&nbsp;' + addr_st 
					+ '<br/>Area: ' + area + '<br/>$' + addCommas(list_price) + '<br/>Bed: ' + bed + '&nbsp; Bath: ' + bath 
					+ '&nbsp; Garage: ' + garage + '<br/><b><a href=details.php?recordID=' 
		  			+ mls_num + '>details</a></b></font></td></tr>';		  
		  
		  //var html = '<a href=details.php?recordID=' + mls_num + '>' + '<img src=../mls_photos/OABRMLS' + mls_num + '.jpg width=110 height=85 border=0/>' + "</a>" + '<b><a href=details.php?recordID=' + mls_num + '>' + " details" + "</a>" + "</b>"+ "<br/>MLS #: " + mls_num  + "<br/>" + addr_num + "&nbsp;" + addr_dir + "&nbsp;" + addr_st + "<br/>Area: " + area + "<br/> $" + addCommas(list_price) + "<br/> Bed: " + bed + "&nbsp; Bath: " + bath + "&nbsp; Garage: " + garage;
		  if(open_date) {
		    	html = html + '<tr><td colspan="2"><b>Open House:</b>' + open_date + ' from ' + open_time + '</td></tr>';
		  }	
		  html = html + '</table>';
		  GEvent.addListener(marker, 'click', function() {
			marker.openInfoWindowHtml(html);
		  });
		  return marker;
	}

	function showMap(lat, lng, mlsnum) {
      if (GBrowserIsCompatible() && lat != 0) {
	  	var div = document.getElementById("map_" + mlsnum);
		div.setAttribute("style","width:555px;height:180px;");
		div.style.width = "555px";
		div.style.height = "180px";
        var map = new GMap2(div);
        map.addControl(new GSmallMapControl());
//        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(lat, lng), 15);
        var point = new GLatLng(lat,lng);
        var marker = new GMarker(point, customIcons["ACTIVE"]);
        map.addOverlay(marker);
		return false;
	  } else {
		  return true;	
	  }
	}
	
	function loadDetailMap(lat, lng) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map2"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(lat, lng), 15);	
            var point = new GLatLng(lat, lng);
  		    var marker = new GMarker(point, customIcons["ACTIVE"]);
            map.addOverlay(marker);

			//Check to see if this property has StreetView
			var streetViewClient = new GStreetviewClient();
			streetViewClient.getNearestPanorama(point, handleStreetView);

			//Add the StreetView overlay
			svOverlay = new GStreetviewOverlay();
        	map.addOverlay(svOverlay);
			
			// create a local search control and add it to your map
			map.addControl(new google.maps.LocalSearch());


			//If a user clicks on the map where a StreetView exists, the StreetView is displayed in a
			//separate div named "streetView"
	        var streetViewDiv = new GStreetviewPanorama(document.getElementById("streetView"));
	        GEvent.addListener(streetViewDiv, "error", handleNoFlash);  
            GEvent.addListener(map,"click", function(overlay,latlng) {
               streetViewDiv.setLocationAndPOV(latlng);
            });		
      }
    }
	//Callback function for getNearestPanorama (called in the load() function)
	function handleStreetView(streetviewData) {
		if(streetviewData.code == 200) {  //StreetView was found, so we display it now
	        var streetViewDiv = new GStreetviewPanorama(document.getElementById("streetView"));
	        GEvent.addListener(streetViewDiv, "error", handleNoFlash);  
			var pov = streetViewDiv.getPOV();
			pov.yaw = pov.yaw - 180;
			streetViewDiv.setLocationAndPOV(streetviewData.location.latlng, pov);
		}
	}
	
    function handleNoFlash(errorCode) {
      if (errorCode == 603) {
        var streetViewDiv = document.getElementById("streetView");
		streetViewDiv.innerHTML = "<p>Street View requires Macromedia Flash Player</p>";
        return;
      }
    }  