  // Initialize the arrays.
/* Time: ID, time. */
var time = [['1', '2:00&ndash;3:00 p.m.'],
			['2', '3:00&ndash;4:00 p.m.'],
			['3', '4:00&ndash;5:00 p.m.'],
			['4', '5:00&ndash;6:00 p.m.'],
			['5', '6:00&ndash;7:00 p.m.'],
			['6', '7:00&ndash;8:00 p.m.']];
/* Locations: ID, location, latitude, longitude. */
var locs = [['1', '2nd and Ankeny', '45.52249', '-122.67226'],
			['2', '3rd and Pine', '45.5216', '-122.67375'],
			['3', 'Broadway and Ankeny', '45.52258', '-122.6778'],
			['4', '10th and Burnside', '45.5229', '-122.68117'],
			['5', '10th and Stark', '45.522024', '-122.681059'],
			['6', '9th and Washington', '45.521026', '-122.680173'],
			['7', 'Broadway and Washington', '45.520678', '-122.678891'],
			['8', '10th and Morrison', '45.520025', '-122.682139'],
			['9', 'Broadway and Alder', '45.520018', '-122.679261'],
			['10', '6th and Alder', '45.519747', '-122.678262'],
			['11', 'Broadway and Morrison', '45.519351', '-122.679621'],
			['12', 'Broadway and Yamhill', '45.518685', '-122.679982'],
			['13', '6th and Yamhill', '45.518341', '-122.67899'],
			['14', '3rd and Yamhill', '45.517571', '-122.675912'],
			['15', '5th and Morrison', '45.5188', '-122.67759'],
			['16', '10th and Yamhill', '45.519334', '-122.682441'],
			['17', '6th and Morrison', '45.519041', '-122.678619']];
/* Acts: ID, name. */
var acts = [['1', 'Amy Bleu'],
			['2', 'Andy Frost'],
			['3', 'Jen Youngs'],
			['4', 'Jan Groh'],
			['5', 'Joe Destroy and the Mincing Prissies'],
			['6', 'The Krebsic Orkestar'],
			['7', 'The Goodwill River'],
			['8', 'Speakeasy'],
			['9', 'Fl&ouml;te'],
			['10', 'Lee Corey Oswald'],
			['11', 'Rodney Mason'],
			['12', "The Miss Me's"],
			['13', 'Wizard Boots'],
			['14', 'Rainstick Cowbell'],
			['15', 'Tex Winters'],
			['16', 'Sound Semantics'],
			['17', 'The Martyrs'],
			['18', 'Target for Tomorrow']];
/* Show: location ID, array of time IDs, array of band IDs. */
var show = [['1', ['1'], ['1']],
			['2', ['1'], ['2']],
			['3', ['4', '5'], ['10', '14']],
			['4', ['2'], ['6']],
			['5', ['3', '4'], ['2', '12']],
			['6', [], []],
			['7', ['3'], ['7']],
			['8', ['5', '6'], ['15', '16']],
			['9', ['5'], ['13']],
			['10', ['2', '4'], ['4', '9']],
			['11', ['1', '2', '3'], ['3', '18', '6']],
			['12', [], []],
			['13', ['4'], ['8']],
			['14', ['2', '6'], ['5', '17']],
			['15', [''], ['']],
			['16', ['2'], ['7']]];


function initializeMap() {
  var myOptions = {
  zoom: 15,
  center: new google.maps.LatLng(45.521, -122.679),
  mapTypeId: google.maps.MapTypeId.ROADMAP
  };

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

  // Run through the arrays and drop the markers.
  for (var n = 0; n < show.length; n++) {
	// Grab the array.
	var nf = show[n];
	// The first element is the location ID.
	var l = nf[0];
	// Get the location array with that ID.
	var ul = locs[(l - 1)];
	// Get the location title.
	var lt = ul[1];
	// The second element is the array of time IDs.
	var t = nf[1];
	// The third element is the array of band IDs.
	var b = nf[2];

	// Initialize the text to use in the info window.
	var inwin = '<strong>'+ul[1]+'</strong>';
	// The lengths of t and b should be equal.
	if (t.length > 0) {
	  for (m = 0; m < t.length; m++) {
		// Get the time and band IDs.
		var gt = t[m]; var gb = b[m];
		// Get the time and band values.
		var ut = time[(gt - 1)]; var ub = acts[(gb - 1)];
		inwin += '<br /><br />'+ut[1]+'<br />'+ub[1];
	  }

	  // Make the info window.
	  var nw = mkwin(inwin);
	  // Make the marker.
	  var nm = mkmrk(map, ul[2], ul[3], ul[1]);
	  // Set it.
	  mklst(map, nm, nw);
	}
  }
}


function mkwin(cont) {
  var inwin = new google.maps.InfoWindow(
										 { content: cont,
											 size: new google.maps.Size(250,55)
											 });
  return inwin;
}


function mkmrk(map, lat, lng, ttl) {
  var nwmrk = new google.maps.Marker({
	position: new google.maps.LatLng(lat, lng), 
		map: map, 
		title: ttl
		});
  return nwmrk;
}


function mklst(map, mrk, win) {
  google.maps.event.addListener(mrk, 'click', function() {win.open(map,mrk);});
  return true;
}
