Thanks for you kind reply. I probably didn't explain myself very well.
The page that I had to include the file on has no server sided scripting. So the above solution wouldn't work as it couldn't parse the document. I do however have php on my server.
I think I've found a solution though. The image itself is static and it is only the <a href> target surrounding the picture that needs to change. My plan is to have that link go to my server to say linker.php and from their I can calculate the page it needs to direct to and simply redirect using php.
Thanks for your help and next time I need to explain myself better.
I sometimes type quicker than I think. 🙂