jQuery(document).ready(function(){

	var contentWidth = jQuery(".main").width();
	var navigationWidth = 0;
	jQuery("#navigation-top li").each(function() {
		navigationWidth += jQuery(this).width();
	});
	jQuery("#bg-spacer").width(contentWidth - navigationWidth - 3);

	// Move header teaser images in a scrolling carousel
	jQuery("#header-carousel").jCarouselLite({
		auto: 4000,
		speed: 1000,
		circular: true,
		visible: 5,
		start: 1
	});
	
	// Shift header teaser images left so that the center image aligns with the content column
	shiftCarousel();
	
	// Register listener to shift again when the browser resizes
	var resizeTimer = null;
	jQuery(window).bind('resize', function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(shiftCarousel, 100);
	});
	
	// Hide categories in news single view
	var newsMetaText = jQuery(".news-single-rightbox").text();
	newsMetaText = newsMetaText.replace(/Kategorie:.*/, "");
	jQuery(".news-single-rightbox").empty().text(newsMetaText);
});

function shiftCarousel() {
	var bodyWidth = jQuery("body").width();
	var contentWidth = jQuery(".main").width();
	jQuery("#header-carousel").css("left", - (contentWidth -((bodyWidth - contentWidth) / 2)));
};
