var maxHeight = 0;
var curHeight = 0;
var grow = true;
var working = false;

function setcss() {
	left=document.getElementById("topleft").offsetLeft;
	right=document.getElementById("topright").offsetLeft;
	width=right-left-61;
	document.getElementById("topbackground").style.width=width+"px";
	right=document.getElementById("bottomright").offsetLeft;
	document.getElementById("bottombackground").style.width=right-28+"px";
	document.getElementById("all").style.visibility="visible";
}


function collapse (div)
{
sfunction = 'collapse(\'' + div + '\');';
	if (grow) {
		document.getElementById (div).style.visibility="visible"
		if (curHeight < maxHeight)
		{
			curHeight += 5;
			document.getElementById(div).style.height = curHeight + "px";		
			setTimeout (sfunction, 10);
		}
		else
			working = false;
	}
	if (!grow)
		if (curHeight > 0)
		{
			curHeight -= 5;
			document.getElementById(div).style.height = curHeight + "px";
			setTimeout (sfunction, 10);
		}
		else {
			working = false;
			document.getElementById (div).style.visibility="hidden";
			document.getElementById (div).style.height="0px";
		}
}

function toggleDiv(div)
{
	curHeight = parseInt(document.getElementById(div).style.height);
	if (document.getElementById(div).style.visibility=="visible") grow=false;
	else { 
	document.getElementById(div).style.height = "";
	maxHeight = document.getElementById(div).offsetHeight;
	document.getElementById (div).style.height="0px"; grow=true; }
	if (! working)
	{
		working = true;
		collapse (div);
	}
}

window.onresize=setcss; 

