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_9() {
  if(GBrowserIsCompatible()) {
    if(!document.getElementById('wagmp_map_9')) return false;
    var map = new GMap2(document.getElementById('wagmp_map_9'));
    wagmp_map_9_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>Newcastle</strong><br />Hwy 76 2 miles north of I-44<br />8x12, North/South face</span>',
      full: '35.273162,-97.654123',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '35.273162',
      longitude: '-97.654123',
      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_5') {
            map.setCenter(point, 13);
            map.addOverlay(marker);
          }
          wagmp_map_9_obj.markers.push(marker);
          wagmp_map_9_obj.addresses.push(address_0);
          wagmp_map_9_obj.icons.push(icon_0);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        }
      }
    );
     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>Newcastle</strong><br />Hwy 62 1.5 miles south of I-44<br />8x12, North/South face</span>',
      full: '35.270990,-97.600737',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '35.270990',
      longitude: '-97.600737',
      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_5') {
            map.setCenter(point, 13);
            map.addOverlay(marker);
          }
          wagmp_map_9_obj.markers.push(marker);
          wagmp_map_9_obj.addresses.push(address_1);
          wagmp_map_9_obj.icons.push(icon_1);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        }
      }
    );
     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>Newcastle</strong><br />Hwy 62 4 miles north of Hwy 9<br />8x12, North/South face</span>',
      full: '35.232440,-97.601080',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '35.232440',
      longitude: '-97.601080',
      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_5') {
            map.setCenter(point, 13);
            map.addOverlay(marker);
          }
          wagmp_map_9_obj.markers.push(marker);
          wagmp_map_9_obj.addresses.push(address_2);
          wagmp_map_9_obj.icons.push(icon_2);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        }
      }
    );
     waitForGeo();

    var icon_3 = new GIcon();
    icon_3.image = 'http://google.webassist.com/google/markers/traditionalflat/pacifica.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/pacifica.gif';
    icon_3.mozPrintImage = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_mozprint.png';
    icon_3.printShadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.gif';
    icon_3.transparent = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_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>Newcastle</strong><br />Hwy 62 3 miles north of Hwy 9<br />8x12, North/South face</span>',
      full: '35.218066,-97.598763',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '35.218066',
      longitude: '-97.598763',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Pacifica'      
    };
    
    geocoder.getLatLng (
      address_3.full,
      function(point) {
        if(point) {
          var marker = new GMarker(point, icon_3);
          GEvent.addListener(marker, 'click', function() {
            marker.openInfoWindowHtml(address_3.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_3' != 'address_5') {
            map.setCenter(point, 13);
            map.addOverlay(marker);
          }
          wagmp_map_9_obj.markers.push(marker);
          wagmp_map_9_obj.addresses.push(address_3);
          wagmp_map_9_obj.icons.push(icon_3);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        }
      }
    );
     waitForGeo();

    var icon_4 = new GIcon();
    icon_4.image = 'http://google.webassist.com/google/markers/traditionalflat/pacifica.png';
    icon_4.shadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.png';
    icon_4.iconSize = new GSize(34,35);
    icon_4.shadowSize = new GSize(34,35);
    icon_4.iconAnchor = new GPoint(9,23);
    icon_4.infoWindowAnchor = new GPoint(19,0);
    icon_4.printImage = 'http://google.webassist.com/google/markers/traditionalflat/pacifica.gif';
    icon_4.mozPrintImage = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_mozprint.png';
    icon_4.printShadow = 'http://google.webassist.com/google/markers/traditionalflat/shadow.gif';
    icon_4.transparent = 'http://google.webassist.com/google/markers/traditionalflat/pacifica_transparent.png';
    
    var address_4 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><strong>Newcastle</strong><br />Hwy 76 .5 mile south of I-44<br />Jr Poster, 2 North/South faces<br /><a href="pdfs/newcastledescript1.jpg" target=_blank>Photos and Pricing</a></span>',
      full: '35.247792,-97.653866',
      isdefault: false,
      addressType: 'coordinates',
      loop: '',
      latitude: '35.247792',
      longitude: '-97.653866',
      markerStyle: 'Google Traditional (flat)',
      markerColor: 'Pacifica'      
    };
    
    geocoder.getLatLng (
      address_4.full,
      function(point) {
        if(point) {
          var marker = new GMarker(point, icon_4);
          GEvent.addListener(marker, 'click', function() {
            marker.openInfoWindowHtml(address_4.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_4' != 'address_5') {
            map.setCenter(point, 13);
            map.addOverlay(marker);
          }
          wagmp_map_9_obj.markers.push(marker);
          wagmp_map_9_obj.addresses.push(address_4);
          wagmp_map_9_obj.icons.push(icon_4);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        }
      }
    );
     waitForGeo();

    var icon_5 = new GIcon();
    icon_5.image = 'http://google.webassist.com/google/markers/flag/poppy.png';
    icon_5.shadow = 'http://google.webassist.com/google/markers/flag/shadow.png';
    icon_5.iconSize = new GSize(31,35);
    icon_5.shadowSize = new GSize(31,35);
    icon_5.iconAnchor = new GPoint(4,27);
    icon_5.infoWindowAnchor = new GPoint(8,3);
    icon_5.printImage = 'http://google.webassist.com/google/markers/flag/poppy.gif';
    icon_5.mozPrintImage = 'http://google.webassist.com/google/markers/flag/poppy_mozprint.png';
    icon_5.printShadow = 'http://google.webassist.com/google/markers/flag/shadow.gif';
    icon_5.transparent = 'http://google.webassist.com/google/markers/flag/poppy_transparent.png';
    
    var address_5 = {
      street: '',
      city: '',
      state: '',
      zip: '',
      country: '',
      infowindow: 'custom',
      infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><strong>Newcastle</strong></span>',
      full: '35.247582,-97.623653',
      isdefault: true,
      addressType: 'coordinates',
      loop: '',
      latitude: '35.247582',
      longitude: '-97.623653',
      markerStyle: 'Flag',
      markerColor: 'Poppy'      
    };
    
    geocoder.getLatLng (
      address_5.full,
      function(point) {
        if(point) {
          var marker = new GMarker(point, icon_5);
          GEvent.addListener(marker, 'click', function() {
            marker.openInfoWindowHtml(address_5.infowindowtext);
          });
          if(!fromAddress.enabled || 'address_5' != 'address_5') {
            map.setCenter(point, 13);
            map.addOverlay(marker);
            marker.openInfoWindowHtml(address_5.infowindowtext);
          }
          wagmp_map_9_obj.markers.push(marker);
          wagmp_map_9_obj.addresses.push(address_5);
          wagmp_map_9_obj.icons.push(icon_5);
        }
        else {
          map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        }
      }
    );
     waitForGeo();


  }
}