var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

var pageTracker;

function readCookie(name) {		// function to read cookie
	var nameRegex = new RegExp("(?:;\\s|^)" + name + "=([^;]+)"), nameValue;
	nameValue = nameRegex.exec(document.cookie);				
	return nameValue && nameValue[1];
}

function noPercent(x) {
	x = unescape(x);
	return x.replace(/\+/g, " ").replace(/(^ +| +$)/g, "");
}

function sleuth() {
	var cpcValue = "cpc - ", userdef, cpcregexp, ref, re, searchq;
	if (location.search.indexOf("gclid") !== -1 || location.search.indexOf("cpc") !== -1) {	
		userdef = readCookie("__utmv");
		cpcregexp = new RegExp(/^cpc - /);
		if (!userdef || !cpcregexp.exec(userdef)) {
			ref = document.referrer;
			re = new RegExp(/(?:\?|&)(?:q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|search_for|string|search_query|searchfor)=([^&]+)/);
			searchq = re.exec(ref);
			if (searchq) { 
				cpcValue += noPercent(searchq[1]);
			} else {
				cpcValue += "Paid Referral: "; 
				cpcValue += ref;
			}
			pageTracker._setVar(cpcValue);
		}
	}
}

window.onload = function() { 
	domainLinking(/attraction\.infusionsoft\.com/i);
}

function domainLinking(linkRegex) {
	var domainLinks = document.getElementsByTagName("a");
	if (typeof(pageTracker) === "object") {
		if(domainLinks) {
			for(i=0;i<domainLinks.length;i++) {
				if(domainLinks[i].href.match(linkRegex)) {
					domainLinks[i].onclick = function() {
						this.href = pageTracker._getLinkerUrl(this.href);
					}
				}
			}		
		}
	} else {
		 setTimeout(function () { 
		    domainLinking(); 
		}, 100);
    }
}

function runGA() {            
	if (typeof(_gat) === "object") {
	    try {
		    pageTracker = _gat._getTracker("UA-2227545-1");
			pageTracker._setAllowHash(false);
			pageTracker._setAllowLinker(true);
			pageTracker._trackPageview();
			sleuth();
		} catch (err) {}
	} else {
        setTimeout(function () { 
		    runGA(); 
		}, 100);
    }
}

runGA();
