/* 
 This file was generated by Dashcode.  
 You may edit this file to customize your widget or web page 
 according to the license.txt file included in the project.
 */

var listController = {
    // This object acts as a controller for the list UI.
    // It implements the dataSource methods for the list.
    
    numberOfRows: function() {
        // The List calls this dataSource method to find out how many rows should be in the list.
        return parks.length;
    },
    
    prepareRow: function(rowElement, rowIndex, templateElements) {
        // The List calls this dataSource method for every row.  templateElements contains references to all elements inside the template that have an id. We use it to fill in the text of the rowTitle element.
        if (templateElements.rowTitle) {
            templateElements.rowTitle.innerText = parks[rowIndex].name;
        }

        // We also assign an onclick handler that will cause the browser to go to the detail page.
        var self = this;
        var handler = function() {
            var park = parks[rowIndex];
            detailController.setPark(park);
            var browser = document.getElementById('browser').object;
            // The Browser's goForward method is used to make the browser push down to a new level.  Going back to previous levels is handled automatically.
            browser.goForward(document.getElementById('detailLevel'), park.name);
        };
        rowElement.onclick = handler;
    }
};

var detailController = {
    // This object acts as a controller for the detail UI.
    
    setPark: function(park) {
        this._park = park;
        this._representedObject = park.name;
        
        // When the park is set, this controller also updates the DOM for the detail page appropriately.  As you customize the design for the detail page, you will want to extend this code to make sure that the correct information is populated into the detail UI.
        var detailTitle = document.getElementById('detailTitle');
        detailTitle.innerHTML = this._park.name;
        var detailLocation = document.getElementById('detailLocation');
        detailLocation.innerHTML = this._park.location;
        var detailDescription = document.getElementById('detailDescription');
        detailDescription.innerHTML = "<img src=http://apps.dot.state.nc.us/tims/cameras/viewimage.ashx?id=" + this._park.location + ".jpg>";
    }
    
};

//
// Function: load()
// Called by HTML body element's onload event when the web application is ready to start
//
function load()
{
    dashcode.setupParts();
}

// Sample data.  Some applications may have static data like this, but most will want to use information fetched remotely via XMLHttpRequest.
var parks = [
{location: "15-501-i-40", name: "I-40 Exit 270 - US 15-501" },
{location: "nc-54-i-40", name: "I-40 Exit 273 - NC 54" },
{location: "nc-751-i-40", name: "I-40 Exit 274 - NC 751" },
{location: "fay-i-40", name: "I-40 Exit 276 - Fayetteville Rd" },
{location: "nc-55-i-40", name: "I-40 Exit 278 - NC 55" },
{location: "durfrwy-i-40", name: "I-40 Exit 279A - Durham Freeway" },
{location: "davis-i-40", name: "I-40 Exit 280 - Davis Dr" },
{location: "miami-i-40", name: "I-40 Exit 281 - Miami Blvd" },
{location: "page-i-40", name: "I-40 Exit 282 - Page Rd" },
{location: "i-540-i-40", name: "I-40 Exit 283 - I-540" },
{location: "airport-i-40", name: "I-40 Exit 284 - Airport Blvd" },
{location: "aviation-i-40", name: "I-40 Exit 285 - Aviation Pkwy" },
{location: "harrison-i-40", name: "I-40 Exit 287 - Harrison Ave" },
{location: "i-40-wade", name: "I-40 Exit 289 - Wade Ave" },
{location: "nw-hptower", name: "Blue Ridge Road - HP TowerCam (Northwest)" },
{location: "se-hptower", name: "Blue Ridge Road - HP TowerCam (Southeast)" },
{location: "trinity", name: "Edwards Mill Rd - Trinity" },
{location: "edmill-wade", name: "Edwards Mill Rd - Wade Ave" },
{location: "i-40-reedycrk", name: "Edwards Mill Rd - Reedy Creek" },
{location: "dural-edmill", name: "Edwards Mill Rd - Duraleigh Rd" },
{location: "gleneden", name: "Edwards Mill Rd - Glen Eden" },
{location: "nc50-us70", name: "Edwards Mill Rd - Glenwood Avenue" },
{location: "newbern-440", name: "US 64 - New Bern Ave - I-440" },
{location: "trawick-us64", name: "US 64 - Trawick Rd" },
{location: "newhope", name: "US 64 - New Hope Rd" },
{location: "rogers", name: "US 64 - Rogers Ln" },
{location: "oldmilburn", name: "US 64 - Old Milburnie Rd" },
{location: "hodge", name: "US 64 - Hodge Rd" },
{location: "smthfld-us64", name: "US 64 - Smithfield Rd" },
{location: "us70-nc98", name: "US 70 Bypass / NC 98" },
{location: "roxboro-i-85", name: "I-85 / Roxboro St" },
{location: "guess-i-85", name: "I-85 / Guess Rd" },
{location: "hillandale-i-85", name: "I-85 / Hillandale Rd" },
{location: "hillsboro", name: "US 15-501 / Hillsborough" },
{location: "fulton-erw", name: "Erwin Rd / Fulton St" },
{location: "mlkpkwy-15-501", name: "US 15-501 / MLK Pkwy" },
{location: "dwntndur", name: "CCB Tower - Downtown Durham" },
{location: "i-440-wade", name: "I-440 / Wade Ave" },
{location: "147nofi-40", name: "NC 147 North of I-40" }
];

