// <[CDATA[
$(document).ready(function() {
	/* Open external links in a new tab/window */
	$('a[href^="http://"]').attr('target', '_blank');


	/* Enable lightbox images */
	$('a[rel*="lightbox"]').lightBox();


	/* Forward/back buttons */
	$('a[href="#back"]').click(function() {
		history.back();
		return false;
	});

	$('a[href="#forward"]').click(function() {
		history.forward();
		return false;
	});


	/* Search box */
	$('div#search :text').focus(function() {
		if ($(this).val() == 'Search') {
			$(this).val('');
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).val('Search');
		}
	});


	/* Enable cycle images */
	selected = 0;

	onAfter = function(curr, next, opts) {
		selected = opts.currSlide;
	};

	autoscroll = 0;
	if ($('div#supplement > ul').hasClass('autoscroll')) {
		autoscroll = 5000;
	}

	$('div#supplement > ul').cycle({
		timeout:	autoscroll,
		speed:		1000,
		next:		'div#controls a#next',
		prev:		'div#controls a#previous',
		after:		onAfter
	});


	/* Play the currently visible Flash movie, if it exists */
	$('div#controls a#play').click(function() {
		id = 'movie' + selected;

		if ($('#' + id).length > 0) {
			movie = window.document[id];
			movie.Play();
		}

		return false;
	});
});
// ]]>
