function mycarousel_initCallback(carousel) {
    $('.slider-nav a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });	    
    
    jQuery('.slider-arrs a.next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('.slider-arrs a.prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};
	
function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
	$('.slider-nav a').removeClass('active');
	$('.slider-nav a').eq(idx-1).addClass('active');
};

$(function(){
	$('#navigation > ul > li:last').addClass('last');
	$('#navigation > ul > li:first').addClass('home-link');
	
	$('#topmenu ul.navigation_niv_2').each(function(){
		$(this).find('li:last').addClass('last');
		$(this).append('<li class="rounded"></li>');
	});
	
	$('#topmenu ul li').hover(function(){
		if($(this).find('ul').length){
			$(this).find('a:first').addClass('hover');
		}
	},function(){
		$(this).find('a:first').removeClass('hover');
	});
	
	$(".slider").jcarousel({
	    scroll: 1,
	    wrap: 'both',
	    auto: 0,
	    itemFirstInCallback: mycarousel_itemFirstInCallback,
		initCallback: mycarousel_initCallback,
	    buttonNextHTML: null,
	    buttonPrevHTML: null
	}); 
	
	setTimeout(function() {$('.sidebar-bottom').css('bottom', "-"+($('.sidebar-bottom').height()+10)+"px");}, 100);
	
	
	$('.block-article-item, .item').each(function(){
		var img = $(this).find('.image').html();
		$(this).find('.image img').remove();
		$(this).find('.image').append('<div class="inner">'+img+'</div>');
	});
	
	$('.block-article-item, .item, .main-entry, .slider li').click(function(){
		var target = $(this).find('a').attr('href');
		window.location.href = target;
	})
	
});

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-3239722-14']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
