/*
 * jQuery Tabs und Slider
 * http://combosa.com/
 *
 * Copyright (c) 2011 combosa
 * Dual licensed under the MIT and GPL licenses.
 * http://combosa.com/
 *
 * Date: 2011-05-16
 */
 // Tabs und Slider

		jQuery(document).ready(function($){
			$('.tabs').each(function(){
				$(this).find('li:first').addClass('current'); // set the first tab to display
				repeat_slideshow($(this));
			});
			$('.tabs li .tab-select').click(function(){
				$(this).closest('.tabs').find('li').not($(this).parent()).removeClass('current'); // hide all tabs except for the current
				$(this).parent().addClass('current'); // set the current tab to display
				reset_slideshow($(this).closest('.tabs'));
				return false;
			});
			function slideshow(slide)
			{
				var index = slide.find('li.current').index();
				var total = slide.find('li').length;
				if ( index+1 >= total )
					var next = 0;
				else
					var next = index + 1;
				slide.find('li.current').removeClass('current');
				slide.find('li').eq(next).addClass('current');
			}
			function repeat_slideshow(slide)
			{
				slide.data('slideshow', setTimeout(function(){
						slideshow(slide);
						repeat_slideshow(slide);
					}, 5000));
			}
			function stop_slideshow(slide)
			{
				clearTimeout(slide.data('slideshow'));
			}
			function reset_slideshow(slide)
			{
				stop_slideshow(slide);
				repeat_slideshow(slide);
			}
		});


