parametr = {
	start:0,     // исходное изображение при автосмене(0,1,2)
	intensiv:5  // скорость интервала (5 сек)
	}
var myInterval;

$(document).ready(function(){
	$(".main-hot .tophot li").click(setOnClickAction);
	myInterval = setTimeout(triggerclick,parametr.intensiv*1000);
});

function setOnClickAction(event)
{
	 event.stopPropagation();
	if (!$(this).hasClass("here")) {
        $(".main-hot-active .tophot li").removeClass("here");
        $(this).addClass("here");
		var index = $(".main-hot-active .tophot li").index(this);
		$(".main-hot-active .img:visible").fadeOut(600, function(){});
		$(".main-hot-active .img:eq(" + index + ")").fadeIn(600, function(){
			parametr.start = index;
			clearTimeout(myInterval);
			myInterval = setTimeout(triggerclick,parametr.intensiv*1000);
		});
	}
}

function triggerclick() {
	(parametr.start < (newsCount-1)) ? parametr.start = parametr.start + 1 : parametr.start = 0;
	ret = parametr.start;
	$(".main-hot-active .tophot li:eq("+ret+")").trigger("click");
}

function toggleBlock(id)
{
	$('.main-hot-active').stop();
	$('.main-hot-active').animate({
		height: '0px'
//		width:	'0'
		},
		600,
		function(){
			$('.main-hot-active').removeClass('main-hot-active');
		}
	);
	$('#main-hot-'+id).stop();
	$('#main-hot-'+id).animate({
		height: '356px'
//		width:	'954px'
		},
		600,
		function(){
			$('#main-hot-'+id).addClass('main-hot-active');
			var index = $(".main-hot-active .tophot li").index($(".main-hot-active .tophot li.here"));
			parametr.start	=	index;
			clearTimeout(myInterval);
			myInterval = setTimeout(triggerclick,parametr.intensiv*1000);
		}
	);
}
