﻿/// <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 findLayer = new VEShapeLayer();
var findArray = new Array();
var bTrafficLoaded;


var index = 0;
var results = null;

if (typeof (DESIGN_TIME) == 'undefined') {
    map = null;
}
else {
    map = new VEMap();
}

function pageLoad() {
    try {
        map = new VEMap("myMap");
        bTrafficLoaded = false;
        map.onLoadMap = map_Loaded;
        map.LoadMap(new VELatLong(29.7413, -95.3624), 12, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);
        oStationShapeL.SetTitle = "Stations";
        oPRShapeL.SetTitle = "ParkRideLoc";
        document.getElementById('MSVE_obliqueNotification').innerHTML = "";
    }
    catch (e) {

    }
}

function GetSmallMap() {
    map = new VEMap("myMap");
    bTrafficLoaded = false;
    map.onLoadMap = map_Loaded;
    map.LoadMap(new VELatLong(29.7413, -95.3624), 12, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);
    oStationShapeL.SetTitle = "Stations";
    oPRShapeL.SetTitle = "ParkRideLoc";
}

function pageUnload() {
    if (map != null) {
        map.Dispose();
    }
}

function PrintMap() {
    var pOptions = new VEPrintOptions(true);
    map.SetPrintOptions(pOptions);
    window.print();
    pOptions = new VEPrintOptions(false);
    map.SetPrintOptions(pOptions);
}

function map_Loaded() {
    AddRail(map);
    AddStations(map, 1);
    LoadParkRideLoc();
    ToggleTraffic();
    AddEvent(map);
}

function AddEvent(map) {
    //    var points1 = new VELatLong(33.431521, -111.940700, 0, VEAltitudeMode.RelativeToGround)
    //    var shape1 = new VEShape( VEShapeType.Pushpin, points1)
    //    shape1.SetDescription("<div style='z-index:5000;background-color: #FF0000;text-align:center'><h2><a href='http://tempemusicfestival.com/'><u>Tempe Music Festival</u></a></h2><br/>April 3 & 4 <br /><img src='http://tempemusicfestival.com/images/photoGallery/thumbs08/fergietv4_thumb.jpg' alt='Tempe Music Festival'/><br/> <img src='http://tempemusicfestival.com/images/photoGallery/thumbs08/fergie2_thumb.jpg' alt='Tempe Music Festival'/><img src='http://tempemusicfestival.com/images/photoGallery/thumbs08/Puddle%20of%20Mud%203_thumb.jpg' alt='Tempe Music Festival'/><img src='http://tempemusicfestival.com/images/photoGallery/thumbs08/Peachcake_thumb.jpg' alt='Tempe Music Festival'/></div>"); 
    //    shape1.SetCustomIcon("http://www.downtownlightrail.com/light-rail-maps/Images/camera39_big.gif");
    //    map.AddShape(shape1);

}

