$(function(){
	var stopMe = 0;

	$('#etherTop a').click(function(){
		
		clearTimeout(stopMe);
		$(this).parent().parent().children("li").removeClass();
		$(this).parent().addClass("sel");
		
		
		var id = $(this).attr("id").replace(/pro/,'');
		$.get(
			'/bitrix/templates/avanport/components/avanport/data.detail/topDetail/ajax.php',
			{'ID':id},
			function(data){
				$('.topImage').add('#topInfo').remove();
				$('#pageText').prepend(data);
			}
		);
		return false;
	});
	
	$.fn.ShowNext = function() {

		$(this).removeClass();
		
		var sel = $(this).next("li").html() != null
			? $(this).next("li") : 
			$(this).parent().children("li:first");
			
		sel.children("a").click();
		sel.addClass("sel");
		stopMe = setTimeout(
			function() {
				sel.ShowNext();
			},
			7000
		);
  }

	$('#etherTop li:last').ShowNext();
	
});

