// slide.js
// written by Gary Von Schilling

var speed = 8;		
var object = null;		
var h = null;			/* h stands for object's height*/
var minH = 22;
var maxH = 220;
var animating = false;

function setPanel (objectID) {

	if (animating == false)		/* Prevent new animations from starting if an animation is running */
	{
		object = document.getElementById(objectID);
		h = object.offsetHeight; 
		/*alert("Initial height: "+h);*/
		
		if (h > minH)
			animateClose (h, minH);
		else
			animateOpen (minH, object.style.max_height);
	}
}

function animateClose (startH, endH) {
	
	animating = true;
	object.style.max_height = h;
	
	if (endH < startH)	{
		/*alert("in closing loop");*/
		startH -= speed;
		object.style.height = startH +"px";
		setTimeout("animateClose(" + startH +","+ endH +")", 0);
	} else { 
		object.style.height=minH+"px";
		/*alert("Ending Height: "+object.style.height);*/
		animating = false;
		return;
	}
}

function animateOpen (startH, endH) {
	//alert("in opening function");
	animating = true;

	if (endH == undefined)			
		endH = maxH;			// If the original height is not found, use max height as a fail safe.

	if (object.offsetHeight < endH) {
		startH += speed;
		object.style.height = startH +"px";
		setTimeout("animateOpen(" + startH +","+ endH +")", 0);
	}
	else { 
		object.style.height = object.style.max_height+"px";
		/*alert("Ending Height: "+object.style.height);*/
		animating = false;
		return;	}
	/*object.style.height= endH+"px";*/
}

function quickHide(objectID) {
	/* Use this to hide a panel right away*/	
	object = document.getElementById(objectID);
	h = object.offsetHeight; 
	object.style.max_height = h;
	object.style.height=minH+"px";
}
