var map;
var map_cur_layer;
var _defaultmaptype = G_PHYSICAL_MAP // terrain

jQuery(document).ready(function() {
    init_map();
});

function init_map() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById('loonie-sightings-map'));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(53,-100),4,_defaultmaptype);
        loadKML('sponsor.kml', 1000000)
        loadKML('sightings.kml', 2000000);
    }
}

function loadKML(kml_url, zindex) {
    var Icon = new GIcon();
    Icon.iconSize = new GSize(35, 28);
    Icon.iconAnchor = new GPoint(5, 16);
    Icon.infoWindowAnchor = new GPoint(5, 4);
    map_cur_layer = new EGeoXml('map_cur_layer', map, kml_url, {
        nozoom: true, 
        baseicon:Icon,
        // set zindex for all markers in this layer (does not apply to polylines, polygons)
        markeroptions:{zIndexProcess:function(){return zindex;}}
        });
    map_cur_layer.parse();
}
