// Version: 1.2
// Author: Nick Trainor
// Modification Date: 24 July 2006 by Dave Miller
// Company: Trainor Thornton Ltd
// Web Address: http://www.trainorthornton.co.uk


// initial variables
var image_height = 1
var image_width = 1
var url_string;
var site_id = 80;



// Determine whether a cookie has been set containing the session information
//
//Create a session id based upon:
//
//1. The site_id
//2. a 18 character random integer number


// with thanks to Bill Dortsch for his cookie recipes



// returns value of cookie from offset
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

// function to get values from cookie
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

// function to create a cookie
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}



//
if(! GetCookie("tracker_session_id") )
{
// No cookie set - so this is a new session
new_session = 1;
// create the session_id used to identify path of user
var session_id;
session_id = site_id + "-" + ((Math.random() * 1)*1000000000000000000); 

//	Netscape specific
//	if( SetCookie("tracker_session_id",session_id,null,"/",null,null) != 1 )
	if(SetCookie("tracker_session_id",session_id,"","/","","") != 1)
	{
//	document.write("<BR><B>Cookie NOT Set</B><BR>");
	}
	else
	{
//	document.write("<BR><B>Cookie Set</B><BR>");
	}
}
else
{

// cookie IS set so this is an existing session
new_session = 0;
}

//	document.write("<BR>..." + site_id + ".....</B><BR>");
url_string = "http://194.216.112.189:8000/";
//url_string = "http://192.168.0.2:8000/";

url_string += "?site_id=" + site_id;
url_string += "&app_name=";
if(escape(navigator.appName) != "")
{
url_string  += escape(navigator.appName);
}
else
{
url_string  += "undefined";
}

url_string += "&app_version=";
if(escape(navigator.appVersion))
{
url_string  += escape(navigator.appVersion);
}
else
{
url_string  += "undefined";
}




url_string += "&browser_language=";
if(escape(navigator.language)!="")
{
url_string  += escape(navigator.language);

}
else
{
url_string  += "undefined";
}

url_string += "&system_language="; 
if(escape(navigator.systemLanguage)!="")
{
url_string  += escape(navigator.systemLanguage);

}
else
{
url_string  += "undefined";
}

url_string += "&platform=";
if(  escape(navigator.platform) != ""  )
{
url_string  +=  escape(navigator.platform);
}
else
{
url_string  += "undefined";
}

url_string += "&protocol=";
if( escape(location.protocol)!= "")
{
url_string  += escape(location.protocol);
}
else
{
url_string  += "undefined";
}

url_string += "&host_name=";
if(escape(location.hostname) != "")
{
url_string  += escape(location.hostname);
}
else
{
url_string  += "undefined";
}

url_string += "&port=";
if(escape(location.port) != "")
{
url_string  += escape(location.port);
}
else
{
url_string  += "undefined";
}






url_string += "&colour_depth=";
if(screen.colorDepth >0)
{
url_string += screen.colorDepth;
}
else
{
url_string += "0";
}


url_string += "&pixel_depth=";
if(screen.pixelDepth >0)
{
url_string += screen.pixelDepth;
}
else
{
url_string += "0";
}



url_string += "&screen_width=";
if(screen.width >0)
{
url_string += screen.width;
}
else
{
url_string += "0";
}



url_string += "&screen_height=";
if(screen.height >0)
{
url_string += screen.height;
}
else
{
url_string += "0";
}



url_string += "&available_width=";
if(screen.availWidth >0)
{
url_string += screen.availWidth;
}
else
{
url_string += "0";
}

url_string += "&available_height=";
if(screen.availHeight >0)
{
url_string += screen.availHeight;
}
else
{
url_string += "0";
}

url_string += "&java_enabled=";
if(navigator.javaEnabled() == "true")
{
url_string += "1";
}
else
{
url_string += "0";
}
url_string += "&document_title=";
if(escape(document.title) != "")
{

url_string += escape(document.title);
}
else
{
url_string += "undefined";
}


url_string += "&path_name="; 
if(escape(location.pathname) != "")
{
url_string  += escape(location.pathname);
}
else
{
url_string  += "undefined";
}



url_string += "&file_name=";
if
(escape( location.pathname.substring(location.pathname.lastIndexOf("/")+1,location.pathname.length) != "" ))
{
url_string += escape( location.pathname.substring(location.pathname.lastIndexOf("/")+1,location.pathname.length) );
}
else
{
url_string  += "undefined";
}



url_string += "&query_string=";
url_string  += escape(location.search);


// convert last modified to seconds since unix_time
url_string += "&last_modified=";
if((Date.parse(document.lastModified)/1000) > 0)
{
url_string  += (Date.parse(document.lastModified)/1000);
}
else
{
url_string += "0";
}


url_string += "&referrer=";
if(escape(document.referrer) != "")
{
url_string += escape(document.referrer);
}
else
{
url_string += "undefined";
}





url_string += "&sales=";
if(sales != "")
{
url_string += sales;
}
else
{
url_string += "undefined";
}




url_string += "&download=";
if(download_file != "")
{
url_string += download_file;
}
else
{
url_string += "undefined";
}




url_string += "&path2download="; 
if(path2download != "")
{
url_string += path2download;
}
else
{
url_string += "undefined";
}

url_string += "&remote_address=";
if(remote_address != "")
{
url_string += remote_address;
}
else
{
url_string += "0.0.0.0";
}

url_string += "&activity=";
if(typeof(activity) != "undefined" && activity != "")
{
url_string += escape(activity);
}
else
{
url_string += "undefined";
}

url_string += "&new_session=" + new_session;
url_string += "&session_id=" + GetCookie("tracker_session_id"); 

if( (download_file != "") && (path2download != ""))
{
document.write("<a href='" + url_string + "' target='_blank'");


	if(text_class != "")
	{

 document.write(" class='" + text_class + "' ");
	}


 document.write(">" + linkcontent + "</a>");
}
else
{
document.write("<img border='0' hspace='0' vspace='0' width='" + image_width + "' height='" + image_height + "' src='" + url_string + "'>");
}

//document.write( "<a href='" + url_string + "'>Click here</a><BR>" ); 
//document.write( "<BR><BR>" + url_string + "<BR><BR>"  ); 
