var currentMargin = 0;
var marginStep = 200;

//function reset() { $('GalleryItems').morph({marginLeft: '0px'});}
function reset() { $('sock').morph({marginLeft: '0px'});}

function scroll(dir) {
    var currentWidth = Element.getStyle('sock','width');
    currentWidth = parseInt(currentWidth.slice(0,currentWidth.length-2));

    //our little inline "sock" hack doesn't fly in safari, so fetch width of the GalleryItems
    if (currentWidth <= 0) {
        currentWidth = Element.getStyle('sock','width');
        currentWidth = parseInt(currentWidth.slice(0,currentWidth.length-2));
    }

    if (dir == "left") {
        currentMargin = currentMargin - marginStep;
    } else {
        currentMargin = currentMargin + marginStep;
    }

    if (currentMargin >= 0) {
        currentMargin = 0;
    } else if (currentMargin < -currentWidth ) {
        currentMargin = currentMargin + marginStep;
    }

    if (currentMargin > -(currentWidth)) {
        $('sock').morph({marginLeft: currentMargin + 'px'});
        //$('GalleryItems').morph({marginLeft: currentMargin + 'px'});
    }
}

