function Slider (element) 
{
    this.el = element;
    this.moveLeft = moveLeft;
    this.moveRight = moveRight;
    this.move = move;
    this.getPos = getPos;
    this.minPos = 0;
    this.moveLength = 132;
//    this.maxPos = this.el.getWidth()-$('project-list').getWidth();
    var children = this.el.childElements();
    var thumbWidth = 55;
    var sliderWidth = 400;
    this.basePos = this.el.offsetLeft;
    this.maxPos = 0;
    this.minPos = sliderWidth - children.length*thumbWidth;
    if(this.minPos > 0)
    {
        $('slider-navigation').hide();
    }
}

function getPos() 
{
    return this.basePos + this.el.offsetLeft;
}

function move(offset)
{
    var curPos = this.getPos();
    var len = offset;
    if(this.minPos > 0) 
    {
        alert('slider too narrow to move');
        return;
    }

    if(curPos + offset > this.maxPos )
    {
        len =  this.maxPos - curPos;
//        alert('modifying offset (too high)');
    }
    else if(curPos + offset < this.minPos)
    {
        len = this.minPos - curPos;
//        alert('modifying offset (too low)');
    }
//    alert('Current position:'+curPos+'\n'+'Min...Max:'+this.minPos+'...'+this.maxPos+'\nDesired offst'+offset+'\nValid offset:'+len);
    new Effect.Move( this.el, {x: len, y: 0, mode: 'relative'} );

}

function moveLeft()
{
    this.move(-300);
}

function moveRight()
{
    this.move(300);
}


