var uiData = 
{
	freq : 4000,
	
	c : 0,
	
	xhrs : [],
	
	// moves / scrolls
	data : { m : [], s : [] },
	
	reset : function () 
	{
		this.data = { m : [], s : [] }
	},
	
	store : function ()
	{
		//proverka, zakonchen li predidushij zapros
		if (this.xhrs.length > 0) { return; }
		
		try
		{
			//esli net dannih - do nothing
			if (this.data.m.length == 0 && this.data.s.length == 0) { return; }
			
			var data = this.data;
			data.uri = window.location.href;
			this.reset();
			
			var xhr = $.post('/hm.php', data, function () {
				uiData.xhrs.pop();
			});
			this.xhrs.push(xhr);
		}
		catch (e)
		{
			//e
		}
	},
	
	point : function (x, y)
	{
		// all:
		//if (this.c++ % 5 > 0) { return; }
		this.data.m.push([x, y]);
	},
	
	repeat : function (start)
	{
		if (!start)
		{
			uiData.store();
		}
		setTimeout("uiData.repeat();", this.freq);
	}
}

$(window).scroll(function () { 
	//$("span").css("display", "inline").fadeOut("slow"); 
}); 

$(window).mousemove(function (event) { 
	uiData.point(event.pageX, event.pageY);
}); 

$(function () {
	uiData.repeat(true);
});


