Storing application state information in the PODSPrefs object

Within the body tag of the master page, the initPage() function is set to execute immediately when the page is loaded:

<body onload="initPage()"...>

The initPage() function stores the Customers datastore name in a variable:

var dbname = "Customers";

An onclick event handler calls a gotoDetailPage() function when it determines the user has tapped a customer row for which the detail page will display more detailed information:

gotoDetailPage("Customers", accountDb.CustomerID, "CustomerDetail.html");

The gotoDetailPage() function takes the parameters that were passed and stores the datastore name and the ID of the customer row that was tapped, then opens the detail page:

function gotoDetailPage(dbname, id, pageurl)
{
    avantgo.preferences.setStringValueForKey("detailPage_"+dbname+"Id", id);
    window.location = pageurl;
}