function startHeaderCycle()
{
	$('#headerImages').cycle({
		nowrap: true,
		random: true,
		fit: true,
		containerResize: false,
		timeout: 10*1000,
		random: true,
		before: function(cur, next, args){
			$('span', args.$cont).stop().fadeOut(2000).promise().done(function(){
				$(this).remove();
				$(cur).stop(true);							
				var helper = $('<span><span class="start"></span></span>').css('width', 'auto').addClass('text').text(next.alt).appendTo(args.$cont);
				var width = helper.width();
				helper.remove();
						
				$('<span><span class="start"></span></span>').addClass('text').hide().appendTo(args.$cont)
					.css('display', 'inline-block')
					.stop(true)
					.fadeIn(1500)
					.animate({width: width}, 'normal', function(){
						$('<span />').text(next.alt).hide().appendTo(this).fadeIn(1500);
						var delta = $(next).height() - $(args.$cont).innerHeight();
						$(next).stop(true).css('margin-top', 0).animate({ 'margin-top': '-='+delta, }, delta*100);
					})
					.animate({
						'margin-left': "+=100px",
					},{
						duration: 10000,
						easing: 'easeInSine'
				});
			});	
		}
	});
	$('a.external').attr('target', '_blank');
}
jQuery(function($){
	startHeaderCycle();
});	
