<!--
// WEBABACUS CLIENT INFO VERSION 1.89b, (c)2005 WebAbacus Ltd ALL RIGHTS RESERVED. 
// Version to be used as a JS include
// See accompanying clientinfo-include-notes.txt for change history, or contact supportuk@webabacus.com

// User variables: Change these values to set global settings
var server = "";   // Set to another server (e.g. http://192.168.1.250) to send tag request to that server (not local)
var secureserver = ""; // Enter the address of the server to which secure tag requests should be sent (include https:// part)
var site = "";     // Enter the name of this site (optional)
var cookieLife = 730;  // No. of days that the cookie is valid for (default is 730 - two years)
var cookieDomain = ""; // Domain for the cookie (must start with and include at least two full stops - e.g. .webabacus.com or .webabacus.co.uk)
var perfinfo = 0; // Flag to indicate whether this script will be used to gather full performance data - set to 1 if it will be
var sourceparamname = ""; // Name of the parameter in the query string which indicates a source value
// 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";

// 2009/04/08 - OLD SERVER: var server = "http://www.caravancamping.co.uk"
// 2009/04/08 - OLD SERVER: var secureserver = "https://www.caravancamping.co.uk"

// create random page id, use in conjuction with IP + UA to ensure uniqueness
var rn=Math.floor(Math.random()*1000000001);
var site = "BH_CaravanCamping";
var server = "http://www.haven.com/tag";
var secureserver = "https://www.haven.com/tag";
var civersion="1.89b";
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 res2;
var ref="-";
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;
cexp = new Date(fromt.getTime() + clifems);
var srctime=0;
var customfields="";
var optout="";
var trioid="-";

function logclientdata(n,res2) {
thispet = n;

// Calculate time differentials
if (thispet=="01") {
  now = new Date();
  tt = now.getTime();
  SRT = (tt - elapsedt);
  trioid = rn;
  }
else if (thispet=="02") {
  now = new Date();
  tt = now.getTime();
  OET = (tt - elapsedt);
  trioid = rn;
  }
else if (thispet=="03") {
  now = new Date();
  tt = now.getTime();
  UET = (tt - elapsedt);
  trioid = rn;
  }
else  {
  SRT = 0;
  OET = 0;
  UET = 0;
  trioid = Math.floor(Math.random()*1000000001);
  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 (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;
  
  // Capture the values of the custom fields
  if (typeof(wacustomvarnames) != "undefined") {
    customfields = "";
    for (i = 0; i < wacustomvarnames.length; i++) {
      customfields = customfields + wacustomvarnames[i] + "~" + wacustomvarvalues[i];
      if (i != wacustomvarnames.length-1) customfields = customfields + "~";
    }
  } else
    customfields = "-"; 
}
else {
  fs = "-";
  is = "-";
  wr = "-";
  customfields = "-";
}

parseQS();

// 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";
    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);
} 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 + "&";
  
// START v1.89 SDB: 10/01/05 - Checks if a custom call has been made (res2)  
if(res2){
	var res = escape('http://') + dn + '/' + escape(res2);
	var ref = escape(document.URL);
}
// END v1.89 

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 = 2000;  // max request size
var reqlen = reqsrc.length;
if (reqlen>maxlen) reqsrc = reqsrc.substring(0,maxlen);
  
var request = new Image();
request.src = base + reqsrc + "&-";

// alert("Tag="+ base + reqsrc + "&-"  );
// end main function  
}

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 = 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);		
		}
	}

}

function tagFields(fn) {
  var fidx;
  if (fn != "") {
    for (fidx = 0; fidx < document.forms.length; fidx++) {
    if (document.forms[fidx].name == fn) break;
  }
  if (fidx == document.forms.length) fidx = 0;
  } else fidx = 0;
  var frm = document.forms[fidx];
  fn = frm.name;
  var fsrc = "&" + (escape(fn) == "" ? "-" : escape(fn));
  var elidx, vName, vVal;
  for (elidx = 0; elidx < frm.elements.length; elidx++) {
    vType = frm.elements[elidx].type.toLowerCase(); //capture the current field type
    vChecked = frm.elements[elidx].checked; 
    vName = escape(frm.elements[elidx].name); 
    if (vName != "__VIEWSTATE") {
        vVal = escape(frm.elements[elidx].value); 
        if(vName == "" || vName == null) vName = "-";

        if(vVal == "" || vVal == null) vVal = "-";
        if (vName == "CC_Number") vVal = "-";
        //ignore if the field is a radio/checkbox and unchecked
        if((vType == "radio" || vType == "checkbox") && (!(vChecked))){}
        else {fsrc = fsrc + "~" + vName + "~" + vVal;}
    }
  }
  if (fsrc == "&") fsrc = "&-";
  var fReq = new Image();
  fReq.src = base + reqsrc + fsrc;
}

// This code executes when the script is first parsed
if (perfinfo == 1) {
  logclientdata("01");
} else {
  logclientdata("");
}

/* Exit Survey starts - called from various pages on the Site */
function surveypopup() {
}
/* Exit Survey ends */

//-->