/* 
 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.location;
        
        // 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 = this._park.description;
    }
    
};

//
// 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: "Thirroul" , location: "Station Street, Thirroul, Australia", description: "http://www.thirroulbutchers.com.au" }, 
    { name: "Bulli HS" , location: "Jardine Street, Bulli, Australia", description: "Bulli High School, Back field. Second ground for Thirroul JRLC" }, 
    { name: "Helensburgh", location: "Cnr Park Avenue and Blackwell Streets, Helensburgh, NSW, Australia", description: "Rex Jackson Oval"  }, 
    { name: "Norths ", location: "Cnr Haig Street and Monash Street, Wombarra, NSW, Australia", description: " " }, 
    { name: "Woonona", location: "Hollymount Park, Woonona, NSW, Australia", description: "Hollymount Park" }, 
    { name: "Corrimal", location: "18 Short Street, Corrimal, NSW, Australia", description: "Robert Ziems Park, behind Corrimal Swimming Pool" }, 
    { name: "Collegians", location: "Swan Street, Wollongong, NSW, Australia", description: "JJ Kelly Park, Cnr Keira Street & Swan Street" }, 
    { name: "Wests", location: "Cnr Cleverdon Crescent and Avalon Terrace, Figtree, NSW, Australia", description: "Sid Parrish Park" }, 
    { name: "St Pius", location: "Cnr Factory Road and Normandie Place, Unanderra, NSW, Australia", description: "Lindsay Maynes Park" }, 
    { name: "Berkeley", location: "Cnr Yawang Street and Burke Way, Berkeley, NSW, Australia", description: "Berkeley Park" }, 
    { name: "St John's", location: "342 Kanahooka Road, Brownsville, NSW, Australia", description: "Dandaloo Oval, behind Dandaloo Hotel" }, 
    { name: "Dapto", location: "77 Bong Bong Road, Dapto, NSW, Australia", description: "Reed Park, Dapto" },
    { name: "Port Kembla", location: "33 Carlotta Crescent, Port Kembla, NSW, Australia", description: "Turn right off at the end of Carlotta Cres, league field above soccer fields." },
    { name: "Windang", location: "46 Boronia Avenue, Windang, NSW, Australia", description: "Car park, turn right off Boronia onto Oakland Avenue, at the bend there is a driveway down to the carpark." },
    { name: "Warilla", location: "161 Reddall Parade, Windang", description: "Cec Glenholmes Oval" },
    { name: "Shellharbour", location: "Cnr Mary Street and William Street, Shellharbour, NSW, Australia", description: "Ron Costello Oval - best viewed in Satellite view." },
    { name: "APOF", location: "115 Croome Road, Albion Park, NSW, Australia", description: "Right turn, before Round about, Croome Rd, Sports Complex." },
    { name: "Kiama", location: "1 Bong Bong Street, Kiama, NSW, Australia", description: "Chittick Oval, Kiama Showground" },
    { name: "Gerringong", location: "20 Blackwood Street, Gerringong, NSW, Australia", description: "Mick Cronin Oval" },
    { name: "Berry SC", location: "1 Woodhill Mountain Road, Berry, NSW, Australia", description: "Berry Sporting Complex — Cnr of Woodhill Mountain Road & North Street" },
    { name: "Berry SG", location: "20 Albany Street, Berry, NSW, Australia", description: "Berry Showground" },
    { name: "Bomaderry", location: "115 Cambewarra Rd, Bomaderry, NSW, Australia", description: "Shoalhaven Sporting Complex. Turn right of Cambewarra Road, unnamed street." },
    { name: "Nowra", location: "101 Jervis Street, Nowra, NSW, Australia", description: "Lyrebird Park" },
    { name: "Culburra", location: "Cnr Prince Edward Avenue and Park Row, Culburra Beach, NSW, Australia", description: "Crookhaven Heads" },
    { name: "St Georges Basin", location: "194 Kenny Street, Sanctuary Point, NSW, Australia", description: "Paradise Beach Road, field is behind the shops." },
    { name: "Sussex Inlet", location: "7 Sandpiper Way, Sussex Inlet, NSW, Australia", description: "Finkernagle Oval" },
    { name: "Milton Ulladulla", location: "Cnr Parson Street and St Vincent Street, Ulladulla, NSW, Australia", description: "Ulladulla Sports Park. At the “Allen’s Store” turn west (right) off the Princes Highway and follow the signs to the ground at the corner of Camden and Parsons Streets Ulladulla. " },
    { name: "Batemans Bay", location: "8 Princes Hwy, Batemans Bay, NSW, Australia", description: "Mackay Park"}
];


function detailButtonHandler(event)
{
    document.location = ("http://maps.google.com.au/maps?client=googlet&q=" + detailController._representedObject);
}







