﻿<!--

// This file is used to de-dupe multiple affiliates.
// It sets the cookie "source" to show which affiliate entered the site last.
// This can then be used on the 'thankyou' page to determine which affiliates code is output for tracking.

var searchString = window.location.search.substring(1); 
var Parameters = new Object(); 
var nameValuePairs = searchString.split(/&/); 
var nameValuePair; 
var name; 
var value; 


for (var i = 0; i < nameValuePairs.length; i++) 
{ 
	nameValuePair = nameValuePairs[i].split(/=/);

 	name = nameValuePair[0]; 
	value = nameValuePair[1];


 	name = name.toLowerCase();

//	 if (name == "adnetwork") - This line modified by Simon Bryant 25th July 2007
//   To cope with more than one Affiliate 
	 if (name=="source") // "source" must match URLParameters.TRACKING.SOURCE
	 { 
		if (typeof(value)!="undefined")
		{ 
			value = value.toLowerCase(); 
	
			pathname = location.pathname; 
			myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/'; 
			// set expiry date to 30 days from now. 
			var largeExpDate = new Date (); 
			largeExpDate.setTime(largeExpDate.getTime() + (30 * 24 * 3600 * 1000)); 

			//SetCookie(name,value,largeExpDate,myDomain); This line modified by Simon Bryant 25th July 2007
			//   To cope with more than one Affiliate 

			SetCookie("source",value,largeExpDate,myDomain)
			//alert(value);
		} 
	} 
} 

//////////////////functions//////////////////////////////////////////////// 

function SetCookie (name, value) { 
var argv = SetCookie.arguments; 
var argc = SetCookie.arguments.length; 
var expires = (argc > 2) ? argv[2] : null; 

var path = (argc > 3) ? argv[3] : null; 
var domain = (argc > 4) ? argv[4] : null; 
var secure = (argc > 5) ? argv[5] : false; 
document.cookie = name + "=" + escape (value) +


 ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) + 
((domain == null) ? "" : ("; domain=" + domain)) + 
((secure == true) ? "; secure" : ""); 


} 
//////////////////functions//////////////////////////////////////////////// 
//--> 
