var map;
var geocoder; 

function showAddress(address, title) {
    $('#googleMapDialog').remove();
    $('body').append('<div id="googleMapDialog"></div>');
    
    $("#googleMapDialog").dialog({
        title: 'Google Map: ' + title,
        width: 600,
        height: 500,
        modal: true,
        close: function(event, ui) {
            $("#googleMapDialog").dialog('destroy');
            map = null;
            geocoder = null;
        }
    });	
        
    var latlng = new google.maps.LatLng(51, 9);
    var options = {
        zoom: 14,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    
    map = new google.maps.Map(document.getElementById("googleMapDialog"), options);              
    geocoder = new google.maps.Geocoder();
    
    geocoder.geocode( {
        'address': address
    }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            map.setCenter(results[0].geometry.location);
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });
        } else {
            alert("Die Map konnte nicht geladen werden: " + status);
        }
    });        
}
