function WAMapRef(mapObj)  {
  this.obj = mapObj;
  this.directions = false;
  this.icons = [];
  this.markers = [];
  this.addresses = [];
  this.points = [];
  this.getPointByAddress = getPointByAddressFunc;
  return this;
}

function waitForGeo()  {
  var startDate = new Date();
  var endDate = new Date();
  while ((endDate-startDate) < 200)  {
    endDate = new Date();
  }
}

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 wagmp_map_3() {
  if(GBrowserIsCompatible()) {
    if(!document.getElementById('wagmp_map_3')) return false;
    var map = new GMap2(document.getElementById('wagmp_map_3'));
    wagmp_map_3_obj = new WAMapRef(map);
    map.enableContinuousZoom();
    map.enableDoubleClickZoom();
    map.addControl(new GLargeMapControl());
    map.addControl(new GScaleControl());
    map.addControl(new GMapTypeControl());
    map.addControl(new GOverviewMapControl());
    var geocoder = new GClientGeocoder();
    
    var fromAddress = {
      enabled: false,
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      full: ''
    };

    var icon_0 = new GIcon();
    icon_0.image = 'http://google.webassist.com/google/markers/traditionalflat/yosemite.png';
    icon_0.shadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.png';
    icon_0.iconSize = new GSize(34,35);
    icon_0.shadowSize = new GSize(34,35);
    icon_0.iconAnchor = new GPoint(9,23);
    icon_0.infoWindowAnchor = new GPoint(19,0);
    icon_0.printImage = 'http://google.webassist.com/google/markers/traditionalflat/yosemite.gif';
    icon_0.mozPrintImage = 'http://google.webassist.com/google/markers/traditionalflat/yosemite_mozprint.png';
    icon_0.printShadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.gif';
    icon_0.transparent = 'http://google.webassist.com/google/markers/traditionalflat/yosemite_transparent.png';
    
    var address_0 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><strong>Spirit Walker Expeditions</strong><br />Our headquarters is located at the<br />end of Grandpa\'s Farm Road.</span>',
      full: '58.406266,-135.760955',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '58.406266',
      longitude: '-135.760955',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Yosemite'      
    };
    
    var point_0 = new GLatLng(address_0.latitude, address_0.longitude);
      var marker_0 = new GMarker(point_0, icon_0);
      GEvent.addListener(marker_0, 'click', function() {
        marker_0.openInfoWindowHtml(address_0.infowindowtext);
      });
      if(!fromAddress.enabled || 'address_0' != 'address_3') {
            map.setCenter(point_0, 13);
            map.addOverlay(marker_0);
            marker_0.openInfoWindowHtml(address_0.infowindowtext);
      }
      wagmp_map_3_obj.markers.push(marker_0);
      wagmp_map_3_obj.addresses.push(address_0);
      wagmp_map_3_obj.icons.push(icon_0);
      wagmp_map_3_obj.points.push(point_0);

    var icon_1 = new GIcon();
    icon_1.image = 'http://google.webassist.com/google/markers/traditionalflat/moab.png';
    icon_1.shadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.png';
    icon_1.iconSize = new GSize(34,35);
    icon_1.shadowSize = new GSize(34,35);
    icon_1.iconAnchor = new GPoint(9,23);
    icon_1.infoWindowAnchor = new GPoint(19,0);
    icon_1.printImage = 'http://google.webassist.com/google/markers/traditionalflat/moab.gif';
    icon_1.mozPrintImage = 'http://google.webassist.com/google/markers/traditionalflat/moab_mozprint.png';
    icon_1.printShadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.gif';
    icon_1.transparent = 'http://google.webassist.com/google/markers/traditionalflat/moab_transparent.png';
    
    var address_1 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><strong>Town Center</strong><br />While in Gustavus, be sure to <br />visit our local shops and galleries!</span>',
      full: '58.412874,-135.727522',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '58.412874',
      longitude: '-135.727522',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Moab'      
    };
    
    var point_1 = new GLatLng(address_1.latitude, address_1.longitude);
      var marker_1 = new GMarker(point_1, icon_1);
      GEvent.addListener(marker_1, 'click', function() {
        marker_1.openInfoWindowHtml(address_1.infowindowtext);
      });
      if(!fromAddress.enabled || 'address_1' != 'address_3') {
            map.setCenter(point_1, 13);
            map.addOverlay(marker_1);
            marker_1.openInfoWindowHtml(address_1.infowindowtext);
      }
      wagmp_map_3_obj.markers.push(marker_1);
      wagmp_map_3_obj.addresses.push(address_1);
      wagmp_map_3_obj.icons.push(icon_1);
      wagmp_map_3_obj.points.push(point_1);

    var icon_2 = new GIcon();
    icon_2.image = 'http://google.webassist.com/google/markers/traditionalflat/pacifica.png';
    icon_2.shadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.png';
    icon_2.iconSize = new GSize(34,35);
    icon_2.shadowSize = new GSize(34,35);
    icon_2.iconAnchor = new GPoint(9,23);
    icon_2.infoWindowAnchor = new GPoint(19,0);
    icon_2.printImage = 'http://google.webassist.com/google/markers/traditionalflat/pacifica.gif';
    icon_2.mozPrintImage = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_mozprint.png';
    icon_2.printShadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.gif';
    icon_2.transparent = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_transparent.png';
    
    var address_2 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><strong>Gustavus Dock</strong><br />Most of our boat transfers begin<br />and end at the Gustavus Dock.</span>',
      full: '58.397568,-135.729003',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '58.397568',
      longitude: '-135.729003',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Pacifica'      
    };
    
    var point_2 = new GLatLng(address_2.latitude, address_2.longitude);
      var marker_2 = new GMarker(point_2, icon_2);
      GEvent.addListener(marker_2, 'click', function() {
        marker_2.openInfoWindowHtml(address_2.infowindowtext);
      });
      if(!fromAddress.enabled || 'address_2' != 'address_3') {
            map.setCenter(point_2, 13);
            map.addOverlay(marker_2);
            marker_2.openInfoWindowHtml(address_2.infowindowtext);
      }
      wagmp_map_3_obj.markers.push(marker_2);
      wagmp_map_3_obj.addresses.push(address_2);
      wagmp_map_3_obj.icons.push(icon_2);
      wagmp_map_3_obj.points.push(point_2);

    var icon_3 = new GIcon();
    icon_3.image = 'http://google.webassist.com/google/markers/traditionalflat/desertspice.png';
    icon_3.shadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.png';
    icon_3.iconSize = new GSize(34,35);
    icon_3.shadowSize = new GSize(34,35);
    icon_3.iconAnchor = new GPoint(9,23);
    icon_3.infoWindowAnchor = new GPoint(19,0);
    icon_3.printImage = 'http://google.webassist.com/google/markers/traditionalflat/desertspice.gif';
    icon_3.mozPrintImage = 'http://google.webassist.com/google/markers/traditionalflat/desertspice_mozprint.png';
    icon_3.printShadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.gif';
    icon_3.transparent = 'http://google.webassist.com/google/markers/traditionalflat/desertspice_transparent.png';
    
    var address_3 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><strong>Gustavus, Alaska</strong><br />Gustavus is the departure point<br />for most of our expeditions. <br />Check out the Satellite View!</span>',
      full: '58.407917,-135.74604',
      isdefault: true,
      addressType: 'coordinates',
      loop: '',
      latitude: '58.407917',
      longitude: '-135.74604',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Desert Spice'      
    };
    
    var point_3 = new GLatLng(address_3.latitude, address_3.longitude);
      var marker_3 = new GMarker(point_3, icon_3);
      GEvent.addListener(marker_3, 'click', function() {
        marker_3.openInfoWindowHtml(address_3.infowindowtext);
      });
      if(!fromAddress.enabled || 'address_3' != 'address_3') {
            map.setCenter(point_3, 12);
            map.addOverlay(marker_3);
            marker_3.openInfoWindowHtml(address_3.infowindowtext);
      }
      wagmp_map_3_obj.markers.push(marker_3);
      wagmp_map_3_obj.addresses.push(address_3);
      wagmp_map_3_obj.icons.push(icon_3);
      wagmp_map_3_obj.points.push(point_3);


  }
}