(function() {

  window.onload = function() {

	  document.getElementById('mnuOffices').options[0].selected=true;
	  //Coords for United States overview showing all offices
	  var usaLat = "38.09";
	  var usaLong = "-95.71";
	  //Coordiantes for Lexington, Kentucky
	  var kyLat = "38.038001";
	  var kyLong = "-84.483857";
	  var kyLatlng = new google.maps.LatLng(38.038001,-84.483857);
	  //Coordiantes for Albuquerque, New Mexico
	  var nmLat = "35.110833";
	  var nmLong = "-106.61";
	  var nmLatlng = new google.maps.LatLng(35.110833,-106.61);
	  //Coordiantes for Berlin Heights, Ohio
	  var ohLat = "41.319412";
	  var ohLong = "-82.531083";
	  //Coordiantes for Evansville, Indiana
	  var inLat = "37.973943";
	  var inLong = "-87.572263";
	  //Coordinates for Hurricane, West Virginia
	  var wvLat = "38.442450";
	  var wvLong = "-81.984066";
	  //Coordiantes for Knoxville, Tennesseee
	  var tnLat = "35.952853";
	  var tnLong = "-83.894812";
	  //Coordinates for Longmont, Colorado
	  var coLat = "40.195822";
	  var coLong = "-105.100171";
	  //Coordinates for Mt. Vernon, Illinois
	  var ilLat = "38.317271";
	  var ilLong = "-88.903120";
	  //Coordiantes for Richmond, Virginia
	  var vaLat = "37.542979";
	  var vaLong = "-77.469092";
	  //Coordiantes for Sheridan, Wyoming
	  var wyLat = "44.806575";
	  var wyLong = "-106.957380";
	  //Coordinates for Shreveport, Louisiana
	  var laLat = "32.479372";
	  var laLong = "-93.720396";
	  
	var kyContact = "<p><b>Corporate Headquarters</b><br />\n" +
  	"151 Walton Avenue <br />\n" +
  	"Lexington, Kentucky 40508<br />\n" +
  	"Phone: 859.252.4737<br />\n" +
  	"Fax: 859.254.3747<br />\n" +
  	"Contact: Steve Creasman, RPA<br />\n" +
  	"<a href=\"mailto:creasman@crai-ky.com\">creasman@crai-ky.com</a></p>\n";
	
	var coContact = "<p><b>Colorado</b><br />" +
  	"421 21st Avenue, Suite 8<br />" +
  	"Longmont, Colorado 80501<br />" +
  	"Phone: 303.772.8881<br />" +
  	"Fax: 303.772.8892<br />" +
  	"Contact: Ted Hoefer III, RPA <br />" +
  	"<a href=\"mailto:thoefer@crai-ky.com\">thoefer@crai-ky.com</a></p>";
	
	var nmContact = "<p><b>New Mexico</b><br />" +
  	"8201 Golf Course Road NW<br />" +
  	"Suite D3, #292<br />" +
  	"Albuquerque, New Mexico 87120<br />" +
  	"Phone: 505.243.1200<br />" +
  	"Contact: William H. Doleman, Ph.D.<br />" +
  	"<a href=\"mailto:whdoleman@crai-ky.com\">whdoleman@crai-ky.com</a></p>";
	
	var ilContact = "<p><b>Illinois</b><br />" +
  	"P.O. Box 744 <br />" +
  	"Mt. Vernon, Illinois 62864-0744<br />" +
  	"Phone: 618.242.7299<br />" +
  	"Fax: 859.254.3747<br />" +
  	"Contact: Richard Herndon, RPA<br />" +
  	"<a href=\"mailto:rherndon@crai-ky.com\">rherndon@crai-ky.com</a></p>";
	
	var inContact = "<p><b>Indiana</b><br />" +
	"201 NW 4th Street, Suite 204<br />" +
	"Evansville, Indiana 47708<br />" +
	"Phone: 812.253.3009<br />" +
	"Fax: 812.253.3010<br />" +
	"Contact: Andrew Martin, RPA<br />" +
	"<a href=\"mailto:amartin@crai-ky.com\">amartin@crai-ky.com</a></p>";
	
	var laContact = "<p><b>Louisiana</b><br />" +
  	"636 East Kings Hwy, Building B<br />" +
  	"Shreveport, LA 71105<br />" +
  	"Phone: 318.213.1385<br />" +
  	"Contact: Paul D. Bundy, RPA<br />" +
  	"<a href=\"mailto:bundypauld@crai-ky.com\">bundypauld@crai-ky.com</a></p>";
	
	var ohContact = "<p><b>Ohio</b><br />" +
 	"4918 Huff Road <br />" +
  	"Berlin Heights, Ohio 44814<br />" +
  	"Phone: 419.433.4168<br />" +
  	"Fax: 419.433.8465<br />" +
  	"Contact: Flora Church, Ph.D., RPA<br />" +
 	"<a href=\"mailto:fjchurch@crai-ky.com\">fjchurch@crai-ky.com</a></p>";
	
	var tnContact = "<p><b>Tennessee</b><br />" +
	"119 W. Summit Hill Drive<br />" +
	"2nd Floor<br />" +
	"Knoxville, Tennessee 37902<br />" +
	"Phone: 865.249.6035<br />" +
  	"Fax: 865.249.6036<br />" +
	"Contact: Pat Garrow, RPA<br /><a href=\"mailto:PGarrow@crai-ky.com\">PGarrow@crai-ky.com</a></p>";
	
	var vaContact = "<p><b>Virginia</b><br />" +
	"P.O. Box 71120 <br />" +
	"Richmond, Virginia 23255 <br />" +
	"Phone: 800.280.0737<br />" +
	"Cell: 804.921.7074<br />" +
	"Contact: Kay Simpson, Ph.D., RPA<br />" +
	"<a href=\"mailto:ksimpson@crai-ky.com\">ksimpson@crai-ky.com</a></p>";
	
	var wvContact = "<p><b>West Virginia</b><br />" +
	"3556 Teays Valley Road, Suite 3<br />" +
  	"Hurricane, West Virginia 25526<br />" +
  	"Phone: 304.562.7233<br />" +
  	"Fax: 304.562.7235<br />" +
	"Contact: Mike Anslinger, RPA<br />" +
  	"<a href=\"mailto:manslinger@crai-ky.com\">manslinger@crai-ky.com</a></p>";
	
	var wyContact = "<p><b>Wyoming</b><br />" +
  	"850 Val Vista<br />" +
	"Sheridan, Wyoming 82801<br />" +
	"Phone: 307.674.1702<br />" +
	"Fax: 307.674.1708<br />" +
	"Contact: Colin Ferriman, RPA<br />" +
	"<a href=\"mailto:crferriman@crai-ky.com\">crferriman@crai-ky.com</a></p>";
	  
    // Set up the initial map
    var myOptions = {
      zoom: 4,
      center: new google.maps.LatLng(usaLat, usaLong),
      //mapTypeId: google.maps.MapTypeId.TERRAIN
	  
	  mapTypeId: google.maps.MapTypeId.TERRAIN
    };

  
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    // Lexington, Kentucky //////////////////////////////////////////////////
	
    var markerLexington = new google.maps.Marker({
	  position: kyLatlng,
      map: map,
      title: 'Corporate Headquarters in Lexington, Kentucky'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowLexington = new google.maps.InfoWindow({
		content: "<div id=\"info\">" + kyContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerLexington, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowLexington.open(map, markerLexington);
	});
	
	

	
	// Berlin Heights, Ohio //////////////////////////////////////////////////
    var markerBerlinHeights = new google.maps.Marker({
      position: new google.maps.LatLng(ohLat, ohLong),
      map: map,
      title: 'Berlin Heights, Ohio'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowBerlinHeights = new google.maps.InfoWindow({
	content: "<div id=\"info\">" + ohContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerBerlinHeights, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowBerlinHeights.open(map, markerBerlinHeights);
	});
	
	// Evansville, Indiana //////////////////////////////////////////////////
    var markerEvansville = new google.maps.Marker({
      position: new google.maps.LatLng(inLat, inLong),
      map: map,
      title: 'Evansville, Indiana'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowEvansville = new google.maps.InfoWindow({
		content: "<div id=\"info\">" + inContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerEvansville, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowEvansville.open(map, markerEvansville);
	});

	// Hurricane, West Virginia //
    var markerHurricane = new google.maps.Marker({
      position: new google.maps.LatLng(wvLat, wvLong),
      map: map,
      title: 'Hurricane, West Virginia'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowHurricane = new google.maps.InfoWindow({
		content: "<div id=\"info\">" + wvContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerHurricane, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowHurricane.open(map, markerHurricane);
	});

	
	// Knoxville, Tennessee //
    var markerKnoxville = new google.maps.Marker({
      position: new google.maps.LatLng(tnLat, tnLong),
      map: map,
      title: 'Knoxville, Tennessee'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowKnoxville = new google.maps.InfoWindow({
		content: "<div id=\"info\">" + tnContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerKnoxville, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowKnoxville.open(map, markerKnoxville);
	});
	
	// Longmont, Colorado ///////////////////////////////////////////////
    var markerLongmont = new google.maps.Marker({
      position: new google.maps.LatLng(coLat, coLong),
      map: map,
      title: 'Longmont, Colorado'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowLongmont = new google.maps.InfoWindow({
		content: "<div id=\"info\">" + coContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerLongmont, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowLongmont.open(map, markerLongmont);
	});
	
	// Mt. Vernon, Illinois ///////////////////////////////////////////////
    var markerMtVernon = new google.maps.Marker({
      position: new google.maps.LatLng(ilLat, ilLong),
      map: map,
      title: 'Mt. Vernon, Illinois'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowMtVernon = new google.maps.InfoWindow({
	content: "<div id=\"info\">" + ilContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerMtVernon, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowMtVernon.open(map, markerMtVernon);
	});
	
	// Sheridan, Wyoming //////////////////////////////////////////////////
    var markerSheridan = new google.maps.Marker({
      position: new google.maps.LatLng(wyLat, wyLong),
      map: map,
      title: 'Sheridan, Wyoming'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowSheridan = new google.maps.InfoWindow({
	content: "<div id=\"info\">" + wyContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerSheridan, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowSheridan.open(map, markerSheridan);
	});
	
	// Shreveport, Louisiana //
    var markerShreveport = new google.maps.Marker({
      position: new google.maps.LatLng(laLat, laLong),
      map: map,
      title: 'Shreveport, Louisiana'
         });

	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowShreveport = new google.maps.InfoWindow({
	content: "<div id=\"info\">" + laContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerShreveport, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowShreveport.open(map, markerShreveport);
	});
	
	// Richmond, Virginia //
    var markerRichmond = new google.maps.Marker({
      position: new google.maps.LatLng(vaLat, vaLong),
      map: map,
      title: 'Richmond, Virginia'
         });
	
	// Creating an InfoWindow with the content text: "<a href="http://www.crai-ky.com>Go to our website</>"
	var infowindowRichmond = new google.maps.InfoWindow({
	content: "<div id=\"info\">" + vaContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerRichmond, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowRichmond.open(map, markerRichmond);
	});
	
	
	// Albuquerque, New Mexico //////////////////////////////////////////////////
    var markerAlbuquerque = new google.maps.Marker({
      position: new google.maps.LatLng(nmLat, nmLong),
	  position: nmLatlng,
      map: map,
      title: 'Albuquerque, New Mexico'
         });

	var infowindowAlbuquerque = new google.maps.InfoWindow({
		content: "<div id=\"info\">" + nmContact + "</div>"
	});

	// Adding a click event to the marker
	google.maps.event.addListener(markerAlbuquerque, 'click', function() {
	// Calling the open method of the infoWindow
	infowindowAlbuquerque.open(map, markerAlbuquerque);
	});
	
	/////////////////////////////////////////////////////////////////////
	currentMapType = map.getMapTypeId();
	
	document.getElementById('mnuOffices').onchange = function() {
		if (this.value == "usa") {
			zoomScale = 4;
		} else {
			zoomScale = 11;
		}
		
	//clear the Address div and put the selected office info in it	
	document.getElementById("selectedAddress").innerHTML="";
	if (this.value != "usa") {
		document.getElementById("selectedAddress").innerHTML=eval(this.value + "Contact");
	}
		
	//zoom in to selected office
	map.setOptions({
		//center: new google.maps.LatLng(latSelected, longSelected),
		center: new google.maps.LatLng(eval(this.value + "Lat"), eval(this.value + "Long")),
		zoom: zoomScale,
		//mapTypeId: google.maps.MapTypeId.TERRAIN
		mapTypeID: currentMapType
	});
	}
  };
})();
