
function openPanel(panelId)
{
	panelCount = 0;
	panelIndex = -1;
	
	// show up the panel (content) itself
	$('#mytabset div.semtabs .panel').each(function() {
		if($(this).attr("id") == panelId )
		{
			$(this).show();
			panelIndex = panelCount;
		}
		else
			$(this).hide();
		// count up
		panelCount++;
	});
	
	// set navigator active
	if(panelIndex != -1)
	{
		panelHeadCount = 0;
		$('#mytabset ul.semtabs li').each(function() {
			if(panelHeadCount == panelIndex)
				$(this).addClass("active");
			else
				$(this).removeClass("active");
			panelHeadCount++;
		});
	}	
}

function mycarousel_initCallback(carousel) 
{
	// jcarousel nav
	$("#teaser_nav a").click(function()
	{
		carousel.scroll(jQuery.jcarousel.intval($(this).attr("title")));
		return false;
	});
}

function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
	$('#teaser_nav a').each(function(index) {
		if($(this).attr("title") == idx)
			$(this).addClass("active");
		else
			$(this).removeClass("active");
	});
};

$(document).ready(function() { 

	// jump to and open "bewertungen" tab on click
	$(".bewertungen a").click(function(){
		openPanel("box_votes");
	});
		
	// jump to and open "frage zum produkt" tab on click
	$("#link_produktquestion").click(function(){
		openPanel("box_article_question");
	});
	
	
	$(".filter_trigger").click(function(){
		$(".filterbox").toggle(); 
		if($(this).hasClass("active"))
		{
			$(this).removeClass("active");
		}
		else
		{
			$(this).addClass("active");
		}
	});
	
	
	$("#kk_advent_calendar_box h3.boxtitle").click(function(){
		$("#kk_advent_calendar_box .sidebox_content").slideToggle();
	});
	
	
	
	// jcarousel teaser
	jQuery('#teaser_container').jcarousel({
        scroll: 1,
        visible: 1,
        auto: 4,
        wrap: 'last',
        animation: 'slow',
		initCallback: mycarousel_initCallback,
		itemFirstInCallback:  mycarousel_itemFirstInCallback,
    });
	
	
});
