I got it working (though I'm acutely aware that there are many other issues in there :-D ).
I just had to remove the cast of the current iteration ID to a String in Post().
iCurrent = new String(Math.floor(iCurrent / 2));
Just changed to...
iCurrent = Math.floor(iCurrent / 2);
In fact I think it is still missing one function - there is no default open AccordionItem. But they do all open and close correctly now.