$(document).ready(function(){

	// add captions to body text images
	$('#content img[title]')
		.one( 'load', function() {
			$(this)
				.wrap( $('<div />').addClass( 'caption ' + this.className).width(this.width) )
				.removeAttr('class')
				.after( $('<span />').text($(this).attr('title')) );
		})
		// fix for browsers that don't fire load event for cached images
		.each( function() {
			if ( this.complete ) { $(this).trigger('load'); }
		});


	// rotating banners
	$('div.homepageBanner').each( function() {
		$(this).children('img:first-child').show();	// for IE6
		var images = $(this).children('img');
		if ( images.length < 2 ) return;
		var current = 0;
		setInterval( function() {
			var previous = current;
			current = ++current % images.size();;
			images.eq( current ).show( 0, function() {
				images.eq( previous ).hide();
			} );
		}, 5000 );
	} );
	
});
