var onHover = 0;
var stop = 0;
var count = 0;

$(document).ready(function() {
	$('.get-news').show();
	
	$("#main-news").hover(function(){
		if (!stop) onHover = 1;
	}, function(){
		if (!stop) onHover = 0;
	});
    
    $(".tln").hoverIntent(function(){
        onHover = 1;
        stop = 1;
        var i = $(this).attr("id");
        changeNews(i);
        moveLabel(i);
    },function(){
        onHover = 0;
        stop = 0;
    });
    autoSlide();
});


function autoSlide(){
	if (!onHover){
		count++;
		if (count == 4) count=1;
		changeNews(count);
        moveLabel(count);
	}
	setTimeout("autoSlide()",4000);
}

function moveLabel(i){
    if( i == 1 ){
        $('.placeholder').stop().animate({
        "top": "10px"
        }, "slow");
    }else if(i == 2){
        $('.placeholder').stop().animate({
        "top": "67px"
        }, "slow");
    }else if(i == 3){
        $('.placeholder').stop().animate({
        "top": "122px"
        }, "slow");
    }
}

function changeNews(i){
    var togglerID = "#toggler-"+i;
    var aGetNews = $(togglerID).find("a.get-news");
    $(".get-news").parent().removeClass('active');
    $(aGetNews).parent().addClass('active');		
    $("#main-news").html($("#hidden-news-"+i).html());
    $('.get-news-attachments').find('a.get-audio-file').click(function(){
    $(this).parent().parent().find('.news-attachments').slideToggle();
    $(this).toggleClass('_toggled');
        return false
    });	
}