var max_y = 0;
var direction = 1;
var offset = 310;
var delay = 3500;
var speed = 1800;

$(document).ready(function() {
	max_y = (($('#top-container .top-item').length -1)*offset)*-1;
	//alert("höhe letztes element: "+$('#top-container :nth-child('+$('.top-item').length+')'));
	if($('#top-container .top-item').length > 1){
		move(310);
	}
});

function move_aktuell(){
	var cur_margin = $('#top-container').css('marginTop').replace("px", "");
	if( cur_margin > max_y && cur_margin != 0){		
		var y = offset*direction;
		//$('#debug').html('move UP: '+direction);
		move(y);
	}else{
		direction = direction*-1;
		var y = offset*direction;
		//$('#debug').html('move DOWN: '+direction);
		move(y);
	}
}



function move(y){
	$('#top-container').delay(delay).animate({"marginTop":"-="+y},speed,"easeInOutExpo",function(){move_aktuell()});
}