﻿/****************************************
*                                       *
*   Global variables                    *
*                                       *
*****************************************/

var map;

/****************************************
*                                       *
*   Constants                           *
*                                       *
*****************************************/

var zoomLevels = {   // [min, max]
    "None": [1, 4],
    "Counties": [5, 9],
    "Areas": [10, 14],
    "Offices": [12, 17],
    "Listings": [15, 17]
};

var iconRoot = "/layout/googlemaps/";
var iconSuffix = "_icon.png";
var icons = {
    "County": new GIcon(G_DEFAULT_ICON, iconRoot + "county" + iconSuffix),
    "Area": new GIcon(G_DEFAULT_ICON, iconRoot + "area" + iconSuffix),
    "Office": new GIcon(G_DEFAULT_ICON, iconRoot + "office" + iconSuffix),
    "Listing": new GIcon(G_DEFAULT_ICON, iconRoot + "noth" + iconSuffix),
    "OpenHouse": new GIcon(G_DEFAULT_ICON, iconRoot + "oh" + iconSuffix)
}

/****************************************
*                                       *
*   Initial load                        *
*                                       *
*****************************************/

$(document).unload(function() {
    GUnload();
});

function initializeMap(latitude, longitude, zoom, mapType) {
    if (GBrowserIsCompatible()) {
        var map = new GMap2($("#map_canvas").get(0), { size: new GSize($("#map_canvas").width(), $("#map_canvas").height()) });
        map.setCenter(new GLatLng(latitude, longitude), zoom);
        map.setUIToDefault();
        if (mapType != null)
            map.setMapType(mapType);
        map.disableScrollWheelZoom();
        return map;
    }
}