var popup = document.getElementById("directions-popup");
var popupTitle = document.getElementById("directions-title");
var popupList = document.getElementById("directions-list");
var directions = [
  ["From 95 Baltimore or Washington",
  "Follow 95 North (from Washington) or 95 South (from New York) to I95 (exit 47) toward Catonsville, away from BWI Airport.",
  "Follow approx. 1 1/2 miles to South Route 166 (Rolling Road). At dead end/stop sign turn left towards Arbutus.",
  "Follow Route 166 (Rolling Road) 3/4 of a mile to Sulphur Spring Rd. Turn left.",
  "Follow Sulphur Spring Rd. 1 mile, to first light at East Drive, proceed through light and make first right onto Selma Avenue.",
  "You'll see a one-story yellow building directly on the left (that's us). Turn left into our parking lot."],
  ["From Annapolis via Route 97",
  "Take Route 97 North to Baltimore beltway (695). Follow to exit 10 Wasington Blvd/Route 1.",
  "At the top of the ramp, turn left. Follow to the first light and make a right onto Sulphur Spring Rd.",
  "Follow Sulphur Spring Road 1 mile (through two lights). Proceed under bridge and take first left onto Selma Avenue before the intersection at East Drive.",
  "You'll see a one-story yellow building directly on the left (that's us). Turn left into our parking lot."],
  ["From BWI Airport/Baltimore-Washington Parkway",
  "Follow Baltimore - Washington Parkway to I95 west toward Catonsville. Take I95 approximately 4 miles to Route 166 (Rolling Road). At dead end/stop sign, turn left.",
  "Follow Route 166 (Rolling Road) 3/4 of a mile to Sulphur Spring Rd. Turn left.",
  "Follow Sulphur Spring Rd. 1 mile, to first light at East Drive, proceed through light and make first right onto Selma Avenue.",
  "You'll see a one-story yellow building directly on the left (that's us). Turn left into our parking lot."],
  ["From Baltimore Beltway (695) Towson and points north and east",
  "Follow Baltimore Beltway (695) towards Glen Burnie to exit 12A South Western Blvd. It's right before the exits for 95.",
  "Proceed 1/3 mile staying in the right hand lane (passing the fire house on your right). Just past the Southwestern Car Care, make a sharp right onto Selma Avenue, a residentail street.",
  "Follow Selma Avenue two blocks. You'll see a one-story yellow building directly on the right (that's us). Turn right into our parking lot. If you get to the intersection at Sulphur Spring Road, back up. You've gone too far."],
  ["From Baltimore Beltway (695) Glen Burnie and points south",
  "Follow Baltimore Beltway (695) towards Towson to exit 10 Washington Blvd/Route 1.",
  "At the top of the ramp, turn left. Follow to the first light and make a right onto Sulphur Spring Road.",
  "Follow Sulphur Spring Road for 1 mile, passing through 2 traffic lights. Proceed under bridge and take first left onto Selma Avenue just before the intersection at East Drive.",
  "You'll see a one-story yellow building directly on the left (that's us). Turn left into our parking lot."]
];

var directionElements = new Array();
for (var i = 0; i < 5; i++) {
  directionElements[i] = document.getElementById("directions-" + (i + 1));
}

var showDirections = function(e) {
  e = getEvent(e);
  var i = e.src.idNumber;
  var listData = "";
  
  for (var j in directions[i]) {
    if (j > 0) {
      listData += "<li>" + directions[i][j] + "</li>";
    }
  }
  
  popupTitle.innerHTML = directions[i][0];
  popupList.innerHTML = listData;
  popup.style.display = "block";
  
  return false;
}

for (var i in directionElements) {
  directionElements[i].idNumber = i;
  addEvent(directionElements[i], "click", showDirections, false);
}