//REFERENCE PAGE TAG
// CONSTANTS
//var ct = "<img src=";
var cd = "http://analytics.sanoma.fi"; //this should contain the domain of the web site
var cu = "/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 ce = ">";

var c = {};
c["sw"] = screen.width;
c["sh"] = screen.height;
c["cd"] = screen.colorDepth;
var co = "";

for ( cKey in c ) {
	co = co+"&"+cKey+"="+escape1(c[cKey]);
}

//document.write(ct,cd,cu,co,ce); // Send constant tag
/*zig_Img = document.createElement('img');
zig_Img.setAttribute('width', '1');
zig_Img.setAttribute('height', '1');
zig_Img.setAttribute('src', cd + cu + co);*/

zig_Div = document.createElement('div');
//zig_Div.appendChild(zig_Img);

document.body.appendChild(zig_Div);


var d = {};
d["dt"] = document.title;
d["dr"] = document.referrer;
d["cb"] = new Date().getTime();
var vo = "";

if (typeof v != "undefined") {
	for ( vKey in v ) {
		vo = vo+"&"+vKey+"="+escape1(v[vKey]);
	}
}
for ( dKey in d ) {
	vo = vo+"&"+dKey+"="+escape2(d[dKey]);
}
//document.write(ct,cd,cu,vo,ce); // Send page level tag

zig_Img2 = document.createElement('img');
zig_Img2.setAttribute('width', '1');
zig_Img2.setAttribute('height', '1');
zig_Img2.setAttribute('src', cd + cu + co + vo);

zig_Div.appendChild(zig_Img2);

//END REFERENCE PAGE TAG


//REFERENCE LINK AND FORM CLICK PAGE TAG
//INITIATE FUNCTIONS ONLOAD
//window.onload = startCapture; 
startCapture();

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;
	lc.src='http://analytics.sanoma.fi/zag2.gif?linkname=' + 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 LINK CAPTURE PAGE TAG
