var Box = new Class({
	isopen: true,
	txtopen: "view details",
	txtclose: "hide",
	initialize: function(box, open) {
		this.box = $(box);
		this.header = this.box.getFirst().getFirst().getNext();
		this.version = this.header.getFirst().innerHTML;
		this.details = this.header.getNext();
		this.foot = this.box.getLast();
		this.link = new Element("a", {
			"href": "#",
			"events": {
				"click": function(e) {
					var event = new Event(e);
					event.preventDefault();
					this.toggle();
				}.bind(this)
			}
		}).appendText(open ? this.txtclose : this.txtopen);
		this.foot.adopt(this.link);
		open ? this.open() : this.close();
	},
	close: function() {
		this.details.setStyle("display", "none");
		this.link.innerHTML = this.txtopen;
		this.isopen = false;
	},
	open: function() {
		this.details.setStyle("display", "block");
		this.link.innerHTML = this.txtclose;
		this.isopen = true;
	},
	toggle: function() {
		this.isopen ? this.close() : this.open();
	}
});

window.addEvent("domready", function() {
	$$(".box").each(function(box) {
		if(box.id == "latest") return;
		new Box(box, false);
	});
});