I'm close to a solution for this, which I'll share once I've worked out the details. I'll look at the links you've kindly provided if I get stuck again.