<!--
// WEBABACUS CLIENT INFO VERSION 2.05, (c)2007 Foviance Ltd ALL RIGHTS RESERVED. 
// Version to be used as a JS include
// See accompanying clientinfo-include-notes.txt for change history, or contact helpdesk@foviance.com

// User variables: Change these values to set global settings
var server = "http://tagging.qas.com";   			// Set to another server (e.g. http://192.168.1.250) to send tag request to that server (not local)
var secureserver = "https://tagging.qas.com"; 	// Enter the address of the server to which secure tag requests should be sent (include https:// part)
var site = webabacusSite;															//  - (Recommended) Enter the name of this site
var cookieLife = 730;  										// No. of days that the cookie is valid for (default is 730 - two years)
var cookieDomain = webabacusCookieDomain; 										//  - (Optional) Domain for the cookie (must start with and include at least two full stops - e.g. .webabacus.com or .webabacus.co.uk)	
var perfinfo = 1; 												// Flag to indicate whether this script will be used to gather full performance data - set to 1 if it will be
var sourceparamname = ""; 								//  - (Optional) Name of the parameter in the query string which indicates a source value
var checkPluggins = false;								// Boolean to determine installed plugins, with the results written into the custom fields. Note that Internet Explorer requires an ActiveX object to be created with requires end user confirmation.
// End of user variables

// set timer
var fromt = new Date();
var elapsedt = fromt.getTime();
var pet = "";
var SRT = "0";
var OET = "0";
var UET = "0";

var civersion="2.05";
var js = "-";
var sc = 0;
var sw = 0;
var sh = 0;
var ww = 0;
var wh = 0;
var je = "-";
var lg = "-";
var dn = "-";
var bt="";
var st="-";
var tz=0;
var vl="-";
var t=0;
var sr="-";
var res="-";
var ref="-";
var res2="-";
var pt="-";
var fs=0;
var is=0;
var id="-";
var idparm="";
var nu="-";
var wr="-";
var base="";
var reqsrc="";
var now="";
var tt=0;
keys = new Array();
values = new Array();
var source = "";
var src = "-";
var clifems = cookieLife * 86400000;
ccrt = new Date(fromt.getTime());
cexp = new Date(fromt.getTime() + clifems);
var srctime=0;
var customfields="";
var optout="";
var trioid="-";

var key1 = '';
var key2 = '';
var charArray = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');


var rn="";
for (i = 0; i < 4; i++){
		rn += charArray[Math.floor(Math.random() * charArray.length)];
	}
var tmp1=new Date();
var tmp2=tmp1.getTime();
var tmp3=Math.floor(tmp2/200000);
var tmp4=Math.floor(tmp3*200000);
var rn2 = rn + (Math.floor(tmp2-tmp4));

