var detailBox = {
	codes : Array,
	init : function() {
		detailBox.codes = document.getElementsByClassName('tab');
		detailBox.attach();
	},
	attach : function() {
		var i;
		for ( i=0;i<detailBox.codes.length;i++ ) {
			Event.observe(detailBox.codes[i],'click',detailBox.collapse,false);
			Element.cleanWhitespace(detailBox.codes[i].parentNode);
		}
	},
	getEventSrc : function (e) {
		if (!e) e = window.event;
		if (e.originalTarget)
			return e.originalTarget;
		else if (e.srcElement)
			return e.srcElement;
	},
	collapse : function(e) {
		var el = detailBox.getEventSrc(e).nextSibling;
		
		// show the one that was clicked
		var bg = detailBox.getEventSrc(e).style.backgroundImage;
		if (bg.indexOf("minus.jpg") > -1) {	// if they clicked the one that was already open, hide it
			detailBox.getEventSrc(e).style.backgroundImage = "url(../includes/images/listings/details-plus.jpg)";
		} else {
			detailBox.getEventSrc(e).style.backgroundImage = "url(../includes/images/listings/details-minus.jpg)";
		}
		
		Effect.toggle(el.id,'slide', {duration:0.2});
	}
};

// ATTACH ONCLICK EVENT TO ALL ELEMENTS WITH THE l-item CLASS
Event.observe(window,'load',detailBox.init,false);
