var premtime = GetTime();
var lastxm = GetMouseX();
var lastym = GetMouseY();
var nextxm = GetMouseX();
var nextym = GetMouseY();

var msentivity = 0.5;

var sen_max = 1.5;
var sen_min = 0.5;
var sen_range = 20;

var g_do_mouse_management = 1;

function ManageMouse()
{
	if (g_do_mouse_management == 0)
	{
		lastxm=GetMouseX();
		lastym=GetMouseY();
		return;
	}
	var newx, newy;

	if (GetTime() -premtime > 1000)
	{
		premtime = GetTime();
		lastxm = GetMouseX();
		lastym = GetMouseY();
		nextxm = GetMouseX();
		nextym = GetMouseY();
	}
	else
	{	
		premtime = GetTime();
		nextxm = GetMouseX();
		nextym = GetMouseY();

/*		
		if (nextxm - lastxm > 0)
			newx = Math.floor((nextxm - lastxm)*msentivity+lastxm);
		else
			newx = Math.ceil((nextxm - lastxm)*msentivity+lastxm);
		
		if (nextym - lastym > 0)
			newy = Math.floor((nextym - lastym)*msentivity+lastym);
		else
			newy = Math.ceil((nextym - lastym)*msentivity+lastym);
	*/

		newx = Math.floor((nextxm - lastxm)*msentivity+lastxm);
		newy = Math.floor((nextym - lastym)*msentivity+lastym);
	
		

		if (newx != lastxm || newy != lastym)
		{
			SetMousePosition(newx, newy);
	
			lastxm=newx;
			lastym=newy;
		}
		else
		{
			SetMousePosition(GetMouseX(), GetMouseY());
		}
	}
}