var v = {};

if(window.vscount != null)
{
    window.vscount = window.vscount + 1;
    v["logCount"] = window.vscount;
}
else
{
    window.vscount = 1;
}

var ct = "<img src=";
var cd = "http://www.npr.org";

if (document.location.href.indexOf("shop.npr.org") > -1) {
	cd = "//v2.npr.org";
}
else if ((document.location.href.indexOf("stage-lb.npr.org") > -1) ||
				(document.location.href.indexOf("stage.seamus-dev.npr.org") > -1)) {
	cd = "http://stage.seamus-dev.npr.org";
}
else if (document.location.href.indexOf("https:") > -1) {
	cd = "https://v.npr.org";
}
var cu = "/images/zag.gif?Log=1";
var ce = ">";

var c = {};
c["sw"] = screen.width;
c["sh"] = screen.height;
c["cd"] = screen.colorDepth;
var co = "";

for ( cKey in c ) {
    co = co+"&"+cKey+"="+escape(c[cKey]);
}
document.write(ct,cd,cu,co,ce);

var d = {};
d["dr"] = document.referrer;
d["cb"] = new Date().getTime();
var vo = "";
var vobase = "";

if (typeof v != "undefined") {
    for ( vKey in v ) {
        vo = vo+"&"+vKey+"="+v[vKey];
    }
}
if(window.vstag != null)
{
    for (vKey in window.vstag) {
        if(vKey != 'title' && vKey != 'dt') {
        vo = vo+"&"+vKey+"="+window.vstag[vKey];
        }
    }
}
if(window.vstag && window.vstag.title)
{
    vo = vo+"&dt="+window.vstag.title;
}
else
{
    vo = vo+"&dt="+escape(document.title);
}

vobase = vo;

for ( dKey in d ) {
    vo = vo+"&"+dKey+"="+escape(d[dKey]);
}
document.write(ct,cd,cu,vo,ce);

function vsPageEvent(vsEventName) {
		var d = {};
		d["dr"] = document.location.href;
		d["cb"] = new Date().getTime();
		
		var vo2 = "";
		vo2 += vobase;
		for ( dKey in d ) {
			vo2 = vo2+"&"+dKey+"="+escape(d[dKey]);
		}
		
		vo2 += "&event=" + vsEventName;
		
		var fc = new Image();
		fc.src = cd + cu + vo2;
}
