if(document.URL.indexOf("?") > 0) {
	var hpparamarray = document.URL.split("?")[1].split("&");
	for(var i=0; i < hpparamarray.length; i++) {
		var hppair = hpparamarray[i].split("=");
		if(hppair[0] == "sc") { var expReplaceSC = hppair[1] }
		if(hppair[0] == "bcd") { var expReplaceBCD = hppair[1] }
		if(hppair[0] == "pmidsc") { var expReplacePMIDSC = hppair[1] }
		if(hppair[0] == "pmidbcd") { var expReplacePMIDBCD = hppair[1] }
	}
	var allLinks = 1;
}

var sessId = mboxFactoryDefault.getSessionId().getId();
for(var i=0, j=document.links.length; i<j; i++) {
	var linko = document.links[i].href;
	var CEprop = 0;
	var CredExp = 0;
	var PMID = 0;
	var AUTO = 0;
	var LMB = 0;
	var expLink = 0;
	if(linko.indexOf('?') > 0) { paramIdent = '&' } else { paramIdent = '?' }

	if(linko.indexOf('creditexpert.co.uk') > -1 || linko.indexOf('joincreditexpert.com') > -1) { CEprop = 1; CredExp = 1; }
	if(linko.indexOf('protectmyid.co.uk') > -1) { CEprop = 1; PMID = 1; }
	if(linko.indexOf('autocheck.co.uk') > -1) { CEprop = 1; AUTO=1; }
	if(linko.indexOf('lowermybills.co.uk') > -1) { CEprop = 1; LMB = 1; }
	if(linko.indexOf('experian.co.uk') > -1 && allLinks == 1) { expLink = 1; }
	
	if(CredExp == 1) {
		if(typeof(window.expReplaceSC) !== 'undefined') { linko = linko.replace(/sc=([\w|-]*)/,'sc=' + expReplaceSC) }
		if(typeof(window.expAppendToSC) !== 'undefined') { linko = linko.replace(/sc=([\w|-]*)/,'sc=$1' + expAppendToSC) }
		if(typeof(window.expReplaceBCD) !== 'undefined') { linko = linko.replace(/bcd=([\w|-]*)/,'bcd=' + expReplaceBCD) }
		if(typeof(window.expAppendToBCD) !== 'undefined') { linko = linko.replace(/bcd=([\w|-]*)/,'bcd=$1' + expAppendToBCD) }
		if(typeof(window.expReplaceBCDId) !== 'undefined') { linko = linko.replace(/bcd=(\w{2}-\w{4}-\w{4}-\w{4})-\w{2}/,'bcd=$1-' + expReplaceBCDId) }
	}
	
	if(PMID == 1) {
		if(typeof(window.expReplacePMIDSC) !== 'undefined') { linko = linko.replace(/sc=([\w|-]*)/,'sc=' + expReplacePMIDSC) }
		if(typeof(window.expAppendToPMIDSC) !== 'undefined') { linko = linko.replace(/sc=([\w|-]*)/,'sc=$1' + expAppendToPMIDSC) }
		if(typeof(window.expReplacePMIDBCD) !== 'undefined') { linko = linko.replace(/bcd=([\w|-]*)/,'bcd=' + expReplacePMIDBCD) }
		if(typeof(window.expAppendToPMIDBCD) !== 'undefined') { linko = linko.replace(/bcd=([\w|-]*)/,'bcd=$1' + expAppendToPMIDBCD) }
		if(typeof(window.expReplacePMIDBCDId) !== 'undefined') { linko = linko.replace(/bcd=(\w{2}-\w{4}-\w{4}-\w{4})-\w{2}/,'bcd=$1-' + expReplacePMIDBCDId) }
	}

	if(AUTO == 1) {
		if(typeof(window.expReplaceAUTOBCDId) !== 'undefined') { linko = linko.replace(/bcd=(\w{2}-\w{4}-\w{4}-\w{4})-\w{2}/,'bcd=$1-' + expReplaceAUTOBCDId) }
	}
	
	if(LMB == 1) {
		if(typeof(window.expReplaceLMBBCDId) !== 'undefined') { linko = linko.replace(/banner=(\w{2}-\w{4}-\w{4}-\w{4})-\w{2}/,'banner=$1-' + expReplaceLMBBCDId) }
	}
	
	if(expLink == 1) {
		if(typeof(window.expReplaceSC) !== 'undefined') { linko += paramIdent + 'sc=' + expReplaceSC }
		if(typeof(window.expReplaceBCD) !== 'undefined') { linko += paramIdent + 'bcd=' + expReplaceBCD }
	}

	if(CEprop == 1 && linko.indexOf('mboxSession') < 0) { linko += paramIdent + 'mboxSession=' + sessId }
	
	document.links[i].href = linko;
	
}

