/*=================================================================================================*/
/*  Implementation Google Map
/*=================================================================================================*/

var geoMaps = [];
var geoMap = null;
//var name = "map";
var zoomFactor = 3;
var allowScrollZoom = true;
var geo_data = [];
var openInfoWindow = null;

google.load( 'maps', '3', {other_params: 'sensor=true&oe=utf8'} );
//google.load( 'jquery', '1' );
//google.setOnLoadCallback( initialize_google_map );

//=== Private functions =======================================================

function refresh() {
    var i = 0;
    var markers = [];
    var contents = [];
    var contentString = '';
    var icon = new google.maps.MarkerImage('/skins/destinationmap/images/pin.png', new google.maps.Size(26, 26));

    for (i; i < geo_data.count; ++i) {
        var latLng = new google.maps.LatLng(geo_data.entries[i].latitude, geo_data.entries[i].longitude);
        var marker = new google.maps.Marker({ position: latLng, draggable: false, icon: icon, title: geo_data.entries[i].title, zIndex: i });

        markers.push(marker);
        marker.setMap(geoMap);

        contentString = '<div class="google_cloud_content">';
        contentString += '<table cellpadding=0 cellspacing=0 border=0 class="google_cloud_table"><tr>';
        if (geo_data.entries[i].photoUrl != "") {
            contentString += '<td valign="top" width="70" nowrap style="padding-right:8px;"><img class="google_cloud_image" src="' + geo_data.entries[i].photoUrl + '"/></td>';
        }
        contentString += '<td valign="top">';
        contentString += '<div class="google_cloud_header">' + geo_data.entries[i].title + '</div><br/>';
        contentString += '<div class="google_cloud_info"><p>' + geo_data.entries[i].info + '</p></div>';
        contentString += '</td></tr>';
        contentString += '<tr>';
        contentString += '<td>';
        contentString += '</td>';
        contentString += '<td nowrap>';
        contentString += '<input type="button" value="Ontdek" class="google_button" onclick="window.location=\'/' + geo_data.entries[i].title + '\'">';
        if (geo_data.entries[i].nrProducts > 0) {
            contentString += '<input type="button" value="Bekijk de ' + geo_data.entries[i].nrProducts + ' reizen" class="google_find_button" onclick="window.location=\'/zoeken?find=' + geo_data.entries[i].title + '+\'">';
        }
        contentString += '</td>';
        contentString += '</tr>';
        contentString += '</table></div>';

        contents.push(contentString);

        google.maps.event.addListener(marker, 'click', function() {
            if (openInfoWindow) {
                openInfoWindow.close();
            }

            openInfoWindow = new SmartInfoWindow({
            position: this.getPosition(), map: geoMap, content: contents[this.zIndex]
            });
        });
    }
};
//=============================================================================

//function initialize_google_map() {
//    var maps = document.getElementsByName(name);
//    for (i = 0; i < maps.length; i++) {
//        map = new google.maps.Map(maps[i], { zoom: zoomFactor, center: new google.maps.LatLng(51, 25), mapTypeId: google.maps.MapTypeId.ROADMAP });
//        map.mapTypeControlOptions = { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU };
//        map.scrollwheel = allowScrollZoom;
//        refresh();
//    }

//}

/*=================================================================================================*/
/*=================================================================================================*/

