// JavaScript Document

//<![CDATA[

if (GBrowserIsCompatible()) { 

      // ========== Read paramaters that have been passed in ==========
      
      // Before we go looking for the passed parameters, set some defaults
      // in case there are no parameters
      var lat = 38.277805;
      var lng = -96.099010;
      var zoom = 4;
      var maptype = G_NORMAL_MAP;

      // If there are any parameters at the end of the URL, they will be in  location.search
      // looking something like  "?lat=50&lng=-3&zoom=10&type=h"

      // skip the first character, we are not interested in the "?"
      var query = location.search.substring(1);

      // split the rest at each "&" character to give a list of  "argname=value"  pairs
      var pairs = query.split("&");
      for (var i=0; i<pairs.length; i++) {
        // break each pair at the first "=" to obtain the argname and value
	var pos = pairs[i].indexOf("=");
	var argname = pairs[i].substring(0,pos).toLowerCase();
	var value = pairs[i].substring(pos+1).toLowerCase();

        // process each possible argname
        if (argname == "lat") {lat = parseFloat(value);}
        if (argname == "lng") {lng = parseFloat(value);}
        if (argname == "zoom") {zoom = parseInt(value);}
        if (argname == "type") {
          if (value == "m") {maptype = G_NORMAL_MAP;}
          if (value == "k") {maptype = G_SATELLITE_MAP;}
          if (value == "h") {maptype = G_HYBRID_MAP;}
        }
      }

      // ========== Create the map using the information obtained above ========
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.setCenter(new GLatLng(lat,lng), zoom, maptype);
      var mm = new GMarkerManager(map);

      // ========== This function will create the "link to this page"
      function makeLink() {
        var a="../the-best-wedding-vendors" 
           + "?lat=" + map.getCenter().lat().toFixed(6)
           + "&lng=" + map.getCenter().lng().toFixed(6)
           + "&zoom=" + map.getZoom()
           + "&type=" + map.getCurrentMapType().getUrlArg();
        document.getElementById("mylink").innerHTML = '<a href="' +a+ '">Link to this page</a>';
      }

      // Make the link the first time when the page opens
      makeLink();

      // Make the link again whenever the map changes
      GEvent.addListener(map, 'moveend', makeLink);
    }
    
    // display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }








	
// Create our "tiny" marker icon
var icon = new GIcon();
icon.iconSize = new GSize(16, 24);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(8, 24);
icon.infoWindowAnchor = new GPoint(5, 1);


// Create the marker and corresponding information window
function createInfoMarker(point, address) {
   var marker = new GMarker(point, icon);
   GEvent.addListener(marker, "click",
      function() {
         marker.openInfoWindowHtml(address);
      }
   );
  return marker;
}


// -------------------- STATE LEVEL ---------------------------------------------

// -------------------- michigan -------------------------
var point = new GPoint(-84.552279, 42.73202);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<h1>MICHIGAN</h1><p>1 Location</p>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,0,4); 

// -------------------- missouri -------------------------
var point = new GPoint (-92.460938, 38.238180);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<h1>MISSOURI</h1><p>1 Location</p>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,0,4);

// -------------------- illinois -------------------------
var point = new GPoint (-89.643604, 39.801055);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<h1>ILLINOIS</h1><p>1 Location</p>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,0,4);

// -------------------- indiana -------------------------
// Latitude: 39.766201  /  Longitude: -86.441254
var point = new GPoint (-86.441254, 39.766201);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<h1>INDIANA</h1><p>1 Location</p>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,0,4);


/*
// -------------------- CITY LEVEL ---------------------------------------------

// -------------------- michigan -------------------------

// EASTPOINTE
var point = new GPoint(-82.955419, 42.4682);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<h1>Eastpointe</h1><p>1 Location</p>";
var marker = createInfoMarker(point, address);
mm.addMarker(marker,5,7); 


// -------------------- missouri -------------------------

// KANSAS CITY
var point = new GPoint (-94.583062, 39.10296);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<h1>Kansas City</h1><p>1 Location</p>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,5,7); 


// -------------------- illinois -------------------------

// WILLOWBROOK
var point = new GPoint (-87.940253, 41.747282);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<h1>Willowbrook</h1><p>1 Location</p>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,5,7); 

// -------------------- indiana -------------------------

// FISHERS  Latitude: 39.9582  /  Longitude: -86.017089
var point = new GPoint (-86.017089, 39.9582);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<h1>Fishers</h1><p>1 Location</p>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,5,7); 
*/


// -------------------- DETAIL LEVEL ---------------------------------------------


// -------------------- michigan -------------------------

// 22432 Petersburg Ave
var point = new GPoint(-82.926959, 42.463124);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<div style='height:170px'><h2>Beautiful Scenery, Inc.</h2><p>22432 Petersburg Ave<br />Eastpointe, MI 48021<br />LaSonda Clark</p><a href='/index.php/the-best-wedding-vendors/beautiful-scenery-inc/'>view details</a></div>";
var marker = createInfoMarker(point, address);
mm.addMarker(marker,5,17); 


// -------------------- missouri -------------------------

// 3101 Broadway
var point = new GPoint (-94.589912, 39.071161);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<div style='height:170px'><h2>Open Options</h2><p style='margin:0px;'>3101 Broadway, Suite 400<br />Kansas City, MO 64111<br />Bruce Scott CEO</p><a href='/index.php/the-best-wedding-vendors/open-options/'>view details</a></div>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,5,17); 


// -------------------- illinois -------------------------

// 16W621 S Frontage Rd
var point = new GPoint (-87.950295, 41.738763);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<div style='height:170px'><h2>Champagne Lodge &amp; Luxury Suites</h2><p>16W621 S Frontage Rd<br />Willowbrook, IL 60527<br />Robert Hanson<br />John VanProoyen</p><a href='/index.php/the-best-wedding-vendors/champagne-lodge-luxury-suites/'>view details</a></div>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,5,17); 

// --------------------- indiana ------------------------
// Latitude: 39.932872  /  Longitude: -86.058327
// Herbal Art (retail location): 9943 Allisonville Road Fishers, Indiana 46038
var point = new GPoint (-86.058327, 39.932872);
var icon = new GIcon(G_DEFAULT_ICON);
address = "<div style='height:170px'><h2>Herbal Art</h2><p>9943 Allisonville Road<br />Fishers, Indiana 46038<br />Brian Paffen</p><a href='/index.php/the-best-wedding-vendors/herbal-art/'>view details</a></div>";
var marker = createInfoMarker (point, address);
mm.addMarker(marker,5,17); 


//]]>
