// gascript 1.1.0

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) {
	if (x) {
		x = unescape(x);
		return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	} else {
		return x;
	}
}

function readSubCookie(name) {      
      var nameRegex = RegExp("(?:\\||\\.|^|; )" + name + "=([^|;]+)"),
            nameValue;
      nameValue = nameRegex.exec(noPercent(document.cookie));
      if (nameValue) {
            return nameValue[1];
      } else {
            return null;
      }
}

function readQuery(name) { 
	var nameRegex = RegExp("(?:\\?|&)" + name + "=([^&]+)");
	nameValue = nameRegex.exec(noPercent(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;
	} else {
		return "|(not set)";
	}
}

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 = ["ga_source", "ga_campaign", "ga_adgroup", "ga_keyword", "ga_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", noPercent(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, firstTracker;
var ua = "1";

roiregexp = new RegExp(/roirevolutiontraining\.com/);
otmregexp = new RegExp(/ontimemall\.com/);
hwpregexp = new RegExp(/honeywellparts\.com/);
npregexp = new RegExp(/nortec\-part\.com/);
aapregexp = new RegExp(/aprilaireparts\.com/);
cpregexp = new RegExp(/carelparts\.com/);
tpregexp = new RegExp(/trionparts\.com/);
afregexp = new RegExp(/autofloparts\.com/);
shregexp = new RegExp(/skuttlehumidifierparts\.com/);
cpsregexp = new RegExp(/chartpaperstore\.com/);
electroregexp = new RegExp(/electroairparts\.com/);
genregexp = new RegExp(/generalaireparts\.com/);
dristeamRE = new RegExp(/dristeemparts\.com/);
dynamicRE = new RegExp(/dynamicfilterstore\.com/);
HerrRE = new RegExp(/herrmidifierparts\.com/);
nepRE = new RegExp(/neptronichumidifierparts\.com/);
vapacRE = new RegExp(/vapacparts\.com/);
waltonRE = new RegExp(/waltonhumidifierparts\.com/);
whiteRE = new RegExp(/whiterodgersparts\.com/);


function ecom(){
  
	pageTracker._addTrans(ss_ordernum, "", ss_subtotal, ss_taxtotal, ss_shiptotal, ss_city, ss_state, ss_country);
	for(var i = 0; i < ss_name.length; i++){
		pageTracker._addItem(ss_ordernum, ss_sku[i], ss_name[i], "", ss_price[i], ss_quantity[i]);
	}

	pageTracker._trackTrans();

}

function runGA() {            
	if(typeof(_gat)=='object') {
		if (otmregexp.exec(x)){
			ua = "1";}
		if (hwpregexp.exec(x)){
			ua = "2";}
		if (npregexp.exec(x)){
			ua = "3";}
		if (aapregexp.exec(x)){
			ua = "4";}
		if (cpregexp.exec(x)){
			ua = "5";}
		if (tpregexp.exec(x)){
			ua = "6";}
		if (afregexp.exec(x)){
			ua = "10";}
		if (electroregexp.exec(x)){
			ua = "12";}		
		if (shregexp.exec(x)){
			ua = "13";}
		if (HerrRE.exec(x)){
			ua = "14";}	
		if (genregexp.exec(x)){
			ua = "15";}	
		if (cpsregexp.exec(x)){
			ua = "16";}		
		if (vapacRE.exec(x)){
			ua = "17";}	
		if (nepRE.exec(x)){
			ua = "18";}
		if (dynamicRE.exec(x)){
			ua = "19";}	
		if (waltonRE.exec(x)){
			ua = "21";}	
		if (whiteRE.exec(x)){
			ua = "22";}	
		if (dristeamRE.exec(x)){
			ua = "23";}
		try{
			pageTracker = _gat._getTracker('UA-1560931-' + ua);
			pageTracker._trackPageview();
			sleuth();
			// only for Thank You page!
			if(window.ss_screen && window.ss_screen == "Thank You"){
				setTimeout("ecom();",500);
			}
		}catch(err){}
	} else {
            setTimeout("runGA();",100);
	  }
}

runGA();
