function gup( name ){  
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
var regexS = "[\\?&]"+name+"=([^&#]*)";  
var regex = new RegExp( regexS );  
var results = regex.exec( window.location.href );  
if( results == null )    return "";  
else    return results[1];
}
var marketing_identifier = 'mpch=ads';
var redirect_identifier = 'pid';
var referringurl = document.referrer.toLowerCase();
var	landingpage = document.URL.toLowerCase();
var pixel = '';
var rnd = Math.floor(Math.random()*1000000000000000000);
// if landing page contains the redirect parameter we write the redirect id to the page
if(landingpage.indexOf(redirect_identifier) >= 0) {
	var redirect = gup('pid');
	pixel = "<img width='1' height='1' src='http://my.styleholidays.co.uk/cm/tr/" + redirect + "'/>"; 
	document.writeln(pixel);
}
else {
if(referringurl != '') {
	if(referringurl.indexOf('http://thomascookstyle.com') >= 0 || referringurl.indexOf('http://www.thomascookstyle.com') >= 0) {
	// if a style page exit script
	}
	else 	{// if there is a referring url and it is not a style page
				if(landingpage.indexOf(marketing_identifier) <= 0) {
				document.write('<iframe frameborder="0" width="1" height="1" src="http://reporting.blmquantum.co.uk/style/ns/index.php?ref=' + escape(referringurl) +'&page=' + escape(landingpage) + '&rnd=' + rnd + '"/></iframe>');
				}
				else {
				// if marketing traffic we ignore it
				}
		}
}	
else {// no referrer => direct load
pixel = "<img width='1' height='1' src='http://my.styleholidays.co.uk/cm/tr/11502-92267-29592-0?mpt=" + rnd + "'/>"; 
document.writeln(pixel); 
}
}