function CheckValue(remote, name) {
	vscollect += '&' + name + '=' + remote;
}

// create variables for the open and close of the image tag writeback
vsimgtagopen = '<script language="javascript" src="//web1.terrylund.com/tlscripts/zag.js?Log=1';
vsimgtagclose = '"></script>';

// setup variable and elements of the VS data collection
vscollect = '&DR=' + (document.referrer);

// get browser parameters and capture the values
var vswidth = screen.availWidth;
var vsheight = screen.availHeight;
var vsresolution = vswidth + "x" + vsheight;
var vstitle = document.title;

vscollect += '&screenwidth=' + vswidth;
vscollect += '&screenheight=' + vsheight;
vscollect += '&screenres=' + vsresolution;
vscollect += '&title=' + vstitle;

//
// Use this section to insert custom variables into the query string.
// Append name and value pair using the following method:
//

if (typeof vs_product != "undefined") {
	CheckValue(vs_product, "vs_product");
}

if (typeof vs_units != "undefined") {
	CheckValue(vs_units, "vs_units");
}

if (typeof vs_price != "undefined") {
	CheckValue(vs_price, "vs_price");
}

if (typeof vs_ship_type != "undefined") {
	CheckValue(vs_ship_type, "vs_ship_type");
}
if (typeof vs_xml_id != "undefined") {
        CheckValue(vs_xml_id, "vs_xml_id");
} 

//2006-01-10 - TL - change reqeusted by EP
if (typeof vs_internal_search != "undefined") {
        CheckValue(vs_internal_search, "vs_internal_search");
}



// End custom variable section


// include a query string parameter to cause cache busting
vscollect += '&cachedefeat=' + (new Date()).getTime();

// build the final image tag
vsfinaltag = vsimgtagopen + vscollect + vsimgtagclose;

// write the image tag back to the browser
document.write(vsfinaltag);


//REFERENCE LINK AND FORM CLICK PAGE TAG
//INITIATE FUNCTIONS ONLOAD
function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}

addEvent(window, 'load', captureLink);
function startCapture(){
//TO CAPTURE LINK CLICKS
 if (vlc == "1"){captureLink();}
}
//BEGIN LINK CAPTURE PAGE TAG
function captureLink(){
  if (document.links[0]){
    if (document.links){
      var links = document.links, link, k=0;
      while(link=links[k++]) {
        link.onclick = captureLinkName;
	}
    }
  }
}
function captureLinkName() {
  var lc=new Image();
  this.parent = this.parentNode;
  var theText = this.text ? this.text : this.innerText; 
  lc.src='//web1.terrylund.com/tlscripts/zag2.gif?Log=1&linkname=' + escape(this.href) + '&linkdesc=' + escape(theText) + '&cd=' + new Date().getTime();
}
//END LINK CAPTURE PAGE TAG
