document.addEventListener("DOMContentLoaded", function() { gl('function', function (env) { var eid = gl.getFEID(); var sid = gl.getSID(); var jsLinks = document.getElementsByClassName('js-gaBtnBilling'); if (jsLinks.length > 0) { for (var i = 0; i < jsLinks.length; i++) { if (jsLinks[i].href !== undefined) { if(jsLinks[i].href.indexOf('feid') >= 0 || jsLinks[i].href.indexOf('fesid') >= 0) { jsLinks[i].href = jsLinks[i].href.replace(/(feid:)([^|&]*)/, "$1" + eid).replace(/(fesid:)([^|&]*)/, "$1" + sid); } else { var params = [{n: "feid", v: eid}, {n: "fesid", v: sid}]; var custom2 = jsLinks[i].href.match(/(\[custom2\]=)([^&]*)/) || []; var c2 = custom2[2].split(':'); if(c2.length > 1) { params.push({n: c2[0], v: c2[1]}); } var new_custom2 = params.map(function(el) { return el.n + ':' + el.v; }).join('|'); jsLinks[i].href = jsLinks[i].href.replace(/(\[custom2\]=)([^&]*)/, "$1" + new_custom2); } } } } var inputs = document.getElementsByName('signup[custom2]'); if(inputs.length > 0) { for (var i = 0; i < inputs.length; i++) { if(inputs[i].value.indexOf('feid') >= 0 || inputs[i].value.indexOf('fesid') >= 0) { var new_custom2 = inputs[i].value.replace(/(feid:)([^|&]*)/, "$1" + eid).replace(/(fesid:)([^|&]*)/, "$1" + sid); } else { var params = [{n: "feid", v: eid}, {n: "fesid", v: sid}]; var c2 = inputs[i].value.split(':'); if(c2.length > 1) { params.push({n: c2[0], v: c2[1]}); } var new_custom2 = params.map(function(el) { return el.n + ':' + el.v; }).join('|'); } inputs[i].value = new_custom2; } } }); });