﻿	var last_id = 1;
	var tid = 0;
	var	dif = 10;
	var heightC;
	var	next_id;
		
	height = new Array();

	function do_slide (dir) {
		var div = document.getElementById("t" + last_id);

		if (dir == 0) {
			div.style.display = 'none';
			heightC=0;
			if (tid != 0) {
				clearInterval (tid);
				tid = 0;			
			}				
		} else if (dir > 0 && heightC < height[last_id]) {		
			heightC += dif;
			div.style.height= heightC + 'px';
			if (heightC == dif)	{
				div.style.display = 'block';
			}
		} else if (dir < 0 && heightC >= dif) {
			heightC -= dif;
			div.style.height= heightC + 'px';
			if (heightC <= dif)	{
				div.style.display = 'none';
			}
		} else {
			if (tid != 0) clearInterval (tid);
			tid = 0;			
			if (dir < 0) {
				last_id = next_id;
				showtab(last_id);
			}
		}			
	}
	
	function showtab (no) {
		if (no < 0) {
			for (i = 1; i < -no; i++) {
				height[i] = document.getElementById("t" + i).clientHeight
				if (i != 1)	document.getElementById("t" + i).style.display = 'none';
			}
		} else if (tid == 0) {
			if (last_id != no) {
				heightC = height[last_id];
				dif = heightC / 20;
				tid = setInterval ("do_slide(-1)", 1);
				next_id = no;
			} else {
				last_id = no;
				dif = height[last_id] / 50;			 				
				heightC = 0;
				tid = setInterval ("do_slide(1)", 1);
			}
		}
	}
	