$(function() {
	
	if ($.fancybox)
		$('a.fancybox').fancybox({
			autoScale: false
		});
	
	if (typeof Shadowbox != 'undefined')
		Shadowbox.init();
		
	$('.featured-blog-display:not(.featured-processed)').each(function() {
	
		var $target = $(this);
		var id = $target.attr('id');
		if (id != '')
			id = '#' + id;//prevent errors by only using id as selector if set
		
		$target.tabs({
			fx: {opacity: 'toggle', duration: 'fast'},
			select: function(event, ui) { $('.serial-scroller', $target).trigger('goto', ui.index); },
			show: function(event, ui) { $(this).find('.featured-item-content').html($(ui.panel).find('.item-content').html()); }
		})
		.tabs('rotate', 3000, true)
		.addClass('featured-processed');
		
		$target.find('.serial-scroller').serialScroll({
			items: 'li.ui-tabs-nav-item',
			prev: id +' a.prev',
			next: id +' a.next',
			duration: 300, constant: false, step: 1, force: true, jump: true, cycle: true,
			onAfter: function(element, scroller) {
				var index = $(scroller.items).index(element);
				$target.tabs('select', index);
			}
		});
	});
	
	$('.featured-blog-display').find('.navigation-arrow').click(function(evt) {
		if (!evt.isDefaultPrevented())
			evt.preventDefault();
	});
});

