function tabs(args) {
	var index, halt;

	build();

	if (args.type == "slider")
		timer_halt_start();

	function build() {
		var input;
		if ($(args.labels).is("option")) 
			input = $(args.labels).parent().find("option:selected");
		else
			input = $(args.labels).find(":checked");

		index = Number(input.attr("class"));
		$(args.labels[index-1]).addClass("selected");

		if (args.type == "slider") {
			var css = {}
			css['width'] = ((args.labels.length) * TVBLOCK_WIDTH) + "px";
			css[TVBLOCK_DIRECTION] = ((index -1) * TVBLOCK_WIDTH) + "px";

			$(args.stack).css(css);
		}
		else {
			$(args.tabs).hide();
			if (args.tabs[index-1])
				$(args.tabs[index-1]).show();
		}

		$("select[name='" + args.name + "']").change(function() {
			go($(this).find("option:selected").attr("class"));
		});

		if ($.browser.msie) {
			/* IE bug fix. see http://stackoverflow.com/questions/208471#1080243 */
			$("input[name='" + args.name + "']").click(function() {
				this.blur();
				this.focus();
			});
		}
		$("input[name='" + args.name + "']").change(function() {
			go(this.className);
		});

		if (args.prev) {
			$(args.prev).click(function() {
				if (index > 1)
					go(index - 1);
			});
		}
		if (args.next) {
			$(args.next).click(function() {
				if (index < args.labels.length)
					go(index + 1);
			});
		}
	}

	function timer_halt_start() {
		halt = setTimeout(function(){go(index + 1)}, args.times.halt);
	}
	function timer_halt_stop() {
		clearTimeout(halt);
	}
	function slide(str) {
		var properties;
		if (TVBLOCK_DIRECTION == "right")
			properties = {"right": str}
		else
			properties = {"left": str}

		$(args.stack).animate(properties, args.times.slide, "linear", timer_halt_start);
	}
	function go(i) {
		i = Number(i);

		if (args.type == "slider") {
			timer_halt_stop();

			if (i >= args.labels.length + 1) {
				var distance = 0;
				str = "0px";
				i = 1;
			}
			else {
				if (i < 1)
					i = 5;

				var distance = i - index;

				if (distance > 0)
					str = "+="+ (distance * TVBLOCK_WIDTH) +"px";
				else {
					str = "-="+ ((distance * TVBLOCK_WIDTH) * -1) +"px";
				}
			}
			slide(str);
		}
		else if (args.functions) {
			if (args.tabs[index-1])
				args.functions.hide($(args.tabs[index-1]));
			if (args.tabs[i-1])
				args.functions.show($(args.tabs[i-1]));
		}
		else {
			if (args.tabs[index-1])
				$(args.tabs[index-1]).hide();
			if (args.tabs[i-1])
				$(args.tabs[i-1]).show();
		}

		$(args.labels[index-1]).removeClass("selected");
		$(args.labels[i-1]).addClass("selected");

		$(args.labels[index-1]).find("input").attr("checked", "");
		$(args.labels[i-1]).find("input").attr("checked", "checked");

		index = i;
	}
}
