﻿/// <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(32.787851, -96.783371), 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(32.787851, -96.783371), 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;

    //plano to mockingbird station
    points = new Array(
            new VELatLong(33.0369, -96.7007, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0240, -96.7009, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0231, -96.7009, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0211, -96.7009, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0178, -96.7010, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0125, -96.7011, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0092, -96.7011, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0078, -96.7012, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0070, -96.7013, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0062, -96.7014, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0052, -96.7017, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(33.0043, -96.7022, 0, VEAltitudeMode.RelativeToGround),

            new VELatLong(33.0026, -96.7030, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9971, -96.7054, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9939, -96.7069, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9884, -96.7094, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9850, -96.7110, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9767, -96.7148, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9756, -96.7153, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9751, -96.7156, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9736, -96.7164, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9701, -96.7187, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9638, -96.7227, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9620, -96.7239, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9576, -96.7267, 0, VEAltitudeMode.RelativeToGround),
            
            new VELatLong(32.9473, -96.7332, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9434, -96.7357, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9406, -96.7375, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9384, -96.7389, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9284, -96.7453, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9247, -96.7477, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9215, -96.7497, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9199, -96.7507, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9192, -96.7513, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9176, -96.7529, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9105, -96.7593, 0, VEAltitudeMode.RelativeToGround),
            
            new VELatLong(32.9100, -96.7598, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9090, -96.7612, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9085, -96.7617, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9078, -96.7625, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9072, -96.7629, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9055, -96.7637, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9035, -96.7645, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9013, -96.7653, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8995, -96.7660, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8992, -96.7660, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8988, -96.7661, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8983, -96.7661, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8978, -96.7660, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8972, -96.7659, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8967, -96.7657, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8947, -96.7650, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8943, -96.7649, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8939, -96.7649, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8934, -96.7648, 0, VEAltitudeMode.RelativeToGround),
            
            new VELatLong(32.8929, -96.7648, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8929, -96.7648, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8846, -96.7649, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8831, -96.7649, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8810, -96.7649, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8803, -96.7649, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8771, -96.7650, 0, VEAltitudeMode.RelativeToGround),    
            
            new VELatLong(32.8765, -96.7650, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8760, -96.7651, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8755, -96.7652, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8729, -96.7659, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8709, -96.7663, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8693, -96.7667, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8672, -96.7671, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8641, -96.7677, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8630, -96.7680, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8598, -96.7687, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8553, -96.7697, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8517, -96.7705, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8513, -96.7706, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8508, -96.7709, 0, VEAltitudeMode.RelativeToGround), 
            
            new VELatLong(32.8499, -96.7713, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8488, -96.7717, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8469, -96.7723, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8449, -96.7725, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8438, -96.7726, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8434, -96.7726, 0, VEAltitudeMode.RelativeToGround),  
            
            new VELatLong(32.8416, -96.7727, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8412, -96.7728, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8407, -96.7729, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8393, -96.7734, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8390, -96.7736, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8389, -96.7737, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8388, -96.7738, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8384, -96.7742, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8380, -96.7747, 0, VEAltitudeMode.RelativeToGround),
            
            //Mockingbird to City Place
            new VELatLong(32.8372, -96.7757, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8368, -96.7762, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8341, -96.7795, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8333, -96.7802, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8324, -96.7805, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8314, -96.7809, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8294, -96.7822, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8260, -96.7841, 0, VEAltitudeMode.RelativeToGround),

            new VELatLong(32.8208, -96.7865, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8093, -96.7926, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8073, -96.7928, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8054, -96.7928, 0, VEAltitudeMode.RelativeToGround),
            //City Place to Westmoreland
            new VELatLong(32.8047, -96.7928, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7959, -96.7927, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7953, -96.7930, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7950, -96.7932, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7948, -96.7933, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7943, -96.7933, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7926, -96.7933, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7922, -96.7933, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7910, -96.7930, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7908, -96.7930, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7906, -96.7930, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7904, -96.7931, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7903, -96.7932, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7901, -96.7933, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7898, -96.7936, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7897, -96.7938, 0, VEAltitudeMode.RelativeToGround),
            
            new VELatLong(32.7896, -96.7939, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7895, -96.7939, 0, VEAltitudeMode.RelativeToGround), 
            new VELatLong(32.7894, -96.7939, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7893, -96.7939, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7893, -96.7939, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7892, -96.7939, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7891, -96.7939, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7891, -96.7939, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7890, -96.7938, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7889, -96.7938, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7888, -96.7936, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7887, -96.7935, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7882, -96.7929, 0, VEAltitudeMode.RelativeToGround),

            new VELatLong(32.7882, -96.7929, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7881, -96.7928, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7880, -96.7928, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7878, -96.7928, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7878, -96.7929, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.7876, -96.7932, 0, VEAltitudeMode.RelativeToGround)

//            new VELatLong(39.6270, -96.0096, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6247, -96.0102, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6225, -96.0108, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6201, -96.0115, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6166, -96.0126, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6142, -96.0136, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6120, -96.0148, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6104, -96.0158, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6054, -96.0185, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6039, -96.0194, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.6025, -96.0198, 0, VEAltitudeMode.RelativeToGround),
//            new VELatLong(39.5940, -96.0212, 0, VEAltitudeMode.RelativeToGround)
//- 96.7935, 32.7873
//- 96.7943, 32.7866
//- 96.7971, 32.7843
//- 96.7994, 32.7823
//- 96.7996, 32.7822
//- 96.7997, 32.7821
//- 96.7998, 32.7821
//- 96.7999, 32.7821
//- 96.8001, 32.7820
//- 96.8007, 32.7819
//- 96.8026, 32.7815
//- 96.8032, 32.7813
//- 96.8036, 32.7812
//- 96.8048, 32.7811
//- 96.8056, 32.7809
//- 96.8077, 32.7804
//- 96.8079, 32.7804
//- 96.8080, 32.7804
//- 96.8082, 32.7804
//- 96.8084, 32.7804
//- 96.8090, 32.7803
//- 96.8091, 32.7803
//- 96.8092, 32.7803
//- 96.8093, 32.7802
//- 96.8095, 32.7802
//- 96.8096, 32.7801
//- 96.8097, 32.7800
//- 96.8097, 32.7799
//- 96.8098, 32.7797
//- 96.8098, 32.7796
//- 96.8098, 32.7795
//- 96.8098, 32.7794
//- 96.8098, 32.7792
//- 96.8097, 32.7790
//- 96.8096, 32.7789
//- 96.8087, 32.7775
//- 96.8086, 32.7773
//- 96.8085, 32.7772
//- 96.8085, 32.7771
//- 96.8084, 32.7770
//- 96.8084, 32.7768
//- 96.8082, 32.7761
//- 96.8079, 32.7752
//- 96.8079, 32.7750
//- 96.8078, 32.7748
//- 96.8078, 32.7746
//- 96.8077, 32.7745
//- 96.8077, 32.7744
//- 96.8074, 32.7741
//- 96.8072, 32.7739
//- 96.8070, 32.7737
//- 96.8064, 32.7733
//- 96.8061, 32.7731
//- 96.8046, 32.7722
//- 96.8044, 32.7722
//- 96.8041, 32.7722
//- 96.8038, 32.7723
//- 96.8018, 32.7727
//- 96.8017, 32.7728
//- 96.8015, 32.7728
//- 96.8014, 32.7728
//- 96.8012, 32.7728
//- 96.8009, 32.7727
//- 96.8006, 32.7727
//- 96.8004, 32.7726
//- 96.8001, 32.7725
//- 96.7954, 32.7698
//- 96.7936, 32.7688
//- 96.7868, 32.7649
//- 96.7865, 32.7647
//- 96.7863, 32.7645
//- 96.7861, 32.7642
//- 96.7858, 32.7638
//- 96.7856, 32.7636
//- 96.7856, 32.7634
//- 96.7856, 32.7631
//- 96.7856, 32.7629
//- 96.7857, 32.7627
//- 96.7858, 32.7626
//- 96.7869, 32.7610
//- 96.7914, 32.7535
//- 96.7918, 32.7529
//- 96.7922, 32.7525
//- 96.7932, 32.7514
//- 96.7936, 32.7510
//- 96.7941, 32.7506
//- 96.7950, 32.7499
//- 96.7959, 32.7493
//- 96.7970, 32.7488
//- 96.7983, 32.7482
//- 96.8102, 32.7426
//- 96.8104, 32.7425
//- 96.8109, 32.7423
//- 96.8113, 32.7420
//- 96.8117, 32.7417
//- 96.8130, 32.7407
//- 96.8194, 32.7354
//- 96.8199, 32.7350
//- 96.8215, 32.7337
//- 96.8217, 32.7335
//- 96.8220, 32.7333
//- 96.8223, 32.7332
//- 96.8226, 32.7331
//- 96.8229, 32.7330
//- 96.8232, 32.7329
//- 96.8236, 32.7328
//- 96.8239, 32.7328
//- 96.8242, 32.7328
//- 96.8246, 32.7328
//- 96.8250, 32.7329
//- 96.8259, 32.7330
//- 96.8263, 32.7331
//- 96.8268, 32.7331
//- 96.8279, 32.7331
//- 96.8281, 32.7331
//- 96.8282, 32.7331
//- 96.8284, 32.7331
//- 96.8288, 32.7332
//- 96.8292, 32.7333
//- 96.8295, 32.7334
//- 96.8299, 32.7335
//- 96.8309, 32.7340
//- 96.8312, 32.7341
//- 96.8316, 32.7342
//- 96.8320, 32.7343
//- 96.8324, 32.7343
//- 96.8328, 32.7343
//- 96.8332, 32.7342
//- 96.8336, 32.7342
//- 96.8385, 32.7331
//- 96.8422, 32.7323
//- 96.8427, 32.7322
//- 96.8432, 32.7321
//- 96.8437, 32.7319
//- 96.8441, 32.7318
//- 96.8447, 32.7315
//- 96.8452, 32.7313
//- 96.8519, 32.7283
//- 96.8525, 32.7280
//- 96.8529, 32.7278
//- 96.8534, 32.7275
//- 96.8554, 32.7264
//- 96.8591, 32.7243
//- 96.8595, 32.7241
//- 96.8600, 32.7239
//- 96.8604, 32.7237
//- 96.8672, 32.7213
//- 96.8697, 32.7204
//- 96.8718, 32.7197
//- 96.8734, 32.7192

    //            new VELatLong(39.6270, -96.0096, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6247, -96.0102, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6225, -96.0108, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6201, -96.0115, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6166, -96.0126, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6142, -96.0136, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6120, -96.0148, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6104, -96.0158, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6054, -96.0185, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6039, -96.0194, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.6025, -96.0198, 0, VEAltitudeMode.RelativeToGround),
    //            new VELatLong(39.5940, -96.0212, 0, VEAltitudeMode.RelativeToGround)
            );
    myPolygon = new VEShape(VEShapeType.Polyline, points);
    myPolygon.SetLineWidth(6);
    myPolygon.HideIcon();
    myPolygon.SetMinZoomLevel(8);
    map.AddShape(myPolygon);


    //garland to mockingbird station
    points = new Array(
            new VELatLong(32.9167, -96.6329, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9163, -96.6353, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9132, -96.6542, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9131, -96.6550, 0, VEAltitudeMode.RelativeToGround),
            
            new VELatLong(32.9130, -96.6565, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9126, -96.6640, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9125, -96.6646, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9124, -96.6652, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9119, -96.6670, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9081, -96.6795, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9067, -96.6837, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9064, -96.6848, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9062, -96.6859, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9058, -96.6872, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9041, -96.6922, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.9015, -96.7008, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8986, -96.7101, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8980, -96.7118, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8954, -96.7202, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8951, -96.7209, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8947, -96.7216, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8943, -96.7222, 0, VEAltitudeMode.RelativeToGround),
            
            new VELatLong(32.8935, -96.7233, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8915, -96.7255, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8908, -96.7267, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8896, -96.7289, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8891, -96.7297, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8887, -96.7301, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8881, -96.7306, 0, VEAltitudeMode.RelativeToGround),

            new VELatLong(32.8875, -96.7309, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8871, -96.7310, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8865, -96.7311, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8861, -96.7311, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8855, -96.7310, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8848, -96.7307, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8840, -96.7305, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8832, -96.7302, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8823, -96.7300, 0, VEAltitudeMode.RelativeToGround),
            
            new VELatLong(32.8819, -96.7300, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8815, -96.7300, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8810, -96.7301, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8805, -96.7302, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8786, -96.7307, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8780, -96.7308, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8775, -96.7308, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8769, -96.7308, 0, VEAltitudeMode.RelativeToGround),

            new VELatLong(32.8750, -96.7308, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8739, -96.7309, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8733, -96.7311, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8689, -96.7332, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8686, -96.7333, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8680, -96.7334, 0, VEAltitudeMode.RelativeToGround),

            new VELatLong(32.8675, -96.7335, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8669, -96.7336, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8616, -96.7340, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8612, -96.7340, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8608, -96.7340, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8605, -96.7339, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8600, -96.7338, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8565, -96.7328, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8560, -96.7327, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8553, -96.7326, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8542, -96.7325, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8539, -96.7325, 0, VEAltitudeMode.RelativeToGround),
                       
            new VELatLong(32.8535, -96.7326, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8529, -96.7328, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8525, -96.7331, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8521, -96.7334, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8518, -96.7338, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8516, -96.7340, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8473, -96.7403, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8470, -96.7408, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8467, -96.7414, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8464, -96.7419, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8462, -96.7425, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8460, -96.7432, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8458, -96.7439, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8395, -96.7715, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8394, -96.7719, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8393, -96.7723, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8390, -96.7730, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8388, -96.7735, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8385, -96.7741, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8382, -96.7744, 0, VEAltitudeMode.RelativeToGround),
            new VELatLong(32.8380, -96.7748, 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);
                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=3', oStationShapeL);
    shapeSource.MaxImportedShapes = 500;
    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=3', 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';
        }
    }
} 


