$(function(){
	$('.control').show();
	$('#slider').cycle({ 
		//fx:    'scrollHorz', 
		fx: 'uncover',
		speed:  1000,
		timeout: 4000,
		random: 0,
		next: '#next',
		prev: '#previous',
		fastOnEvent:   0,
		before:   onBefore
	});
});

//#function to display caption
function onBefore() {
	var caption = '';
	//#if this is just an image with no link, use its alt attribute as the caption
	if(this.alt)
	{
		caption = this.alt;
	}
	//#otherwise, check if this is an image inside a link
	//#if so, use the image alt attribute
	else
	{
		var linkImageCaption = $(this).children()[0].alt;
		if(linkImageCaption)
		{
			caption = linkImageCaption;
		}
	}
	$('#caption').text(caption); 
}
