// This file was generated by Dashcode from Apple Inc.
// You may edit this file to customize your web application.

var listController = {
    // This object acts as a controller for the list UI.
    // It implements the dataSource methods for the list.
    
    // This dataSource uses fixed data for the content of the list.  Some applications may have such static data for their lists, others will want to replace this with information fetched remotely via XMLHttpRequest.
    _rowData: [
        "Alta",
        "Aspen",
        "Big Bear",
        "Boreal",
        "Brundage Mountain",
        "Heavenly",
        "Kirkwood",
        "Mammoth",
        "Northstar",
        "Park City",
        "Snowbird",
        "Squaw Valley",
        "Sugar Bowl",
        "Sun Valley",
        "Vail",
    ],
    
    numberOfRows: function() {
        // The List calls this dataSource method to find out how many rows should be in the list.
        return this._rowData.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 = this._rowData[rowIndex];
        }

        // We also assign an onclick handler that will cause the browser to go to the detail page.
        var self = this;
        var handler = function() {
            var resort = self._rowData[rowIndex];
            detailController.setRepresentedObject(resort);
            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'), resort);
        };
        rowElement.onclick = handler;
    }
};

var detailController = {
    // This object acts as a controller for the detail UI.
    
    setRepresentedObject: function(representedObject) {
        // To start, the represented object of our detail controller is simply a string, the title of the list row that the user chose.  You may want to make the represented object any kind of object when you customize the template.
        this._representedObject = representedObject;
        
        // When the represented object 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 detailText = document.getElementById('detailText');
        detailText.innerHTML = "The snow conditions in " + representedObject + " are awesome!";
    }
    
};

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