function hide(y)
{
	for (i=0; i<y+1; ++i)
	{
		el = "panel"+i;
  		document.getElementById(el).style.display = 'none';
	}
}

var openPanel = 0;

function show(x,y)
{
	hide(y);
	openPanel = x;
	el = "panel"+x;
  	document.getElementById(el).style.display = 'block';
		
	if (document.getElementById('more'+x) != null) {
		document.getElementById('more'+x).innerHTML = "<em>Close</em>";
	}
}

num = 0;
width = 646;
playing = 1;

function moveSlide(x,y)
{
	thisNum = y-1;
	if(num < thisNum)
	{
		num = num+1;
	}
	else
	{
		num = 0;
	}
	
	for (i=0; i<y; ++i)
	{
		document.getElementById('circle'+i).style.backgroundPosition = "0 0";
	}
	document.getElementById('circle'+num).style.backgroundPosition = "0 -12px";
	document.getElementById(x).style.backgroundPosition = "-" + num*width + "px 0";
	//moveEm = setTimeout("moveSlide('slideShow',"+y+")",5000);
}

function moveToSlide(x,y,z)
{
	for (i=0; i<z; ++i)
	{
		document.getElementById('circle'+i).style.backgroundPosition = "0 0";
	}
	//clearTimeout(moveEm);
	clearTimeout(grow);
	document.getElementById('circle'+y).style.backgroundPosition = "0 -12px";
	document.getElementById(x).style.backgroundPosition = "-" + y*width + "px 0";
	playing = 0;
	num = y;
	document.getElementById('pause').style.backgroundPosition = "0 -11px";	
	document.getElementById('progressBar').style.width = "0";		
}

function pauseSlide(x,y)
{
	if (playing == 1)
	{
		//clearTimeout(moveEm);
		clearTimeout(grow);
		playing = 0;
		document.getElementById('pause').style.backgroundPosition = "0 -11px";
		document.getElementById('progressBar').style.width = "0";	
	}
	else
	{
		for (i=0; i<y; ++i)
		{
			document.getElementById('circle'+i).style.backgroundPosition = "0 0";
		}
		moveSlide(x,y);
		len = 6;
		progressBar();
		playing = 1;
		document.getElementById('pause').style.backgroundPosition = "0 0";
	}
}

var len = 6;
function progressBar(x)
{
	if(len < 646)
	{
		len = len+8;
	}
	else
	{
		moveSlide('slideShow',x)
		len = 6;
	}
	document.getElementById('progressBar').style.width = len+"px";
	grow = setTimeout("progressBar("+x+")",75);
}
