	var z = 0;
	var showMarker = false;

	var myCribs = new Array() //Address	
	var myPeeps = new Array() //Description
	var mySaves = new Array() //Saved Location
	var myPropName = new Array() // Property Name
	var currProp;
	var delay = 10;
	var nextAddress = 0;
	var addresses = [];
	var addressToId= [];
    var map;
    var geocoder;
	var favorites;
	var bounds = new GLatLngBounds();
	var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";
      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      
	
	var thisPeer = -1;
	var resp;

	var purpleicon = new GIcon();
		purpleicon.image = "img/pointer.png";
		purpleicon.shadow = "img/shadow.png";
		purpleicon.iconSize = new GSize(12, 20);
		purpleicon.shadowSize = new GSize(22, 20);
		purpleicon.iconAnchor = new GPoint(6, 20);
		purpleicon.infoWindowAnchor = new GPoint(5, 1);

	var blueicon = new GIcon();
		blueicon.image = "img/pointer_blue.png";
		blueicon.shadow = "img/shadow.png";
		blueicon.iconSize = new GSize(20, 34);
		blueicon.shadowSize = new GSize(22, 20);
		blueicon.iconAnchor = new GPoint(6, 20);
		blueicon.infoWindowAnchor = new GPoint(5, 1);

    function loadMap() {
      map = new GMap2(document.getElementById("map"));
	 	//geocoder.getLocations("Edmonton Alberta canada",gotoCenter);
	  map.setCenter(new GLatLng(52.4419, -120.1419), 5);
      //map.setCenter(new GLatLng(0, 0), 10);
	  map.addControl(new GSmallMapControl() );
      geocoder = new GClientGeocoder();
	  
		
	 // map.checkResize();
	  //Put markers on map
	 loadLocations();
	 //map.setCenter(geocoder.getLocations("Edmonton Alberta canada"),gotoCenter);
	
	 	//(new GLatLng(60, -100), 13);
		//map.setCenter(new GLatLng(60, -114));
    }
	
	function loadLocations(){
		var c = 0;
		//clean up array
		for (z=0;z<myCribs.length;z++){
			if(myCribs[z]){
				addresses[c] = myCribs[z];
				addressToId[c] = z;
				c++;
			}
		}
		theNext();
		
	   // showMarker = true;
	 /* var i = 0;
	   var saves = new Array();
	   var locations = new Array();
		for (z=0;z<myPeeps.length;z++){
			
			if(myCribs[z]){
				//alert ('load locations ' + z + ' ' + myCribs[z]);
				if(mySaves[z]){
					//currProp = z;
					saves[i] = myCribs[z];
					i = i+1;
					//geocoder.getLocations(myCribs[z],addAddressToMapB);
					}
				else {
					locations[i]=myCribs[z];
					i = i+1;
					//currProp = z;
					//alert('currProp = ' + currProp);
					//geocoder.getLocations(myCribs[z],addAddressToMap);
					}
				}
				
		}
		addAddressToMap(locations);
		*/
		//setCenter();
	}
	function getAddress(address, id, next) {
        geocoder.getLocations(address, function (result)
          { 
            // If that was successful
            if (result.Status.code == G_GEO_SUCCESS) {
              // Lets assume that the first marker is the one we want
              var p = result.Placemark[0].Point.coordinates;
              var lat=p[1];
              var lng=p[0];
			  
			  //Add point to map
			  point = new GLatLng(p[1],p[0]);
			  var marker = createMarker(point,"<b><a href='http://www.rentmidwest.com/index.php?a=details&id=" + id + "&param=buildings'>" + myPropName[id] + "</b><br>" + myCribs[id],id);
			  //var marker = new GMarker(new GLatLng(p[1],p[0]));
			   map.addOverlay(marker);
			   if (addresses.length == 1){
			   marker.openInfoWindowHtml('<b>' + myPropName[id] + "</b><br>" + myCribs[id]);
			   }
			  // Display the results in XML format
              //var xml = '&nbsp;&nbsp;&lt;marker address="' + address + '" lat="' +lat+ '" lng="' +lng+ '"&gt;<br>';
              //document.getElementById("message").innerHTML += xml;
            }
            // ====== Decode the error status ======
            else {
              // === if we were sending the requests to fast, try this one again and increase the delay
              if (result.Status.code == G_GEO_TOO_MANY_QUERIES) {
                nextAddress--;
                delay++;
              } else {
                var reason="Code "+result.Status.code;
                if (reasons[result.Status.code]) {
                  reason = reasons[result.Status.code]
                } 
                var error = 'address="' + address + '" could not be maped because "' +reason+ '"';
                alert(error);
              }   
            }
            next();
          }
        );
      }
	  
	  function theNext() {
        if (nextAddress < addresses.length) {
          setTimeout('getAddress("'+addresses[nextAddress]+'",'+addressToId[nextAddress]+',theNext)', delay);
          nextAddress++;
        } //else {
          //document.getElementById("message").innerHTML += "&lt;/markers&gt;";
        //}
      }
	  
	  function createMarker(point,html,id) {
		if(mySaves[id]){
			 var marker = new GMarker(point, blueicon);
		}else{
        	var marker = new GMarker(point, purpleicon);
		}
        GEvent.addListener(marker, "click", function() {
          document.getElementById("message").innerHTML = myPeeps[id];
        });

        // The new marker "mouseover" listener        
        GEvent.addListener(marker,"mouseover", function() {
          marker.openInfoWindowHtml(html);
        });       
		  
		
        bounds.extend(point);
		map.setZoom(map.getBoundsZoomLevel(bounds)-1);
		map.setCenter(bounds.getCenter());
		setcenteroveride();
		return(marker);
      // map.addOverlay(marker);
      }
	
	/*function addAddressToMap(locations){
		alert(locations.length);
		for (z=0;z<locations.length;z++){
			alert("z = " + z + "location = " + locations[z]);
		geocoder.getLocations(locations[z], function (result)
          { 
            // If that was successful
            if (result.Status.code == G_GEO_SUCCESS) {
              // How many resuts were found
              alert("Found " +result.Placemark.length +" results");
              // Loop through the results, placing markers
              for (var i=0; i<result.Placemark.length; i++) {
                var p = result.Placemark[i].Point.coordinates;
                var marker = new GMarker(new GLatLng(p[1],p[0]));
                alert((i+1)+": "+ result.Placemark[i].address + marker.getPoint());
                map.addOverlay(marker);
              }
              // centre the map on the first result
              var p = result.Placemark[0].Point.coordinates;
              map.setCenter(new GLatLng(p[1],p[0]),14);
            }
            // ====== Decode the error status ======
            else {
              var reason="Code "+result.Status.code;
              if (reasons[result.Status.code]) {
                reason = reasons[result.Status.code]
              } 
              alert('Could not find "'+locations[z]+ '" ' + reason);
            }
          }
        );
		}
          
	}
	*/
	
	function findLocation(z){
				//alert(nextAddress);
				nextAddress = 0;
				map.clearOverlays();
				addresses=[];
				addresses[0] = myCribs[z];
				addressToId[0] = z;
				bounds=new GLatLngBounds();
				theNext();
				
				//if(mySaves[z]){
				//	currProp = z;
				//	geocoder.getLocations(myCribs[z],addAddressToMapB);}
				//else {
				//	currProp = z;
				//	//alert('This address could not be mapped. ' + z);
				//	geocoder.getLocations(myCribs[z],addAddressToMapP);
				//	}
	}
	
