function $(id) {
    return document.getElementById(id);
}
function slide_box(element, dir, start) {
    if(typeof(element) == 'string') {
        container = $(element);
    } else {
        container = element.parentNode.parentNode
    }
    scrollbox = container.getElementsByTagName('div').item(0);
    h = container.getElementsByTagName('div').item(1);
    divs = h.getElementsByTagName('div');
    width = 287+50;
    h.style.width = (divs.length * width) + 'px';
    
    if(dir > 0 && scrollbox.scrollLeft >= (divs.length-1) * width)
        return;
    
    if(start || scrollbox.scrollLeft % width != 0) {
        lower_end = (scrollbox.scrollLeft - (scrollbox.scrollLeft % width));
        if(dir > 0)
            destination = lower_end + width;
        else if(dir < 0 && start)
            destination = lower_end - width;
        else 
            destination = lower_end;
        distance = destination - scrollbox.scrollLeft;

        travel = distance/10 + (Math.abs(distance)/distance * 5);
        if(Math.abs(distance) <= 10)
            travel = distance;
        scrollbox.scrollLeft += travel;
        setTimeout('slide_box(\''+container.id+'\', '+dir+', false)', 30);
    } 
}
