var growingArray = new Array;

function grow (id, s) {
	if (growingArray[id]) {
		growingArray[id].stopGrow();
		growingArray[id].s = s;
	}
	else {
		growingArray[id] = new Growable(id, s);
	}
	growingArray[id].startGrow();
}

function execInterval (id) {
	growingArray[id].timer = setInterval("growingArray['"+id+"'].execGrow()", 1);
}

function Growable (id, s) {
	this.id = id;
	this.elt = document.getElementById(id);
	this.s = s;
	this.timer = null;
	this.execGrow = function (){
				if (this.s == parseInt(this.elt.style.height)) {
					this.elt.style.height = this.s+"px";
					clearInterval(this.timer);
					this.timer = null;
					return;
				}
				else if (this.s > parseInt(this.elt.style.height)) {
					this.elt.style.height = (parseInt(this.elt.style.height) + 1)+"px";
				}
				else if (this.s < parseInt(this.elt.style.height)) {
					this.elt.style.height = (parseInt(this.elt.style.height) - 1)+"px";
				}
			};
	this.startGrow = function () {
				if (this.timer != null)
					clearInterval(timer);
				execInterval(this.id);
			}
	this.stopGrow = function () {
				if (this.timer != null)
					clearInterval(this.timer);
				this.timer = null;
			}
}

