$(function() {
	
	// Convert to archive date list to accordion
	$('.archive_range').accordion({autoHeight: false, icons: { 'header': 'closed', 'headerSelected': 'open' }});
	
	// Add a little date bubble time elements with a title attribute
	$('time[title]').each(function() {
		var bubble = $('<span/>').prependTo($(this)).html($(this).attr('title')).hide();
		$(this).addClass('bubble').hover(function() { bubble.stop(true,true).fadeIn(); }, function() { bubble.stop(true,true).fadeOut(); }).removeAttr('title');
	});
	
	// Topic Lists
	$('ul.topics li a').hover(function() { $(this).find('span.headline').stop(true,true).slideDown(100) }, function() { $(this).find('span.headline').stop(true,true).slideUp(100); }).find('span.headline').hide();
	
	// Lightbox
	$("a.lightbox").fancybox();
	
	// Horizontal scrolling for topics..
	$('#next').click(function(event){
		event.preventDefault();
		$('section#topics ul li').first().hide(400, function(){
			$('section#topics ul li').first().clone().appendTo($('section#topics ul')).show();
			$('section#topics ul li').first().remove();
		});
	});
	
	$('#prev').click(function(event){
		event.preventDefault();
		$('section#topics ul li').last().hide(400, function(){
			$('section#topics ul li').last().clone().prependTo($('section#topics ul')).show();	
			$('section#topics ul li').last().remove();
		});
	});

	
});
