// JavaScript Document
var flashinterval,
	flashNews,
	flashNewsLI,
	topPosition = 0,
	newsHeight,
	flashSpeed = 75;

function getFlashNews()
{
	
	if(flashNews == undefined) flashNews = document.getElementById('flashNews');
	if(flashNews == undefined) return false;
	if(flashNewsLI == undefined) flashNewsLI = flashNews.getElementsByTagName('li');
	
	newsHeight = flashNewsLI[0].offsetHeight;
	flashNews.style.top = '0';
	
	
	flashNews.onmouseover = function()
	{
		flashinterval = clearInterval(flashinterval);
	}
	
	flashNews.onmouseout = function()
	{
		//flashinterval = setInterval('flashSlide(flashNews)', flashSpeed);
		flashinterval = setInterval('moveflashNewsLI()', flashSpeed);
	}
		
	//flashinterval = setInterval('flashSlide(flashNews)', flashSpeed);
	flashinterval = setInterval('moveflashNewsLI()', flashSpeed);
}


function moveflashNewsLI()
{
	
	topPosition -= 1;
	flashNews.style.top = topPosition + 'px';
	
	if(topPosition < -newsHeight)
	{
		flashNews.appendChild(flashNewsLI[0]);
		topPosition = -1;
		flashNews.style.top = '-1px';
		flashNewsLI = flashNews.getElementsByTagName('li');
		newsHeight = flashNewsLI[0].offsetHeight;
	}
}

function switchFlashNews(page)
{
	var flashNews = document.getElementById('flashContainer');
	
	var xmlhttp;
	
	if (window.XMLHttpRequest)
	  {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	
	xmlhttp.onreadystatechange=function()
	{
	if(xmlhttp.readyState==4)
	  {
	  flashNews.innerHTML = xmlhttp.responseText;
	  }
	}
	xmlhttp.open("GET",'/newversion/notizie/getflashnews.php?p='+page,true);
	xmlhttp.send(null);
	
	return false;
}
	
