function extAffCookie()
{
	var cookie_date = new Date ( );  // current date & time
	expires =  1000 * 60 * 60 * 24 *14 ; //expire by 14 days
	cookie_date.setTime ( cookie_date.getTime() + expires );
  
  //get the host name and split it to find the domain
	this.host = $.url.attr("host");
	this.domain = this.host.split("ladbrokes")[1];
	this.ladbrokesDomain = '.ladbrokes'+this.domain;
		
	this.extValue = '';
	this.affID = $.url.param("AFF_ID")  ? $.url.param("AFF_ID"): '';
	this.assetID = $.url.param("ASSET_ID") ? $.url.param("ASSET_ID") : '';
	this.sc = $.url.param("SC") ? $.url.param("SC") : '';

	if( this.affID != '' && this.assetID != '')
	{
		this.extValue =  'AFF_TIMESTAMP|'+Math.round(new Date().getTime() / 1000)+'|AFF_ASSET_ID|'+ this.assetID;
	}
	else if(this.affID != '' && this.assetID == '')
	{
		this.extValue =  'AFF_TIMESTAMP|'+Math.round(new Date().getTime() / 1000);
	}

	if(this.affID != ''){
		document.cookie = 'AFF_ID_persist='+ this.affID +';expires='+cookie_date.toGMTString()+ ';domain='+this.ladbrokesDomain+';path=/';
		document.cookie = 'AFF_ID='+ this.affID+ ';domain='+this.ladbrokesDomain+';path=/';
	}

	if(this.extValue != ''){
	document.cookie = 'EXT_AFF_persist='+ this.extValue +';expires='+cookie_date.toGMTString()+ ';domain='+this.ladbrokesDomain+';path=/';
	document.cookie = 'EXT_AFF='+ this.extValue+ ';domain='+this.ladbrokesDomain+';path=/';
	}
	
	if(this.sc != ''){
		document.cookie = 'SOURCE_CODE='+ this.sc+ ';domain='+this.ladbrokesDomain+';path=/';
		document.cookie = 'SC='+ this.sc+ ';domain='+this.ladbrokesDomain+';path=/';
	}

}

