var tabMaker = new Class({

	Implements: [Events, Options],
	options: {
		callBackFunc: ''
	},
	
	classNameToSearch: '',
	
	initialize: function(className, options) {
		
		this.setOptions(options);

		this.classNameToSearch = className;

		this.createTabs();

	},
	createTabs: function(){
		
		var root = this;
		
		// search for any tabs that might exist within divs with a className of this.classNameToSearch
		$$('div[class='+this.classNameToSearch+']').each(function(e){
			
			// firstly, hide all other tab content holders.
			root.hideAllHolders(e);
			
			// now, show the first holder.
			e.getElement('div.'+root.classNameToSearch+'-holder').setStyle('display','block');
			
			// connect tabs to their associated holders.
			var tabList = e.getElement('ul');
			tabList.getElements('li').each(function(i){
				i.addEvent('click', function(evt){
					if(this.id){
						root.resetTabStates(e);
						root.hideAllHolders(e);
						root.showTab(this.id);
						root.showHolder(this.id);
					}
				});
			});
			
		});
	
    },
	resetTabStates: function(e){
		var tabList = e.getElement('ul');
		tabList.getElements('li').each(function(i){
			i.set('class','off');
		});
	},
	hideAllHolders: function(parent){
		var root = this;
		parent.getElements('div.'+root.classNameToSearch+'-holder').each(function(i){
			i.setStyle('display','none');
		});
	},
	showTab: function(id){
		$(id).set('class','on');
	},
	showHolder: function(id){
		if($defined($(id+'-holder'))){
			$(id+'-holder').setStyle('display','block');
		}
	}
});