// This function needs to reproduced in full for two pointer colors
// due to a limitation in the google code.
//---------------------------------BLUE POINTER
   /* function addAddressToMapB(response) {
alert('why');
      if (!response || response.Status.code != 200) {

		if(showMarker){
          alert("This address could not be mapped. (" + myPropName[currProp] + ": " + myCribs[currProp] + ")");
		  showarker = false;
		  }
		  
      } else {


        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
		bounds.extend(new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]));
var icon = new GIcon();
//alert("This address1 could not be mapped." + currProp );
		//Add The Text Description
    	marker = new GMarker(point, blueicon);

		if(showMarker){
			map.clearOverlays();
			map.panTo(point);
        	map.addOverlay(marker);
			marker.openInfoWindowHtml('<b>' + myPropName[currProp] + "</b><br>" + myCribs[currProp]);
			//alert ('map address1');
			map.setZoom(13);
		} else {
			if (favorites){
				map.setZoom(3);
			}else{
				map.setZoom(10);
			}
			
			map.addOverlay(marker);
		}
	
      }
    }
	*/
//---------------------------------Purple POINTER
    /*function addAddressToMapP(response) {
	        
      if (!response || response.Status.code != 200) {
		  
//alert('This address could not be mapped. ' + place.Point.coordinates[1] + ' dude ');
//alert("This address could not be mapped. (" + thisPeep + ": " + myCribs[thisPeep-1] + ")");
		if(showMarker){
			alert("This address could not be mapped. (" + myPropName[currProp] + ": " + myCribs[currProp] + ")");
          //alert("This address could not be mapped. ");
		  showarker = false;
		  }
		  
      } else {
		 // alert("This address1 could not be mapped. (" + myPropName[currProp] + ": " + myCribs[currProp] + ")");
		//alert("This address could not be mapped. (: " + myPropName[z-1] + myCribs[z-1] + myPeeps[z -1] +")");
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
		bounds.extend(new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]));
		map.setZoom(map.getBoundsZoomLevel(bounds)-1);
		map.setCenter(bounds.getCenter());
		alert('currProp = ' + currProp);
		var marker = createMarker(point,'<b>' + myPropName[currProp] + "</b><br>" + myCribs[currProp]);
	//var marker = new GMarker(point, purpleicon);
	
		if(showMarker){
			map.clearOverlays();
			map.panTo(point);
        	map.addOverlay(marker);
			marker.openInfoWindowHtml('<b>' + myPropName[currProp] + "</b><br>" + myCribs[currProp]);
			map.setZoom(13);
		} else {
			map.addOverlay(marker);
		}
	
      }
    }*/
	
	 
	
/*	function gotoCenter(response){
      if (!response || response.Status.code != 200) {
	  	if(showMarker){
          alert("This address could not be mapped. (" + myPropName[currProp] + ": " + myCribs[currProp] + ")");
		  showarker = false;
		  }
	  } else {
			place = response.Placemark[0];
			point = new GLatLng(place.Point.coordinates[1],
								place.Point.coordinates[0]);
						    	
			map.setZoom(map.getBoundsZoomLevel(bounds)-1);
			map.setCenter(bounds.getCenter());

			
			marker = new GMarker(point, purpleicon);
			map.panTo(point);
		}}*/

	/*function removePoint(){
	    map.closeInfoWindow();		
		}

	function backtoProperty(thisProperty){
		map.clearOverlays();
		loadLocations();
		setCenter();
		map.setZoom(10); 
		setTimeout("document.location.href='\#" + thisProperty + "';",1500); 
		}*/
		