function changePage(){
	var page = document.getElementById('newPage').value; 
	var catForm = document.getElementById('catForm')
	var display = document.getElementById('displayPages').value;
	
	//if the enter a page number and are in thumbnail view change them to single page view
	if (display == 3)
		display = 1;
		
	catForm.action="/catalog/" + page + "/" + display + "/";	
	catForm.submit(); 
}

function newPage(page,direction){
	var catForm = document.getElementById('catForm')
	var display = document.getElementById('displayPages').value;
	
	if (display == 2 && direction == 'P')
		page = page - 2;
		
	if (display == 2 && direction == 'N')
		page = page + 2;
		
	if (page < 3) 
		page = 3;
		
		
	catForm.action="/catalog/" + page + "/" + display + "/";	
	catForm.submit(); 
}

function pageLink(page,menu, menuStatus, display){
	var catForm = document.getElementById('catForm')
	var display = document.getElementById('displayPages').value;
	catForm.action="/catalog/" + page + "/" + "/1/";	
	catForm.submit(); 
}

function displayType(display) {
	var catForm = document.getElementById('catForm')
	var page = document.getElementById('newPage').value; 
	catForm.action="/catalog/" + page + "/" + display;	
	catForm.submit(); 

}



var ContentHeight = 200;
var accord1Height = 200;
var accord2Height = 550;
var accord3Height = 90;
var accord4Height = 620;
var accord5Height = 100;
var accord6Height = 100;
var accord7Height = 100;
var accord8Height = 475;
var accord9Height = 100;
var menuStatus = 0;
var openMenu = 0;
var displayPages = 0;




var TimeToSlide = 250.0;

var openAccordion = '';

function runAccordion(index)
{
  ContentHeight = divHeight(index);
  var nID = "Accordion" + index + "Content";
  var startOpenMenu = openMenu;
  if(openAccordion == nID)
    nID = '';
        
  setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'" 
      + openAccordion + "','" + nID + "')", 33);
  
  openAccordion = nID;
  openMenu = index;
  
}


function animate(lastTick, timeLeft, closingId, openingId)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  
  var opening = (openingId == '') ? null : document.getElementById(openingId);
  var closing = (closingId == '') ? null : document.getElementById(closingId);
  
  if (opening == null)
  	openMenu = 0;
 
  if(timeLeft <= elapsedTicks)
  {
    if(opening != null)
      opening.style.height = ContentHeight + 'px';
    
    if(closing != null)
    {
      closing.style.display = 'none';
      closing.style.height = '0px';
    }
    return;
  }
 
  timeLeft -= elapsedTicks;
  var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);

  if(opening != null)
  {
    if(opening.style.display != 'block')
      opening.style.display = 'block';
    opening.style.height = (ContentHeight - newClosedHeight) + 'px';
  }
  
  if(closing != null)
    closing.style.height = newClosedHeight + 'px';

  setTimeout("animate(" + curTick + "," + timeLeft + ",'" 
      + closingId + "','" + openingId + "')", 33);
}

function divHeight(index)  {
  var myHeight = ContentHeight;
  if (index == 1) 
  	myHeight = accord1Height;

  if (index == 2) 
  	myHeight = accord2Height;

  if (index == 3) 
  	myHeight = accord3Height;

  if (index == 4) 
  	myHeight = accord4Height;

  if (index == 5) 
  	myHeight = accord5Height;

  if (index == 6) 
  	myHeight = accord6Height;

  if (index == 7) 
  	myHeight = accord7Height;

  if (index == 8) 
  	myHeight = accord8Height;
  	
  if (index == 9) 
  	myHeight = accord9Height;
  	
  	
  return myHeight;
}


function hideSideNav()  {
	//document.getElementById('sideTableOfContents').style.visibility="hidden";
	document.getElementById('sideTableOfContents').style.display="none";
	//document.getElementById('sideTableOfContents').style.width = "0px";
	document.getElementById('menuDiv').innerHTML = "<span id=\"menuControl\" onclick=\"showSideNav()\">Show Menu</span>";
	menuStatus = 0;	

}

function showSideNav() {
	//document.getElementById('sideTableOfContents').style.width = "250px";
	//document.getElementById('sideTableOfContents').style.visibility="visible";
	document.getElementById('sideTableOfContents').style.display="block";
	//document.getElementById('sideTableOfContents').style.width = "250px";
	document.getElementById('menuDiv').innerHTML = "<span id=\"menuControl\" onclick=\"hideSideNav()\">Hide Menu</span>";
	menuStatus = 1;
}

function init()  {
	var sideMenu = document.getElementById('hideMenu').value;
	if (sideMenu == 0)
		hideSideNav();

}

function setOpenMenu(index)  {
	openMenu = index;
	menuStatus = status;
}

function setHideMenu(status)  {
	menuStatus = status;
}




