﻿/// <reference path="VEJS/VeJavaScriptIntellisenseHelper.js" />

// NOTE:    The above reference is used only at design time.
//          It provides a skeleton of the VE API to enable 
//          intellisense.  Notice that the Default.aspx 
//          page DOES NOT reference VeJavaScriptIntellisenseHelper.js.
//          At run time, we use the real VE API.


var map
var oPRShapeL = new VEShapeLayer();  // park-n-ride layer
var oStationShapeL = new VEShapeLayer();
var oCitiesShapeL = new VEShapeLayer();
var findLayer = new VEShapeLayer();
var findArray = new Array();
var bTrafficLoaded;


var index = 0;
var results = null;

var latitudeCenter = 39.50;
var longitudeCenter = -98.35;
var zoomLevel = 3;

if (typeof (DESIGN_TIME) == 'undefined') {
    map = null;
}
else {
    map = new VEMap();
}

function pageLoad() {

    try {
        map = new VEMap("myMap");
        map.SetDashboardSize(VEDashboardSize.Tiny);
        bTrafficLoaded = false;
        map.onLoadMap = map_Loaded;
        map.LoadMap(new VELatLong(39.50, -98.35), 3, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);
        map.SetCenterAndZoom(new VELatLong(latitudeCenter, longitudeCenter), zoomLevel);
        oStationShapeL.SetTitle = "Stations";
        oPRShapeL.SetTitle = "ParkRideLoc";
    }
    catch (e)
   { }
}

function pageUnload() {
    if (map != null) {
        map.Dispose();
    }
}

function setMapLevel(latitude, longitude, zoomlevel) {
    try {
        latitudeCenter = latitude;
        longitudeCenter = longitude;
        zoomLevel = zoomlevel;
    }
    catch (e) {
        
    }
}

function map_Loaded() {

    //   map.ClearInfoBoxStyles();

    //    var cssRef = document.createElement("link");
    //    cssRef.setAttribute("rel", "stylesheet");
    //   cssRef.setAttribute("type", "text/css");
    //   cssRef.setAttribute("href", "http://www.downtownlightrail.com/Styles/MapStyle.css");
    //   document.getElementsByTagName("head")[0].appendChild(cssRef);
    //    map.SetInfoBoxStyles();
    AddCities(map)
    AddRail(map);

    AddStations(map, 0);
    LoadParkRideLoc();

    ToggleTraffic();
    map.SetMapView(oStationShapeL.GetBoundingRectangle());

}
function onCitesFeedLoad(feed) {
    if (feed != null) {
        var numShapes = feed.GetShapeCount();
        for (var i = 0; i < numShapes; ++i) {
            try {
                var shape1 = feed.GetShapeByIndex(i);
                shape1.SetCustomIcon("http://www.downtownlightrail.com/light-rail-maps/Images/Star.gif");
                shape1.SetMaxZoomLevel(7);
            }
            catch (e) {
            }
        }
    }
}

function AddCities(map) {
    var shapeSource = new VEShapeSourceSpecification(VEDataType.ImportXML, 'http://www.downtownlightrail.com/light-rail-maps/routes-georss.aspx?TypeID=1', oCitiesShapeL);

    map.ImportShapeLayerData(shapeSource, onCitesFeedLoad, 0);
}




