// JavaScript Document
/* Directions Map */
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;

function initialize() {
  directionsDisplay = new google.maps.DirectionsRenderer();
  var ohbc = new google.maps.LatLng(38.8719,-77.2647);
  var center = new google.maps.LatLng(38.8719,-77.2647);
  var myOptions = {
    zoom: 13,
    center: center,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
  directionsDisplay.setMap(map);
  directionsDisplay.setPanel(document.getElementById("directions_text"));
  
  var infoContent = '<strong>CSFI Office</strong><br />'+
    '9302 Lee Highway, Suite 950A<br />Fairfax, Virginia 22031, USA<p />'+
    'For directions to CSFI,<br />enter your starting location<br />'+
    '<input style="color:#777;" type="text" name="routeStart" id="routeStart" value="(address/city,state/zip)" onfocus="if(this.value==\'(address/city,state/zip)\')this.value=\'\';" onblur="if(this.value==\'\')this.value=\'(address/city,state/zip)\';"> &nbsp;'+
    '<input type="button" name="routeSubmit" id="routeSubmit" value="Go" onclick="calcRoute()">';
		
  var infoWindow = new google.maps.InfoWindow({
    content: infoContent
  });
	
  var marker = new google.maps.Marker({
    position: ohbc,
    map: map,
    title:"CSFI Office",
    animation: google.maps.Animation.DROP
  });

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

function calcRoute() {
  var start = document.getElementById("routeStart").value;
  var end = "9302 Lee Highway, Fairfax, Virginia, 22031";
  var request = {
    origin:start, 
    destination:end,
    travelMode: google.maps.DirectionsTravelMode.DRIVING
  };
  directionsService.route(request, function(result, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(result);
    }
  });
}

/* Normal Map (v3) */ /*
  function initialize() {
    var ohbc = new google.maps.LatLng(42.460321,-83.475322);
	var center = new google.maps.LatLng(42.470321,-83.475322);
    var myOptions = {
      zoom: 13,
      center: center,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
	
	var infoContent = '<strong>Orchard Hills Baptist Church</strong><br />23455 Novi Road<br />Novi, MI 48375<br />248.349.5665<p /><a href="#">Get directions to OHBC</a>.';
	var infoWindow = new google.maps.InfoWindow({
		content: infoContent
	});
	
	var marker = new google.maps.Marker({
		position: ohbc,
		map: map,
		title:"Orchard Hills Baptist Church",
		animation: google.maps.Animation.DROP,
	});
	
	google.maps.event.addListener(marker, 'click', function() { infoWindow.open(map,marker); });
  } */

/* Normal Map (v2) */ /*
	function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
		
        map.addControl(new GSmallMapControl());
        map.setCenter(new GLatLng(42.460321,-83.475322), 12);
		
        var blueIcon = new GIcon();
        blueIcon.image = 'images/markers/blue.png';
        blueIcon.shadow = 'images/markers/shadow.png';
        blueIcon.iconSize = new GSize(13,14);
        blueIcon.shadowSize = new GSize(20,14);
        blueIcon.iconAnchor = new GPoint(7,14);
        blueIcon.infoWindowAnchor = new GPoint(7,0);
        blueIcon.printBlue = 'images/markers/printBlue.gif';
        blueIcon.mozPrintBlue = 'images/markers/mozPrintBlue.gif';
        blueIcon.printShadow = 'images/markers/printShadow.gif';
        blueIcon.transparent = 'images/markers/transparent.png';
        blueMarker = { icon:blueIcon };
		
        var point1 = new GLatLng(42.460321,-83.475322);		
        var marker1 = new GMarker(point1);
        var html1 = "<strong>Orchard Hills Baptist Church</strong><br />23455 Novi Road<br />Novi, MI 48375<br />248.349.5665<p /><a href='http://maps.google.com/maps?f=q&hl=en&geocode=&time=&date=&ttype=&q=23455+Novi+Road,+Novi+Michigan&sll=37.0625,-95.677068&sspn=29.219963,59.765625&ie=UTF8&ll=42.462046,-83.474422&spn=0.006633,0.014591&z=16&iwloc=addr&om=1' target='_blank'>click here</a> for directions.";
        marker1.openInfoWindowHtml(html1);
		GEvent.addListener(marker1, 'click', function() { marker1.openInfoWindowHtml(html1); });
        map.addOverlay(marker1);
		
        map.setMapType(G_NORMAL_MAP);
        map.setUIToDefault();
	  }
	}
*/
