function WAMapRef(mapObj)  {
  this.obj = mapObj;
  this.directions = false;
  this.icons = [];
  this.markers = [];
  this.addresses = [];
  this.points = [];
  this.getPointByAddress = getPointByAddressFunc;
  this.addressFailed = true;
  return this;
}

function WAMapPoint(theMarker, theAddress, theIcon)  {
  this.icon = theIcon;
  this.marker = theMarker;
  this.address = theAddress;
  return this;
}

function getPointByAddressFunc(value,attname)  {
  if (!attname) attname = "street";
  for (var x=0; x < this.addresses.length; x++) {
    if (eval("this.addresses[x]."+attname) == value)  {
      return WAMapPoint(this.markers[x],this.addresses[x],this.icons[x]);
    }
  }
  return false;
}

function getHTTPObject(){   
  if (window.ActiveXObject)        
    return new ActiveXObject("Microsoft.XMLHTTP");   
  else if (window.XMLHttpRequest)        
    return new XMLHttpRequest();   
  else {
    return null;
  }
}

function searchCache(searchStr, zip) {
	var xmlDoc = null;
  if (window.ActiveXObject) {//IE
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  } else if(navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('webkit') >= 0) { //webkit (Safari, Chrome)
  	var coordinates = '';
    xmlDoc = getHTTPObject();
    if(xmlDoc) {
      xmlDoc.onreadystatechange = function() {
        if(xmlDoc.readyState == 4) {
          var x = xmlDoc.responseXML.getElementsByTagName("geocode_entry");
          var geocode, id;
          searchStr = searchStr.replace(/,/g, ''); //remove commas
          for (i=0; i < x.length; i++) {
            id = x[i].getAttribute("ID");
            if (id == searchStr) {
              coordinates = x[i].getElementsByTagName("geocode")[0].childNodes[0].nodeValue;
              return coordinates;
            }
          }
        }
      };
      xmlDoc.open("GET", "_promaps_cache/_promaps_geocache.xml", false);
      xmlDoc.send(null);
    }
    
    return coordinates;
  } else if (document.implementation.createDocument) {//gecko (Mozilla, Firefox, Opera)
    xmlDoc=document.implementation.createDocument("","",null);
  } else {
    return '';
  }
  if (xmlDoc != null) {
    xmlDoc.async=false;
    if(xmlDoc.load("_promaps_cache/_promaps_geocache.xml")) {
      var x=xmlDoc.getElementsByTagName("geocode_entry");
      var geocode, id;
      searchStr = searchStr.replace(/,/g, ''); //remove commas
      for (i=0; i < x.length; i++) {
        id = x[i].getAttribute("ID");
        if (id == searchStr) {
          return x[i].getElementsByTagName("geocode")[0].childNodes[0].nodeValue;
        }
      }
    }
  }
  
  return '';
}

function addToCache(fullAddress,zip, geocode){
  httpObject = getHTTPObject();
  if (httpObject != null) {
    httpObject.open("POST", "google_javascript/promaps_geocache_.js", true);
    httpObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    var entryId = fullAddress.replace(/,/g, '');
    if (zip != '') {
      fullAddress = fullAddress.replace(zip+',', '');
    }
    entryId = escape(entryId);
    fullAddress = escape(fullAddress);
    geocode = escape(geocode);
    httpObject.send("sender=promapsforgoogle&action=add&entryId="+entryId+"&address="
+fullAddress+"&geocode="+geocode);
  }
}


