// JavaScript Document

function PXSOL_createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function PXSOL_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;
}

function PXSOL_eraseCookie(name) {
	createCookie(name,"",-1);
}

function PXSOL_getArgs() { 
	var args = new Object(); 
	var query = location.search.substring(1); 
	var pairs = query.split("&"); 
	for(var i = 0; i < pairs.length; i++) { 
		var pos = pairs[i].indexOf('='); 
		if (pos == -1) continue; 
		var argname = pairs[i].substring(0,pos); 
		var value = pairs[i].substring(pos+1); 
		args[argname] = unescape(value); 
	} 
return args; 
} 

var PXSOL_CN = 'PXSOL'+document.domain;
PXSOL_CN = PXSOL_CN.replace(".", "");
PXSOL_CN = PXSOL_CN.replace(".", "");
PXSOL_CN = PXSOL_CN.replace(".", "");
var PXSOL_FU = '0';

var PXSOL_C = '0';
var PXSOL_T = '0';
var PXSOL_A = '0';
var PXSOL_REF = '0';

var PXSOL_RC = '0';
var PXSOL_RT = '0';
var PXSOL_RA = '0';
var PXSOL_RREF = '0';


if (!document.referrer) {
	PXSOL_REF = "Direct"
}
else {
	PXSOL_REF = document.referrer;
}

var rn = Math.floor(Math.random()*1000000000000000001);
var tiempo = new Date();
var tm = tiempo.getTime();
var PXSOL_UID = tm+'_'+rn;
var PXSOL_RUID = PXSOL_UID;


var PXSOL_args = PXSOL_getArgs(); 
if (PXSOL_args.c) PXSOL_C = parseInt(PXSOL_args.c);
if (PXSOL_args.t) PXSOL_T = parseInt(PXSOL_args.t);
if (PXSOL_args.a) PXSOL_A = parseInt(PXSOL_args.a);
if (PXSOL_args.ref) PXSOL_REF = parseInt(PXSOL_args.ref);
if (PXSOL_args.fu) PXSOL_FU = parseInt(PXSOL_args.fu);

var PXSOL_RC = PXSOL_readCookie(PXSOL_CN+'C')
var PXSOL_RT = PXSOL_readCookie(PXSOL_CN+'T')
var PXSOL_RA = PXSOL_readCookie(PXSOL_CN+'A')
var PXSOL_RREF = PXSOL_readCookie(PXSOL_CN+'REF')
var PXSOL_RUID = PXSOL_readCookie(PXSOL_CN+'UID')

if (PXSOL_RC == null) {
	PXSOL_RC = '0';
}
if (PXSOL_RT == null) {
	PXSOL_RT = '0';
}
if (PXSOL_RA == null) {
	PXSOL_RA = '0';
}
if (PXSOL_RREF == null) {
	PXSOL_RREF = '0';
}
if (PXSOL_RUID == null) {
	PXSOL_RUID = '0';
}

	
if (PXSOL_RC == '0') {
	if (PXSOL_C != '0') {
		PXSOL_createCookie(PXSOL_CN+'C',PXSOL_C,30);
		PXSOL_RC = PXSOL_C;
	}
}


if (PXSOL_RT == '0') {
	if (PXSOL_T != '0') {
		PXSOL_createCookie(PXSOL_CN+'T',PXSOL_T,30);
		PXSOL_RT = PXSOL_T;
	}
}

if (PXSOL_RA == '0') {
	if (PXSOL_A != '0') {
		PXSOL_createCookie(PXSOL_CN+'A',PXSOL_A,30);
		PXSOL_RA = PXSOL_A;
	}
}

if (PXSOL_RREF == '0') {
	if (PXSOL_REF != '0') {
		PXSOL_createCookie(PXSOL_CN+'REF',PXSOL_REF,30);
		PXSOL_RREF = PXSOL_REF;
	}
}


if (PXSOL_RUID == '0') {
	if (PXSOL_UID != '0') {
		PXSOL_createCookie(PXSOL_CN+'UID',PXSOL_UID,30);
		PXSOL_RUID = PXSOL_UID;
	}
}

if (PXSOL_FU == '1') {
	if (PXSOL_C != '0') {
		PXSOL_createCookie(PXSOL_CN+'C',PXSOL_C,30);
		PXSOL_RC = PXSOL_C;
	}
	if (PXSOL_T != '0') {
		PXSOL_createCookie(PXSOL_CN+'T',PXSOL_T,30);
		PXSOL_RT = PXSOL_T;
	}
	if (PXSOL_A != '0') {
		PXSOL_createCookie(PXSOL_CN+'A',PXSOL_A,30);
		PXSOL_RA = PXSOL_A;
	}
	if (PXSOL_REF != '0') {
		PXSOL_createCookie(PXSOL_CN+'REF',PXSOL_REF,30);
		PXSOL_RREF = PXSOL_REF;
	}	
	if (PXSOL_UID != '0') {
		PXSOL_createCookie(PXSOL_CN+'UID',PXSOL_UID,30);
		PXSOL_RUID = PXSOL_UID;
	}
}

function PxsolFollowUp(URLref) {
	//alert(URLref.indexOf('?'));
	if (URLref.indexOf('?') == -1) {
		//alert(URLref+"?c="+PXSOL_C+"&t="+PXSOL_T+"&a="+PXSOL_A);
		window.location = URLref+"?c="+PXSOL_RC+"&t="+PXSOL_RT+"&a="+PXSOL_RA+"&fu=1";
	} else {
		//alert(URLref+"&c="+PXSOL_C+"&t="+PXSOL_T+"&a="+PXSOL_A);
		window.location = URLref+"&c="+PXSOL_RC+"&t="+PXSOL_RT+"&a="+PXSOL_RA+"&fu=1";
	}
}

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"));
document.write(unescape("%3Cscript type='text/javascript'%3E"));
document.write(unescape("try {var PxsolTracker = _gat._getTracker('UA-11914495-1'); PxsolTracker._setDomainName('none'); PxsolTracker._setAllowLinker(true); PxsolTracker._setAllowHash(false); PxsolTracker._trackPageview(); } catch(err) {}"));
document.write(unescape("%3C/script%3E"));

document.write("<img src='http://bo.pxsol.com/api/tk2/visit.asp?c="+PXSOL_RC+"&t="+PXSOL_RT+"&a="+PXSOL_RA+"&ref="+escape(PXSOL_RREF)+"&uid="+PXSOL_RUID+"&dom="+escape(document.domain)+"' width='1' height='1' />");