While I would love to share the whole script, the writing style is quite haphazard and badly structured. I found this when trying to incorporate these functions in. Last night my head was on fire thinking on how to get all this working and I had to take a break.
The more I practice, the easier it becomes mostly due to re-usable code. If I can remember that I have done it before then its easy to adopt it.
I'd likely be lost. It has been so long since I have coded. I tried to follow along with what you posted, but many of the pieces didn't seem that intuitive to me. I guess once you learn the language it probably isn't too bad.
I have trouble following some of it. It is not second nature to me (yet) as other languages have become.