var myLatlng;
var map;
var directionDisplay;
var directionsService = new google.maps.DirectionsService();

function LoadMap()
{
    directionsDisplay = new google.maps.DirectionsRenderer();

	myLatlng = new google.maps.LatLng(40.656382,-75.478276);
	var myOptions = {
	  zoom: 12,
	  center: myLatlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
	var marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        title:"LVIRK Training Center"
    });   
	
	var contentString = '<div style="width: 180px; height: 80px;"><h1>LVIRK Training Center</h1>' +
						'<p>767 Front Street<br>Catasauqua, PA 18032</p>' + 
						'<p>Phone: (610) 443-5107</p></div>'; //+
//						'<p>LVIRK Training Center is located in Catasauqua, PA in the Lehigh Valley, ' +
//						'just minutes from Allentown PA, Bethlehem PA, Easton PA, Whitehall PA, and Northampton PA. ' +
//						'LVIRK Training Center offers programs in Isshin Ryu Karate, Mixed Martial Arts (MMA), ' + 
//						'Muay Thai Kickboxing, Boxing, and Ashtanga Yoga.</p>';
						
    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });

    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
	
    directionsDisplay.setMap(map);
    directionsDisplay.setPanel(document.getElementById("MapDirections"));						
}

function calcRoute(start, end) {
	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);
	  }
	});
}


//	var map;
//	var gdir;
//	var geocoder = null;
//	var addressMarker;
//
//	function LoadMap(strMapDiv, strDirectionsDiv) {
//		if (GBrowserIsCompatible()) {
//			var map = new GMap2(document.getElementById(strMapDiv));
//			// center map
//			map.setCenter(new GLatLng(40.656241, -75.478424), 13);
//			map.setMapType(G_NORMAL_MAP);
//
//			// add marker at our facility - 767 front st, catasauqua, pa 18032
//			//var point = new GLatLng(40.6562, -75.4785);
//			var marker = new GMarker(new GLatLng(40.656241, -75.478424));
//			map.addOverlay(marker);	
//			
//			// add info window
//			//var html="<div class='maptext'>LVIRK Training Center<br/>767 Front St, Catasauqua, PA</div>";
//			//marker.openInfoWindowHtml(html);
//			
//			// add map zoom controls
//			map.addControl(new GSmallZoomControl()); 
//			
//			if (strDirectionsDiv)
//			{
//				gdir = new GDirections(map, document.getElementById(strDirectionsDiv));
//				GEvent.addListener(gdir, "load", onGDirectionsLoad);
//				GEvent.addListener(gdir, "error", handleErrors);
//				//setDirections("San Francisco", "Mountain View", "en_US");
//			}
//		}
//	}
//	
//	function setDirections(fromAddress, toAddress, locale) {
//      gdir.load("from: " + fromAddress + " to: " + toAddress,
//                { "locale": locale });
//	}
//
//	function handleErrors() {
//	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
//	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
//	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
//	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
//	   
//	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
//	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
//
//	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
//	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
//	     
//	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
//	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
//
//	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
//	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
//	    
//	   else alert("An unknown error occurred.");
//	}
//
//	function onGDirectionsLoad() { 
//      // Use this function to access information about the latest load()
//      // results.
//
//      // e.g.
//      // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
//	  // and yada yada yada...
//	}
//
