I did not realize my question was so difficult to understand.
I couldn't get it to work because I only later realized The page was in a frameset and the url within the frameset did not have those vars. sorry about that. thanks for that great function!