var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline=0;

$(document).ready(function(){
  headline_count = $("div.headline").size();
  $("div.headline:eq("+current_headline+")").css('top','5px');
  
  headline_interval = setInterval(headline_rotate,3000); //time in milliseconds
  $('#scrollup').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,3000); //time in milliseconds
    headline_rotate();
  });
  // new
});

function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count; //remainder will always equal old_headline until it reaches headline_count - at which point it becomes zero. clock arithmetic
  $("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
    $(this).css('top','210px');
    });
  $("div.headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
  old_headline = current_headline;
}


try {
var pageTracker = _gat._getTracker("UA-2884027-2");
pageTracker._trackPageview();
} catch(err) {}

function NiftyCheck(){
if(!document.getElementById || !document.createElement)
    return(false);
var b=navigator.userAgent.toLowerCase();
if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
    return(false);
return(true);
}

function Rounded(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    AddTop(v[i],bk,color,size);
    AddBottom(v[i],bk,color,size);
    }
}

function RoundedTop(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
    AddTop(v[i],bk,color,size);
}

function RoundedBottom(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
    AddBottom(v[i],bk,color,size);
}

function AddTop(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rbottom";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.appendChild(d,el.firstChild);
}

function getElementsBySelector(selector){
var i;
var s=[];
var selid="";
var selclass="";
var tag=selector;
var objlist=[];
if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    objlist.push(document.getElementById(selid));
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className==selclass){
        objlist.push(v[i]);
        }
    }
return(objlist);
}


//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="format01.php">L\'evento</a>'
menu1[1]='<a href="format02.php">Planimetria</a>'
menu1[2]='<a href="format03.php">Location</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="visit01.php">Chi incontrerete</a>'
menu2[1]='<a href="visit02.php">Iscriviti</a>'

var menu3=new Array()
menu3[0]='<a href="espo01.php">Come partecipare</a>'
menu3[1]='<a href="espo02.php">Tutti gli espositori</a>'

var menu4=new Array()
menu4[0]='<a href="sele01.php">Incontri liberi</a>'
menu4[1]='<a href="sele02.php">Selezioni</a>'

var menu5=new Array()
menu5[0]='<a href="eventi01.php">17 febbraio</a>'
menu5[1]='<a href="eventi02.php">18 febbraio</a>'

var menu6=new Array()
menu6[0]='<a href="af04.php">Proposte formative</a>'
menu6[1]='<a href="af01.php"">Percorsi formativi</a>'
menu6[2]='<a href="af02.php"">Punti di forza</a>'
menu6[3]='<a href="af03.php"">Stage</a>'
menu6[4]='<a href="af05.php"">Placement</a>'
		
var menuwidth='165px' //default menu width
var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}

