
function getRef(name) { return document.getElementById(name); }

	var speed = 0;
	var acc = 1;

	var box_positions = new Array();
	var max_boxes = new Array();
	var position_num = 0;
	
	function do_move(direction,id_num) {
	speed = 0;
		if (direction == 'right' && position_num == 0) {
		movebox(box_positions[id_num][0],box_positions[id_num][max_boxes[id_num]],'left',id_num);
		position_num = max_boxes[id_num];
		} else if (direction == 'left' && position_num == max_boxes[id_num]) {
		movebox(box_positions[id_num][max_boxes[id_num]],box_positions[id_num][0],'right',id_num);
		position_num = 0;
		} else {
		next_pos = (direction == 'left') ? position_num+1 : position_num-1;
		movebox(box_positions[id_num][position_num],box_positions[id_num][next_pos],direction,id_num);
		position_num = (direction == 'left') ? position_num+1 : position_num-1;
		}
	}
	
	
	function movebox(curX,endX,direction,id_num) {
		//only run scripts on DOM browsers
		if(!document.getElementById || !document.getElementsByTagName) return;
		
		//position box vertically
		getRef("projectbox"+id_num).style.left = 0 + "px";
		
		
		eval_cur = (direction == 'left') ? curX < endX : curX > endX;
		
		if (eval_cur) {	//finished animation
			getRef("projectbox"+id_num).style.top = endX + "px";
		
		} else {		//continue with animation
			speed += acc;	//accellerate
			getRef("projectbox"+id_num).style.top = curX + "px";
			calc_pos = (direction == 'left') ? curX-speed : curX+speed;
			setTimeout("movebox(" + (calc_pos) + "," + endX + ",'"+direction+"',"+id_num+");",5);
		}
	}
	
