function ispy()
{
	this.inited = false;
	this.spy_wait = 10000;
	this.spybox = null;
	this.timeout = null;
	this.lang_pause = '';
	this.lang_start = '';
	this.spymsg = null;
}

ispy.prototype.init = function()
{
	ispy.inited = true;
	ispy.timestamp = ispy.return_timestamp();
	ispy.spybox = my_getbyid('spybox');
	ispy.spymsg = my_getbyid('spymsg');
	
	if(parseInt(ispy.spy_wait) == 0)
	{
		ispy.spy_wait = 10000;
	}
	
	ispy.init_spy();
}

ispy.prototype.stop_spy = function()
{
	ispy.spymsg.innerHTML = ispy.lang_pause;
	clearTimeout(ispy.timeout);
}

ispy.prototype.init_spy = function()
{
	ispy.spymsg.innerHTML = ispy.lang_start;
	ispy.timeout = setTimeout("ispy.spy();", ispy.spy_wait);
}

ispy.prototype.spy = function()
{
	if(!ispy.inited)
	{
		return false;
	}
	
	if(ispy.spy_wait == 0)
	{
		ispy.spy_wait = 10000;
	}
	
	req = function()
	{
		if (xmlobj.readystate_ready_and_ok())
		{
			var html = xmlobj.xmlhandler.responseText;
			ispy.spybox.innerHTML = html + ispy.spybox.innerHTML;
			ispy.timestamp = ispy.return_timestamp();
		}
	}

	xmlobj = new ajax_request();
	xmlobj.onreadystatechange(req);
	
	var u = ipb_var_base_url+'autocom=spy&cmd=show&time='+ispy.timestamp;
	
	xmlobj.process(u, 'GET');
	ispy.timeout = setTimeout("ispy.spy();", ispy.spy_wait);
}

ispy.prototype.return_timestamp = function(x)
{
	if(!ispy.inited)
	{
		return false;
	}

	var d = (typeof(x) != 'undefined' && x != null && x != '') ? new Date(x) : new Date();
	var t = d.getTime();

	return Math.floor(t/1000);
}

