//REFERENCE PAGE TAG
// CONSTANTS
var ct = "<img src=";
var cd = "//wiiportal.nintendo-europe.com"; //this should contain the domain of the
                                 // web site that will host the page tag
var cu = "/fileadmin/templates/images/all/zag.gif?Log=1";
                                 //this should contain the full path to
                                 // the zag.gif file (excluding domain) and
                                 // include the query string of log=1
var cc = "/fileadmin/templates/images/all/zag2.gif?Log=1";
                                //this should contain the full path to
                                // the zag2.gif file (excluding domain) and
                                // include the query string of log=1
var cf = "/fileadmin/templates/images/all/zag3.gif?Log=1";
                                //this should contain the full path to
                                // the zag3.gif file (excluding domain) and
                                // include the query string of log=1
var ce = ">";

var vs_c = {};
vs_c["sw"] = screen.width;
vs_c["sh"] = screen.height;
vs_c["cd"] = screen.colorDepth;
var co = "";

for ( vs_cKey in vs_c ) {
	co = co+"&"+vs_cKey+"="+escape1(vs_c[vs_cKey]);
}
document.write(ct,cd,cu,co,ce);

var vs_d = {};
vs_d["dt"] = document.title;
vs_d["dr"] = document.referrer;
vs_d["cb"] = new Date().getTime();
var vo = "";

if (typeof v != "undefined") {
	for ( vKey in v ) {
		vo = vo+"&"+vKey+"="+escape1(v[vKey]);
	}
}
for ( vs_dKey in vs_d ) {
	vo = vo+"&"+vs_dKey+"="+escape2(vs_d[vs_dKey]);
}
document.write(ct,cd,cu,vo,ce);
//END REFERENCE PAGE TAG



//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', startCapture);

function startCapture(){
 //TO CAPTURE LINK CLICKS
 if (typeof vlc != "undefined") {
   if (vlc == "1") {captureLink();}
 }
 //TO CAPTURE FORM FIELD NAMES
 if (typeof vfc != "undefined") {
   if (vfc == "1") {captureForm();}
 }
}

//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.onmousedown = captureLinkName;
      }
    }
  }
}

function captureLinkName() {
  var lc=new Image();
  this.parent = this.parentNode;
  lc.src=cd + cc + '&linkname=' + escape1(this.name) + "&cd=" + new Date().getTime();
}

//END LINK CAPTURE PAGE TAG
//BEGIN FORM CLICK CAPTURE PAGE TAG

function captureForm(){
  if (document.forms[0]) {
    if(document.forms){
      for(i=0; i<document.forms[0].elements.length; i++){
        var forms = document.forms[0].elements[i];
        forms.onfocus = captureFormName;
      }
    }
  }
}

function captureFormName() {
  var fc=new Image();
  fc.src= cd + cf + '&fieldname=' + escape1(this.name) + "&cd=" + new Date().getTime();
}

function escape1(s)
{ return escape(s).replace(/\+/g,"%20") }

function escape2(s)
{ return escape(s).replace(/\+/g, "%2B") }

//END FORM CLICK CAPTURE PAGE TAG

