﻿	
	function promo_find_currend_show() {
		$$('.topic_promo.aktiv').each(function(item) {
			now_aktiv_element_id = item.identify();
		});
		return now_aktiv_element_id;
	}
	
	function promo_find_next_to_show(element_id) {
		next_will_be = $(element_id).next();
		if (next_will_be) {
			return next_will_be.identify();
		} else {
			return $$('.topic_promo')[0].identify();
		}
	}
	
	function promo_appear_toggle(element_id, duration) {
		if (duration == false) {
			duration = 2.0;
		}	
		Effect.toggle(element_id, 'appear', { duration: duration }); 
		$(element_id).toggleClassName('aktiv');
		$$('.topic_promo_link').each(function(item) {
			$(item).removeClassName('aktiv');
		});
		var link_class = '.' + element_id + '_link';
		$$(link_class).each(function(item) {
			$(item).addClassName('aktiv');
		});
		$$('.topic_promo.aktiv').each(function(item) {
			new Ajax.Request('index.php', {
				method: 'post',
            	parameters: 'aktion=set_sc_value&bfr_sc='+ item.id,
			});
		});
		return false;
	}
	
	function promo_toggle() {
		var now_aktiv = promo_find_currend_show();
		var show_next = promo_find_next_to_show(now_aktiv);
		promo_appear_toggle(now_aktiv, false);
		promo_appear_toggle(show_next, false);
	}
	
	function promo_toggle_on_click(element_id) {
		clearInterval(promo_toogle_timer);
		var now_aktiv = promo_find_currend_show();
		if (element_id != now_aktiv) {
			promo_appear_toggle(now_aktiv, 0.2);
			promo_appear_toggle(element_id, 0.2);
		}
	}
	
	var promo_toogle_timer = window.setInterval("promo_toggle()", 10000);
