function getppc() {
	var experiancomsrc = '5002';     // Source code for experian.com
	var ppclink = experiancomsrc;    // Set link source code to experian.com
	var ppcorganic = '';             // Set up organic marker
	var ppcoffer = '';               // Set up offer code (from kw)
	var locode = '';                 // Set up page location code

	// check for previously set session cookie and extract link, offer and organic
	var ppccookie = document.cookie.split("; ");
	for(var i=0; i < ppccookie.length; i++) {
		var crumb = ppccookie[i].split("=");
		if(crumb[0] == "ppclink") {
			ppclink = crumb[1];
		}
		if(crumb[0] == "ppcoffer") {
			ppcoffer = crumb[1];
		}
		if(crumb[0] == "ppcorganic") {
			ppcorganic = crumb[1];
		}
	}

        // if link code is set then a keyword is being tracked (link code cookie is only set from inbound keyword links)
	// otherwise it will remain as initialised
	if(ppclink == experiancomsrc) {

		// if organic is not set in a cookie, try and set organic from the referring URL
		if(ppcorganic == '') {
			var referrer = document.referrer;

			if(referrer != '') {                                        // if no referrer then don't even bother
				var regex = new RegExp(/^http:\/\/(.+?)\/.*?$/g);   // this regex obtains the hostname
				var referrerarray = regex.exec(referrer);           // from the referring URL.
				var referrername = referrerarray.pop();             // spit the last element (the match) off the resultant array

				if(referrername.search(/\./) > -1) {			    // if no dots in referrer (e.g. local link) then don't bother
					var referrerdomainarray = referrername.split('.');  // split the hostname at the dots
					var referrerdomaintld = referrerdomainarray.pop();  // the TLD is the last element (assuming US-style domains)
					var referrerdomainname = referrerdomainarray.pop(); // the org/corp name is the second-last element
					var referrerdomain = referrerdomainname + '.' + referrerdomaintld;  // put it all together

					switch(referrerdomain) {                            // simple switch statement to set up organic markers for the top ten
						case "google.com":
							ppcorganic = 'a';
							break;

						case "yahoo.com":
							ppcorganic = 'b';
							break;

						case "msn.com":
							ppcorganic = 'c';
							break;

						case "ask.com":
							ppcorganic = 'd';
							break;

						case "aol.com":
							ppcorganic = 'e';
							break;

						case "comcast.net":
							ppcorganic = 'f';
							break;

						case "netscape.com":
							ppcorganic = 'g';
							break;

						case "mywebsearch.com":
							ppcorganic = 'h';
							break;

						case "bellsouth.net":
							ppcorganic = 'i';
							break;

						case "earthlink.net":
							ppcorganic = 'j';
							break;

						default:
							ppcorganic = '';
					}

					if(ppcorganic != '') {
						document.cookie = 'ppcorganic=' + ppcorganic + '; path=/;';  // set the organic marker session cookie if necessary
					}
				}
			}
		}
		ppclink += ppcorganic;   // if the link code is experian.com, add the organic marker to it
	}

	// check for parameters in the URL and if they include keyword params, set the appropriate variables and session cookies
	if(document.URL.indexOf("?") > 0) {

		var urlarray = document.URL.split("?");
		var paramstring = urlarray[1];	
		var foundcookie = 0;

		var paramarray = paramstring.split("&");
		for(var i=0; i < paramarray.length; i++) {
			var pair = paramarray[i].split("=");
			if(pair[0] == "link") {
				ppclink = pair[1];
				document.cookie = 'ppclink=' + ppclink + '; path=/;';
				foundcookie++;
			}
			if(pair[0] == "offercode") {
				ppcoffer = pair[1];
				document.cookie = 'ppcoffer=' + ppcoffer + '; path=/;';
				foundcookie++;
			}
			// if both paid keyword parameters are found, delete organic marker cookie
			if(foundcookie == 2) {
				document.cookie = 'ppcorganic=; path=/; expires=Fri, 31 Dec 1999 23:59:59 GMT;';
			}
		}
	}

	// cycle through the links to find ones that need parameters added to them
	for(var i=0; i < document.links.length; i++) {
		if(document.links[i].id.indexOf('sbrlink_') == 0 || document.links[i].id.indexOf('bprlink_') == 0) {
			var idarray = document.links[i].id.split("_");
			var locode = idarray[1];
			if(document.links[i].href.indexOf("wvw.experian.com") > 0) {
				document.links[i].href += '%3Flink=' + ppclink + '%26offercode=' + ppcoffer + locode;
			} else if(document.links[i].href.indexOf("?") > 0) {
				document.links[i].href += '&link=' + ppclink + '&offercode=' + ppcoffer + locode;
			} else {
				document.links[i].href += '?link=' + ppclink + '&offercode=' + ppcoffer + locode;
			}
		}
	}

	// cycle through the dropdowns to find ones that need parameters added to them
	var dropdowns = document.getElementsByTagName('option');
	for(var i=0; i < dropdowns.length; i++) {
		if(dropdowns[i].id.indexOf('sbrdrop_') == 0 || dropdowns[i].id.indexOf('bprdrop_') == 0) {
			var idarray = dropdowns[i].id.split("_");
			var locode = idarray[1];
			if(dropdowns[i].value.indexOf("?") > 0) {
				dropdowns[i].value += '&link=' + ppclink + '&offercode=' + ppcoffer + locode;
			} else {
				dropdowns[i].value += '?link=' + ppclink + '&offercode=' + ppcoffer + locode;
			}
		}
	}

	// cycle through the areas (image maps) to find ones that need parameters added to them
	var areas = document.getElementsByTagName('area');
	for(var i=0; i < areas.length; i++) {
		if(areas[i].id.indexOf('sbrarea_') == 0 || areas[i].id.indexOf('bprarea_') == 0) {
			var idarray = areas[i].id.split("_");
			var locode = idarray[1];
			if(areas[i].href.indexOf("?") > 0) {
				areas[i].href += '&link=' + ppclink + '&offercode=' + ppcoffer + locode;
			} else {
				areas[i].href += '?link=' + ppclink + '&offercode=' + ppcoffer + locode;
			}
		}
	}

	// fix the relevant form fields
	if(document.getElementById('sbrformlink')) { document.getElementById('sbrformlink').value = ppclink }
	if(document.getElementById('sbrformoffercode')) {
		var locode = document.getElementById('sbrformoffercode').value;
		if(locode.indexOf(ppcoffer) < 0) {
			document.getElementById('sbrformoffercode').value = ppcoffer + locode;
		}
	}

	if(document.getElementById('bprformlink')) { document.getElementById('bprformlink').value = ppclink }
	if(document.getElementById('bprformoffercode')) {
		var locode = document.getElementById('bprformoffercode').value;
		if(locode.indexOf(ppcoffer) < 0) {
			document.getElementById('bprformoffercode').value = ppcoffer + locode;
		}
	}
}