var stop = false;
var cont = 0;

function chamada(id, clicked, cod) {
	if (clicked) stop = true;
	$.ajax({
		url: 'chamadas.php',
		type: 'get',
		data: "id_article="+id,
		global: false,
		beforeSend: function() {
			$('img#carregador').show();
		},
		success: function(data) {
			$('img#carregador').hide();
			$('#box_chamadas').html(data);
		}
	});
	var x = 'id' + cod;
	$('#'+x).css('background', 'url(public/images/fundoAtual.png) no-repeat');
	for (i = 0; i < 4; i++){
        if (i != cod){
        	var y = 'id' + i;
        	$('#'+y).css('background', 'url(public/images/fundoLink.png) no-repeat');
        }
    }
}

function carrosel() {

	if (!stop) {
		if (cont >= chamadas.length) 
			cont = 0;
		chamada(chamadas[cont], false, cont);
		cont++;
	}
	else clearInterval(interval);
}
