/* Author: 
	Johannes Brückner - 12/2011
*/

$(document).ready(function() {
	/*
	$('#langSwitcher').click( function(e) {
		
		e.preventDefault();
		alert('An english version will be available soon.');
	
	});*/

	
	if($('#portraits').size()==1) {
		$('#portraits').galleria({
			width:740,
			height:480,
			transition: 'fade',
			autoplay: 5000,
			transitionSpeed: 1000
		});
	}
	
	$('.portraits').click( function(e) {
		e.preventDefault();
		$('#galleryNav .active').removeClass('active');
		$('#shootings, #szenenbilder').hide();
		$('#portraits').show();
		$(this).addClass('active');
		$('#portraits').galleria({
			width:740,
			height:480,
			transition: 'fade',
			autoplay: 5000,
			transitionSpeed: 1000
		});
	});
	
	$('.shootings').click( function(e) {
		e.preventDefault();
		$('#galleryNav .active').removeClass('active');
		$('#portraits, #szenenbilder').hide();
		$('#shootings').show();
		$(this).addClass('active');
		$('#shootings').galleria({
			width:740,
			height:480,
			transition: 'fade',
			autoplay: 5000,
			transitionSpeed: 1000
		});
	});
	
	$('.szenenbilder').click( function(e) {
		e.preventDefault();
		$('#galleryNav .active').removeClass('active');
		$('#shootings, #portraits').hide();
		$('#szenenbilder').show();
		$(this).addClass('active');
		$('#szenenbilder').galleria({
			width:740,
			height:480,
			transition: 'fade',
			autoplay: 5000,
			transitionSpeed: 1000
		});
	});
	
});



	
$(window).load(function() {
	if($('body').is('#vita')) {
		mCustomScrollbars();
	}
	
	if($('#slider').size()==1) {
		$('#slider').nivoSlider({
			effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
			slices: 12, // For slice animations
			boxCols: 12, // For box animations
			boxRows: 10, // For box animations
			animSpeed: 1500, // Slide transition speed
			pauseTime: 5000, // How long each slide will show
			startSlide: 0, // Set starting Slide (0 index)
			directionNav: false, // Next & Prev navigation
			directionNavHide: false, // Only show on hover
			controlNav: false, // 1,2,3... navigation
			controlNavThumbs: false, // Use thumbnails for Control Nav
			controlNavThumbsFromRel: false, // Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', // Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
			keyboardNav: false, // Use left & right arrows
			pauseOnHover: false, // Stop animation while hovering
			manualAdvance: false, // Force manual transitions
			captionOpacity: 0, // Universal caption opacity
			prevText: 'Prev', // Prev directionNav text
			nextText: 'Next', // Next directionNav text
			randomStart: false, // Start on a random slide
			beforeChange: function(){ $('#aktuelles,#spiral').css('zIndex',999); }, // Triggers before a slide transition
			afterChange: function(){ $('#aktuelles,#spiral').css('zIndex',999); }, // Triggers after a slide transition
			slideshowEnd: function(){ $('#aktuelles,#spiral').css('zIndex',999); }, // Triggers after all slides have been shown
			lastSlide: function(){ $('#aktuelles,#spiral').css('zIndex',999); }, // Triggers when last slide is shown
			afterLoad: function(){ $('#aktuelles,#spiral').css('zIndex',999); } // Triggers when slider has loaded
		});
	}
	
});

function mCustomScrollbars(){
	/* 
	malihu custom scrollbar function parameters: 
	1) scroll type (values: "vertical" or "horizontal")
	2) scroll easing amount (0 for no easing) 
	3) scroll easing type 
	4) extra bottom scrolling space for vertical scroll type only (minimum value: 1)
	5) scrollbar height/width adjustment (values: "auto" or "fixed")
	6) mouse-wheel support (values: "yes" or "no")
	7) scrolling via buttons support (values: "yes" or "no")
	8) buttons scrolling speed (values: 1-20, 1 being the slowest)
	*/
	$("#innerWrapper").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,"auto","yes","yes",15); 
}

/* function to fix the -10000 pixel limit of jquery.animate */
$.fx.prototype.cur = function(){
    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
      return this.elem[ this.prop ];
    }
    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
    return typeof r == 'undefined' ? 0 : r;
}

/* function to load new content dynamically */
function LoadNewContent(id,file){
	$("#"+id+" .customScrollBox .content").load(file,function(){
		mCustomScrollbars();
	});
}