//loads the light rail map
function AddRail(map) {
    var points;

    //    //union station to littleton
    //    points = new Array(
    //            new VELatLong(39.7553, -104.9989, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7545, -104.9999, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7543, -105.0007, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7539, -105.0012, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7533, -105.0020, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7532, -105.0022, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7532, -105.0023, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7532, -105.0024, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7532, -105.0025, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7532, -105.0026, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7533, -105.0027, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7538, -105.0034, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.7539, -105.0036, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7539, -105.0038, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7539, -105.0040, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7539, -105.0040, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7538, -105.0042, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7537, -105.0043, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7536, -105.0044, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7534, -105.0045, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7528, -105.0050, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7526, -105.0051, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7523, -105.0054, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7516, -105.0063, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7509, -105.0070, 0, VEAltitudeMode.RelativeToGround),
    //-93.2388, 44.8542
    //- 93.2387, 44.8526
    //- 93.2387, 44.8525
    //- 93.2386, 44.8524
    //- 93.2373, 44.8522
    //- 93.2371, 44.8522
    //- 93.2359, 44.8519
    //- 93.2357, 44.8519
    //- 93.2341, 44.8519
    //- 93.2339, 44.8519
    //- 93.2336, 44.8519
    //- 93.2333, 44.8521
    //- 93.2331, 44.8523
    //- 93.2330, 44.8524
    //- 93.2329, 44.8526
    //- 93.2329, 44.8548
    //- 93.2328, 44.8549
    //- 93.2327, 44.8550
    //- 93.2326, 44.8551
    //- 93.2323, 44.8553
    //- 93.2310, 44.8562
    //- 93.2308, 44.8563
    //- 93.2306, 44.8564
    //- 93.2303, 44.8564
    //- 93.2300, 44.8564
    //- 93.2278, 44.8564
    //- 93.2268, 44.8564
    //- 93.2240, 44.8564
    //- 93.2238, 44.8564
    //- 93.2237, 44.8564
    //- 93.2235, 44.8565
    //- 93.2234, 44.8566
    //- 93.2232, 44.8567
    //- 93.2232, 44.8568
    //- 93.2232, 44.8570
    //- 93.2231, 44.8601
    //- 93.2231, 44.8608
    //- 93.2230, 44.8614
    //- 93.2231, 44.8634
    //- 93.2231, 44.8637
    //- 93.2233, 44.8650
    //- 93.2233, 44.8655
    //- 93.2232, 44.8679
    //- 93.2233, 44.8727
    //- 93.2233, 44.8731
    //- 93.2235, 44.8734
    //- 93.2238, 44.8738
    //- 93.2247, 44.8748
    //- 93.2247, 44.8750
    //- 93.2248, 44.8752
    //- 93.2248, 44.8754
    //- 93.2248, 44.8757
    //- 93.2247, 44.8759

    //            new VELatLong(39.7504, -105.0075, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7495, -105.0082, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7491, -105.0087, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7489, -105.0091, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7485, -105.0101, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7479, -105.0115, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7474, -105.0125, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7471, -105.0130, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7466, -105.0135, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7464, -105.0137, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7460, -105.0140, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.7453, -105.0142, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7449, -105.0143, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7443, -105.0143, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7440, -105.0143, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7437, -105.0141, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7436, -105.0140, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7435, -105.0139, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7435, -105.0138, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7435, -105.0137, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7435, -105.0133, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7434, -105.0124, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.7433, -105.0121, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7432, -105.0119, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7431, -105.0117, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7416, -105.0106, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7414, -105.0104, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7413, -105.0103, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7413, -105.0101, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7413, -105.0100, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.7413, -105.0097, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7413, -105.0095, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7413, -105.0082, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7413, -105.0082, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7412, -105.0081, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7412, -105.0080, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7410, -105.0079, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.7396, -105.0069, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7390, -105.0065, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7388, -105.0064, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7386, -105.0064, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7384, -105.0063, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7372, -105.0063, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7360, -105.0062, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7347, -105.0061, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7332, -105.0060, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7327, -105.0059, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7323, -105.0058, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7311, -105.0054, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7299, -105.0050, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7282, -105.0044, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7269, -105.0040, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7259, -105.0036, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7247, -105.0029, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7235, -105.0021, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7225, -105.0015, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7214, -105.0008, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.7202, -105.0000, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7190, -104.9992, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7172, -104.9982, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7160, -104.9975, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7145, -104.9966, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7120, -104.9953, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7098, -104.9942, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7093, -104.9938, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.7087, -104.9933, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7079, -104.9925, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7073, -104.9920, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7069, -104.9918, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7057, -104.9911, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7047, -104.9907, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7038, -104.9905, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7024, -104.9903, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.7010, -104.9901, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.6993, -104.9900, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6956, -104.9893, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6945, -104.9891, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6936, -104.9890, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6930, -104.9891, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6917, -104.9892, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6896, -104.9897, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6873, -104.9902, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6847, -104.9909, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6833, -104.9914, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.6817, -104.9918, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6799, -104.9923, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6780, -104.9928, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6754, -104.9935, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6716, -104.9944, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6698, -104.9948, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6667, -104.9956, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6643, -104.9962, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6627, -104.9969, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6603, -104.9980, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6583, -104.9988, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.6563, -104.9996, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6534, -105.0011, 0, VEAltitudeMode.RelativeToGround), //here
    //            new VELatLong(39.6488, -105.0026, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6455, -105.0039, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6429, -105.0049, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6403, -105.0058, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6382, -105.0064, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6346, -105.0074, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6322, -105.0080, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6316, -105.0083, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6306, -105.0088, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6298, -105.0090, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6286, -105.0092, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.6270, -105.0096, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6247, -105.0102, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6225, -105.0108, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6201, -105.0115, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6166, -105.0126, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6142, -105.0136, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6120, -105.0148, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6104, -105.0158, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6054, -105.0185, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6039, -105.0194, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6025, -105.0198, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.5940, -105.0212, 0, VEAltitudeMode.RelativeToGround),

    //            new VELatLong(39.5896, -105.0223, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.5848, -105.0231, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.5837, -105.0234, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.5801, -105.0250, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.5786, -105.0258, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.5760, -105.0270, 0, VEAltitudeMode.RelativeToGround)
    //            );
    //    myPolygon = new VEShape(VEShapeType.Polyline, points);
    //    myPolygon.SetLineWidth(6);
    //    myPolygon.HideIcon();
    //    myPolygon.SetMinZoomLevel(8);
    //    map.AddShape(myPolygon);


    //            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)

}

