/*
 * Lightweight Accordion v1.0 - http://www.mariusranft.de
 * 
 * Copyright © 2011 Marius Ranft
 * All rights reserved.
 * 
 * Redistribution with or without modification have to be approved by the author. 
*/

$(document).ready(function() {
						   
	var speed 	= 750;							// Animationsgeschwindigkeit in Millisekunden 
	var textIn 	= "Informationen einblenden ";	// Einblendungstext
	var textOut = "Informationen ausblenden ";	// Ausblendungstext
	var fxOpen 	= "easeOutBounce";				// Öffnungsanimation (easeOutQuad, easeOutBack, easeOutBounce)
	var fxClose = "easeInBack";					// Verschlussanimation (easeInQuad, easeInBack, easeInBounce)
	
	$('.toggler').each(function() { $(this).html("<"+"span class='info'>"+textIn+"<"+"/span>"+$(this).html()); }); 
	$('.active').each(function() { $(this).next().show(); $(this).children(".info").text(textOut); }); 
//	$('.togglerBox').css('width', $('.accordion').css('width'));
	$('.toggler').click(function() {
		$('.toggler').removeClass('active');
		$('.togglerBox').slideUp(speed, fxClose, function(){ $(this).prev().children(".info").text(textIn);});
		if($(this).next().is(':hidden') == true) {
			$(this).addClass('active');	
			$(this).next().slideDown(speed, fxOpen);
			$('.toggler').each(function() { $(this).children(".info").text(textIn);}); 
			$(this).children(".info").text(textOut);} 
			
	});
});


jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad', swing: function (x, t, b, c, d) { return jQuery.easing[jQuery.easing.def](x, t, b, c, d); },
	
	easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; },
	easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; },
	easeInBack: function (x, t, b, c, d, s) { if (s == undefined) s = 1.70158; return c*(t/=d)*t*((s+1)*t - s) + b; },
	easeOutBack: function (x, t, b, c, d, s) { if (s == undefined) s = 1.70158; return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; },
	easeInBounce: function (x, t, b, c, d) { return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b; },
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) { return c*(7.5625*t*t) + b; } else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; } else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; } else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	}
});
