//<![CDATA[

google.load("maps", "2.x", {"other_params":"sensor=false"});

var map;
var markers = new Array();
var markerGroups = { "all": [],
                     "current": [],
                     "area": [],
                     "forrent": [],
                     "forsale": [],
                     "esus_id_1": [],
                     "esus_id_2": [],
                     "esus_id_3": [],
                     "esus_id_4": [],
                     "esus_id_5": [],
                     "esus_id_6": [],
                     "esus_id_7": [],
                     "esus_id_8": [],
                     "esus_id_9": [],
                     "esus_id_10": [],
                     "esus_id_11": [],
                     "esus_id_12": [],
                     "esus_id_13": []
                   };


function gmap_starter() {
     if (GBrowserIsCompatible()) {

        // Load dynamic gmap settings
        gmap_settings = gmap_load_dynamic_settings();

        // Initialize map
        map = new google.maps.Map2(document.getElementById("map"));
        map.setCenter(new google.maps.LatLng(gmap_settings['mapcenter_google_x'], gmap_settings['mapcenter_google_y']), gmap_settings['mapcenter_google_z']);

        map.setUIToDefault();
        map.disableScrollWheelZoom();

        switch(gmap_settings['map_type'])
        {
            case 'esof_detail':
                GIcons = initialize_estate_icons();
                add_markers_esof_detail(gmap_settings['id']);
                break;
            case 'map_nl':
                add_markers_gmap_nl();
                break;
            case 'map_province':
                add_markers_gmap_province(gmap_settings['id']);
                break;
            case 'map_city':
                GIcons = initialize_estate_icons();
                add_markers_gmap_city(gmap_settings['id']);
                break;
        }
    }
}


function hideGroup(type) {
  for (var i = 0; i < markerGroups[type].length; i++) {
    var marker = markerGroups[type][i];
    marker.hide();
  }
}

function showGroup(type) {
  for (var i = 0; i < markerGroups[type].length; i++) {
    var marker = markerGroups[type][i];
    marker.show();
  }
}

function updateFilter() {
    if($('input:radio[name=show_markers]:checked').val() == 'current') {
        hideGroup('all');
        showGroup('current');
    }

    if($('input:radio[name=show_markers]:checked').val() == 'all') {
        showGroup('all');
    }

}

function initialize_estate_icons()
{
    // Load estate markers
    var GIcons = new Array()
    // Bedrijfsruimte
    GIcons['esus_id_1'] = new GIcon();
    GIcons['esus_id_1'].image = '/style/images/estate-icon-bedrijfsruimte.png';
    GIcons['esus_id_1'].iconSize = new GSize(20, 20);
    GIcons['esus_id_1'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_1'].infoWindowAnchor = new GPoint(15, 15);

    // Beleggingspand
    GIcons['esus_id_2'] = new GIcon();
    GIcons['esus_id_2'].image = '/style/images/estate-icon-kantoorruimte.png';
    GIcons['esus_id_2'].iconSize = new GSize(20, 20);
    GIcons['esus_id_2'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_2'].infoWindowAnchor = new GPoint(15, 15);

    // Horecapand
    GIcons['esus_id_3'] = new GIcon();
    GIcons['esus_id_3'].image = '/style/images/estate-icon-winkelruimte.gif';
    GIcons['esus_id_3'].iconSize = new GSize(20, 20);
    GIcons['esus_id_3'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_3'].infoWindowAnchor = new GPoint(15, 15);

    // Kantoorruimte
    GIcons['esus_id_4'] = new GIcon();
    GIcons['esus_id_4'].image = '/style/images/estate-icon-kantoorruimte.png';
    GIcons['esus_id_4'].iconSize = new GSize(20, 20);
    GIcons['esus_id_4'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_4'].infoWindowAnchor = new GPoint(15, 15);

    // Kavel
    GIcons['esus_id_5'] = new GIcon();
    GIcons['esus_id_5'].image = '/style/images/estate-icon-bedrijfsruimte.png';
    GIcons['esus_id_5'].iconSize = new GSize(20, 20);
    GIcons['esus_id_5'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_5'].infoWindowAnchor = new GPoint(15, 15);

    // Opslagruimte
    GIcons['esus_id_6'] = new GIcon();
    GIcons['esus_id_6'].image = '/style/images/estate-icon-bedrijfsruimte.png';
    GIcons['esus_id_6'].iconSize = new GSize(20, 20);
    GIcons['esus_id_6'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_6'].infoWindowAnchor = new GPoint(15, 15);

    // Praktijkruimte
    GIcons['esus_id_7'] = new GIcon();
    GIcons['esus_id_7'].image = '/style/images/estate-icon-kantoorruimte.png';
    GIcons['esus_id_7'].iconSize = new GSize(20, 20);
    GIcons['esus_id_7'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_7'].infoWindowAnchor = new GPoint(15, 15);

    // Verzamelgebouw
    GIcons['esus_id_8'] = new GIcon();
    GIcons['esus_id_8'].image = '/style/images/estate-icon-kantoorruimte.png';
    GIcons['esus_id_8'].iconSize = new GSize(20, 20);
    GIcons['esus_id_8'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_8'].infoWindowAnchor = new GPoint(15, 15);

    // Winkelruimte
    GIcons['esus_id_9'] = new GIcon();
    GIcons['esus_id_9'].image = '/style/images/estate-icon-winkelruimte.gif';
    GIcons['esus_id_9'].iconSize = new GSize(20, 20);
    GIcons['esus_id_9'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_9'].infoWindowAnchor = new GPoint(15, 15);

    // Showroom
    GIcons['esus_id_10'] = new GIcon();
    GIcons['esus_id_10'].image = '/style/images/estate-icon-bedrijfsruimte.png';
    GIcons['esus_id_10'].iconSize = new GSize(20, 20);
    GIcons['esus_id_10'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_10'].infoWindowAnchor = new GPoint(15, 15);

    // Garagebox
    GIcons['esus_id_11'] = new GIcon();
    GIcons['esus_id_11'].image = '/style/images/estate-icon-bedrijfsruimte.png';
    GIcons['esus_id_11'].iconSize = new GSize(20, 20);
    GIcons['esus_id_11'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_11'].infoWindowAnchor = new GPoint(15, 15);

    // Werkplek
    GIcons['esus_id_12'] = new GIcon();
    GIcons['esus_id_12'].image = '/style/images/estate-icon-kantoorruimte.png';
    GIcons['esus_id_12'].iconSize = new GSize(20, 20);
    GIcons['esus_id_12'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_12'].infoWindowAnchor = new GPoint(15, 15);

    // Agrarisch vastgoed
    GIcons['esus_id_13'] = new GIcon();
    GIcons['esus_id_13'].image = '/style/images/estate-icon-bedrijfsruimte.png';
    GIcons['esus_id_13'].iconSize = new GSize(20, 20);
    GIcons['esus_id_13'].iconAnchor = new GPoint(8, 8);
    GIcons['esus_id_13'].infoWindowAnchor = new GPoint(15, 15);

    return GIcons;

}

//]]>