    var inter;
    var intTime = 3000;
    var AnimSpeed = 1000;
    var currElement; 
	var pause=false;
	
	
	var startScroll = function () {
		var inter = setInterval(initGallery, intTime);
	}


	var initGallery = function () {
		if (!pause) {
			var allList = $(".topsliderblock");
			
			$(allList).each(function () {
				if ($(this).hasClass("activeBlock")) {
					currElement = $(this);
				}
			});
			
			var ind = $(allList).index(currElement);
			
			if ((allList.length-1) == ind ) {
				nextElementIndex = 0;
			} else {
				nextElementIndex = ind + 1;
			}
			
			var ela = allList[nextElementIndex];
			
			$(ela).addClass("PrevActiveBlock");
			
			$(currElement).animate({opacity: 0}, AnimSpeed, function () {
				$(this).removeClass("activeBlock");
				$(this).css("opacity", "1");
				
				$(ela).addClass("activeBlock");
				$(ela).removeClass("PrevActiveBlock");
			});
		}
	}	
	
	
$(document).ready(function () {

	$(".topsliderblock:first-child").css("display","block").addClass("activeBlock");

	if ($(".topsliderblock").size() > 1) {
		startScroll();
	}
	
	/*
		$(".topsliderblock").hover(function () {
				pause = true;
			}, 
			function () {
				pause = false;;
		});
	*/
});