function logclientdata(n,r) {
	thispet = n;
		if(r)
		res2=r;
	// Calculate time differentials
	if (thispet=="01") {
	  now = new Date();
	  tt = now.getTime();
	  SRT = (tt - elapsedt);
	  trioid = rn2;
	  }
	else if (thispet=="02") {
	  now = new Date();
	  tt = now.getTime();
	  OET = (tt - elapsedt);
	  trioid = rn2;
	  }
	else if (thispet=="03") {
	  now = new Date();
	  tt = now.getTime();
	  UET = (tt - elapsedt);
	  trioid = rn2;
	  }
	else if (thispet=="0") {
		var tmp5=new Date();
		var tmp6=tmp5.getTime();
		var tmp7=Math.floor(tmp6/200000);
		var tmp8=Math.floor(tmp7*200000);
		var rn3 = rn + (Math.floor(tmp6-tmp8));
	  SRT = 0;
	  OET = 0;
	  UET = 0;
	  trioid = rn3;
	}
	else  {
	  SRT = 0;
	  OET = 0;
	  UET = 0;
	  trioid = rn2;
	  thispet = "-";
	  }
	
	if (navigator.appName == 'Netscape') bt = "NS";
	else {
	if (navigator.appName == 'Microsoft Internet Explorer') bt = "IE";
	else bt="OT";
	}
	
	je = navigator.javaEnabled() ? "Y" : "N";
	dn = document.domain;
	lg = bt=="NS" ? navigator.language : navigator.browserLanguage;
	sc = Math.pow(2, screen.colorDepth);
	sp = screen.pixelDepth;
	sw = screen.width;
	sh = screen.height;
	now = new Date();
	
	st = escape(site);
	if (st==null || st=="") st = "-";
	tz = now.getTimezoneOffset();
	vl = history.length;
	t = now.getTime();
	sr = sw + "x" + sh;
	
	res = escape(document.URL);
	ref = escape(document.referrer);
	if (ref==null || ref=="") ref = "-";
	pt = escape(document.title);
	if (pt==null || pt=="") pt = "-";
	
	if((navigator.appName == 'Netscape')&&(parseInt(navigator.appVersion)<5)){
		fs = "-";
	  is = "-";
	  wr = "-";
	  customfields = "-";
	}
	else {
		if (thispet != "01"){
	  	// Capture size of document and related graphics
	  	is = 0;
	  	try {
	  		fs = document.fileSize * 1;  
	  		var iMap = new Object();
	    	for (i = 0; i < document.images.length; i++) {
	      	  if (!iMap[document.images[i].src]) {
	        	    is += parseInt(document.images[i].fileSize);
	          	  iMap[document.images[i].src] = true;
	        	}
	    	}
	  	} catch (e) {fs = 0; is = 0;}
	  
	  	if (bt == 'IE') {
	    	 if (document.documentElement && document.documentElement.clientWidth) {
	      	  ww = document.documentElement.clientWidth;
	        	wh = document.documentElement.clientHeight;
	     	}
	     	else if (document.body){
	      	  ww = document.body.clientWidth;
	        	wh = document.body.clientHeight;
	     	}
	  	}
	  	else {
	    	try {
	      	ww = window.outerWidth; wh = window.outerHeight;
	    	} catch (e) {ww = 0; wh = 0;}
	  	}
	  	var wr = ww + "x" + wh;
	  
		}
		else {
	  	fs = "-";
	  	is = "-";
	  	wr = "-";
		}
	}
	
	// Capture the values of the custom fields
	if (typeof(wacustomvarnames) != "undefined") {
  	customfields = "";
  	for (i = 0; i < wacustomvarnames.length; i++) {
  	  customfields = customfields + escape(wacustomvarnames[i]) + "~" + escape(wacustomvarvalues[i]);
    	if (i != wacustomvarnames.length-1) customfields = customfields + "~";
  	}
	} else
  		customfields = "-"; 
  
	if(checkPluggins)
		{
		if(customfields == "-")
			customfields = ""
		customfields += "~je~"+detectJava()+"~ce~"+detectCookies()
		if(canDetectPlugins())
			{
			customfields +="~qt~"+detectQuickTime()+"~rp~"+detectReal()+"~wm~"+detectWindowsMedia()+"~ar~"+detectAcrobat()+"~sw~"+detectDirector()+"~fl~"+detectFlashVersion()
			}
		}
  	
	parseQS();
	
	
function gen_id(int2) {
	var key1="";
	var key2="";
	for (i = 0; i < int2; i++){
		key1 += charArray[Math.floor(Math.random() * charArray.length)];
	}
	for (i = 0; i < key1.length; i++){
		key2 += key1.charCodeAt(i).toString(16);
	}
	var curDate = new Date();
	var curMonth = curDate.getMonth()+1;
	var curYear = curDate.getYear();
	var curDay = curDate.getDate();
	
	//Create Date, Time, and GMT offset String
	if(curDay<10) curDay = "0" + curDay;
	if(curMonth<10) curMonth = "0" + curMonth;
	if(curYear<1000) curYear+=1900;
	     
	var CreationDate = curYear.toString() + curMonth.toString()+ curDay.toString();
	var curDateTime = new Date();
	var curHour = curDateTime.getHours() + curDateTime.getTimezoneOffset()/60;

	if (curHour > 24)  curHour -= 24;
	if (curHour < 0) curHour += 24;

	var curMin = curDateTime.getMinutes();
	var curSec = curDateTime.getSeconds();
	var curTime = ((curHour < 10) ? "0" : "") + curHour + ((curMin < 10) ? "0" : "") + curMin + ((curSec < 10) ? "0" : "") + curSec;
	var CreationTime = curTime + "-GMT" + (curDateTime.getTimezoneOffset()/60);

	var CreatedAt = "d" + CreationDate + "_t" + CreationTime;

	//Create WebAbacus ID (ID) from two random strings, and the date/time/offset string             
	var id = key1 + key2 + "-1";
	//Reinstate once Siebel has been updated - Tim Chalk - 24/07/07
	//var id = key1 + key2 + "-1-" + CreatedAt;
	return(id);
}
	
	// Check for and issue cookie - will use the value of a "webabacus_id" parameter by preference
	optout = getCookie("nocookie");
	
	if (optout != "1") {
	  idparm = getQSParam("webabacus_id");
	  if (idparm == null || idparm == "") {
	    id = getCookie("webabacus_id");
	  } else {
	    id = idparm;
	  }
	  if (id == null || id == "-1") {
	    //id = now.getTime()+"-1";
	    id = gen_id(5);
	    nu="1" // New user (they've not been issued a cookie before)
	  } else {
	    nu="0"
	  }
	  document.cookie = "webabacus_id="+escape(id)+"; expires=" + cexp.toUTCString() + "; path=/" + (cookieDomain == "" ? "" : "; domain=" + cookieDomain);
	  // Check that cookie has been set. If not set the webabacus id value to null.
	   if(document.cookie.indexOf(escape(id))<0){
	  	var id = null;
	  	var nu = null;
	  }
	 	
	} else {
	  id = "nocookie";
	  nu = "-1";
	}
	// Get query string info & parse out required parameters
	source=getQSParam(sourceparamname);
	// If a particular parameter is non-null, set that value in the "click source" cookie
	if (source != null) {
	  src = escape(source);
	  srctime=fromt.getTime();
	  if (optout != "1") {
	    document.cookie = "wa_last_source="+escape(source)+"; expires=" + cexp.toUTCString() + "; path=/" + (cookieDomain == "" ? "" : "; domain=" + cookieDomain);
	    document.cookie = "wa_last_source_date="+srctime+"; expires=" + cexp.toUTCString() + "; path=/" + (cookieDomain == "" ? "" : "; domain=" + cookieDomain);
	  }
	} else {
	  if (optout != "1") {
	    src = getCookie("wa_last_source");
	    srctime = getCookie("wa_last_source_date");
	  }
	  if (src == null) src = "-";
	  if (srctime == null) srctime = 0;
	}
	  
	// decide which tag request (secure vs non-secure) to use
	if (res.substring(0,5) == "https"){
	  base = secureserver + "/clientinfo.gif?" + civersion + "&" + t + "&";
	}
	else{
	  base = server + "/clientinfo.gif?" + civersion + "&" + t + "&";
	}
	
	// Checks if a custom event call has been made (res2)  
	if(res2!="-"){
		var res = escape('http://') + dn + '/' + escape(res2.replace('http://',''));
		var ref = escape(document.URL);
	}
	
	reqsrc = st + "&" + tz + "&" +id + "&" +nu + "&" + sc + "&" +sr + "&" + wr + "&" + js + "&" + je + "&" + lg + "&" + dn + "&" + res + "&" + ref + "&" + pt + "&" + fs + "&" + is + "&" + trioid + "&" + thispet + "&" + SRT + "&" + OET + "&" + UET + "&" + src + "&" + srctime + "&" + customfields;
	var maxlen = 4000;  // max request size
	var reqlen = reqsrc.length;
	if (reqlen>maxlen) reqsrc = reqsrc.substring(0,maxlen);
	  
	var request = new Image();
	request.src = base + reqsrc + "&-";
	
	if((document.URL.indexOf('wa_debug=true')>-1)|(document.cookie.indexOf("webabacus_debug=true")>-1)){
		alert("WebAbacus Debug Infomation\n\nnote: to remove add 'wa_debug=false' to the URL\n\nSite name (st): " + st +"\nTime zone offset (tz): "+tz+"\nWebabacus ID (id): "+id+"\nNew user flag (nu): "+nu+"\nVisitor Screen Colour Depth (sc): "+sc+"\nVisitor Screen resolution (sr): "+sr+"\nVisitor Window resolution (wr): "+wr+"\nJavascript version (js): "+js+"\nJava Enablement (je): "+je+"\nBrowser Language (lg): "+lg+"\nServer name (dn): "+dn+"\nResource (res): "+res+"\nReferrer (ref): "+ref+"\nPage Title (pt): "+pt+"\nfs: "+fs+"\nis: "+is+"\ntrioid: "+trioid+"\nthispet: "+thispet+"\nSRT: "+SRT+"\nOET: "+OET+"\nUET: "+UET+"\nsrc: "+src+"\nsrctime: "+srctime+"\ncustomfields: "+customfields + "\n\nMain Tag: "+ base + reqsrc + "&-");
		document.cookie="webabacus_debug=true; expires="+cexp.toUTCString()+"; path=/"+(cookieDomain==""?"":"; domain="+cookieDomain);
	}
	
	if(document.URL.indexOf('wa_debug=false')>-1){
		document.cookie="webabacus_debug=false; expires="+cexp.toUTCString()+"; path=/"+(cookieDomain==""?"":"; domain="+cookieDomain);
	}
}

