//****************************************************************************
//* Trexy.com - Blaze Search Trails
//*
//* Copyright 2007
//*
//* Author:	Nigel Hamilton
//*
//* Version: 12
//*
//*---------------------------------------------------------------------------
//*
//*//////////////////////////////////////////////////////////////////////////
var _trexy_test_mode = false;
function start_sensor(adapterid) {
_do_alert('start sensor fired');
for (var i = 0; i < document.links.length; i++) {
if (location.hostname == document.links[i].hostname) {
continue;
}
if (document.links[i].href.indexOf("https") == 0) {
continue;
}
_do_alert('adding mousedown handler for ' + document.links[i].href);
add_event_handler(document.links[i], 'mousedown', toc, true);
}
tic();
}
function add_event_handler(element, event_type, callback_function, use_capture) {
if (element.addEventListener) {
element.addEventListener(event_type, callback_function, use_capture);
return true;
}
else if (element.attachEvent) {
var r = element.attachEvent('on' + event_type, callback_function);
return r;
}
else {
element['on' + event_type] = callback_function;
}
}
function tic() {
if (location.href.indexOf("https") == 0) {
return true;
}
if (document.images) {
var _trexy_tic_url = "http://trexy.com/tic?" 			+
"u="	+ encodeURIComponent(location.href)			+
"&r="	+ encodeURIComponent(document.referrer) 	+
"&h="	+ encodeURIComponent(location.hostname)		+	
"&x="	+ Math.random();
_do_alert('tic fired ' + _trexy_tic_url);
(new Image).src = _trexy_tic_url;
}
return true;
}
function toc(e) {
if (typeof e == 'undefined') {
var e = window.event;
}
var source_element;
if (typeof e.target != 'undefined') {
source_element = e.target;
}
else if (typeof e.srcElement != 'undefined') {
source_element = e.srcElement;
}
else {
_do_alert("toc: could not determine source element");
return true;
}
if (document.images) {
var _trexy_toc_url = "http://trexy.com/toc?" 							+
"u=" 	+ encodeURIComponent(source_element.href) 	+	
"&r="	+ encodeURIComponent(location.href)			+	
"&h="	+ encodeURIComponent(location.hostname)		+	
"&x=" 	+ Math.random();
_do_alert(_trexy_toc_url);
(new Image).src = _trexy_toc_url;
}
return true;
}
function _do_alert(message) {
if (_trexy_test_mode) {
window.alert(message);
}
}
