var marganzaLat = 53.320572;
var marganzaLng = 6.913541;
var directions = null;
var marker = null;

function loadMap()
{    
    var strHtmlData = "<span style=\"font-size: 11px; color: #4C5B52; line-height: 18px;\"><strong>Marganza</strong><br />Zwet 32<br />9932 AB&nbsp;&nbsp;Delfzijl (Gr.)<br />Nederland</span>";

    if (GBrowserIsCompatible())
    {
        // Initialize the map.
        var map = new GMap2(document.getElementById("map"));
        
        // Set minimal map controls.
        map.addControl(new GSmallMapControl());
               
        // Set the map center to the location of Marganza.
        map.setCenter(new GLatLng(marganzaLat, marganzaLng), 15);
        
        // Initialize and display the Marganza marker.
        var point = new GLatLng(marganzaLat,
                                marganzaLng);
        marker = new GMarker(point);
        map.addOverlay(marker);              
          
        // Bind and show the Marganza information window.
        marker.bindInfoWindowHtml(strHtmlData);
        marker.openInfoWindowHtml(strHtmlData);     
        
        // Initialize the directions engine and set the error listener.
        directions = new GDirections(map, document.getElementById("directions"));  
        GEvent.addListener(directions, "error", handleErrors);               
    }
}

function calcDirections()
{
    marker.hide();
    directions.load("from: " + document.getElementById("fromLoc").value + " to: Zwet 32, Delfzijl",
                    { "locale" : "nl_NL" });
    document.getElementById("directions").style.display = "block";
}

function handleErrors()
{
    document.getElementById("directions").style.display = "none";        
    alert("Het adres kon niet worden gevonden, of er is een technische fout opgetreden.");
    marker.show();    
}
