Heres a thought, any record set you create will have a variable to return the number of rows.
you can use that variable - 1 to set the default panel. for example:
var Accordion1 = new Spry.Widget.Accordion("Accordion1", { defaultPanel: <?php echo($totalRows_recordsetName - 1); ?> });
you have to subtract 1 because the panels are indexed starting at 0.