/*
Skin Specific JS goes here. The jQuery library has already been loaded by the core templates.
THerfore, if you use jQuery, you are ready to go. We recommend that you write all skin jQuery to be 
noConflict friendly to avoid issues with TYPO3 extensions that use other libraries. This means
using syntax like this:

jQuery('.myClass').hide();

NOT

$('.myClass').hide();

The TemplaViola Framework sets jQuery().noConflict() by default so you will need to unset it
in TypoScript if you want it otherwise.

*/


function resizeModuleGroup(moduleGroupElement) {
	var groupHeight = jQuery(moduleGroupElement).height();
	if (jQuery(moduleGroupElement).children('.module').size() > 1) {
		jQuery(moduleGroupElement).children('.module').each(function(){
			var moduleHeaderHeight = jQuery(this).children('.moduleHeader').outerHeight(true);
			var moduleFooterHeight = jQuery(this).children('.moduleFooter').outerHeight(true);
			var moduleBodyWrapHeight = groupHeight - moduleHeaderHeight - moduleFooterHeight;
			jQuery(this).children('.moduleBodyWrap').height(moduleBodyWrapHeight + 'px');
		});
	}
}

jQuery(document).ready(
	function() {

		// Macht alle Featureboxen gleich hoch
		jQuery('.moduleGroup').each(function(){
			resizeModuleGroup(this);
		});

		// Definiert das Superfish-Menü
		jQuery(".sf-menu").superfish({
			pathClass: 'current',
			pathLevels: 1,
			delay: 1200,
			autoArrows: false,
			dropShadows: false
		});
		
		
/*		// Opazität auf den Standardwert setzen
		jQuery('.moduleBody').animate({
			opacity: 0.3
		}, "0");
		
		// Bei MouseOver die Opazität anpassen. MouseOut setzt sie wieder zurück.
		jQuery('.moduleBody').hover(
			function(){
				jQuery(this).stop()
					.animate({
						opacity: 1
						}, "fast"
					);
			},
			function(){
				jQuery(this).stop()
					.animate({
						opacity: 0.3
						}, "fast"
					);
			}
		);
*/
		// Gesamten Inhalt von .moduleBody verlinken
		jQuery(".moduleBody").click(function(){
			window.location=jQuery(this).find("a").attr("href");
			return false;
		});



		// Nivo-Slider "Standalone".
		jQuery('#news-slider .news-single-img').nivoSlider({
			effect:'random',
			slices:10,
			animSpeed:500,
			pauseTime:6500,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:true, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:true, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
//			controlNavThumbsSearch: '.jpg', //Replace this with...
//			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
			manualAdvance:true, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){} //Triggers after all slides have been shown
		});


		jQuery('.colorbox').colorbox({transition:'fade', speed:500});


		// Referenzen aus tt_news laden. Nur Inhalt von .news-single-item in ColorBox anzeigen!
		jQuery('.referenz').each(function(){
			jQuery(this).colorbox({
				transition: "elastic",
				width:"950px", 
				height:"600px",
				href: jQuery(this).find("a").attr("href") + " div.news-single-item",
				onComplete:function(){
							jQuery('#news-slider .news-single-img').nivoSlider({
									effect:'random',
									slices:10,
									animSpeed:500,
									pauseTime:6500,
									startSlide:0, //Set starting Slide (0 index)
									directionNav:true, //Next & Prev
									directionNavHide:true, //Only show on hover
									controlNav:true, //1,2,3...
									controlNavThumbs:false, //Use thumbnails for Control Nav
					//				controlNavThumbsSearch: '.jpg', //Replace this with...
					//				controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
									keyboardNav:true, //Use left & right arrows
									pauseOnHover:true, //Stop animation while hovering
									manualAdvance:true, //Force manual transitions
									captionOpacity:0.8, //Universal caption opacity
									beforeChange: function(){},
									afterChange: function(){},
									slideshowEnd: function(){} //Triggers after all slides have been shown
								});
				}
			});
		});
		
		


		// Hover-Effekt für Bilder im .boxgrid
		jQuery(".boxgrid img").addClass('b');
		jQuery(".boxgrid img:first-child").removeClass('b');
		jQuery(".boxgrid img:first-child").addClass('a');
		
		jQuery(".boxgrid img.a").hover(
			function() {
				jQuery(this).stop().animate({"opacity": "0"}, "fast");
			},
			function() {
				jQuery(this).stop().animate({"opacity": "1"}, "slow");
		});



		jQuery(".cover", this).stop().animate({top:'162px'});

		jQuery('.boxgrid.captionfull').hover(function(){
			jQuery(".cover", this).stop().animate({top:'137px'},{queue:false,duration:160});
		}, function() {
			jQuery(".cover", this).stop().animate({top:'162px'},{queue:false,duration:160});
		});

/*		jQuery(function () {
			jQuery('.anythingSlider').anythingSlider({
				easing: "easeInCubic",        // Anything other than "linear" or "swing" requires the easing plugin
				autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
				delay: 8000,                    // How long between slide transitions in AutoPlay mode
				startStopped: false,            // If autoPlay is on, this can force it to start stopped
				animationTime: 1000,             // How long the slide transition takes
				hashTags: true,                 // Should links change the hashtag in the URL?
				buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
				pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
				startText: "Weiter",        	    // Start text
				stopText: "Stop", 
				nextBackButtons: false,              // Stop text
			});
		});
*/


		// Nivo-Slider "Standalone".
		jQuery('#startnews').nivoSlider({
			effect:'random',
			slices:10,
			animSpeed:500,
			pauseTime:6500,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:true, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:true, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
//			controlNavThumbsSearch: '.jpg', //Replace this with...
//			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){} //Triggers after all slides have been shown
		});




		// TwitterFeed konfigurieren
		jQuery(".tweet").tweet({
			username: "abteilung",
			join_text: "auto",
			avatar_size: 32,
			count: 3,
			auto_join_text_default: "We said:",
			auto_join_text_ed: "We",
			auto_join_text_ing: "We were",
			auto_join_text_reply: "We replied to:",
			auto_join_text_url: "We checked",
			loading_text: "Loading Tweets..."
		});
		
//		jQuery('#flickr-pascal').flickrGallery('72157623793381934','d75c291ae0dd881309bd6edf5c5da345');
	    
		
// Hier ist das jQuery-File zu Ende
});