/*
	divSwap:		Tab swapping class
	@author: 		Josh Vandergrift
	@uses:			prototype.js
*/

var divSwap = Class.create({

	currentShowing : null,

	initialize : function(container, shownId){
		divSwap.currentShowing = $(shownId);
		this.container = container || false;
		this._attachEvents();
	},

	showSection : function(){
		divToShow = this.readAttribute('rel');

		if (divSwap.currentShowing != null) {
			divSwap.currentShowing.hide();
			$$('ul.swap li a.selected')[0].removeClassName('selected');
		}
		$(divToShow).show();
		divSwap.currentShowing = $(divToShow);
		this.addClassName('selected');
		return false;
	},

_attachEvents : function() {
if (this.container) {
var links = this.container.childElements();
links.each(function(li){
var link = li.down();
Event.observe(link, 'click', this.showSection.bind(link));
}.bind(this));
}
}

});