// JavaScript Document
var Tabs = Class.create(
	{
		initialize:function(ele,options){
			this.ele=$(ele);
			this.tabs = this.ele.select(".tabbutton a").map(function(e){
				e.onclick=function(){e.blur();return false}
				e.observe("click",function(){
					this.ele.select(".tabbutton.selected").invoke("removeClassName","selected");
					e.up(".tabbutton").addClassName("selected");
					this.update();
					
				}.bind(this));
				return $(String(e.href).sub(/^.*#/,''))
			}.bind(this));
			this.update();
		},
		update:function(){
			this.tabs.invoke("hide");
			this.ele.select(".tabbutton.selected a").each(
				function(e){
					$(String(e.href).sub(/^.*#/,'')).show();
				}
			);
		}
	}
);
document.observe("dom:loaded",function(){
	$$(".tabs").each(function(e){new Tabs(e)});									   
})

