function Tabber(tabberID)
{
	// ID
	this.tabberID = tabberID;
	this.prevent = false;

	// Functions
	this.build = TabberBuild;
	this.buildEvents = TabberBuildEvents;
	this.preventPress = TabberPreventPress;
	this.tabPress = TabberPress;
	this.tabUnpress = TabberUnpress;
}
function TabberBuild()
{
	if(this.anchorID==undefined)
		this.anchorID = false;
	if(this.pressed==undefined)
		this.pressed = false;
	if(this.url==undefined)
		this.url = false;

	contID = document.getElementById(this.tabberID);
	contID.className = this.disable?'tabberDisable':'tabber';

	if(contID.hasChildNodes())
	{
		this.children = contID.childNodes;
		for(var i=0;i<this.children.length;i++) 
		{
			if(this.children[i].nodeName!='LI')
			{
				contID.removeChild(contID.childNodes[i]);
				continue;
			}
		}
		for(var i=0;i<this.children.length;i++) 
		{
			if((this.pressed==false && i==0) || this.children[i].id==this.pressed)
				this.tabPress(this.children[i]);
			else
				this.tabUnpress(this.children[i]);
		}
	}
	if(!this.disable)
		this.buildEvents();
}
function TabberBuildEvents()
{
	var tbr=this;
	for(var i=0;i<this.children.length;i++) 
	{
		if(this.children[i].id!=this.pressed)
			this.children[i].onclick = function(){TabberOnClick(this.id,tbr)};
		else
			this.children[i].onclick = null;
	}
}
function TabberOnClick(id,tbr)
{
	tbr.tabUnpress(document.getElementById(tbr.pressed));
	tbr.pressed = id;
	tbr.tabPress(document.getElementById(id));
	tbr.buildEvents();
	if(tbr.anchorID!=false)
		$('html, body').scrollTop($('#'+tbr.anchorID).offset().top);
}
function TabberPress(tab)
{
	if(this.prevent)
	{
		this.prevent = false;
		return false;
	}
	if(!this.disable && !this.url)
		$('[id='+this.tabberID+'_'+tab.id+']').show();
	$('[id='+tab.id+']').addClass('pressed');
	this.pressed = tab.id;
}
function TabberPreventPress()
{
	this.prevent = true;
}
function TabberUnpress(tab)
{
	if(!this.disable && !this.url)
		$('[id='+this.tabberID+'_'+tab.id+']').hide();
	if(tab.id!='')
		$('[id='+tab.id+']').removeClass('pressed');
}
