var qqq = null;
var current = null
var CHANGE_TIME = 2000;
var DISPLAY_TIME = 30000;
showNext = function() {
	if (current != null) 
	{
		current.fadeOut(CHANGE_TIME);
		next = current.next(".consts_div");
		
		if (!next[0])
		{
			next = $(".consts_div:first");
		}
	} else {
		next = $(".consts_div:first");	
	}
	
	next.fadeIn(CHANGE_TIME);
	current = next
	setTimeout(function() { 
		
		showNext();
		
	 }, DISPLAY_TIME);
}

$(document).ready(function() {
	
	$(".consts_container").css('height', 0);


	var currentTallest = 0;
	$(".consts_container").children().each(function(i){
		if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
	});
	$(".consts_container").css('height', currentTallest+45);

	
	$(".promo_next").click(function(){
		if (current != null) 
		{
			current.fadeOut(CHANGE_TIME);
			next = current.next(".consts_div");
		
			if (!next[0])
			{
				next = $(".consts_div:first");
			}
		} else {
			next = $(".consts_div:first");	
		}
	
		next.fadeIn(CHANGE_TIME);
		current = next
	});
	
	
	$(".promo_prev").click(function(){
		if (current != null) 
		{
			current.fadeOut(CHANGE_TIME);
			next = current.prev(".consts_div");
		
			if (!next[0])
			{
				next = $(".consts_div:last");
			}
		} else {
			next = $(".consts_div:last");	
		}
	
		next.fadeIn(CHANGE_TIME);
		current = next
	});
	
	showNext();
	
});


