function Tabber(tabberID)
{
	// ID
	this.tabberID = tabberID;
	
	// Functions
	this.build = TabberBuild;
	this.buildEvents = TabberBuildEvents;
	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)
	{
		var pos;
		pos = TabberAnchorPos(tbr.anchorID);
		self.scrollTo(pos.x, pos.y);
	}
}
function TabberPress(tab)
{
	if(!this.disable && !this.url)
		showByID(this.tabberID+'_'+tab.id);
	tab.className = 'pressed';
	this.pressed = tab.id;
}
function TabberUnpress(tab)
{
	if(!this.disable && !this.url)
		hideByID(this.tabberID+'_'+tab.id);
	tab.className = '';
}
function TabberAnchorPos(anchorname)
{
	// This function will return an Object with x and y properties
	var useWindow = false;
	var coordinates = new Object();
	var x = 0, y = 0;

	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById)
		use_gebi = true;
	else if (document.all)
		use_css = true;
	else if (document.layers)
		use_layers = true;

	// Logic to find position
 	if (use_gebi && document.all)
	{
		x = TabberAnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y = TabberAnchorPosition_getPageOffsetTop(document.all[anchorname]);
	}
	else if (use_gebi)
	{
		var o = document.getElementById(anchorname);
		x = TabberAnchorPosition_getPageOffsetLeft(o);
		y = TabberAnchorPosition_getPageOffsetTop(o);
	}
 	else if (use_css)
	{
		x = TabberAnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y = TabberAnchorPosition_getPageOffsetTop(document.all[anchorname]);
	}
	else if (use_layers)
	{
		var found=0;
		for (var i=0; i<document.anchors.length; i++)
		{
			if (document.anchors[i].name==anchorname)
			{
				found=1;
				break;
			}
		}
		if (found==0)
		{
			coordinates.x = 0;
			coordinates.y = 0;
			return coordinates;
		}
		x = document.anchors[i].x;
		y = document.anchors[i].y;
	}
	else
	{
		coordinates.x = 0;
		coordinates.y = 0;
		return coordinates;
	}
	coordinates.x = x;
	coordinates.y = y;
	return coordinates;
}

// Functions for IE to get position of an object
function TabberAnchorPosition_getPageOffsetLeft (el)
{
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null)
	{
		ol += el.offsetLeft;
	}
	return ol;
}
function TabberAnchorPosition_getWindowOffsetLeft (el)
{
	return TabberAnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}	
function TabberAnchorPosition_getPageOffsetTop (el)
{
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null)
	{
		ot += el.offsetTop;
	}
	return ot;
}
function TabberAnchorPosition_getWindowOffsetTop (el)
{
	return TabberAnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}