function dropdownmenu(obj, e, menucontents, menuwidth){

if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation();

clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu


function aPPlica()
{
veLox = 1;
eL = document.getElementById("dentro");
eL.style.top = 0;
alteZZa = eL.offsetHeight	;
alteZZaEst = document.getElementById("fuori").offsetHeight;
setTimeout('Izz=setInterval("scoRRi()",50)', 1000);
}

function scoRRi()
{
if (parseInt(eL.style.top)>(alteZZa*(-1)))
eL.style.top=parseInt(eL.style.top)-veLox +'px';
else
eL.style.top=parseInt(alteZZaEst)+'px';
}

if (window.addEventListener)
window.addEventListener("load", aPPlica, false);
else if (window.attachEvent)
window.attachEvent("onload", aPPlica);
else if (document.getElementById)
window.onload=aPPlica;

function aumDim(stopAgain)
{
	veLox = stopAgain;
}



// Onload --------------------------------------------------------


window.onload=function(){
	
if(document.getElementById('resizablez')!=null)
{
rez = document.getElementById('resizablez');

  if (rez.addEventListener){ 
rez.addEventListener('mouseover', function(){InFiLa('news-aj.php','resizable')}, false); 	
} else if (rez.attachEvent) { 
rez.attachEvent('onmouseover', function(){InFiLa('news-aj.php','resizable')}); 
} 
}
	
if(!NiftyCheck())
    return;
	
Rounded("div.nifty","#FFFFFF","#d68631");
Rounded("div.nifty2","#000000","#d68631");
Rounded("div.niftyred","#000000","#712124");
Rounded("div.niftyw","#000000","#FFFFFF");
Rounded("div.niftyscheda","#FFFFFF","#712124");

<!-- target blank inizio -->
var i = 0;
  var collegamenti = document.links;
  for (i=0; i<collegamenti.length; i++)
  {
    if (collegamenti[i].title == "Nuova finestra")
    {
      collegamenti[i].target = "_blank";
    }
  }
 // Elementi del menu
formu = document.getElementById('formatz');
visitu = document.getElementById('visitz');
espu = document.getElementById('espoz');
selu = document.getElementById('selez');
eventiu = document.getElementById('eventiz');
afu = document.getElementById('afz');

// Barra news (dx)
destru = document.getElementById('fuori');

<!-- target blank fine -->
/*
document.getElementById('formatz').onmouseover =  function(){dropdownmenu(this, event, menu1, "85px");} ;
document.getElementById('formatz').onmouseout = function(){delayhidemenu();};
*/

    if (formu.addEventListener){ 
			// Menu
            formu.addEventListener('mouseover', function(e){var evt = window.event || e; dropdownmenu(formu, evt, menu1, "98px")}, false); 
			visitu.addEventListener('mouseover', function(e){var evt = window.event || e; dropdownmenu(visitu, evt, menu2, "116px")}, false);
			espu.addEventListener('mouseover', function(e){var evt = window.event || e; dropdownmenu(espu, evt, menu3, "120px")}, false);
			selu.addEventListener('mouseover', function(e){var evt = window.event || e; dropdownmenu(selu, evt, menu4, "112px")}, false);
			eventiu.addEventListener('mouseover', function(e){var evt = window.event || e; dropdownmenu(eventiu, evt, menu5, "91px")}, false);
			afu.addEventListener('mouseover', function(e){var evt = window.event || e; dropdownmenu(afu, evt, menu6, "163px")}, false);
			// Destra
			 destru.addEventListener('mouseover', function(){aumDim(0)}, false); 
			
			// Menu
			formu.addEventListener('mouseout', function(){delayhidemenu()}, false); 
			visitu.addEventListener('mouseout', function(){delayhidemenu()}, false); 
			espu.addEventListener('mouseout', function(){delayhidemenu()}, false); 
			selu.addEventListener('mouseout', function(){delayhidemenu()}, false); 
			eventiu.addEventListener('mouseout', function(){delayhidemenu()}, false); 
			afu.addEventListener('mouseout', function(){delayhidemenu()}, false); 
			//Destra
			destru.addEventListener('mouseout', function(){aumDim(1)}, false); 
    } else if (formu.attachEvent){ 
			//Menu
			formu.attachEvent('onmouseover', function(){dropdownmenu(formu, event, menu1, "98px");}); 
			visitu.attachEvent('onmouseover', function(){dropdownmenu(visitu, event, menu2, "116px");}); 
			espu.attachEvent('onmouseover', function(){dropdownmenu(espu, event, menu3, "120px");}); 
			selu.attachEvent('onmouseover', function(){dropdownmenu(selu, event, menu4, "112px");}); 
			eventiu.attachEvent('onmouseover', function(){dropdownmenu(eventiu, event, menu5, "91px");}); 
			afu.attachEvent('onmouseover', function(){dropdownmenu(afu, event, menu6, "163px");}); 
			// Destru
			destru.attachEvent('onmouseover', function(){aumDim(0)}); 
			
			//Menu
			formu.attachEvent('onmouseover', function(){delayhidemenu()}); 
			visitu.attachEvent('onmouseover', function(){delayhidemenu()});
			espu.attachEvent('onmouseover', function(){delayhidemenu()}); 
			selu.attachEvent('onmouseover', function(){delayhidemenu()}); 
			eventiu.attachEvent('onmouseover', function(){delayhidemenu()}); 
			afu.attachEvent('onmouseover', function(){delayhidemenu()}); 
			destru.attachEvent('onmouseout', function(){aumDim(1)}); 
    } 

if(document.getElementById('manunta'))
{
	nomi=new Array("manunta", "barbarossa", "petrucci", "albano", "scauri", "creti", "dutto");
	
	for (i=0; i<8;i++)
	{
	
		nometipo = nomi[i];
		cv = document.getElementById(nometipo);
		chiuditipo=nomi[i]+'chiudi';
		chiudi = document.getElementById(chiuditipo);
		
		if (cv.addEventListener)
		{ 
			cv.addEventListener('click', Alza, false);  
			chiudi.addEventListener('click', Abbassa, false);
		} 
		else if (cv.attachEvent) 
		{ 
			cv.onclick = function() {Alza(this)};
			chiudi.onclick = function(){Abbassa(this)};
		}
	
	}
}







}



function Alza(eL)
{
	if(this.id)
	stringa = this.id + 'click';
	else
	stringa = eL.id + 'click';
	var eleM =document.getElementById(stringa) ;
	eleM.style.zIndex = 3;

}

function Abbassa(eL)
{
		
	if(this.id)
	{
		
		stringa = this.id;
		stringa = stringa.replace("chiudi", "");
		stringa = stringa + 'click';
	}
	else
	{	
		stringa = eL.id;
		stringa = stringa.replace("chiudi", "");
		stringa = stringa + 'click';
	}
	var eleM =document.getElementById(stringa);
	eleM.style.zIndex = -3;
}
