var IE = document.all? 1: 0;
var interval = IE? 20: 8;
var time = IE? 1: 10;

function collapse( div, swap1, swap2, arrow )
{
	if( div.length )
		div = document.getElementById(div);
	if (div.animation)
		window.clearInterval(div.animation); 
	arrow.innerHTML = "&#43;";
	div.animation = window.setInterval(
	function() { 
		div.style.height = (div.clientHeight - interval) + "px";
		if( div.clientHeight - interval <= 1 ){
			div.style.height = "1px";
			window.clearInterval(div.animation);
			div.style.display = "none";
			div.parentNode.style.marginBottom = "5px";
			swap1.style.backgroundImage = "url(graphics/navTitleL1.png)";
			swap2.style.backgroundImage = "url(graphics/navTitleR1.png)";
		}
	} 
	,time);
}

function expand( div, max, swap1, swap2, arrow )
{	
	if( div.length )
		div = document.getElementById(div);
	if (div.animation)
		window.clearInterval(div.animation);

	arrow.innerHTML = "&#8722;";
	div.style.display = "block";
	swap1.style.backgroundImage = "url(graphics/navTitleL2.png)";
	swap2.style.backgroundImage = "url(graphics/navTitleR2.png)";
	div.animation = window.setInterval(
	function() { 
		div.style.height = (div.clientHeight + interval) + "px";
		if( div.clientHeight + interval >= max ){
			div.style.height = max + "px";	
			window.clearInterval(div.animation);
		}
	} 
	,time);
}

function isExpanded( div )
{
	if( div.getAttribute('direction') == "up" ){
		div.setAttribute('direction', "down");
		return true;
	}
	else{
		div.setAttribute('direction', "up");
		return false;
	}
}

function animateList( parent, div, max, swap1, swap2, arrow )
{
	if(isExpanded(parent)) {
		writeCookie( div.charAt(7), "false" );
		collapse(div, swap1, swap2, arrow);
	}
	else {
		writeCookie( div.charAt(7), "true" );
		expand(div, max, swap1, swap2, arrow);
	}
}

function writeCookie( number, truth )
{
	document.cookie = number + "=" + truth;
}
	