var duoPathBookshelf2Text = new Array(-154,-144,-140,-138,-137,-119,-101,-84,-68,-53,-41,-29,-20,-12,-5,-0,3,5,6,6,5,4,2,0);
var duoPathBookshelf2Visual = new Array(-154,-198,-199,-200,-201,-201,-201,-200,-198,-195,-190,-185,-177,-169,-158,-145,-130,-113,-94,-75,-55,-35,-17,0);

var pathIndex=0;
var pathBack=0;
var moveID=null;
var moveID_back = null;
var flagSwitch = 0;
var activeLink = 0;
var allowChange = 0;

delay=10;

function preRoll(div, active){
	if(allowChange == 0)
		RollInfo(div, active);
}

function RollInfo(div, active) { 
	allowChange = 1;
	if(flagSwitch == 1){
		RollBackActive('linkColumn' + activeLink.toString());
	}
	
	var auxDiv = document.getElementById(div);
	
	clearTimeout(moveID);
	clearTimeout(moveID_back);
	var yPos = duoPathBookshelf2Text[pathIndex];
	pathIndex+=1;
	
	auxDiv.style.top=yPos+"px";
	
	if(pathIndex<duoPathBookshelf2Text.length-1) {
		moveID=setTimeout("RollInfo('" + div + "'," + active + ")",delay);
	}
	else
	{
		pathBack=pathIndex;
		pathIndex=0; 
		moveID_back = moveID;
		flagSwitch = 1;
		activeLink = active;
		allowChange = 0;
	}
}

function RollBack(div)
{
	clearTimeout(moveID_back);
	activeLink = 0;
	var yPos = duoPathBookshelf2Visual[pathBack];
	pathBack-=1;
	document.getElementById(div).style.top=yPos+"px";

	if(pathBack>0){
		moveID_back=setTimeout("RollBack('" + div + "')",delay);
	}
	else {
		flagSwitch = 0;	
	}
}

function RollBackActive(div)
{
	clearTimeout(moveID_back);
	var yPos = duoPathBookshelf2Visual[pathBack];
	pathBack-=1;
	document.getElementById(div).style.top=yPos+"px";

	if(pathBack>0){
		moveID_back=setTimeout("RollBackActive('" + div + "')",10);
	}
	else {
		flagSwitch = 0;	
	}
}