I was going through the Help and Improvement queue, and found this question. It's a bit difficult to read, includes links to images instead of the code, and seems to be asking for someone else to write the software for him. Ordinarily I'd flag this question to be closed, but in this case, OP has self-answered the question with what appears to be a working solution.
What do I do in this situation?