function TabManager( id ) {
	this.jump = false;
	this.id = id;
	this.activated = false;
	TabManager.managers.push(this);

	var fdiv = document.getElementById(id);
	if (!fdiv) return;

	this.div = fdiv;

	var liList = this.div.getElementsByTagName("LI");

	this.tabs = new Array(); this.tabRights = new Array();

	var count = -1;
	for(var i = 0; i < liList.length; i++) {
		var li = liList[i];
		// check for known list items
		switch(li.className) {
			case "i":
			case "ii":
			case "ia":
			case "ai":
			case "a":
				li.manager = this;
				li.tabNum = ++count;

				li.onclick = this.clicked;
				li.onselectstart = this.selectStart;
				li.mousedown = this.selectStart;
				this.tabs.push(li);
				break;
			default:
				// unknown list item
		}
	}
}
TabManager.prototype.setDivData = function( tab1, tab2, tab3 ) {
	var d = document.getElementById("content_" + this.id);
	if (!d) return;

	this.contentDiv = d;
	this.tabDivsIds = new Array();
	this.tabDivsIds[0] = tab1;
	this.tabDivsIds[1] = tab2;
	this.tabDivsIds[2] = tab3;
}
TabManager.prototype.setUgrabugra = function(jump) {
	this.jump = jump;
}
TabManager.prototype.isIE = function() {
	return (navigator.userAgent.indexOf("MSIE") != -1 ? true : false);
}
TabManager.prototype.initialize = function() {
	if (this.contentDiv) {
		this.tabDivs = new Array();
		for(var i = 0; i < this.tabDivsIds.length; i++) {
			var did = this.tabDivsIds[i];
			this.tabDivs[i] = document.getElementById(did);
		}
	}

	if (this.tabDivs && this.tabDivs.length) {
		if (this.tabDivs[0] && this.jump == false) {
			var maxHeight = 0;
			for (var i = 0; i < 3; i++) {
				if (this.tabDivs && this.tabDivs[i]) {
					this.tabDivs[i].style.width = this.contentDiv.clientWidth + "px";
					if (this.tabDivs[i].scrollHeight > maxHeight) maxHeight = this.tabDivs[i].scrollHeight;
				}
			}
			if (!this.isIE()) maxHeight -= 9; else maxHeight -= 5;
			this.contentDiv.style.height = maxHeight + "px";
		}
	}
}
TabManager.prototype.selectStart = function() { return false; }
TabManager.prototype.clicked = function( e ) {
	var tgt;
	if (window.event) {
		tgt = this;
	} else {
		tgt = e.currentTarget;
	}
	return tgt.manager.activate(tgt.tabNum);
}
TabManager.prototype.activateTabById = function( id ) {
	for(var i = 0; i < this.tabs.length; i++) {
		var item = this.tabs[i];
		if (item.id == id) {
			this.activate(i)
			return true;
		}
	}
}
TabManager.prototype.setTabClass = function( num, active ) {
	if (num < 0 || num >= this.tabs.length) return;
	switch(active) {
		default:
		case -1:
			if (num == 0) this.tabs[num].className = "i";
			else this.tabs[num].className = "ii";
			break;
		case 0:
			if (num == 0) this.tabs[num].className = "a";
			else this.tabs[num].className = "ia";
			break;
		case 1:
			this.tabs[num].className = "ai";
			break;
	}
}
TabManager.prototype.activate = function( num ) {
	this.activated = true;
	for (var i = 0; i < this.tabs.length; i++) {
		if (i == num) {
			this.setTabClass(i, 0);
			this.setTabClass(i - 1, -1);
			this.setTabClass(i + 1, 1);
		} else if ((i < (num - 1)) || (i > (num + 1))) {
			this.setTabClass(i, -1);
		}
	}

	if (this.contentDiv) {
		this.contentDiv.innerHTML = "";
		if (this.tabDivs[num]) this.contentDiv.innerHTML = this.tabDivs[num].innerHTML;
		return false;
	}

	return true;
}
TabManager.managers = new Array();

