$(document).ready(function () {
    var cid;
    cid = getUrlVars()["lpcid"];
    if (cid)
        AddToUrl(cid)
});

function AddToUrl(cid) {
    var urlPart = $.param({ pid: cid })
    $('a[href*="https://community.good.com/start-trial.jspa"]').each(function () {
        var tempHref = $(this).attr("href");
        if (tempHref.indexOf("?") == -1)
            $(this).attr("href", tempHref + "?" + urlPart);
        else
            $(this).attr("href", tempHref + "&" + urlPart);
    });
}

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
