<!--

Array.prototype.find = function (s)
{
	for(var i=0;i<this.length;i++) {
		if(this[i] == s) return true;
	}
	return false;
}

/*---------------------------* 
 * create the tracker class  *
 *---------------------------*/
 
function tracker()
{	
	this.client_id='wa_texaco';
	
	// cookies can be dealt with via php on the wa server
	// on the other hand IE is fussy on occasions
	var c=document.cookie; // cookie
	var s = c.indexOf("visit_id="); // start
	if (s != -1) {
		e=c.indexOf(';',s) // next ;
		this.cookie_value=c.substring(s+9,e<0?c.length:e);
	}	else {
		this.cookie_value = (new Date().getMilliseconds() + Math.random()).toString();
		document.cookie = 'visit_id=' + this.cookie_value + ';';
	}		

	// define items to send through with every request regardless
	this.f_var_pagetitle = encodeURIComponent(document.title);
	this.f_var_pageurl = encodeURIComponent(document.location);
	this.f_var_do_impression = 'y';
	this.f_var_referrer = document.referrer;
	this.img = new Image();
	
	// this should be defined outside of this script,
	// as it;s a per-page setting
	// this.f_var_impression_type = 4;
}

tracker.prototype.geturl = function()
{

	var var_types = new Array('ii_','is_','id_','ei_','es_','ed_');
	
	var protocolRegex = /^https/i;
	
	if (protocolRegex.test(document.location)) {
		var protocol = 'https';
	}
	else {
		var protocol = 'http';
	}

	var url = protocol + '://stats.tobias.tv/img.php?client_id=' + this.client_id + '&visit_id=' + this.cookie_value;
	for (p in this) {
		if (var_types.find(p.substring(0, 3))) {
		//if (p.substring(0, 5) == 'i_var') {
			url = url + '&' + p + '=' + encodeURI(this[p]);
			delete this[p];	
		}	
		if (p.substring(0, 5) == 'f_var') {
			// we don't delete f_vars, as they need to be sent through 
			// with subsequent image reloads for events
			url = url + '&' + p + '=' + encodeURI(this[p]);
		}	
	}
	
	return url;
}


tracker.prototype.show = function() 
{   	
	this.img.src = this.geturl();
}

tracker.prototype.reload = function() 
{  
	this.f_var_do_impression = 'n';
	this.img.src = this.geturl();
}


/*--------------------------------------* 
 *     end tracker object definitions   *
 *--------------------------------------*/



// initialise a new tracker object
var t = new tracker();
//t.id_2 = '132.32';
// any other impression (i_var) vars could be added here

// show image
//t.show();
-->
