jQuery(document).ready(function(){
	
	// Navigation
	jQuery("#topMenu ul li:not(.nosub)").hover(function(){
    	jQuery(this).addClass("hover");
		 }, function(){
    	jQuery(this).removeClass("hover");
   	});
	
	// roundTeaser
	buildRoundTeaser();
	
	// breadcrumb productdetail delete last background
	jQuery('.breadcrumbProductdetail ul li a:last').css('background',0);
	
	jQuery('a.zoom').fancybox({'titlePosition':'inside'});
	linkBlogentryImages();
	
});

function buildRoundTeaser() {
	var roundTeaser = jQuery('#roundTeaser ul');
	var teaserCount = teaserCountOrig = jQuery('li', roundTeaser).length;
	if(teaserCount != 0) {
		jQuery('#roundTeaser').show();
		while(teaserCount < 10) {
			jQuery('li', roundTeaser).eq(teaserCount - teaserCountOrig).clone().appendTo(roundTeaser);
			teaserCount = jQuery('li', roundTeaser).length;
		}
		teaserToggle = jQuery('<a>', {href:'javascript:void(0);'}).focus(function () {jQuery(this).blur();});
		roundTeaser.before(teaserToggle.clone(true).attr('id', 'roundabout-prev'), teaserToggle.clone(true).attr('id', 'roundabout-next'));
		roundTeaser.roundabout({
			btnNext: '#roundabout-next',
			btnPrev: '#roundabout-prev',
			minOpacity: 1,
			minScale: 0.6
		});
	}
}

function linkBlogentryImages() {
	jQuery('.blogList .item', '#t3blog').each(function () {
		var postHeadline = jQuery('.itemContent .itemBody h3:first a', this);
		jQuery('.itemImage img', this).wrap('<a href="' + postHeadline.attr('href') + '" title="' + postHeadline.text() + '"></a>');
	});
}