/**
 * Slider - jQuery plugin
 * written by Alexander All
 * http://www.com-a-tec.de
 * 
 * Copyright (c) com-a-tec GmbH
 * Built for jQuery library
 * http://jquery.com
 * This copyright notice MUST APPEAR in all copies of the script!
 */
(function($){
	$.fn.slider = function(options) {
		var defaults = {
			event: 'mouseover',
			duration: 500
		};
		var config = $.extend(defaults, options);
		
		return this.each(function() {
			container = $(this);
			var children = container.children('li');
			// loop through all kwick elements
			children.each(function(i) {
				var active = $(this);
				active.bind(config.event, function() {
					if(typeof(config.beforeSlide) == "function") {
						config.beforeSlide(active)
					}					
					children.stop().removeClass('active');
					active.addClass('active');
					$.each(children, function(index, element){
						var obj = $(element).attr('class') == 'active' ? {'height':  config.max+'px'} : {'height': config.min+'px'};
						$(element).animate(obj, config.duration);
					});
				});
			});
			container.mouseleave(function() {
				children.stop().removeClass('active');
				if(typeof(config.beforeOut) == "function") {
					config.beforeOut()
				}
				$.each(children, function(index, element){
					$(element).animate({'height': config.min+'px'}, config.duration);
				});
			});
		});
	};
})(jQuery);
