function load () {
var map = document.getElementById("map");
if (GBrowserIsCompatible()) {
var gmap = new GMap2(map);
gmap.addControl(new GLargeMapControl());
gmap.addControl( new GMapTypeControl()) ;
gmap.enableScrollWheelZoom();
//gmap.addControl( new GOverviewMapControl(new GSize(100,100)) );
gmap.setCenter( new GLatLng(47.63023101663225, -122.35336303710937), 11);
GDownloadUrl("Main.json", function(data, responseCode) { parseJson(data);});
} else {
alert("Sorry, your browser cannot handle the true power of Google Maps");
}

function createMarker(input) {
var marker = new GMarker(input.coordinates, makeIcon(input.iconimage) );
var tabs = [ new GInfoWindowTab("Information", formatWindow1(input)), new GInfoWindowTab("Summary", formatWindow2(input)) ];
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowTabsHtml( tabs );
});
return marker;
}
function parseJson (doc) {
var jsonData = eval("(" + doc + ")");
for (var i = 0; i < jsonData.markers.length; i++) {
var marker = createMarker(jsonData.markers[i]);
gmap.addOverlay(marker);
}
}
function makeIcon (image) {
var icon = new GIcon();
icon.image = image;
icon.shadow = "../images/pin_shadow.png"
icon.iconSize = new GSize(22, 22);
icon.shadowSize = new GSize(26, 22);
icon.iconAnchor = new GPoint(8, 16);
icon.infoShadowAnchor = new GPoint(0, 0);
icon.infoWindowAnchor = new GPoint(8, 1);
return icon;
}
GDownloadUrl("Main.json", function(data, responseCode) {
parseJson(data);
});
function formatWindow1 (input) {
var html = "<div class=\"bubble\">";
html += "<table>";
html += "<th>" + input.name + "</th>";
//html += "<tr><td>" + input.summary + "</td></tr>";
html += "<tr><td><b>Construction scheduled to Begin:</b> " + input.scheduled + "</td></tr>";
html += "<tr><td><b>Estimated Construction Cost:</b> " + input.cost + "</td></tr>";
html += '<tr><td><b>Contact:</b> <a href="mailto:' + input.email + '">' + input.contact + "</a></tr></td>";
html += "</table>";
html += "<p>"
if(input.fixture != null) {
html += "<strong>Cost:</strong> " + input.scheduled + "<br />";
}
/* Some more formatting */
html += "</p></div>";
return html;
}
function formatWindow2 (input) {
var html = "<div class=\"bubble2\">";
html += "<table>";
//html += "<th>" + input.name + "</th>";
html += "<tr><td>" + input.summary + "</td></tr>";
//html += "<tr><td><b>Estimated Construction Cost:</b> " + input.cost + "</td></tr>";
//html += '<tr><td>Contact: <a href="mailto:' + input.email + '">' + input.contact + "</a></tr></td>";
html += "<tr><td><strong>URL:</strong> <a href='" + input.URL + "' target='_blank'>" + input.URL + "</a></td></tr>";
html += "</table>";
html += "<p>"
if(input.fixture != null) {
html += "<strong>Cost:</strong> " + input.scheduled + "<br />";

}
/* Some more formatting */
html += "</p></div>";
return html;
}
}
window.onload = load;
window.onunload = GUnload;