$(document).ready(function(){
	
	// --------------------- GLOBAL
	
	//Give show/hide functionality to buttons
	$('.show-hide-button').toggle(
		      function () {
				linkText = $(this).html();
				$(this).html(linkText + " (hide)")
				$(this).nextAll('.show-hide-content:first').show();
		      },
		      function () {
				$(this).html(linkText);
		        $(this).nextAll('.show-hide-content:first').hide();
		      }
		);
		
	
	// --------------------- LESSONS
  if ($('.col-single #lessons').length) {
		$('#lessons .lesson-section').hide();
		$('#lessons .lesson-section-title').hide();
		if (document.getElementById("hdTerm").value=="")
		  $('#lessons .lesson-section:first').show();
		else{
		  $('#lessons .lesson-section').hide();
		  $('#lessons #lessons-list-paragraph').hide();
		  $('#display_glossary').show();
		}
		$('#lessons #lessons-list-title').text($('#lessons .lesson-section:visible').find('.lesson-section-title').text()+" Lessons");
		if (document.getElementById("lessons-list-title").innerHTML==" Lessons")
		  $('#lessons #lessons-list-title').text($('#lessons .lesson-section:visible').find('.lesson-section-title').text()+" Glossary");
	
		$('#lesson-section-select a').click(function(){
	
			$('#lessons .lesson-section').hide();
			$('#display_'+$(this).attr('id')).show();
				
			//add by klu
			if ($(this).attr('id')=='glossary'){
			    $('#lessons #lessons-list-title').text($('#lessons .lesson-section:visible').find('.lesson-section-title').text()+" Glossary");
			    $('#lessons #lessons-list-paragraph').hide();
			}
			else{
			    $('#lessons #lessons-list-title').text($('#lessons .lesson-section:visible').find('.lesson-section-title').text()+" Lessons");
			    $('#lessons #lessons-list-paragraph').show();
			}
			return false;
		})
	}
	
})