//loads the light rail map
function AddRail(map) {
    var points;

    //Camelback to Bethany Home Road
    // along camelback from Central to 19th ave
    //Along central from Washington to Camelback
    //Along Washington from 45th Street to Desert Drive
    //curve at Desert Drive
    //curve at Desert Drive
    //through priest to the curve
    //curve
    //curve
    //to parkside dr
    //to washington st and lakeside curve
    //curve
    //curve to bridge
    //bridge to river
    //across river
    //angle on the last part of bridge
    //start of curve to east
    //middle of curve
    //curve some more
    //curve
    //curve
    //curve to east of mill
    //east of mill to rail stop
    //before next rail stop
    //to curve
    //next curve before SD Statium
    //curve at San Pablo Hall
    //curve at 6th street.
    //curve Manzanita Hall
    //to apache road
    //to Sycamore in Mesa
    points = new Array(
        new VELatLong(33.520969, -112.099815, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.509663, -112.099899, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.5093, -112.073807, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.509197, -112.073677, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.465744, -112.073936, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4482799, -112.0738, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.44805, -111.9842, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.44515, -111.9602, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.44475, -111.9590, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4441, -111.9578995, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4436, -111.9575, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.44122, -111.9554, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.44090, -111.9550, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.44060, -111.9545, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.43969, -111.9500, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.43889, -111.9480, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.43769, -111.9460, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.43698, -111.94495, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.43659, -111.94455, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.43609, -111.94425, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4349, -111.9438, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4319, -111.94346, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4289, -111.94346, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.42855, -111.943387, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4283, -111.94325, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4278, -111.94279, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4277, -111.9426, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.4276, -111.9423, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.42752, -111.9419, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.42752, -111.9396, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.42737, -111.93905, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.42652, -111.9370, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.42585, -111.93515, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.42533, -111.93455, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.425205, -111.9343, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.424750, -111.9330, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.424430, -111.9325, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.423405, -111.93120, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.423305, -111.93090, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.423200, -111.93020, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.423100, -111.92980, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.422800, -111.92920, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.415000, -111.92045, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.414800, -111.9202, 0, VEAltitudeMode.RelativeToGround),
        new VELatLong(33.414805, -111.8700, 0, VEAltitudeMode.RelativeToGround)
    );

    myPolygon = new VEShape(VEShapeType.Polyline, points);
    myPolygon.SetLineWidth(6);
    myPolygon.HideIcon();
    myPolygon.SetMinZoomLevel(8);
    map.AddShape(myPolygon);


    //*** Jefferson Line
    //first ave curve to Roosevelt
    //Washington to before curve at Roosevelt on first ave  
    // Washington to first part of Jefferson along 1st ave
    // Washington to second part of Jefferson along 1st ave
    //Along Jefferson from 1st ave to 1st street
    //Along Jefferson first part of curve
    //straight after curve
    //Along Jefferson Second part of curve
    //2 more points in the curve
    //Along Jefferson from 7st street to 25st street curve
    //first part of curve at Jefferson and 25st street
    //second part of curve at Jefferson and 25st street
    //third part of curve at Jefferson and 25st street
    //fourth part of curve at Jefferson and 25st street
    points = new Array(
                            new VELatLong(33.45993, -112.07382, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.457815, -112.07514, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.4482790, -112.07514, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.447775, -112.07518, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44710, -112.07518, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44710, -112.07250, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44640, -112.07000, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44635, -112.06800, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44645, -112.06750, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44687, -112.06660, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44705, -112.0660, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44720, -112.065, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44720, -112.02791, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44730, -112.0274, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44760, -112.02675, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.4480, -112.026000, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.44808, -112.025600, 0, VEAltitudeMode.RelativeToGround),
                            new VELatLong(33.448155, -112.025200, 0, VEAltitudeMode.RelativeToGround)
                            );


    myPolygon = new VEShape(VEShapeType.Polyline, points);
    myPolygon.SetLineWidth(6);
    myPolygon.HideIcon();
    myPolygon.SetMinZoomLevel(8);
    map.AddShape(myPolygon);

    points = new Array(
            new VELatLong(45.522492, -122.991031, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521646, -122.991053, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521496, -122.990972, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521409, -122.990774, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521398, -122.990538, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521391, -122.987244, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521342, -122.983553, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521304, -122.979138, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521263, -122.975571, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521255, -122.970652, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521191, -122.969654, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521045, -122.967814, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521049, -122.965432, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521176, -122.964451, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521977, -122.961677, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.522420, -122.960647, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.523913, -122.957568, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.524893, -122.955610, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.525375, -122.954248, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.525717, -122.952681, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.526096, -122.950670, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.527021, -122.945992, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.527825, -122.942376, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.528253, -122.940145, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.528486, -122.938755, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.528832, -122.936642, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.529471, -122.933423, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.530050, -122.930312, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.530215, -122.929201, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.530230, -122.928278, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.530260, -122.923638, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.530275, -122.918504, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.530290, -122.913617, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.530174, -122.911928, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.529850, -122.909819, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.529595, -122.908773, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.529076, -122.907116, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.528095, -122.904031, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.526622, -122.899450, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.525130, -122.894837, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.523477, -122.889665, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521917, -122.884773, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.520383, -122.879859, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.518782, -122.874860, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517260, -122.870230, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.515610, -122.865268, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.514068, -122.860478, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.513437, -122.858568, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.513035, -122.857672, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.512118, -122.855832, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510572, -122.852699, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.508663, -122.848831, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.506516, -122.844690, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.504508, -122.840731, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.503193, -122.838446, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.501098, -122.834390, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.499312, -122.830973, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.498241, -122.828881, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.496473, -122.824552, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.495278, -122.821527, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.493416, -122.816892, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.491540, -122.812225, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490314, -122.809119, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490186, -122.808630, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490205, -122.808271, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490378, -122.807552, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490743, -122.805938, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490825, -122.805176, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490799, -122.804055, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490750, -122.802644, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.490886, -122.802038, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.491600, -122.801206, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.492070, -122.800621, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.492224, -122.800139, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.492236, -122.799414, 0, VEAltitudeMode.RelativeToGround),        
            new VELatLong(45.492205, -122.796485, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.492251, -122.795391, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.492416, -122.794474, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.492713, -122.793664, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.493210, -122.792875, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.493755, -122.792398, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.494371, -122.792097, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.495815, -122.791840, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.497917, -122.791652, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.498628, -122.791443, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.499756, -122.790778, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.500425, -122.790112, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.501068, -122.789211, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.502865, -122.785800, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.504211, -122.783364, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.504753, -122.782586, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.505881, -122.781309, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.506681, -122.780392, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.507118, -122.779963, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.507565, -122.779727, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.508012, -122.779732, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.508370, -122.779925, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.508704, -122.780339, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509377, -122.781996, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509565, -122.782398, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509866, -122.782699, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510166, -122.782731, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510385, -122.782592, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510554, -122.782307, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510546, -122.781942, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510486, -122.781551, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510136, -122.780666, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509298, -122.778348, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.508727, -122.776862, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.508212, -122.775843, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.507407, -122.773547, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.507230, -122.772839, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.506775, -122.770565, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.506422, -122.768435, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.506159, -122.766246, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.505948, -122.763494, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.505896, -122.761676, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.505888, -122.759069, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.505975, -122.757239, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.506328, -122.753876, 0, VEAltitudeMode.RelativeToGround),  
            new VELatLong(45.507700, -122.746553, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509354, -122.740030, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509354, -122.734151, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509264, -122.731576, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509806, -122.729087, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510046, -122.726212, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509445, -122.723508, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.508813, -122.721963, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.508783, -122.720203, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.509475, -122.719131, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510257, -122.718358, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510475, -122.718025, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510603, -122.717618, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510648, -122.717215, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510666, -122.716384, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510681, -122.715960, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510618, -122.713466, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.510888, -122.710204, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.511640, -122.707586, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.512813, -122.705483, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.515129, -122.702050, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.516602, -122.700806, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.518301, -122.700334, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.518865, -122.700119, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.519113, -122.699765, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.519226, -122.699132, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.519196, -122.698338, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.519060, -122.697372, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.518587, -122.695355, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.518245, -122.694352, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517959, -122.693177, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517989, -122.692845, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.518143, -122.692630, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.519586, -122.691852, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.520162, -122.691343, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.520819, -122.690871, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521586, -122.690490, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521721, -122.690291, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521755, -122.690007, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521868, -122.689310, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521860, -122.689079, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.520770, -122.685018, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.519673, -122.680888, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.518481, -122.676457, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517786, -122.673860, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517809, -122.673619, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517948, -122.673447, 0, VEAltitudeMode.RelativeToGround)  
    );
    myPolygon = new VEShape(VEShapeType.Polyline, points);
    myPolygon.SetLineWidth(6);
    myPolygon.HideIcon();
    myPolygon.SetMinZoomLevel(8);
    map.AddShape(myPolygon);

    points = new Array(
            new VELatLong(45.521015, -122.690769, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521387, -122.690511, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521451, -122.690329, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.521413, -122.690114, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.520958, -122.688425, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.519632, -122.683511, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.518414, -122.678924, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517327, -122.675040, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517151, -122.674397, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517128, -122.674016, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517211, -122.673839, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.517940, -122.673447, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.519312, -122.672712, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.520041, -122.672374, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.522120, -122.671226, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.522605, -122.671253, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(45.523533, -122.671355, 0, VEAltitudeMode.RelativeToGround)
        );
    myPolygon = new VEShape(VEShapeType.Polyline, points);
    myPolygon.SetLineWidth(6);
    myPolygon.HideIcon();
    myPolygon.SetMinZoomLevel(8);
    map.AddShape(myPolygon);
}

//formats the station pushpins
function onStationsFeedLoad(feed) {
    if (feed != null) {
        var numShapes = feed.GetShapeCount();
        for (var i = 0; i < numShapes; ++i) {
            try {
                var shape1 = feed.GetShapeByIndex(i);
                shape1.SetCustomIcon("http://www.downtownlightrail.com/light-rail-maps/Images/Station.gif");

                var shapeHTML = "";
                var sImage = "";

                shapeHTML = "";
                var stationDescription = "<div style='border:solid 0px white;z-index:999;width:200px'>";
                stationDescription = stationDescription + sImage + shapeHTML;

                stationDescription = stationDescription + "<div style='padding: 5px'><a href='http://www.downtownlightrail.com/light-rail/interactive-light-rail-map.aspx'>See larger map</a></div> ";

                //bottom of div
                stationDescription = stationDescription + "</div>";
                shape1.SetPhotoURL("");
                shape1.SetMoreInfoURL("");
                shape1.SetDescription(stationDescription);
                shape1.SetMinZoomLevel(8);
            }
            catch (e) {

            }
        }
    }
}

//imports Stations from the data feed.
function AddStations(map, bestlocation) {

    var shapeSource = new VEShapeSourceSpecification(VEDataType.ImportXML, 'http://www.downtownlightrail.com/light-rail-maps/Light-Rail-GEORss.aspx?TypeID=1', oStationShapeL);

    map.ImportShapeLayerData(shapeSource, onStationsFeedLoad, bestlocation);
}

//formats the pushpins for the park-n-rides
function onParkRideLocFeedLoad(feed) {
    if (feed != null) {
        for (var i = 0; i < feed.GetShapeCount(); ++i) {
            try {
                var shape = feed.GetShapeByIndex(i);
                shape.SetMinZoomLevel(8);
                shape.SetCustomIcon("http://www.downtownlightrail.com/light-rail-maps/Images/car.gif");
                var stationDescription = "<div style='border:solid 0px white;z-index:999;width:200px'>";
                stationDescription = stationDescription + "<div style='padding: 5px'><a href='http://www.downtownlightrail.com/light-rail/interactive-light-rail-map.aspx'>See larger map</a></div></div>";
                shape.SetPhotoURL("");
                shape.SetMoreInfoURL("");
                shape.SetDescription("<div style='border:solid 0px white;z-index:999;width:200px'> </div>");
            }
            catch (e) {

            }
        }
    }
}

//gets the park and ride locations and loads them in the shapelayer. 
function LoadParkRideLoc() {
    var shapeSource = new VEShapeSourceSpecification(VEDataType.ImportXML, 'http://www.downtownlightrail.com/light-rail-maps/Light-Rail-GEORss.aspx?TypeID=2', oPRShapeL);

    map.ImportShapeLayerData(shapeSource, onParkRideLocFeedLoad, 0);
}

//This function is used to hide and show the station shape layer after it is loaded.
function ToggleStationLayer() {
    if (oStationShapeL.GetVisibility()) {
        oStationShapeL.Hide();
    }
    else {
        oStationShapeL.Show();
    }
}

//This function is used to hide and show the park-n-ride shape layer after it is loaded.
function ToggleParknRideLayer() {
    if (oPRShapeL.GetVisibility()) {
        oPRShapeL.Hide();
    }
    else {
        oPRShapeL.Show();
    }
}

//Toggles traffic off and on.
function ToggleTraffic() {
    if (bTrafficLoaded) {
        bTrafficLoaded = false;
        map.HideTrafficLegend();
        map.ClearTraffic();
    }
    else {
        bTrafficLoaded = true;
        map.ShowTrafficLegend(20, 470);
        map.SetTrafficLegendText("Traffic");
        map.LoadTraffic(bTrafficLoaded);
    }
}