/*	Expanding Menus for Indexhibit
 *		uses jquery
 *
 *	Created by Ross Cairns  Mar 2008
*/

function textboxHeight() {

	var textsize = $('#textbox').height();
	var menusize = $('#menu').height();
	
	if(textsize < 126) textsize = 126;
	
	if (textsize > menusize) {
		$('#menu').height(textsize);
	} else {
		$('#menu').height(menusize);
	}
}



function accordion_li() {
	var speed = 100;
	$("#menu ul li").addClass("nav");
	$("#menu ul li.section-title").css({cursor:"pointer"});
	
	$('#menu ul li').hide(); // hide all unordered lists inside the accordion list
	$('#menu ul:eq(0) li:eq(0)').show(); //show the first unordered list inside the accordion
	$('#menu ul:eq(1) li:eq(0)').show(); //show the first unordered list inside the accordion
	$('#menu ul:eq(2) li:eq(0)').show(); //show the first unordered list inside the accordion
  
	$('#menu').find("li.active").prevAll(".nav").nextAll(".nav").show(speed); // show the active category
	
  
	$('#menu ul li.section-title').click(function() {
		var checkElement = $(this).next();
		var thisElement = $(this);
		
		if((checkElement.is('li')) && (checkElement.is(':visible'))) { //if you click on an unordered list and this list is opened (visible)
			// return false; nothing happens
			thisElement.next().toggle(speed);
			checkElement.nextAll('.nav').toggle(speed);
		}
		
		if((checkElement.is('li')) && (!checkElement.is(':visible'))) { //if you click on an unordered list and this list is not opened (visible)
			//$('#menu li:visible').slideUp('normal'); // the list that is visible will close (slideUp)
			//checkElement.slideDown('normal'); //the list you clicked will open (slideDown)
			//checkElement.toggle(speed);
			thisElement.next().toggle(speed);
			checkElement.nextAll('.nav').toggle(speed);
		}
	});
}


function accordion_div() {
	var speed = 100;
	$("#menu ul li").addClass("nav");
	$("#menu div.section-title0").css({cursor:"pointer"});
	$("#menu div.section-title1").css({cursor:"pointer"});
	$("#menu div.section-title2").css({cursor:"pointer"});

	$('#menu ul').hide();	// hide all unordered lists inside the accordion list
	$('#menu ul:has(li.active)').show(speed); // show the active category
	
	$('#menu div.section-title0').click(function() {
		$('#menu div.section1 ul').hide();
		$('#menu div.section2 ul').hide();
		$('#menu div.section0 ul').toggle(speed);
	});
	
	$('#menu div.section-title1').click(function(speed) {
		$('#menu div.section0 ul').hide();
		$('#menu div.section2 ul').hide();
		$('#menu div.section1 ul').toggle(speed);
	});
	
	$('#menu div.section-title2').click(function() {
		$('#menu div.section0 ul').hide();
		$('#menu div.section1 ul').hide();
		$('#menu div.section2 ul').toggle(speed);
	});
}


  
$(document).ready(function() {
	//accordion_li();
	accordion_div();
}); //when the document is ready to load the script it iniciates the function