function wagmp_map_2() {
  if(GBrowserIsCompatible()) {
    if(!document.getElementById('wagmp_map_2')) return false;
    var map = new GMap2(document.getElementById('wagmp_map_2'));
	map.setMapType(G_PHYSICAL_MAP);
    wagmp_map_2_obj = new WAMapRef(map);
    map.enableContinuousZoom();
    map.enableDoubleClickZoom();
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    var geocoder = new GClientGeocoder();
    
    var fromAddress = {
      enabled: false,
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      full: ''
    };
<!-- Speargrass, Caresland --!>
    var icon_0 = new GIcon();
icon_0.image = 'images/maps/speargrass/image.png';
icon_0.shadow = 'images/maps/speargrass/shadow.png';
icon_0.iconSize = new GSize(50,22);
icon_0.shadowSize = new GSize(61,22);
icon_0.iconAnchor = new GPoint(0,22);
icon_0.infoWindowAnchor = new GPoint(25,0);
icon_0.printImage = 'images/maps/speargrass/printImage.gif';
icon_0.mozPrintImage = 'images/maps/speargrass/mozPrintImage.gif';
icon_0.printShadow = 'images/maps/speargrass/printShadow.gif';
icon_0.transparent = 'images/maps/speargrass/transparent.png';
icon_0.imageMap = [49,0,49,1,49,2,49,3,49,4,49,5,49,6,49,7,49,8,49,9,49,10,49,11,49,12,49,13,49,14,49,15,49,16,49,17,49,18,49,19,49,20,49,21,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,0,1,0,0];

    var address_0 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
  	  infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: #996633; text-decoration: none;"><center><img src="/images/maps/logoSpeargrass100.gif" alt="Speargrass" /><p><a href="http://www.speargrass.ca" target="_blank">Click for more details</a></p></center></span>',
      full: '50.706126,-113.340241',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '50.706126',
      longitude: '-113.340241',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Tahiti Sea'
    };
    
    if (address_0.addressType == "coordinates") {
      var cacheReturn = '';
    } else {
      var cacheReturn = searchCache(address_0.full, address_0.zip);
    }
    if (cacheReturn != "" || (address_0.addressType == "coordinates")) {
      if(address_0.addressType == "coordinates") {
        var latitude = address_0.latitude;
        var longitude = address_0.longitude;
      } else {
        var latitude = cacheReturn.substring(1,cacheReturn.indexOf(",")-1);
        var longitude = cacheReturn.substring(cacheReturn.indexOf(",")+1,(cacheReturn.length)-1);
      }
      var point = new GLatLng(latitude, longitude);
      if (point && !isNaN(latitude)) {
        wagmp_map_2_obj.addressFailed = false;
        var marker_0 = new GMarker(point, icon_0);
        GEvent.addListener(marker_0, 'click', function() {
          marker_0.openInfoWindowHtml(address_0.infowindowtext);
        });
        if(!fromAddress.enabled || 'address_0' != 'address_0') {
          if('address_0' == 'address_0')
          map.setCenter(point, 13);
          map.addOverlay(marker_0);
		  map.setZoom(8);;
        }
          wagmp_map_2_obj.markers.push(marker_0);
          wagmp_map_2_obj.addresses.push(address_0);
          wagmp_map_2_obj.icons.push(icon_0);
          wagmp_map_2_obj.points.push(point);
        } else {
        if (wagmp_map_2_obj.addressFailed) {
          map.setCenter(new GLatLng(30, -98), 3);
        }
        wagmp_map_2_obj.addressFailed = true;
      }
    } else if (address_0.addressType == "address") {
      geocoder.getLatLng (
      address_0.full,
      function(point) {
        if(point) {
          this.addressFailed = false;
          addToCache(address_0.full, '', point);
          var marker_0 = new GMarker(point, icon_0);
          GEvent.addListener(marker_0, 'click', function() {
            marker_0.openInfoWindowHtml(address_0.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_0' != 'address_0') {
            if('address_0' == 'address_0')
            map.setCenter(point, 13);
            map.addOverlay(marker_0);
		  map.setZoom(8);;
          }
              wagmp_map_2_obj.markers.push(marker_0);
          wagmp_map_2_obj.addresses.push(address_0);
          wagmp_map_2_obj.icons.push(icon_0);
          wagmp_map_2_obj.points.push(point);
        
        } else {
          var noZipAddress = address_0.full.replace((address_0.zip+','), '');
          geocoder.getLatLng (noZipAddress,
            function(point) {
              if(point) {
                wagmp_map_2_obj.addressFailed = false;
                addToCache(address_0.full, address_0.zip, point);
                var marker_0 = new GMarker(point, icon_0);
                GEvent.addListener(marker_0, 'click', function() {
                  marker_0.openInfoWindowHtml(address_0.infowindowtext);
                });
                if (!fromAddress.enabled || 'address_0' != 'address_0') {
                  if('address_0' == 'address_0')
                  map.setCenter(point, 13);
                  map.addOverlay(marker_0);
		  map.setZoom(8);;
                }
                    wagmp_map_2_obj.markers.push(marker_0);
          wagmp_map_2_obj.addresses.push(address_0);
          wagmp_map_2_obj.icons.push(icon_0);
          wagmp_map_2_obj.points.push(point);
        
              } else {
                if (wagmp_map_2_obj.addressFailed) {
                  map.setCenter(new GLatLng(30, -98), 3);
                }
                  wagmp_map_2_obj.addressFailed = true;
              }
            }
          );
        }
      }
    );
  }
<!-- Copperpond, Hopewell --!>
    var icon_1 = new GIcon();
icon_1.image = 'images/maps/copperpond/image.png';
icon_1.shadow = 'images/maps/copperpond/shadow.png';
icon_1.iconSize = new GSize(50,24);
icon_1.shadowSize = new GSize(62,24);
icon_1.iconAnchor = new GPoint(25,24);
icon_1.infoWindowAnchor = new GPoint(25,0);
icon_1.printImage = 'images/maps/copperpond/printImage.gif';
icon_1.mozPrintImage = 'images/maps/copperpond/mozPrintImage.gif';
icon_1.printShadow = 'images/maps/copperpond/printShadow.gif';
icon_1.transparent = 'images/maps/copperpond/transparent.png';
icon_1.imageMap = [49,0,49,1,49,2,49,3,49,4,49,5,49,6,49,7,49,8,49,9,49,10,49,11,49,12,49,13,49,14,49,15,49,16,49,17,49,18,49,19,49,20,49,21,49,22,49,23,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,0,1,0,0];

    var address_1 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: #996633; text-decoration: none;"><center><img src="/images/maps/logoCopperfield100.gif" alt="Copperpond" /><p><a href="http://www.copperfield.ca" target="_blank">Click for more details</a></p></center></span>',
      full: '50.919179,-113.926638',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '50.919179',
      longitude: '-113.926638',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Granite Pine'
    };
    
    if (address_1.addressType == "coordinates") {
      var cacheReturn = '';
    } else {
      var cacheReturn = searchCache(address_1.full, address_1.zip);
    }
    if (cacheReturn != "" || (address_1.addressType == "coordinates")) {
      if(address_1.addressType == "coordinates") {
        var latitude = address_1.latitude;
        var longitude = address_1.longitude;
      } else {
        var latitude = cacheReturn.substring(1,cacheReturn.indexOf(",")-1);
        var longitude = cacheReturn.substring(cacheReturn.indexOf(",")+1,(cacheReturn.length)-1);
      }
      var point = new GLatLng(latitude, longitude);
      if (point && !isNaN(latitude)) {
        wagmp_map_2_obj.addressFailed = false;
        var marker_1 = new GMarker(point, icon_1);
        GEvent.addListener(marker_1, 'click', function() {
          marker_1.openInfoWindowHtml(address_1.infowindowtext);
        });
        if(!fromAddress.enabled || 'address_1' != 'address_0') {
          if('address_1' == 'address_0')
          map.setCenter(point, 13);
          map.addOverlay(marker_1);
		  map.setZoom(8);;
        }
          wagmp_map_2_obj.markers.push(marker_1);
          wagmp_map_2_obj.addresses.push(address_1);
          wagmp_map_2_obj.icons.push(icon_1);
          wagmp_map_2_obj.points.push(point);
        } else {
        if (wagmp_map_2_obj.addressFailed) {
          map.setCenter(new GLatLng(30, -98), 3);
        }
        wagmp_map_2_obj.addressFailed = true;
      }
    } else if (address_1.addressType == "address") {
      geocoder.getLatLng (
      address_1.full,
      function(point) {
        if(point) {
          this.addressFailed = false;
          addToCache(address_1.full, '', point);
          var marker_1 = new GMarker(point, icon_1);
          GEvent.addListener(marker_1, 'click', function() {
            marker_1.openInfoWindowHtml(address_1.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_1' != 'address_0') {
            if('address_1' == 'address_0')
            map.setCenter(point, 13);
            map.addOverlay(marker_1);
		  map.setZoom(8);;
          }
              wagmp_map_2_obj.markers.push(marker_1);
          wagmp_map_2_obj.addresses.push(address_1);
          wagmp_map_2_obj.icons.push(icon_1);
          wagmp_map_2_obj.points.push(point);
        
        } else {
          var noZipAddress = address_1.full.replace((address_1.zip+','), '');
          geocoder.getLatLng (noZipAddress,
            function(point) {
              if(point) {
                wagmp_map_2_obj.addressFailed = false;
                addToCache(address_1.full, address_1.zip, point);
                var marker_1 = new GMarker(point, icon_1);
                GEvent.addListener(marker_1, 'click', function() {
                  marker_1.openInfoWindowHtml(address_1.infowindowtext);
                });
                if (!fromAddress.enabled || 'address_1' != 'address_0') {
                  if('address_1' == 'address_0')
                  map.setCenter(point, 13);
                  map.addOverlay(marker_1);
		  map.setZoom(8);;
                }
                    wagmp_map_2_obj.markers.push(marker_1);
          wagmp_map_2_obj.addresses.push(address_1);
          wagmp_map_2_obj.icons.push(icon_1);
          wagmp_map_2_obj.points.push(point);
        
              } else {
                if (wagmp_map_2_obj.addressFailed) {
                  map.setCenter(new GLatLng(30, -98), 3);
                }
                  wagmp_map_2_obj.addressFailed = true;
              }
            }
          );
        }
      }
    );
  }

<!-- Cimarron, Okotoks, Tristar --!>
    var icon_3 = new GIcon();
icon_3.image = 'images/maps/cimarron/image.png';
icon_3.shadow = 'images/maps/cimarron/shadow.png';
icon_3.iconSize = new GSize(30,33);
icon_3.shadowSize = new GSize(47, 33);
icon_3.iconAnchor = new GPoint(15,33);
icon_3.infoWindowAnchor = new GPoint(15,0);
icon_3.printImage = 'images/maps/cimarron/printImage.gif';
icon_3.mozPrintImage = 'images/maps/cimarron/mozPrintImage.gif';
icon_3.printShadow = 'images/maps/cimarron/printShadow.gif';
icon_3.transparent = 'images/maps/cimarron/transparent.png';
icon_3.imageMap = [29,0,29,1,29,2,29,3,29,4,29,5,29,6,29,7,29,8,29,9,29,10,29,11,29,12,29,13,29,14,29,15,29,16,29,17,29,18,29,19,29,20,29,21,29,22,29,23,29,24,29,25,29,26,29,27,29,28,29,29,29,30,29,31,29,32,0,32,0,31,0,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,0,1,0,0];

var address_3 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: #996633; text-decoration: none;"><center><img src="/images/maps/logoCimarron70.gif" alt="Cimarron, Okotoks" /><p><a href="http://www.tristar-cimarron.com" target="_blank">Click for more details</a></p></center></span>',
      full: '50.708554,-113.9592359',
      isdefault: true,
      addressType: 'coordinates',
      loop: '',
      latitude: '50.708554',
      longitude: '-113.9592359',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Pacifica'
    };
    
    if (address_3.addressType == "coordinates") {
      var cacheReturn = '';
    } else {
      var cacheReturn = searchCache(address_3.full, address_3.zip);
    }
    if (cacheReturn != "" || (address_3.addressType == "coordinates")) {
      if(address_3.addressType == "coordinates") {
        var latitude = address_3.latitude;
        var longitude = address_3.longitude;
      } else {
        var latitude = cacheReturn.substring(1,cacheReturn.indexOf(",")-1);
        var longitude = cacheReturn.substring(cacheReturn.indexOf(",")+1,(cacheReturn.length)-1);
      }
      var point = new GLatLng(latitude, longitude);
      if (point && !isNaN(latitude)) {
        wagmp_map_2_obj.addressFailed = false;
        var marker_3 = new GMarker(point, icon_3);
        GEvent.addListener(marker_3, 'click', function() {
          marker_3.openInfoWindowHtml(address_3.infowindowtext);
        });
        if(!fromAddress.enabled || 'address_3' != 'address_0') {
          if('address_3' == 'address_0')
          map.setCenter(point, 13);
          map.addOverlay(marker_3);
		  map.setZoom(8);;
if('address_3' == 'address_0')
            marker_3.openInfoWindowHtml(address_3.infowindowtext);
        }
          wagmp_map_2_obj.markers.push(marker_3);
          wagmp_map_2_obj.addresses.push(address_3);
          wagmp_map_2_obj.icons.push(icon_3);
          wagmp_map_2_obj.points.push(point);
        } else {
        if (wagmp_map_2_obj.addressFailed) {
          map.setCenter(new GLatLng(30, -98), 3);
        }
        wagmp_map_2_obj.addressFailed = true;
      }
    } else if (address_3.addressType == "address") {
      geocoder.getLatLng (
      address_3.full,
      function(point) {
        if(point) {
          this.addressFailed = false;
          addToCache(address_3.full, '', point);
          var marker_3 = new GMarker(point, icon_3);
          GEvent.addListener(marker_3, 'click', function() {
            marker_3.openInfoWindowHtml(address_3.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_3' != 'address_0') {
            if('address_3' == 'address_0')
            map.setCenter(point, 13);
            map.addOverlay(marker_3);
		  map.setZoom(8);;
if('address_3' == 'address_0')
            marker_3.openInfoWindowHtml(address_3.infowindowtext);
          }
              wagmp_map_2_obj.markers.push(marker_3);
          wagmp_map_2_obj.addresses.push(address_3);
          wagmp_map_2_obj.icons.push(icon_3);
          wagmp_map_2_obj.points.push(point);
        
        } else {
          var noZipAddress = address_3.full.replace((address_3.zip+','), '');
          geocoder.getLatLng (noZipAddress,
            function(point) {
              if(point) {
                wagmp_map_2_obj.addressFailed = false;
                addToCache(address_3.full, address_3.zip, point);
                var marker_3 = new GMarker(point, icon_3);
                GEvent.addListener(marker_3, 'click', function() {
                  marker_3.openInfoWindowHtml(address_3.infowindowtext);
                });
                if (!fromAddress.enabled || 'address_3' != 'address_0') {
                  if('address_3' == 'address_0')
                  map.setCenter(point, 13);
                  map.addOverlay(marker_3);
		  map.setZoom(8);;
if('address_3' == 'address_0')
            marker_3.openInfoWindowHtml(address_3.infowindowtext);
                }
                    wagmp_map_2_obj.markers.push(marker_3);
          wagmp_map_2_obj.addresses.push(address_3);
          wagmp_map_2_obj.icons.push(icon_3);
          wagmp_map_2_obj.points.push(point);
        
              } else {
                if (wagmp_map_2_obj.addressFailed) {
                  map.setCenter(new GLatLng(30, -98), 3);
                }
                  wagmp_map_2_obj.addressFailed = true;
              }
            }
          );
        }
      }
    );
  }


  }
}