var zufall;
var maxzufall = 670;
var minzufall = 0;
var px = 10;//mehr=schneller
var timer;
var autodir;

function scrollDenDiv(val, speed, auto) {
    clearTimeout(timer);
    var d = document.getElementById('rightlocations_inner');
    var y = d.scrollTop;

    if(auto==1){
        if(autodir==1)y-=50;
        if(autodir==2)y+=speed;
    } else {
        if(val==1)y-=speed;
        if(val==2)y+=speed;
    }

    d.scrollTop=y;
    timer=setTimeout('scrollDenDiv('+val+', '+speed+', '+auto+')',50);

    if(y < 0||y > d.scrollHeight-d.offsetHeight){
        if(auto == 0){
            clearTimeout(timer);
        }
        if(y<0){
            autodir = 2;
        }
        if(y>d.scrollHeight-d.offsetHeight){
            autodir = 1;
        }

    }
}

function zufallsscroll(){
    zufall = Math.floor(maxzufall+(maxzufall-minzufall+1)*(Math.random()));
    document.getElementById('rightlocations_inner').scrollTop = zufall;
    autodir = 2;
}

$(document).ready(function() {
    $.get('ajax/ajax.php?action=getLocations', function(data) {
        $('#getLocations').html(data);
    });
});
