var rootCanvas;
var selectionRect;

//
// Set global variables.
//
function rootLoaded(sender) {
    rootCanvas = sender;
    selectionRect = rootCanvas.FindName("selectionRect");
}

//
// Determine which landmark was selected.
//
function landmarkSelected(sender) {
    for (i = 0; i < Landmarks.length; i++) {
        if (Landmarks[i].Name == sender.name) {
            SetMapToLandmark(Landmarks[i], sender["Canvas.Top"]);
            return;
        }
    } 
}

//
// Set the selection rectangle, and set the Birdseye view to the landmark.
//
function SetMapToLandmark(landmark, top) {
    if (selectionRect["Canvas.Top"] == top) return;

    selectionRect["Canvas.Top"] = top;
    selectionRect.opacity = 0.5;

    map.LoadMap(
        new VELatLong(landmark.Latitude, landmark.Longitude),
        2,
        VEMapStyle.Oblique);
}


//
// Toggle the opacity of the TextBlock to indicate focus.
//
function mouseEnter(sender) {
     sender.opacity = 1.0;
}
function mouseLeave(sender) {
     sender.opacity = 0.8;
}


//
// Virtual Earth Map Data
//
Landmark = function(name, latitude, longitude)
{
    this.Name = name;
    this.Latitude = latitude;
    this.Longitude = longitude;
}

var Landmarks = new Array();
var newLandmark;

newLandMark = new Landmark("Battery Park", 40.70379, -74.01632);
Landmarks.push(newLandMark);

newLandMark = new Landmark("Brooklyn Bridge", 40.70745, -73.99831);
Landmarks.push(newLandMark);

newLandMark = new Landmark("Central Park", 40.76624, -73.97421);
Landmarks.push(newLandMark);

newLandMark = new Landmark("The Cloisters", 40.86520, -73.93171);
Landmarks.push(newLandMark);

newLandMark = new Landmark("Coney Island", 40.57409, -73.97991);
Landmarks.push(newLandMark);

newLandMark = new Landmark("Ellis Island", 40.69925, -74.03963);
Landmarks.push(newLandMark);

newLandMark = new Landmark("Staten Island Ferry", 40.64400, -74.07150);
Landmarks.push(newLandMark);

newLandMark = new Landmark("Statue of Liberty", 40.68968, -74.04464);
Landmarks.push(newLandMark);

newLandMark = new Landmark("Verrazano-Narrows", 40.6098, -74.039);
Landmarks.push(newLandMark);

newLandMark = new Landmark("Yankee Stadium", 40.82721, -73.92754);
Landmarks.push(newLandMark);


