function WAMapRef(mapObj)  {
  this.obj = mapObj;
  this.directions = false;
  this.icons = [];
  this.markers = [];
  this.addresses = [];
  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_7() {
  if(GBrowserIsCompatible()) {
    if(!document.getElementById('wagmp_map_7')) return false;
    var map = new GMap2(document.getElementById('wagmp_map_7'));
    wagmp_map_7_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: ''
    };

    var icon_0 = new GIcon();
    icon_0.image = 'http://google.webassist.com/google/markers/traditionalflat/pacifica.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/pacifica.gif';
    icon_0.mozPrintImage = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_mozprint.png';
    icon_0.printShadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.gif';
    icon_0.transparent = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_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>Lindsay</strong><br />Hwy 19, 2.5 miles west of 76<br />2,900 AVD<br /><a href="pdfs/lindsayhwy19wof76.jpg" target=_blank>Photos and Pricing</a></span>',
      full: '34.841246,-97.633910',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '34.841246',
      longitude: '-97.633910',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Pacifica'      
    };
    
    geocoder.getLatLng (
      address_0.full,
      function(point) {
        if(point) {
          var marker = new GMarker(point, icon_0);
          GEvent.addListener(marker, 'click', function() {
            marker.openInfoWindowHtml(address_0.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_0' != 'address_1') {
            map.setCenter(point, 12);
            map.addOverlay(marker);
          }
          wagmp_map_7_obj.markers.push(marker);
          wagmp_map_7_obj.addresses.push(address_0);
          wagmp_map_7_obj.icons.push(icon_0);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 12);
        }
      }
    );
     waitForGeo();

    var icon_1 = new GIcon();
    icon_1.image = 'http://google.webassist.com/google/markers/traditionalflat/pacifica.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/pacifica.gif';
    icon_1.mozPrintImage = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_mozprint.png';
    icon_1.printShadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.gif';
    icon_1.transparent = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_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>Lindsay</strong><br />Hwy 19, 4 miles east of 76<br />4,800 AVD<br /><a href="pdfs/lindsayhwy19eof76.jpg" target=_blank>Photos and Pricing</a></span>',
      full: '34.823105,-97.521515',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '34.823105',
      longitude: '-97.521515',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Pacifica'      
    };
    
    geocoder.getLatLng (
      address_1.full,
      function(point) {
        if(point) {
          var marker = new GMarker(point, icon_1);
          GEvent.addListener(marker, 'click', function() {
            marker.openInfoWindowHtml(address_1.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_1' != 'address_1') {
            map.setCenter(point, 12);
            map.addOverlay(marker);
          }
          wagmp_map_7_obj.markers.push(marker);
          wagmp_map_7_obj.addresses.push(address_1);
          wagmp_map_7_obj.icons.push(icon_1);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 12);
        }
      }
    );
     waitForGeo();

    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>Lindsay</strong><br />Hwy 76, 2.8 miles south of 19<br />5,500 AVD<br /><a href="pdfs/lindsayhwy76sof19descript.jpg" target=_blank>Photos and Pricing</a></span>',
      full: '34.800484,-97.597818',
      isdefault: true,
      addressType: 'coordinates',
      loop: '',
      latitude: '34.800484',
      longitude: '-97.597818',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Pacifica'      
    };
    
    geocoder.getLatLng (
      address_2.full,
      function(point) {
        if(point) {
          var marker = new GMarker(point, icon_2);
          GEvent.addListener(marker, 'click', function() {
            marker.openInfoWindowHtml(address_2.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_2' != 'address_1') {
            map.setCenter(point, 12);
            map.addOverlay(marker);
            marker.openInfoWindowHtml(address_2.infowindowtext);
          }
          wagmp_map_7_obj.markers.push(marker);
          wagmp_map_7_obj.addresses.push(address_2);
          wagmp_map_7_obj.icons.push(icon_2);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 12);
        }
      }
    );
     waitForGeo();


  }
}