$(document).ready(function() {

//Drucker einblenden

if($(".breadcrumb").is("div")) {
	var printButton = '<a class="printer" title="Diese Seite drucken">&nbsp;</a>';	
	$(".breadcrumb").append(printButton);
	$(".printer").click(function() {
		print();
	})
} 

// Kompetenzfelder Navigation
	if($(".boxSkills ul li")) {
		$(".boxSkills ul li").hover(function() {
			$(this).css("position","relative");
			elem = $(this).find("span");
			$(elem).css("position","absolute");
			$(elem).fadeIn("fast");
			$(this).children("a").attr("class","active");

		
		}, function(){	
			$($(this).find("span")).css("display","none");
			$($(this).find("span")).css("position","static");	
			$(this).css("position","static");
			$($(this).find("span")).hide("fast");
			$($(this).find("a")).attr("class","inactive");
			$($(this).find("span")).attr("class","item");
		})
	}
	
	
//**************Plugin Aufrufe*********************/

//Metanavi DropDown
$('#metaNavigation').singleDropMenu({parentMO: 'ddmenu-hover', childMO: 'ddchildhover', currentSibling: true});

//Navigation
$('#topNavigation').singleDropMenu({parentMO: 'ddmenu-hover', childMO: 'ddchildhover', childContainer: "div"});

//Accordion Recherchepool
$('#dialogcenter').accordion({ 
    active: 0, 
    autoheight: false,
    header: '.head', 
    navigation: true
});

//Accordion Recherchepool
$('#rechercheTool').accordion({ 
    active: 0, 
    autoheight: false,
    header: '.head', 
    navigation: true
});



//Accordion Content
$('.accordionTeaser').accordion({ 
    autoheight: false,
	alwaysOpen: false,
	active: false,	 
    header: 'h4'
});


//Selectbox
if($('#selectBoxModule').is("ul")) {
	$('#selectBoxModule').linkselect();
}


//Carousel
$("div#medienVideo").carousel({ 
	pagination: true,
	dispItems: 3,
	itemMargin: 20	
});
	
$("div#medienAudio").carousel({ 
	pagination: true,
	dispItems: 3,
	itemMargin: 20	
});
	
$("div#medienBilder").carousel({ 
	pagination: true,
	dispItems: 3,
	itemMargin: 20	
});

//Tabbox 

if($("div.mediaBox .tabBox").is("div")) {
	
  $('div.mediaBox .tabBox .tabBoxContainer').hide();
  $('div.mediaBox .tabBox .show').show();
	
  //Get all the LI from the #tabMenu UL
  $('div.mediaBox .tabBox .tabhead > li').click(function(){
        
    //perform the actions when it's not selected
    if (!$(this).hasClass('current')) {    

    	//remove the selected class from all LI    
    	$('div.mediaBox .tabBox .tabhead> li').removeClass('current');
    
    	//After cleared all the LI, reassign the class to the selected tab
   		 $(this).addClass('current');
    
    	//Hide all the DIV in .boxBody
    	$('.tabBoxContainer').hide();

   	 //	Look for the right DIV index based on the Navigation UL index
    	$('.tabBoxBody div.tabBoxContainer:eq(' + $('.tabhead > li').index(this) + ')').show();

	}
});	

}

//Carousel


$("div#publications").carousel({ 
	pagination: true,
	dispItems: 3,
	itemMargin: 20	
});

$("div#mitglieder").carousel({
	autoSlide: true,
	effect: "fade",
	loop: true,
	randomItems: true
});

$("div#initiativen").carousel({
	autoSlide: true,
	effect: "fade",
	loop: true,
	randomItems: true
});

$("div#termine").carousel({
	dispItems: 3,
	effect: "fade",
	direction: "vertical"
});

$("div#topbanner").carousel({
	effect: "fade"
});


//Gallery Aufruf
if($('#gallery-adv').is("div")) {

	var galleryAdv = $('#gallery-adv').galleriffic('#thumbs-adv', {
        delay:                  3000,
        numThumbs:              16,
        preloadAhead:           40, // Set to -1 to preload all images
        enableTopPager:         true,
        enableBottomPager:      true,
		showImageContainer: 	false,
		imageContainerSel: 		'',
		controlsContainerSel: 	'#controls-adv',
		captionContainerSel: 	'',
		loadingContainerSel: 	'',
        renderSSControls:       false,
        renderNavControls:      false,
        playLinkText:           'Abspielen',
        pauseLinkText:          'Pause',
        prevLinkText:           'Zur&uuml;ck',
        nextLinkText:           'Weiter',
        nextPageLinkText:       'Weiter',
        prevPageLinkText:       'Zur&uuml;ck',
        enableHistory:          false,
        autoStart:              false,
        onChange:               undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
        onTransitionOut:        undefined, // accepts a delegate like such: function(callback) { ... }
        onTransitionIn:         undefined, // accepts a delegate like such: function() { ... }
        onPageTransitionOut:    undefined, // accepts a delegate like such: function(callback) { ... }
        onPageTransitionIn:     undefined  // accepts a delegate like such: function() { ... }
    });

}

if($('.thumbs').is("ul")) {

	 $('.thumbs a.thumb').lightBox({
	txtImage: ' ',
	txtOf: '/'
   });

}




if($(".homepage #keyvisual").is("div")) {
		
	$(".homepage #keyvisual .imgList").cycle({ 
		delay:  2000, 
		speed:  1000
	}); 
		
}


});


