var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;


function initialize(co1, co2) {
	
 directionsDisplay = new google.maps.DirectionsRenderer();
var myLatlng = new google.maps.LatLng(co1, co2);
var myOptions = {
    zoom: 10,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
}
  
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 directionsDisplay.setMap(map);
 directionsDisplay.setPanel(document.getElementById("directionsPanel"));


        
var contentString = '<p class="generaltekst">Huys Waerenberg</p>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});
  
var marker = new google.maps.Marker({
      position: myLatlng, 
      map: map, 
      title:"Unielabel BV"
});
  


google.maps.event.addListener(marker, 'click', function() 
{
	infowindow.open(map,marker);
});

}

function getRoute(co1, co2) {
	calcRoute(co1, co2);
	
	return false

}

function calcRoute(co1, co2) {

  var start = document.getElementById("start").value;
  var end = co1+","+co2;
  var request = {
    origin:start, 
    destination:end,
    travelMode: google.maps.DirectionsTravelMode.DRIVING
  };
  directionsService.route(request, function(result, status) {
    if (status == google.maps.DirectionsStatus.OK) {
		
	$("#directionsPanel").html("");
      directionsDisplay.setDirections(result);
	  
		  
	$("#map_canvas").animate({
					height: "300"
					}, 300);
	
	$("#directionsPanel").delay(400).slideDown("slow");
    }
	else {
		
		$("#directionsPanel").html("<p class=\"alertlocatie\">Deze locatie kan helaas niet gevonden worden.</p>");
		$("#directionsPanel").slideDown("slow");
		
		}
  });
}

