// JavaScript Document

  var directionDisplay;
  var directionsService = new google.maps.DirectionsService();
  var map;
 
  function initialize() {
    directionsDisplay = new google.maps.DirectionsRenderer();
    var chicago = new google.maps.LatLng(40.703706,-74.008345);
    var myOptions = {
      zoom:15,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
	  mapTypeControl: true,
	  mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
	  navigationControl: true,
	  center: chicago
    }
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    directionsDisplay.setMap(map);
    directionsDisplay.setPanel(document.getElementById("directionsPanel"));

  
  	var contentString = '<div id="content">'+
		'<div id="siteNotice">'+
		'<img src="../../images/logo/logo_white.jpg" width="125"/><br>'+
		'<div id="google">'+
		'The New York City Police Museum is dedicated to preserving the history of the New York City Police Department, the world&#39;s largest and most famous police force.<br><br>'+
		'<a href="http://www.nycpm.org" target="_blank">Visit our Website</a><br><br>'+
		'<form onsubmit="calcRoute();return false;">'+
		'<input type="text" id="start" value="">'+
		'<input type="submit" value="Find directions"></form>'+
		'</div>'+
		'</div>';
  
  
  var infowindow = new google.maps.InfoWindow({ 
    	content: contentString 
	}); 
	
	var companyImage = new google.maps.MarkerImage('../../images/logo/logo_google.png',
		new google.maps.Size(200,74),
		new google.maps.Point(0,0)
	);
 
var marker = new google.maps.Marker({ 
    position: chicago,
	icon: companyImage,
	map: map, 
    title:"New York City Police Museum" 
}); 

 
google.maps.event.addListener(marker, 'click', function() { 
  infowindow.open(map,marker); 
});
   
  }
  
  function calcRoute() {
    var start = document.getElementById("start").value;
    var end = "40.703706,-74.008345";
    var request = {
        origin:start, 
        destination:end,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };
    directionsService.route(request, function(response, status) {
      if (status == google.maps.DirectionsStatus.OK) {
        directionsDisplay.setDirections(response);
      }
    });
  }
