// JavaScript Document   
var map;
var directionsPanel;
var directions;

function recenter(loc) {
	 switch (loc) {
  case 'carthage':
lng = '40.416494';
lat = '-91.141495';
break;
  case 'keokuk':
lng = '40.398341';
lat = '-91.385769';
  break;
    case 'quincy':lng = '39.913604';lat = '-91.396379';  break;
  case 'carthtrain':
lng = '40.413717';
lat = '-91.134939';
  break;
}

        map.setCenter(new GLatLng(lng,lat), 15);
		return true;
}


function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
			directionsPanel = document.getElementById("directionss");

		directions = new GDirections(map, directionsPanel);


        map.setCenter(new GLatLng(40.202477,-91.143265), 9);
		var icona = new GIcon();
icona.image = "/locations/images/location1.png";
icona.iconSize = new GSize(20, 28);
icona.iconAnchor = new GPoint(15, 26);
icona.infoWindowAnchor = new GPoint(20, 17);

/*
	var iconb = new GIcon();
iconb.image = "/locations/images/location3.png";
iconb.iconSize = new GSize(20, 28);
iconb.iconAnchor =  new GPoint(9, 26);
iconb.infoWindowAnchor = new GPoint(99, 51);
*/

var icond = new GIcon();
icond.image = "/locations/images/location2.png";
icond.iconSize = new GSize(20, 28);
icond.iconAnchor =  new GPoint(5, 26);
icond.infoWindowAnchor = new GPoint(99, 1);


  var markerd = new GMarker(new GLatLng(40.413717,-91.134939), icond);


 var markera = new GMarker(new GLatLng(40.416494,-91.141495), icona);


var iconc = new GIcon();iconc.image = "/locations/images/location3.png";iconc.iconSize = new GSize(20, 28);iconc.iconAnchor =  new GPoint(9, 26);iconc.infoWindowAnchor = new GPoint(99, 1);



/* 
var markerb = new GMarker(new GLatLng(40.398341,-91.385769), iconb); */
  var markerc = new GMarker(new GLatLng(39.91367,-91.396422), iconc);

map.addOverlay(markera);
//map.addOverlay(markerb);
map.addOverlay(markerc);

map.addOverlay(markerd);

      }
    }

function doDirections() {
      if (GBrowserIsCompatible()) {
  directions.clear()
  switch (document.getElementById('dest').value) {
  case 'carthage':
  desty = '225 Buchanan, Carthage, IL';
  break;
  case 'keokuk':
  desty = '811 Main St, Keokuk, IA';
  break;  case 'quincy':  desty = '1513 S. 12th, Quincy, IL';  break;
  case 'carthtrain':
  desty = '553 Main St, Carthage, IL';
  break;
  }
    directions.load(document.getElementById("start_addr").value+" to "+desty);

GEvent.addListener(directions, "error", function() {
if(directions.getStatus().code == '602') {
alert('Google could not understand your address');
} else {
alert ('An unknown error has occurred.');
}
  directions.clear();

});

}
return false;
}

if (window.addEventListener) {
window.addEventListener ("load",load,false);
} else if (window.attachEvent) {
window.attachEvent ("onload",load);
} else {
window.onload = load;
}
