var kuilLat = 53.201245;
var kuilLng = 6.658916;
var directions = null;
var marker = null;

function loadMap()
{
    var strHtmlData = "<span style=\"font-size: 11px; color: #4C5B52; line-height: 18px;\"><strong>Kuil Banden</strong><br />Engelberterweg 116<br />9723 EP&nbsp;&nbsp;Engelbert (Gr.)<br />The Netherlands</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 Kuil.
        map.setCenter(new GLatLng(kuilLat, kuilLng), 15);

        // Initialize and display the Kuil marker.
        var point = new GLatLng(kuilLat,
                                kuilLng);
        marker = new GMarker(point);
        map.addOverlay(marker);

        // Bind and show the Kuil 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: Engelberterweg 116, Engelbert",
                    { "locale" : locale });
    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();
}
