var visual = {
	changeHeight: function(node, y) {
		this.Height += y;
		node.style.height = this.Height + 'px';
		if(y > 0) {
			if(this.Height >= this.h) {
				clearInterval(this.hFlag);
				node.style.height = this.h + 'px';
			}
		}
		else if(this.Height <= this.h) {
			clearInterval(this.hFlag);
			node.style.height = this.h + 'px';
		}
        },
	champTables: function(e, node, speed) {
		e = e || window.event;
		var div = node.parentNode.parentNode;
		this.Height = div.clientHeight;
		if(typeof this.realHeight == 'undefined') this.realHeight = this.Height;
		this.h = div.getElementsByTagName('table')[0].clientHeight + 20;
                var tmpObj = this;
		if(node.firstChild.nodeValue == 'скрыть таблицу') {
			this.h = this.realHeight;
			this.hFlag = setInterval(function() { tmpObj.changeHeight(div, -speed) }, 1);
			node.firstChild.nodeValue = 'вся таблица';
			node.nextSibling.nodeValue = '\u00A0\u2193';
		}
		else {
			this.hFlag = setInterval(function() { tmpObj.changeHeight(div, speed) }, 1);
			node.firstChild.nodeValue = 'скрыть таблицу';
			node.nextSibling.nodeValue = '\u00A0\u2191';
		}
		if(typeof e.preventDefault != 'undefined') e.preventDefault();
		else e.returnValue = false;
		return false;
	},
	init: function() {
		this.champTables.init = function(speed) {
			var node = document.getElementsByClassName('down');
			var tmpFunc = function(e) { visual.champTables(e, this, speed); };
			var i = node.length;
			while(i--) {
				addEvent(node[i].firstChild, 'click', tmpFunc);
			}
		};
	}
};
visual.init();