//if the user comes from HRM - use their pixel with visit_id in querystring.
var strPixCookie="pixTrack";


function fPixTrack(){
	var strVisitID=getURLValue("affrefer");	
	if(strVisitID){
		//create the Pix cookie
		//setNameVal(cookieName, keyName, keyValue)
		setNameVal(strPixCookie,"visit_id",strVisitID);		
	}	
}

function fPixTrackRevenue(){
	var strRevenueID=getURLValue("rid");
	if(strRevenueID){
		//create the Pix cookie
		//setNameVal(cookieName, keyName, keyValue)
		setNameVal(strPixCookie,"revenue_id",strRevenueID);
	}
}

function fFirePixel(){
	
	strLoc = new String(document.location)
	
	if(strLoc.indexOf("110")!=-1 || strLoc.indexOf("210")!=-1){
		//if the user is NEW (order or non order) track them	
		//if(GetCookie(strPixCookie)){
		var pixCookie = getNameVal(strPixCookie,"visit_id");
		var pixRevCookie = getNameVal(strPixCookie,"revenue_id");
		
		var pixTrack = document.getElementById("pixTrack");

		if((pixCookie)&&(pixRevCookie)){			
			pixTrack.src = "https://tracking.optinstyle.com/?ID=2&UID="+getNameVal(strPixCookie,"visit_id")+"&OID="+getNameVal(strPixCookie,"revenue_id");
			pixTrack.style.display="block";
		}				
		
		if((pixCookie)&&(!pixRevCookie)){
			pixTrack.src = "http://www.aqclick.com/leads/tracking.php?sid="+getNameVal(strPixCookie,"visit_id");			
			pixTrack.style.display="block";
		}		
	}
}

// parse a variable from the query string
function getURLValue(variable){
	queryString = document.location.search.substring(1);
	if (queryString == "") return "";
	pairs = queryString.split("&");
	for (i=0; i<pairs.length; i++){
		if (pairs[i].split("=")[0].toLowerCase() == variable.toLowerCase()) return unescape(pairs[i].split("=")[1]);
	}
	return "";
}