// START Script for profiler tracking link recording 2009 esterling base

// first party cookie to record clicks and show previous views

function profilerLink() 
	{ document.cookie = "profilerCookie=true;path=/"; }

function profilerRepeat(session) {
	var date = new Date();
	date.setTime(date.getTime()+(60*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "profilerRepeat=" + session + expires + ";path=/";
}

function readCookie() { 
	var nameEQ = "profilerCookie="; 
	var ca = document.cookie.split(';'); 
		for(var i=0;i < ca.length;i++) 
			{ var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); 
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } 
	return "END"; }


// tracking code to get meta data

function getmetaContents(mn) {
	var m = document.getElementsByTagName('meta');   
	for(var i in m){    if(m[i].name == mn){      return m[i].content;  
  }   } }

var profSearchRef = "&PROFPROD=0";

// check for product page
if (document.body.innerHTML.match('id="whole"') || document.body.innerHTML.match('id=whole')) {

	profSearchRef = "&PROFPROD=1";
	
	// get product name
	var profprodname = document.getElementById('productname').innerHTML;
	profSearchRef = profSearchRef + "&prodname=" + profprodname;
	
	
	// get image
	var profprodimage = document.getElementById('productimage').src;
	profSearchRef = profSearchRef + "&prodimage=" + profprodimage;
	
	// get product price
	var profprodcode = document.getElementById('productprice').innerHTML;
	profSearchRef = profSearchRef + "&prodprice=" + profprodcode;

}

var profilerCookieValue = "FALSE";
profilerCookieValue = readCookie();
document.cookie = "profilerCookie=false;path=/";
// test to check if cookies are enabled
if (readCookie() == "END") profilerCookieValue = "noCookiesEnabled";
var profTitle = document.title.replace("'", "");

// clean url
var urlprof = document.location.href;
var urlprofarray = urlprof.split("#");
urlprof = urlprofarray[0];

// send data to server

if (!document.location.href.match("https:")) {
document.write("<s" + "cript language='javascript' src='http://www.profilertracking.com/esterling/recordClicks_inside.asp?HREF=" + urlprof + "&TITLE=" + profTitle + "&PLINK=" + profilerCookieValue + profSearchRef + "&REF=" + document.referrer + "'></sc" + "ript>"); 
} else {
document.write("<s" + "cript language='javascript' src='https://www.profilertracking.com/esterling/recordClicks_inside.asp?HREF=" + urlprof + "&TITLE=" + profTitle + "&PLINK=" + profilerCookieValue + profSearchRef + "&REF=" + document.referrer + "'></sc" + "ript>"); 
}

// END Script for profiler tracking link recording