$(document).ready(function(){
	$('.sf-menu').superfish({
		delay: 500,
		animation: {opacity:'show'},
		speed: 'fast',
		autoArrows: false,
		dropShadows: true,
		pathClass: 'activePage',
		pathLevels: 1
	});

	$('a.ext').click(function(){
		// open in a new window
		window.open(this.href);
		return false;
	});

	/* home fader */
	function onBefore() {
		$('#slideshow h2').html("...");
	}
	function onAfter() {
		$('#slideshow h2').html(this.title)
	}
	$('#slides')
	.after('<div id="slideNav">')
	.cycle({
		fx: 'fade',
		before: onBefore,
		after: onAfter,
		next: '#nextArrow',
		prev: '#prevArrow',
		pager: '#slideNav'
	});

	// When a link is clicked
	$("a.tab").click(function () {

		// switch all tabs off
		$(".active").removeClass("active");

		// switch this tab on
		$(this).addClass("active");

		// slide all elements with the class 'content' up
		$(".tabcontent").slideUp();

        // Now figure out what the 'title' attribute value is and find the element with that id.  Then slide that down.
		var content_show = '#'+$(this).attr("rel");
		$(content_show).slideDown();

	});

	function mycarousel_initCallback(carousel) {
		$('#thumb-right-arrow img').bind('click', function() {
			carousel.next();
			return false;
		});

		$('#thumb-left-arrow img').bind('click', function() {
			carousel.prev();
			return false;
		});
	};

	// Ride the carousel...
	$(document).ready(function() {
		$("#thumblist").jcarousel({
			scroll: 1,
			initCallback: mycarousel_initCallback,
			// This tells jCarousel NOT to autobuild prev/next buttons
			buttonNextHTML: null,
			buttonPrevHTML: null
		});
	});

	$("#thumblist li a").fancybox();


	$('.show-article').click(function(){
		var showThis = $(this).attr('rel');
		$('#'+showThis).toggle();
		return false;
	});

});