//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);
                var shapeHTML = shape1.GetDescription();
                var latlong = shape1.GetPoints()[0];
                var lat = latlong.Latitude;
                var lon = latlong.Longitude;

                shapeHTML = shapeHTML + "<br /><hr /><a onclick='JavaScript:DoZoom(" + lat + "," + lon + ") ;' style='background-color:#BBC423; cursor:pointer; color:black; padding:3px;border: solid 1px black;'>Zoom to this station</a>";
                var sImage = "";

                sImage = sImage + "<br />";
                shape1.SetDescription("<div style='z-index:5000;'>" + sImage + shapeHTML + "</div>");
            }
            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/StationFeed.ashx?lineId=13', oStationShapeL);
    map.ImportShapeLayerData(shapeSource, onStationsFeedLoad, bestlocation);
}
function DoZoom(lat, lon) {
    map.SetCenterAndZoom(new VELatLong(lat, lon), 19);
    map.SetMapStyle(VEMapStyle.Hybrid);
}
//formats the pushpins for the park-n-rides
function onParkRideLocFeedLoad(feed) {
    if (feed != null) {
        var numShapes = feed.GetShapeCount();
        for (var i = 0; i < numShapes; ++i) {
            try {
                var shape = feed.GetShapeByIndex(i);
                shape.SetCustomIcon("http://www.downtownlightrail.com/light-rail-maps/images/car.gif");
            }
            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/Parking.ashx?lineId=13', oPRShapeL);
    //    map.ImportShapeLayerData(shapeSource, onParkRideLocFeedLoad, 0);
}

//function Resize()
//{
//    var mapDiv = document.getElementById("myMap");
//    var sqlTXT = document.getElementById("txtSQL");
//    var accordion = document.getElementById("Accordion1");
//    var windowWidth = document.body.clientWidth;
//    var windowHeight = document.body.clientHeight;
//    mapWidth = windowWidth - 305;
//    mapHeight = windowHeight  - 155;
//    mapDiv.style.width = mapWidth + "px";
//    mapDiv.style.height = mapHeight + "px";
//    sqlTXT.style.width = mapWidth - 175 + "px";
//    accordion.style.height = (windowHeight - 45) + "px";
//    map.Resize(mapWidth, mapHeight);
//    map.ShowMiniMap(mapWidth-205, 13, VEMiniMapSize.Large);
//}

//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);
    }
}

