
	var Tabs = Class.create({
		
		initialize: function(id, prefix, postfix, closeall, def) {
		
			this.target = $(id);
			
			if (!this.target) 
				return false;
			else
				var p = this;

			
			// init variables
			//
			this.sel 		= 0;
			this.tabs		= new Array();
			
			// childs
			//
			var re 			= new RegExp(prefix+'[0-9]+$','i');

			_d.allChildElements(this.target).each(function(s) {
				if (s.id.match(re)) p.tabs.push(s.id);
			});
			
			
			// params
			//
			this.postfix	= postfix;
			this.def 		= (this.tabs[def]) ? def : 0;
			this.closeall 	= (typeof(closeall) == 'boolean') ? closeall : false;	

			
			// set default viewport
			//
			this.tabs.each(function(s) {
				$(s).observe('click', p.select.bindAsEventListener($(s), p), false );
				if ($(s+postfix)) $(s+postfix).hide();
			});
			
			this.target.show();

			this.select(this.tabs[this.def]);
			
		},

		
		select: function(n, p) {

			if (typeof(n) == 'object') n = this.id;
			if (!p) p = this;
			
			if (p.sel) {
				$(p.sel).removeClassName('current');
				$(p.sel+p.postfix).hide();
			}

			if (p.sel == n && p.closeall) {
				p.sel = null;

			} else {
				$(n).addClassName('current');
				$(n+p.postfix).show();

				p.sel = n;
			}
			
		}

		
	});

