$(document).ready(function() {

	//Get hubspotutk cookie from browser with function below
	var hsutk = readCookie('hubspotutk');
	//alert(hsutk);
	
	//Place hubspotutk at end of each link that starts with 'esd.element5.com'
	$("a[href^='http://adrianmott.com']").each(function() {
   		var href = $(this).attr("href"); 
   		//alert(href)
   		$(this).attr("href", href+"&UserToken="+hsutk+"&HS_Domain="+hs_ppa);
	});

	//Function to read the value of the cookie - 3rd party code here...
    function readCookie(name) {
        var nameEQ = name + "=";
        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 null;
    }

});

