var query = location.search;
var cj_string = /WT.mc_n=(edu_cj_[^\&]+)/i;

if (query.search(cj_string) > -1) {
    var result = query.match(cj_string);
    var cj_flag = result[1];

    var hostname = location.hostname;
    var domain_string = /\W?(\w+\.\w+)$/;
    if (hostname.search(domain_string) > -1) {
        result = hostname.match(domain_string);
        hostname = result[1];
    }
    document.cookie = 'CJ_flag=' + encodeURIComponent(cj_flag) + '; path=/; domain=.' + encodeURIComponent(hostname);
}

// ... and that's all, folks.  We don't want an else statement here; that will just
// cause trouble if the user initially came in from a CJ site but is returning to this
// page after visiting various other sub-pages.
