window.onload = function () {
	logStats();
};

// Logs OneStat stats.
function logStats() {

	// prevent logging of stats if this script is being executed on the local server.
	if (location.hostname === 'boris') return;

	// create OneStat URL, using parameters to pass browser/document/OS information.
	var accountId = '558672';
	var newDate = new Date();
	var oneStatUrl =
			location.protocol + '//stat.onestat.com/stat.aspx?tagver=2' +
			'&sid=' + accountId +
			'&url=' + escape(document.URL) +
			'&ti=' + escape(document.title) +
			'&rf=' + escape((parent == self) ? document.referrer : top.document.referrer) +
			'&tz=' + escape(newDate.getTimezoneOffset()) +
			'&ch=' + escape(newDate.getHours()) +
			'&ul=' + escape((navigator.appName == 'Netscape') ? navigator.language : navigator.userLanguage) +
			'&jo=' + ((navigator.javaEnabled()) ? 'Yes' : 'No') +
			'&sr=' + screen.width + 'x' + screen.height +
			'&cd=' + screen.colorDepth +
			'&js=1';

	// create image element which passes statistics to OneStat via a parameterised src attribute.
	// This technique capitalises on browser image caching; although the image is not appended to
	// the DOM, a preemptive request is made by all browsers which allows statistics to be sent.
	document.createElement('img').setAttribute('src', oneStatUrl);
}
