var scroll_timer = null;
var c_width = 0;

function startMove(dir){
	if(!c_width)
		c_width = parseInt(document.getElementById("moving_menu_table").offsetWidth);
	scroll_timer = setInterval(function(){doMove(dir);}, 10);
}

function doMove(direction){
	var c = parseInt($("#moving_menu").css('left'));
	if(c == 0 && direction == 0 || c < 639 - c_width && direction == 1){
		stopMove();
		return 0;
	}	
	var nc = direction == '1' ? c-2 : c+2;
	$("#moving_menu").css('left', nc);
}

function stopMove(){
	clearInterval(scroll_timer);
	$.post('/engine/ajax/save_menu_position.php', {x : $("#moving_menu").css('left')});
}
