/* 
 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('detailNote');
        detailLocation.innerHTML = this._park.note;
        var detailDescription = document.getElementById('detailText');
        detailDescription.innerHTML = this._park.text;
    }
    
};

//
// 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 = [
    { name: "About us", note: "", text: "FiftyFootSquid know that good campaigns need to work within a sound communication channel. Our experienced team can offer the best of: Creative, Design, Development, Project Management, Data & Analytics, SEO, Brand Strategy, Post Production." }, 
    { name: "Life Made better", note: "", text: "<strong>A claim too far? We don’t think so.</strong> We believe that true creative thinking combined with smart use of technology can really improve day to day life, a Life Made Better if we may. Everything we do is driven by this philosophy and by working in collaboration with clients to media enterprise partners we find ways to make sure a person’s brand experience is meaningful, rewarding and memorable." }, 
    { name: "The Work", note: "", text: "Currently we’re working with:<br><strong>Dove</strong><br><strong>Navman</strong><br><strong>Accor</strong><br><strong>Flora</strong><br><strong>Knorr</strong><br><strong>Basware</strong><br>and<br><strong>World Heart Federation</strong>." }, 
    { name: "Contact Us", note: "info@fiftyfootsquid.com", text: "8a Great Newport Street<br>London<br>WC2H 7JA<br>T / +44 (0)20 3077 1185<br>Nearest tube: Leicester Sq<br>Nearest railway: Charing Cross" }
];
