/* 
 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();

    // http://webkit.org/misc/DatabaseExample.html
/*
        if (window.openDatabase) {
            db = openDatabase("NoteTest", "1.0", "HTML5 Database API example", 200000);
            if (!db)
                alert("Failed to open the database on disk.  This is probably because the version was bad or there is not enough space left in this domain's quota");
            else{
                alert("db aangemaakt en is weer toegankelijk als u terugkomt op deze site..")
            }
        } else
            alert("Couldn't open the database.  Please try with a WebKit nightly with this feature enabled");
*/
}

function loaded()
{
    db.transaction(function(tx) {
        tx.executeSql("SELECT COUNT(*) FROM WebkitStickyNotes", [], function(result) {
            loadNotes();
        }, function(tx, error) {
            tx.executeSql("CREATE TABLE WebKitStickyNotes (id REAL UNIQUE, note TEXT, timestamp REAL, left TEXT, top TEXT, zindex REAL)", [], function(result) { 
                loadNotes(); 
            });
        });
    });
}

            
function update_db(){

      db.transaction(function (tx)
        {
            tx.executeSql("UPDATE WebKitStickyNotes SET note = ?, timestamp = ?, left = ?, top = ?, zindex = ? WHERE id = ?", [note.text, note.timestamp, note.left, note.top, note.zIndex, note.id]);
        });

}            
var feed=''

// 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);
}

function photo_podcast_xml(){
    window.scrollTo(0,1);
    document.getElementById('button2').style.visibility = 'visible'
    document.getElementById("stackLayout").object.setCurrentView("loadingProgress", false);
    podcastLoad('../rss2.php');

}

function video_podcast_xml(){
    window.scrollTo(0,1);
    document.getElementById('button2').style.visibility = 'visible'
    document.getElementById("stackLayout").object.setCurrentView("loadingProgress", false); 
    podcastLoad('../rss.php');

}
function go_back(e){
    window.scrollTo(0,1);
    document.getElementById('button2').style.visibility = 'hidden';
    button2.object.enabled = false;
    document.getElementById("stackLayout").object.setCurrentView("medialab", false); 

}
