Changed referral detection slightly for IE compatibility.