$(document).ready(function(){
	$(".usefulTerms").accordion({
			header: 'dt',
			active: false,
			collapsible: true,
			autoHeight: false
	});	

	$("#sidebarNav").accordion({
			header: 'h4',
			active: false,
			collapsible: true,
			autoHeight: false,
			animated: 'easeslide'
	});

$('#catSubjectBox').localScroll({
   target:'#SubjectScroll',
   axis:'xy',
   queue:'true',
   duration:1000,
   navigation: '.navigation a',
   onAfter: trigger
});

$('#book-book').localScroll({
   target:'#bookScroll',
   axis:'xy',
   duration:500,
   navigation: '.navigation a'
});

/* AK handle nav selection
--------------------------------------------------------------*/
function selectNav() {
  $(this)
    .parents('ul:first')
      .find('a')
        .removeClass('selected')
      .end()
    .end()
    .addClass('selected');
}

$('#catSubjectBox .SubjectNav').find('a').click(selectNav);

// go find the navigation link that has this target and select the nav
function trigger(data) {
  var el = $('#catSubjectBox .SubjectNav').find('a[href$="' + data.id + '"]').get(0);
  selectNav.call(el);
}

if (window.location.hash) {
  trigger({ id : window.location.hash.substr(1) });
} else {
  $('ul.SubjectNav a:first').click();
}

});

/* AK hover for ie6
--------------------------------------------------------------*/
/*sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/