function getCookie (name) {
var dc = document.cookie;
var cname = name + "=";
var clen = dc.length;
var cbegin = 0;
while (cbegin < clen) { 
var vbegin = cbegin + cname.length;
  if (dc.substring(cbegin, vbegin) == cname) { 
    var vend = dc.indexOf (";", vbegin);
    if (vend == -1) vend = clen;
    return unescape(dc.substring(vbegin, vend));
    }
  cbegin = dc.indexOf(" ", cbegin) + 1;
  if (cbegin== 0) break;
  }
return null;
}

function getQSParam(key)
{
	var value = null;
	for (var i=0;i<keys.length;i++)
	{
		if (keys[i]==key)
		{
			value = values[i];
			break;
		}
	}
	return value;
}

function parseQS()
{
	var query = "";
	try {
	  query = top.window.location.search.substring(1);
	} catch (e) {}
	var query1 = query.toLowerCase();
	var pairs = query1.split("&");
	
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			keys[keys.length] = pairs[i].substring(0,pos);
			values[values.length] = pairs[i].substring(pos+1);		
		}
	}
}

// This code executes when the script is first parsed
if (perfinfo == 1) {
  logclientdata("01");
} else {
  logclientdata("");
}

//Sniffer
var start, end, version, browser; var msMadeMeUseVB = false; if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) { document.writeln ('<script language="VBscript">'); document.writeln ('\'do a one-time test for a version of VBScript that can handle this code'); document.writeln ('msMadeMeUseVB = False'); document.writeln ('If ScriptEngineMajorVersion >= 2 then'); document.writeln ('  msMadeMeUsevB = True'); document.writeln ('End If'); document.writeln ('\'this next function will detect most plugins'); document.writeln ('Function detectActiveXControl(activeXControlName)'); document.writeln ('  on error resume next'); document.writeln ('  detectActiveXControl = False'); document.writeln ('  If msMadeMeUseVB Then'); document.writeln ('     detectActiveXControl = IsObject(CreateObject(activeXControlName))'); document.writeln ('  End If'); document.writeln ('End Function'); document.writeln ('\'and the following function handles QuickTime'); document.writeln ('Function detectQuickTimeActiveXControl()'); document.writeln ('  on error resume next'); document.writeln ('  detectQuickTimeActiveXControl = False'); document.writeln ('  If msMadeMeUseVB Then'); document.writeln ('    detectQuickTimeActiveXControl = False'); document.writeln ('    hasQuickTimeChecker = false'); document.writeln ('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")'); document.writeln ('    If IsObject(hasQuickTimeChecker) Then'); document.writeln ('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then '); document.writeln ('        detectQuickTimeActiveXControl = True'); document.writeln ('      End If'); document.writeln ('    End If'); document.writeln ('  End If'); document.writeln ('End Function'); document.writeln('</scr' + 'ipt>');}
function detectJava () { return (navigator.javaEnabled())?1:0;}
function canDetectPlugins() { if (msMadeMeUseVB || (navigator.plugins && navigator.plugins.length > 0) )
return true; else
return false
}
function detectPlugin () { var daPlugins = detectPlugin.arguments; var pluginFound = false; if (navigator.plugins && navigator.plugins.length > 0) { var pluginsArrayLength = navigator.plugins.length; for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) { var numFound = 0; for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) { if ((navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) { numFound++;}
}
if(numFound == daPlugins.length) { pluginFound = true; break;}
}
}
return pluginFound;}
function detectDirector() { pluginFound = detectPlugin('Shockwave','Director'); if(!pluginFound && msMadeMeUseVB)
pluginFound = detectActiveXControl('SWCtl.SWCtl.1'); return pluginFound?1:0;}
function detectFlash () { pluginFound = detectPlugin('Shockwave','Flash'); if(!pluginFound && msMadeMeUseVB)
pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1'); return pluginFound?1:0;}
function detectFlashVersion () { var flashVersion = 0
if(detectFlash())
{ if(msMadeMeUseVB)
{ for(var i=15; i>0; i--)
{ try
{ var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i); flashVersion = i; break;} catch(e) { }
}
}
else
{ if (navigator.plugins && navigator.plugins.length)
{ x = navigator.plugins["Shockwave Flash"]; if (x) { if (x.description) { y = x.description; flashVersion = y.charAt(y.indexOf('.')-1);}
}
if (navigator.plugins["Shockwave Flash 2.0"]) { flashVersion = 2;}
} else if (navigator.mimeTypes && navigator.mimeTypes.length)
{ x = navigator.mimeTypes['application/x-shockwave-flash']; if (x && x.enabledPlugin)
{ flashVersion =0;}
}
}
}
return flashVersion;}
function detectQuickTime () { pluginFound = detectPlugin('QuickTime'); if(!pluginFound && msMadeMeUseVB)
pluginFound = detectQuickTimeActiveXControl(); return pluginFound?1:0;}
function detectReal () { pluginFound = detectPlugin('RealPlayer'); if(!pluginFound && msMadeMeUseVB) { pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') || detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') || detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));}
return pluginFound?1:0;}
function detectWindowsMedia () { pluginFound = detectPlugin('Windows Media Player'); if(!pluginFound && msMadeMeUseVB)
pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1'); return pluginFound?1:0;}
function detectAcrobat () { pluginFound = false; if (navigator.mimeTypes && navigator.mimeTypes["application/pdf"] == "[object MimeType]")
pluginFound = true; if (!pluginFound && msMadeMeUseVB) { pluginFound = (detectActiveXControl('AcroExch.Document') || detectActiveXControl('PDF.PdfCtrl.1') || detectActiveXControl('Acrobat Reader') || detectActiveXControl('PDF.PdfCtrl.5') );}
return pluginFound?1:0;}
function detectCookies () { testValue=Math.floor(1000*Math.random()); SetCookie('AreCookiesEnabled',testValue); return (testValue==ReadCookie('AreCookiesEnabled'))?1:0;}
function SetCookie (cookieName,cookieValue,nDays) { var today = new Date(); var expire = new Date(); if (nDays==null || nDays==0) nDays=1; expire.setTime (today.getTime() + 3600000*24*nDays); document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();}
function ReadCookie (cookieName) { var theCookie=""+document.cookie; var ind=theCookie.indexOf(cookieName); if (ind==-1 || cookieName=="") return ""; var ind1=theCookie.indexOf(';',ind); if (ind1==-1) ind1=theCookie.length; return unescape(theCookie.substring(ind+cookieName.length+1,ind1));}


//-->
