function CheckValue(remote, name) {
	vscollect += '&' + name + '=' + remote;
}

// create variables for the open and close of the image tag writeback
vsfailimg = '//g-ec2.images-amazon.com/images/G/16/nav/spacer._V42753720_.gif';
vstimeout = "4000";
vssensor = '//vs.target.com/mktag.gif?Log=1';
vsimgtagopen = '<img src="'+vssensor;
vsimgtagclose = '">';

// setup variable and elements of the VS data collection
vscollect = '&REFERRER=' + (document.referrer);

// get browser parameters and capture the values
var vswidth = screen.availWidth;
var vsheight = screen.availHeight;
var vsresolution = vswidth + "x" + vsheight;
var vstitle = escape(document.title);

vscollect += '&screenwidth=' + vswidth;
vscollect += '&screenheight=' + vsheight;
vscollect += '&screenres=' + vsresolution;
vscollect += '&title=' + vstitle;
vscollect += '&dlocation=' + escape2(document.location);

var asin_array = new Array();
var quantity_array = new Array();
var price_array = new Array();

//
// Use this section to insert custom variables into the query string.
// Append name and value pair using the following method:
//

if (typeof waError != "undefined") {
	CheckValue(waError, "waError");
}

if (typeof waShippingOptions != "undefined") {
	CheckValue(waShippingOptions, "waShippingOptions");
}

//if (typeof waItemDescription != "undefined") {
//	CheckValue(waItemDescription, "waItemDescription");
//}

if (typeof waItemQuantity != "undefined") {
	CheckValue(waItemQuantity, "waItemQuantity");
	var quantity_array = waItemQuantity.split("^");
}

if (typeof waItemsPrice != "undefined") {
	CheckValue(waItemsPrice, "waItemsPrice");
}

// Note - this is not the same as the entry above.
if (typeof waItemPrice != "undefined") {
	CheckValue(waItemPrice, "waItemPrice");
	var price_array = waItemPrice.split("^");
}

if (typeof waShippingHandling != "undefined") {
	CheckValue(waShippingHandling, "waShippingHandling");
}

if (typeof waPromo != "undefined") {
	CheckValue(waPromo, "waPromo");
}

if (typeof waTotalBeforeTax != "undefined") {
	CheckValue(waTotalBeforeTax, "waTotalBeforeTax");
}

if (typeof waEstimatedTax != "undefined") {
	CheckValue(waEstimatedTax, "waEstimatedTax");
}

if (typeof waItemAvailability != "undefined") {
	CheckValue(waItemAvailability, "waItemAvailability");
}

if (typeof waItemImageNA != "undefined") {
	CheckValue(waItemImageNA, "waItemImageNA");
}

if (typeof waItemRating != "undefined") {
	CheckValue(waItemRating, "waItemRating");
}

if (typeof waOrderTotal != "undefined") {
	CheckValue(waOrderTotal, "waOrderTotal");
}

if (typeof waOrderId != "undefined") {
	CheckValue(waOrderId, "waOrderId");
}

if (typeof waItemGiftWrap != "undefined") {
	CheckValue(waItemGiftWrap, "waItemGiftWrap");
}

if (typeof waBillingAddressZip != "undefined") {
	CheckValue(waBillingAddressZip, "waBillingAddressZip");
}

if (typeof waShippingAddressZip != "undefined") {
	CheckValue(waShippingAddressZip, "waShippingAddressZip");
}

if (typeof VSCONTENTTITLE != "undefined") {
	CheckValue(VSCONTENTTITLE, "VSCONTENTTITLE");
}

if (typeof waItemAsin != "undefined") {
	CheckValue(waItemAsin, "waItemAsin");
	var asin_array = waItemAsin.split("^");
}

if (typeof waPage != "undefined") {
	CheckValue(waPage, "waPage");
}

if (typeof waPromsg != "undefined") {
	CheckValue(waPromsg, "waPromsg");
}

if (typeof waProductDesc != "undefined") {
	CheckValue(waProductDesc, "waProductDesc");
}

if (typeof waBuybox != "undefined") {
	CheckValue(waBuybox, "waBuybox");
}

if (typeof waItemcoll != "undefined") {
	CheckValue(waItemcoll, "waItemcoll");
}

if (typeof waCheckout != "undefined") {
	CheckValue(waCheckout, "waCheckout");
}

if (typeof wabetter != "undefined") {
	CheckValue(wabetter, "wabetter");
}

if (typeof wabuysave != "undefined") {
	CheckValue(wabuysave, "wabuysave");
}

if (typeof warelitem != "undefined") {
	CheckValue(warelitem, "warelitem");
}

if (typeof waSearch != "undefined") {
	CheckValue(waSearch, "waSearch");
}

if (typeof waNavTest != "undefined") {
	CheckValue(waNavTest, "waNavTest");
}

if (typeof waChannel != "undefined") {
	CheckValue(waChannel, "waChannel");
}

if (typeof waResult != "undefined") {
	CheckValue(waResult, "waResult");
}

if (typeof waResultT != "undefined") {
	CheckValue(waResultT, "waResultT");
}

if (typeof waResultA != "undefined") {
	CheckValue(waResultA, "waResultA");
}

if (typeof waCustID != "undefined") {
	CheckValue(waCustID, "waCustID");
}

if (typeof waABN != "undefined") {
	CheckValue(waABN, "waABN");
}

if (typeof waWeblab != "undefined") {
	CheckValue(waWeblab, "waWeblab");
}


if (typeof waABtest != "undefined") {
	CheckValue(waABtest, "waABtest");
}

if (typeof watctag != "undefined") {
	CheckValue(watctag, "watctag");
}

// End custom variable section

// build the final image tag
var vsimg=new Image();
vsimg.src=vssensor+vscollect+'&cachedefeat='+(new Date()).getTime();
setTimeout("if(!vsimg.complete)vsimg.src=vsfailimg;",vstimeout);

var vsImgArr=new Array();
if ( asin_array.length == quantity_array.length && quantity_array.length  == price_array.length ) {
	for (i=0; i<asin_array.length; i++) {
		vsImgArr[i] = new Image();
		vsImgArr[i].src=vssensor+"&vsAsin="+escape(asin_array[i])+"&vsAsinQuantity="+escape(quantity_array[i])+"&vsAsinPrice="+escape(price_array[i]);
		setTimeout("if(!vsImgArr["+i+"].complete)vsImgArr["+i+"].src=vsfailimg;",vstimeout);
		//document.write(vsimgtagopen,"&vsAsin=",asin_array[i],"&vsAsinQuantity=",quantity_array[i],"&vsAsinPrice=",price_array[i],vsimgtagclose);
	}
}

//HTML ESCAPE FUNCTIONS
function escape1(s)
{ return escape(s).replace(/\+/g,"%20") }

function escape2(s)
{ return escape(s).replace(/\+/g, "%2B") }