I know I can get the host name of the current page, by simply doing:
var myhostname = location.hostname;
var referrer = document.referrer;
document.referrer.hostname
By parsing it. referrer.split( '/' );
will get you close. Or take a look at this
http://blog.stevenlevithan.com/archives/parseuri
If referrer is coming from a browser, it will be sane -- but just in case you want more robust parsing.