
function initGMAP(mapId, show, zoom) {
    if(!show) {
        show = [ 'conference', 'special', 'hotel', 'hotel_conv' ];
    }
    if(!zoom)
        zoom = 15;
    var places = [
        {
            'name': 'Hotel Laurus',
            'description': '<p>L\'Hotel Laurus ospita i tre giorni della conferenza</p>',
            'coordinate': new google.maps.LatLng(43.7734241, 11.2526663),
            'type': 'conference'
        }/*,
        {
            'name': 'Williams',
            'description': '<p>Il pub <strong>Williams</strong> ci ospiterà per la PyBirra</p>',
            'coordinate': new google.maps.LatLng(43.7676679, 11.261409),
            'type': 'conference'
        },
        {
            'name': 'Trattoria Zazà',
            'description': '<p>La <strong>trattoria Zazà</strong> dove ci ritroveremo per la PyFiorentina</p>',
            'coordinate': new google.maps.LatLng(43.7765079, 11.2544709),
            'type': 'conference'
        }*/
    ];
    var pyconIcon = new GIcon(G_DEFAULT_ICON);
    pyconIcon.image = "/static/9e802f66e238/p4/i/marker_pycon.png";
    var hotelIcon = new GIcon(G_DEFAULT_ICON);
    hotelIcon.image = "/static/9e802f66e238/p4/i/marker_hotel.png";
    var hotelCIcon = new GIcon(G_DEFAULT_ICON);
    hotelCIcon.image = "/static/9e802f66e238/p4/i/marker_hotel_conv.png";

    var mapEl = $('#' + mapId);
    var map = new google.maps.Map2(mapEl.get(0));
    map.setCenter(places[0]['coordinate'], zoom);
    map.setUIToDefault();
    if(mapEl.width() < 300) {
        /*
         * se la mappa è piccola riduco il testo del footer (con le indicazioni
         * del copyright) perché altrimenti sfonda il bordo della mappa
         */
        function reduceFontText() {
            $('#' + mapId + ' div span').each(function() {
                var s = $(this);
                if(s.text().indexOf('Map data') != -1) {
                    s.parent().css('font-size', '9px');
                }
            });
        }
        /*
         * ritardo l'esecuzione perché in questo momento gli elementi che sto
         * cercando non sono stati creati.
         */
        setTimeout(reduceFontText, 500);
    }
    function addConferencePlaceMarker() {
        if($.inArray(this.type, show) == -1)
            return;
        var marker = new google.maps.Marker(
            this.coordinate, {title: this.name, icon: pyconIcon});
        map.addOverlay(marker);
        marker.bindInfoWindowHtml(this.description);
    }
    function addHotelMarker() {
        var htype = this.affiliated ? 'hotel_conv' : 'hotel';
        if($.inArray(htype, show) == -1)
            return;
        var point = new google.maps.LatLng(this.lat, this.lng);
        var marker = new google.maps.Marker(point, { icon: this.affiliated ? hotelCIcon : hotelIcon });
        map.addOverlay(marker);
        var d = '';
        d += '<div class="info-hotel">';
        d += '<h1>' + this.name + ' <a href="/pycon3/dove/#h-' + this.id + '">&rarr;</a></h1>';
        d += '<table>';
        if(this.telephone)
            d += '<tr><th>telefono:</th><td>' + this.telephone + '</td></tr>';
        if(this.email)
            d += '<tr><th>email:</th><td><a href="mailto:' + this.email+ '">' + this.email + '</a></td></tr>';
        if(this.url)
            d += '<tr><th>sito:</th><td><a href="' + this.url+ '">' + this.url + '</a></td></tr>';
        d += '<tr><th>prezzo:</th><td>' + this.price + '</td></tr>';
        d += '</table>';
        d += '<br /><br />';
        d += '</div>';
        marker.bindInfoWindowHtml(d);
    }
    $.each(places, addConferencePlaceMarker);
    $.getJSON('/conference/hotels/', function(data) {
        $.each(data, addHotelMarker);
    });
}


