Is it possible to intercept every request made from a page using javascript? i.e. Clicking on a link, loading an image, ajax request...
In a word, no. There's no place you can hook into to get all the requests.
Having said that, you can us javascript to place event handlers on the links, look at the src attribute of image tags and so on. There's no "generic" way to hook into all the AJAX requests - it depends on the library you're using.
There are other things to consider, such as CSS background images, Flash (what if a flash file makes a request?).
If possible you should be using the browser itself (e.g. Firebug) or a proxy (e.g. Fiddler) or a packet sniffer (e.g. Ethereal... seems to be WireShark now)
Greg's right, there's no one place you can hook into all the requests. Having said that, what is your end goal in rewriting all the requests? If you need to add a "parameter" to every request and then use it on the server side, one way to do it is the host header. You can modify the host header on the server side (i.e. redirect the user from your-site.com to your-parameter.your-site.com) and all the requests after that will have *your-parameter" in it. On the server-side, you can use url-rewriting techniques to modify the url to your-site.com?parameter=your-parameter.
For redirecting use the http 302 response code. Appropriate url-rewriting component will need to be set up on the server-side (mod_rewrite for apache, ISAPIrewrite for ASP.NET)
Some points to noted: 1) The user will not be logged out since the sub-domains and domains share the session cookie 2) You will need to set up wildcard mapping on your DNS server 3) The browser caching will not be as effective 4) You need to analyze the "business-impact" of a changed url