/*
* JqNews - JQuery NewsTicker
* Author: Gravagnola Saverio and Iuliano Renato
* Version: 1.0
*/

var newsVisual = 1; // Numero di news da visualizzare - news to be displayed
var intervallo = 5000; // >1500

$(document).ready(function() {
    // Totale news
    var numNews = $("#actusHbox").children().length;
    if(numNews>1)
	{
		// Controllo di overflow
		if (newsVisual > numNews) {
			newsVisual = numNews;
		}
	
		var gestInter = setInterval(jqNewsRotate, intervallo);
	
		// Gestione del mouseover-mouseout
		$("#actusHbox").mouseover(function() { clearInterval(gestInter) });
		$("#actusHbox").mouseout(function() { gestInter = setInterval(jqNewsRotate, intervallo); });
	}
});

function jqNewsRotate(_newsVisual) {

    // Inserire lo stesso valore utilizzato per definire l'altezza ed i margini dei div nel file css/style.css
    var altezzaDiv = -173; 
    var margineDiv = 5;

   
    // Movimento verso l'alto
        $($("#actusHbox").children()[0]).animate({ marginTop: altezzaDiv }, 1000, "linear", function() {
        // Ripristino posizione elemento nascosto
            $($("#actusHbox").children()[0]).css("margin", margineDiv);
            // Spostamento in coda dell'elemento nascosto
            $("#actusHbox").append($($("#actusHbox").children()[0]));
        });
}
