﻿var map;
var geocoder;
var FfbMarkerIcon;

function InitializeMap() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("divMap"));
        map.setCenter(new GLatLng(28.3235, -83.496094), 7);
        map.setUIToDefault();
        map.disableScrollWheelZoom();
        geocoder = new GClientGeocoder();
        FfbMarkerIcon = new GIcon(G_DEFAULT_ICON);
        FfbMarkerIcon.image = "ffbmarker.png";
        AddOfficeMarkers(map);
    }
}

function InitializeMapAtLocation(location) {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("divMap"));
        geocoder = new GClientGeocoder();
        geocoder.getLatLng(location, function(point) { if (!point) { alert(location + " not found"); InitializeMap(); return false; } else { map.setCenter(point, 11); } });
        map.setUIToDefault();
        map.disableScrollWheelZoom();
        FfbMarkerIcon = new GIcon(G_DEFAULT_ICON);
        FfbMarkerIcon.image = "ffbmarker.png";
        AddOfficeMarkers(map);
    }
}

function UpdateMap(location) {
    if (GBrowserIsCompatible()) {
        // Determine lat long of location and recenter map
        geocoder.getLatLng(location, function(point) { if (!point) { alert(location + " not found"); } else { if (point.lat() >= 24.4 && point.lat() <= 31.1 && point.lng() <= -79.9 && point.lng() >= -87.7) { map.setCenter(point, 11); } else { UpdateMap(location + " FL"); } } });
    }
}
