$(function(){var documentWidth=211;$(".widget, .widget li, .widget ul div div").width(documentWidth);var newsCarouselflag=1;var newsCarouselWidth=documentWidth;$(".widget .c-btn").each(function(i){$(".widget li").eq(i).addClass($(this).attr("id"));});$(".widget li:last").prependTo(".widget ul");$(".widget ul").width($(".widget li").length*newsCarouselWidth);$(".widget ul").css("left","-"+newsCarouselWidth+"px");$(".widget .c-next, .widget .c-prev").removeClass("hidden");function doSlide(i,y,nav){newsCarouselflag=0;$(".widget ul").animate({left:nav+newsCarouselWidth},250/y,function(){if(nav=='+=')$(".widget li:last").prependTo(".widget ul");else $(".widget li:first").appendTo(".widget ul");$(".widget ul").css("left","-"+newsCarouselWidth+"px");i++;newsCarouselflag=1;if(i<y)doSlide(i,y,nav);else{$(".widget .c-btn").removeClass("activ");$("#"+$(".widget li").eq(1).attr("class")).addClass("activ");}});}function slideNews(){$(".widget .c-next").click();setTimeout(slideNews,12000);}$(".widget .c-btn").click(function(){if($(this).hasClass("activ"))return false;if(newsCarouselflag==0)return false;var currentElement=$(".widget li").eq(1).attr("class").replace("c-news-","");var currentButton=$(this).index();if(currentElement<currentButton)doSlide(0,currentButton-currentElement,'-=');else doSlide(0,currentElement-currentButton,'+=');return false;});$(".widget .c-next").click(function(){if(newsCarouselflag==0)return false;doSlide(1,1,'-=');});$(".widget .c-prev").click(function(){if(newsCarouselflag==0)return false;doSlide(1,1,'+=');});setTimeout(slideNews,12000);});