var minLat = 0;
var minLng = 0;
var maxLat = 0;
var maxLng = 0;
var pointCount = 0;
var central_marker = null;

function initialize() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("gmap"));
        map.addControl(new GLargeMapControl());
        var calcCenter = AddPoints(map);

        if (calcCenter == true) {
            var sw = new GLatLng(minLat, minLng);
            var ne = new GLatLng(maxLat, maxLng);
            //map.setMapType(G_PHYSICAL_MAP);
            //alert (sw.lat() + ", " + sw.lng());
            var bounds = new GLatLngBounds(sw, ne);
            //alert (bounds.getSouthWest().lat() + ", " + bounds.getSouthWest().lng());
            //alert (bounds.getNorthEast().lat() + ", " + bounds.getNorthEast().lng());
            var zoom = map.getBoundsZoomLevel(bounds);
            //if (zoom > 8) {
             //   zoom -= 1;
            //}
            var center = bounds.getCenter();
            map.setCenter(center, zoom);
        }
        else {
            //map.setCenter(new GLatLng(51.576111, -0.371382), 2);
        }
    }
}


// Creates a marker at the given point with the given number label
function createMarker(point, text) {
    var marker = new GMarker(point, { title: "Apartment" });
    GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(text); });
    return marker;
}



function AjaxCallBack(action, result) {
    //alert(action + ", " + result);
    switch (action) {
        case "countriesfromregion":
            PopulateCountries(result);
            break;

        case "placesfromcountry":
            PopulatePlaces(result);
            break;
    }
}

