Alex beat me, but I would say make a function and use "each" to call the function on each fo the boxes:
var $boxes = $(".box").click(function () {
var $this = $(this),
left = parseFloat($this.css('left')) || 0;
if (left == 0) {
$this.stop(true).animate({left: "100px"}).css('background','blue');
$boxes.not(this).stop(true).animate({left: 0}).css('background','red');
} else {
MoveLeft();
}
});
function MoveLeft() {
$(this).stop(true).animate({left: 0});
$(this).css('background','green');
}
$(".close").click(function () {
$boxes.each(MoveLeft);
});
UPDATE:
corrected the link, fiddle: http://jsfiddle.net/SgDwn/62/