var walk_index = 0;
var walk_x = [ 0, 1, 2, 2, 2, 1, 1, 0, 0, 1, 2, 2, 2, 1, 1, 0 ];
var walk_y = [ 0, 0, 0, 1, 2, 2, 1, 1, 2, 2, 2, 1, 0, 0, 1, 1 ]; 

var at_x = 0;
var at_y = 0;

var to_x = 0;
var to_y = 0;

var g_box;
var g_task;

var pause_tics = 80;
var slide_tics = 0;

function setup_grid( )
{
	if (document.getElementById)
		{
		g_box = document.getElementById("slider");
		g_task = window.setInterval("grid_slider()",50);
		}
}

function grid_slider( )
{
	if (pause_tics!=0)
		{
		/* pausing; do nothing for some x number of tics */
		pause_tics -= 1;
		if (pause_tics<=0)
			{
			/* pause is over; pick the next coordinate */
			pause_tics = 0;
			slide_tics = 1;
			walk_index += 1;
			if (walk_index>=16)
				walk_index = 0;
			to_x = walk_x[walk_index];
			to_y = walk_y[walk_index];
			}
		}
	else
		{
		if (slide_tics<=20)
			{
			var xp;
			var yp;
			xp = ( at_x + ((to_x-at_x)*slide_tics)/20 )*224;
			yp = ( at_y + ((to_y-at_y)*slide_tics)/20 )*224;
			g_box.style.backgroundPosition = (0-xp)+"px "+(0-yp)+"px";
			slide_tics += 1;
			}
		else
			{
			/* done with slide; record position and pause */
			/*slide_tics = 0;*/
			pause_tics = 60;
			at_x = to_x;
			at_y = to_y;
			}
		}
}

