/* 
 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.
 */

//
// Function: load()
// Called by HTML body element's onload event when the web application is ready to start
//
function load()
{
    dashcode.setupParts();
    document.getElementById("stackLayout").object.setCurrentView("loadingProgress", false);
    podcastLoad();
}


// This object implements the dataSource methods for the list.
var episodeListController = {
    
    // The List calls this method to find out how many rows should be in the list.
numberOfRows: function() {
    if (results == null)
        return 0;           // Return 0 if there are no results to load 
    else
        return results.length;
},
    
    // The List calls this method once for every row.
prepareRow: function(rowElement, rowIndex, templateElements) {
    // templateElements contains references to all elements that have an id in the template row.
    // Ex: set the value of an element with id="label".
    if (templateElements.label) {
        templateElements.label.innerText = extractText(results[rowIndex].title);
    }
    if (templateElements.date) {
        var date = createDateStr(results[rowIndex].date);
        templateElements.date.innerText = date;
    }
    
    // Assign a click event handler for the row.
    rowElement.onclick = function(event) {
        // Do something interesting
        window.location = (results[rowIndex].track);
    };
}
};

function displayTitles () {
    document.getElementById("episodes").object.reloadData();
    document.getElementById("stackLayout").object.setCurrentView("episodeList", false);
}