// abstand link zu link : 28px;
// abstand link mit content zu link : 201px;
abstand = 28;
abstand2 = 201;
timerOn = 0;
timer = 0;
intervaltime = 20;
n = 2;
			
function start() {				
		document.getElementById('quicklayer1').style.top = '0px';					
		var tempabstand = abstand2;
		for(var i=2; i<=4; i++) {						
			document.getElementById('quicklayer'+i).style.top = tempabstand+'px';
			tempabstand += abstand;
		}					
}

function linkFocus(i) {
			if(timerOn == 1) { 
				window.clearInterval(timer); 			
				n = 2;
			}		
			timer = window.setInterval('setpos('+i+')', intervaltime);
			timerOn = 1;
}

function setpos(myindex) {								
		var finished = 1;					
		var additionswert = Math.pow(1.15,n);
		
		for(var i=0; i<4; i++) {
			if(i<myindex) {
				var limit = i*abstand;	
				if((currentTop(i+1)-additionswert) > limit) {		
					document.getElementById('quicklayer'+(i+1)).style.top = (currentTop(i+1)-additionswert) +'px';
					finished = 0;
				}
				else {		
					document.getElementById('quicklayer'+(i+1)).style.top = limit +'px';
					finished = 0;
				}
			}
			else {							
				var limit = (i-1)*abstand + abstand2;
				if((currentTop(i+1)+additionswert) < limit) {
					document.getElementById('quicklayer'+(i+1)).style.top = (currentTop(i+1)+additionswert) +'px';
					finished = 0;
				}
				else {
					document.getElementById('quicklayer'+(i+1)).style.top = limit +'px';
					finished = 0;
				}
			}
			
			
		}
		n += 3;
		if(finished == 1)
			window.clearInterval(timer);
}

function currentTop(index) {
		var mystring = document.getElementById('quicklayer'+index).style.top;			
		var mypos = parseInt(mystring.substring(0,mystring.length-2));		
		
		return mypos;
}