Sometimes it's better to go with a simpler script, like the one I posted, rather than a complex script, like Horstl's.

If you find that my simple script works for you, we can work on adding stuff to it later.