// File JScript
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function readCookie(name) {
    var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
//****************************************************************
// Fade per le news
try
{
	window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);
}
catch(E)
{
	}

var d=document, terna_news_array = new Array(), operatori_news_array = new Array(), zInterval = null;
var objs = new Array(), terna_current=0, operatori_current=0, pause=false;
var fadeColorNews = new Array('238ad9','2b8fdb','3594dc','419ade','50a1e1','5fa9e3','6fb3e6','80bbe9','91c4ec','a2cdef','b3d7f1','c3dff4','d3e7f8','e0effa','ecf5fc','ffffff');
var fadeColorDate = new Array('808080','858585','8c8b8b','939393','9c9c9c','a6a5a5','b0afb0','bababa','c4c5c5','cfcfd0','d9dada','e2e3e3','ecebeb','f3f3f3','fafafa','ffffff');
function so_init()
{
	if(!d.getElementById || !d.createElement)return;
	css = d.createElement('link');
	css.setAttribute('href','slideshow2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d.getElementsByTagName('head')[0].appendChild(css);
	try{
		objs = d.getElementsByTagName('div');
		//alert(objs.length);
		var t_index = 0, o_index = 0 ;
		for(n=0;n<objs.length;n++){
			if(objs[n].id=="terna_news"){
				terna_news_array[t_index]=objs[n];
				t_index++;
			}
			if(objs[n].id=="operatori_news"){
				operatori_news_array[o_index]=objs[n];
				o_index++;
			}
		}
		//alert(terna_news_array.length);
		for(i=1;i< terna_news_array.length;i++)
		{
			terna_news_array[i].xOpacity = 0;
			terna_news_array[i].style.display = 'none';
		}
		terna_news_array[0].style.display = 'block';
		terna_news_array[0].xOpacity = .99;

		//alert(operatori_news_array.length);
		for(i=1;i< operatori_news_array.length;i++)
		{
			operatori_news_array[i].xOpacity = 0;
			operatori_news_array[i].style.display = 'none';
		}
		operatori_news_array[0].style.display = 'block';
		operatori_news_array[0].xOpacity = .99;

		setTimeout(so_xfade,3000);
	}catch(err){
		//alert(err);
	};
}

function so_xfade()
{
	cOpacity = terna_news_array[terna_current].xOpacity;
	n_terna_Index = terna_news_array[terna_current +1]?terna_current +1:0;
	n_operatori_Index = operatori_news_array[operatori_current +1]?operatori_current +1:0;
	nOpacity = terna_news_array[n_terna_Index].xOpacity;

	cOpacity-=.09;
	nOpacity+=.09;	
	if(terna_news_array.length>1)
	{
		terna_news_array[terna_current].xOpacity = cOpacity;
		setOpacity(terna_news_array[terna_current]);
	}
	if(operatori_news_array.length>1)
	{
		operatori_news_array[operatori_current].xOpacity = cOpacity;
		setOpacity(operatori_news_array[operatori_current]);
	}

	if(cOpacity<=0)
	{
		terna_news_array[terna_current].style.display = 'none';
		terna_current = n_terna_Index;
		operatori_news_array[operatori_current].style.display = 'none';
		operatori_current = n_operatori_Index;

		terna_news_array[terna_current].style.display = 'inline';
		terna_news_array[terna_current].xOpacity = 1;
		setOpacity(terna_news_array[terna_current]);

		operatori_news_array[operatori_current].style.display = 'inline';
		operatori_news_array[operatori_current].xOpacity = 1;
		setOpacity(operatori_news_array[operatori_current]);

		setTimeout(so_xfade,3000);
	}
	else
	{
		setTimeout(so_xfade,50);
	}
}
/*
function so_xfade_old()
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;

	cOpacity-=.03;
	nOpacity+=.03;
	imgs[current].xOpacity = cOpacity;
	setOpacity(imgs[current]);

	if(cOpacity<=0)
	{
		imgs[current].style.display = 'none';
		current = nIndex;

		imgs[current].style.display = 'block';
		imgs[current].xOpacity = 1;
		setOpacity(imgs[current]);
		setTimeout(so_xfade,3000);
	}
	else
	{
		setTimeout(so_xfade,50);
	}
}
*/
function setOpacity(obj)
{
	if(obj.xOpacity>.99)
	{
		obj.xOpacity = .99;
		newColorNews=fadeColorNews[0];
		newColorDate=fadeColorDate[0];
	//alert(newColor);	
		//obj.getElementsByTagName('span')[0].style.color="#"+newColorNews;
		//obj.getElementsByTagName('span')[1].style.color="#"+newColorDate;
			
	}
	obj.style.opacity = obj.xOpacity;
	obj.style.MozOpacity = obj.xOpacity;
	obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	if (obj.xOpacity)
	{
		newIndex=15-Math.floor(((obj.xOpacity)*15));
		if (newIndex<0) newIndex=0;
		if (newIndex>15) newIndex=15;
		newColorNews=fadeColorNews[newIndex];
		newColorDate=fadeColorDate[newIndex];
	//alert(newColor);	
		//obj.getElementsByTagName('span')[0].style.color="#"+newColorNews;
		//obj.getElementsByTagName('span')[1].style.color="#"+newColorDate;
	}	
	//alert(obj.xOpacity + " : " +newColor);
	//eval(obj.id+"["+obj.sourceIndex+"].style.color='#"+newColor+newColor+newColor+"'");
	//obj.style.color="#"+newColor+newColor+newColor+newColor+newColor+newColor;
}
