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 x = location.hostname;

function noPercent(x)
{
	x = unescape(x);
	return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function readSubCookie(name) {      
      var nameRegex = RegExp("(?:\\||\\.|^|; )" + name + "=([^|;]+)"),
            nameValue;
      nameValue = nameRegex.exec(document.cookie);
      if (nameValue) {
            return nameValue[1];
      } else {
            return null;
      }
}

function readQuery(name) { 
	var nameRegex = RegExp("(?:\\?|&)" + name + "=([^&]+)");
	nameValue = nameRegex.exec(location.search);
	if(nameValue) {
		return nameValue[1];
	} else {
		return null;
	}
}

function exactQuery() {
	var re = new RegExp(/(?:\?|&)(?:q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|search_for|string|search_query|searchfor)=([^&]+)/);
	var searchq = re.exec(document.referrer);
	if (searchq) {
		searchq = "|" + noPercent(searchq[1]);
		return searchq;
	}
}
function sleuth() {
	if(readQuery("gclid")||readQuery("utm_medium")=="cpc") {
		if (!pageTracker._getVisitorCustomVar(1)) {
			pageTracker._setCustomVar(1, "exact_keyword", exactQuery() , 1);
		}
	}
}

function modifyForm(name) {
	if (name) {
		var fieldNames = ["Contact0_sourcemedium", "Contact0_campaign", "Contact0_adgroup", "Contact0_keyword", "Contact0_landingpage"];
		if (document.forms[name]) {
			for (i = 0; i < fieldNames.length; i+= 1) {
				var gaField = document.createElement("input");
				gaField.setAttribute("name", fieldNames[i]);
				gaField.setAttribute("value", pageTracker._getVisitorCustomVar(i + 1));
				gaField.setAttribute("type", "hidden");
				document.forms[name].appendChild(gaField);
			}
		}
	} 
}

function isFirstVisit() {
    var acookie = readCookie('__utma').split('.');
    var bcookie = readCookie('__utmb').split('.');
    if (acookie[5] == 1 && bcookie[1] < 1) {
        return true;
    }
    else {
        return false;
    }
}

var pageTracker;

/*
Adds referral data to a separate cookie namespace and Google Analytics profile.

!!!DO NOT USE WITH SLEUTH!!!

*/

function runGA() {
	var re, re2, reAll, utmz, utmz2, utmAll, exdate, initial, 
		myDomain = "auto",	// if you're using subdomains, change this
		N = function (i) { 
            if (!i || i=="" || i=="none") { 
				i=""; 
				return i; 
			}
		 	if (i=="auto") {
  				var d = document.domain;
	  			if (d.substring(0,4) === "www.") {
   					d = d.substring(4,d.length);
			  	}
		  		i = d;
			}
			i = i.toLowerCase(); 
			return i;
		},
		cookieNames = {	
			"utma": 63072E6, 
			"utmb": 18E5, 
			"utmz": 15768E6
		},
		cookieDomain, i,
		noUpdateZ = false;		

	myDomain = N(myDomain);
	cookieDomain = myDomain ? "domain=" + N(myDomain) + ";" : "";
	initial = /\^first/.test(document.cookie) && /(?:^|;\s)__utmz=/.test(document.cookie);
	
	if (typeof(_gat) === "object") {
		try {
			pageTracker = _gat._getTracker('UA-2450975-1');
			if (myDomain) {
				pageTracker._setDomainName(myDomain);
			}
			pageTracker._initData();
			if (!pageTracker._getVisitorCustomVar(1)) {
				pageTracker._setCustomVar(1, "s/m", (readQuery("gclid") ? "google/cpc" : readSubCookie("utmcsr") + "/" + readSubCookie("utmcmd")) || "(not set)", 1);
				pageTracker._setCustomVar(2, "c", readQuery("ga_campaign") || readSubCookie("utmccn") || "(not set)", 1);
				pageTracker._setCustomVar(3, "ag", readQuery("ga_adgroup") || readSubCookie("utmcct") || "(not set)", 1);
				if (readQuery("ga_keyword")) {
					pageTracker._setCustomVar(4, "kw", readQuery("ga_keyword") + exactQuery(), 1);
				}
				else if (readSubCookie("utmctr")) {
					pageTracker._setCustomVar(4, "kw", readSubCookie("utmctr") + exactQuery(), 1);
				}
				else {
					pageTracker._setCustomVar(4, "kw", "(not set)", 1);
				}
				pageTracker._setCustomVar(5, "lp", location.pathname || "(not set)", 1);
			}
			pageTracker._trackPageview();
			modifyForm("quoteform");
	
			firstTracker = _gat._getTracker("UA-2450975-3"); // add secondary profile ID
			if (myDomain) {
				firstTracker._setDomainName(myDomain);
			}
			firstTracker._setNamespace("first");
			if (/\^first\.[^^;]*(utmgclid=|utmcmd=(cpc|ppc))/.test(document.cookie)) {
				firstTracker._setReferrerOverride(); 
				firstTracker._setCampNameKey(); 
				firstTracker._setCampMediumKey(); 
				firstTracker._setCampSourceKey(); 
				firstTracker._setCampTermKey(); 
				firstTracker._setCampContentKey(); 
				firstTracker._setCampCIdKey();
				noUpdateZ = true;
			}
			
			firstTracker._initData();

			if (!firstTracker._getVisitorCustomVar(1)) {
				firstTracker._setCustomVar(1, "first_visit_is_cpc", pageTracker._getVisitorCustomVar(1).indexOf("%2Fcpc") === -1 ? "No" : "Yes", 1);
			}
			
			re = new RegExp(/(?:^|;\s)__utmz=[^;]*\.([^;.]*);/);
			re2 = new RegExp(/(?:^|;\s)2__utmz=([^;]*)\^first\.([^^;]*)\.[^^;.]*([^;]*)/);
			utmz = re.exec(document.cookie);
			utmz2 = re2.exec(document.cookie);
						
			if (!initial && utmz && utmz2 && /utmgclid=|utmcmd=(cpc|ppc)/.test(utmz[1])) {
				exdate = new Date();
				exdate.setTime(exdate.getTime() + 15768000000);
				document.cookie = "2__utmz=" + utmz2[1] + "^first." + utmz2[2] + "." + utmz[1] + utmz2[3] + ";expires=" + exdate.toGMTString() + ";path=/;" + cookieDomain;
			}
			
			firstTracker._trackPageview();
		
			for (i in cookieNames) {
				if (i !== "utmz" || noUpdateZ === false) {
					reAll = new RegExp("(?:^|;\\s)2__" + i + "(=[^;]*)");
					utmAll = reAll.exec(document.cookie);
					exdate = new Date();
					exdate.setTime(exdate.getTime() + cookieNames[i]);
					document.cookie = "2__" + i + utmAll[1] + ";expires=" + exdate.toGMTString() + ";path=/;" + cookieDomain;
				}
			}
		} catch(err) {}
	} else {
		setTimeout("runGA();",100);
      }
}

runGA();