$(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
});

$('#panelbox').localScroll({
   target:'#panelscroll',
   axis:'xy',
   queue:'true',
   duration:1000,
   navigation: '.navigation a',
   onAfter: trigger
});

/* slides
----------------------------------------------- */
	$('#fadex').cycle({fx:'scrollDown',timeout: 6000});


/* 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 open new window
--------------------------------------------------------------*/
$('a.new-window').click(function(){
        window.open(this.href);
        return false;
		});
		
});

/* pop-up windows
----------------------------------------------- */
function openwindow()
{
	window.open("http://www.leedscitycollege.ac.uk/ak-lib/forms/email-alert.php?xak="+location.href,"mywindow","menubar=0,resizable=1,width=620,height=500");
}

function openwindowb()
{
	window.open("http://www.leedscitycollege.ac.uk/ak-lib/forms/hb-application.php?xak="+location.href,"mywindow","menubar=0,resizable=1,scrollbars=1,width=620,height=500");
}
