$(document).ready(function(){
    
   var berlinschool_imageflow = $('imageflow').imageflow({
       
       /* Configuration variables */
	     reflections : true,
		 reflectionGET: '&bgc=009cec',
         reflection_p:   0,           // Sets the height of the reflection in % of the source image
         focus:          10,          // Sets the numbers of images on each side of the focussed one
         slider_width:   14,          // Sets the px width of the slider div
         images_cursor:  'pointer',   // Sets the cursor type for all images default is 'default'
         slider_cursor:  'default',   // Sets the slider cursor type: try "e-resize" default is 'default'

         /* advanced: modification of the carousel animation */
         //scale_factor:   2.295, // for 80x160           // bigger numbers make the whole animation smaller 2.1756 - 130
         //scale_factor:   2.613, // for 75x150 display of 80x160 pics
         //scale_abs:      100,
         scale_factor: 4.15,
         scale_abs: 100,
         xstep:          70,
         reflection_delta: 0.25,
         
         coverflow_function: 'abs', // sqrt(curved coverflow) or abs(more straight)
         coverflow_function_abs: 302.42, // bigger numbers result in smaller images
         coverflow_function_abs_scale: 0.7
         
   });
/**
 * Home Page Slideshow Config
 * 
 */ 	
	function slideshow_initCallback(carousel) {
		// jCarousel Controls 
		$('.jcarousel-control a').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval($(this).attr('href').replace(/\//, "").replace(/#/, "")));
			$('.jcarousel-control a').removeClass("active");
			$(this).addClass('active');
			return false;
		});
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});		
	}
	/**
	 * This is the callback function which receives notification
	 * when an item becomes the first one in the visible range.
	 * Triggered before animation.
	 */
	function slideshow_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
		$(".jcarousel-control li a").attr("href", function (arr) {
			for(i=0;i<=arr;i++){
				$(this).removeClass("active");
			}
		});
	};
	/**
	 * This is the callback function which receives notification
	 * when an item becomes the first one in the visible range.
	 * Triggered after animation.
	 */
	function slideshow_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
	    //console.log('Item #' + idx + ' is now visible');
		$(".jcarousel-control li a").attr("href", function (arr) {
			for(i=0;i<=arr;i++){
			if(arr+1 == idx){
					$(this).addClass("active");
				}
			}
		});
	};   
	$('#slideshow-panel').jcarousel({
		auto: 6,
		wrap: 'both',
		initCallback: slideshow_initCallback,
		animation: 'slow',
		scroll: 1,		
		itemVisibleInCallback: {
			onBeforeAnimation: slideshow_itemVisibleInCallbackBeforeAnimation,
			onAfterAnimation: slideshow_itemVisibleInCallbackAfterAnimation
		}		
		
	});
	$(".jcarousel-control li a").bind('click', function(){
		$(this).addClass('active');
	});   
	// Partners Slider
	jQuery.easing.easeOutQuart = function(x, t, b, c, d){
		return -c * ((t = t / d - 1) * t * t * t - 1) + b;
	};
	$('#partnerSlider').serialScroll({
		items: 'a',
		prev: '',
		next: '',
		offset: 0, //when scrolling to photo, stop 230 before reaching it (from the left)
		start: 0, //as we are centering it, start at the 2nd
		duration: 700,
		force: true,
		stop: false,
		lock: false,
		interval: 10,
		cycle: true, //don't pull back once you reach the end
		easing: 'easeOutQuart', //use this easing equation for a funny effect
		jump: false //click on the images to scroll to them
	});
});