//Does the find functionality - yellow book find. bNext = -1 means a new search.
function DoFind(numResults, bNext) {
    try {
        var what = document.getElementById('txtWhat').value;
        findLayer.DeleteAllShapes();
        findLayer = new VEShapeLayer();

        map.AddShapeLayer(findLayer);

        if (bNext == -1) {
            index = 0;
        }
        else if (bNext != 1) {
            index = parseInt(index) - (numResults * 2)
        }

        if (index < 0) index = 0;
        if (numResults > 20) numResults = 20;
        results = map.Find(what,
                          null,
                          null,
                          findLayer,
                          index,
                          numResults,
                          true,
                          true,
                          true,
                          true,
                          MoreResults);
        index = parseInt(index) + numResults;
    }
    catch (e) {
        alert(e.message);
    }
}

function MoreResults(layer, resultsArray, places, hasMore, veErrorMessage) {
    var r = "";
    if (hasMore) {
        if (index > 10) {
            r = "<a href='#' onclick='javascript:DoFind(10,0);'>&lt;Prev</a>&nbsp;&nbsp;";
        }
        r = r + "<a href='#' onclick='javascript:DoFind(10,1);'>Next></a><hr />";
    }
    else if (index < 10) {
        r = "<a href='#' onclick='javascript:DoFind(10,1);'>Next></a><hr />";
    }
    else {
        if (index > 9) {
            r = "<a href='#' onclick='javascript:DoFind(10,0);'>&lt;Prev</a>";
        }
    }

    document.getElementById('results').innerHTML = r;
    var resList = "";

    if (layer != null) {
        var numShapes = layer.GetShapeCount();
        for (var i = 0; i < numShapes; ++i) {
            var x = i + 1
            var shape = layer.GetShapeByIndex(i);
            shape.SetCustomIcon("http://www.downtownlightrail.com/light-rail-maps/images/Black" + x + ".gif");

            try {
                var fName = resultsArray[i].Name;
                var fDescrip = resultsArray[i].Description;
                var fPhone = resultsArray[i].Phone;
            }
            catch (e) {

            }
            resList = resList + "<img src='http://www.downtownlightrail.com/light-rail-maps/images/Black" + x + ".gif'</img>" + fName + "<br />" + fDescrip + "<br />" + fPhone + "<br /><hr />";
        }
    }
    document.getElementById('resultslist').innerHTML = resList;
}

function hideFindDiv() {
    //hide the find part of the control
    if (document.getElementById) { // DOM3 = IE5, NS6 
        document.getElementById('findControl').style.visibility = 'hidden';
    }
    else {
        if (document.layers) { // Netscape 4 
            document.findControl.visibility = 'hidden';
        }
        else { // IE 4 
            document.all.findControl.style.visibility = 'hidden';
        }
    }

    //hide the results part of the control
    if (document.getElementById) { // DOM3 = IE5, NS6 
        document.getElementById('results').style.visibility = 'hidden';
    }
    else {
        if (document.layers) { // Netscape 4 
            document.results.visibility = 'hidden';
        }
        else { // IE 4 
            document.all.results.style.visibility = 'hidden';
        }
    }
}

function showFindDiv() {
    //show the find part of the control
    if (document.getElementById) { // DOM3 = IE5, NS6 
        document.getElementById('findControl').style.visibility = 'visible';
    }
    else {
        if (document.layers) { // Netscape 4 
            document.findControl.visibility = 'visible';
        }
        else { // IE 4 
            document.all.findControl.style.visibility = 'visible';
        }
    }

    //show the results part of the control
    if (document.getElementById) { // DOM3 = IE5, NS6 
        document.getElementById('results').style.visibility = 'visible';
    }
    else {
        if (document.layers) { // Netscape 4 
            document.results.visibility = 'visible';
        }
        else { // IE 4 
            document.all.results.style.visibility = 'visible';
        }
    }
} 


