/*Browsercheck:*/
ie=document.all?1:0 
n=document.layers?1:0 

//declare globals to build object reference
var whichDom = "", styleObj = "", howDom ="", writeObj =""
var isNav4, isNav6, isIE
var isBrand = navigator.appName
var agt = navigator.userAgent.toLowerCase()
var navVer = parseInt(navigator.appVersion)

isNav4 = (isBrand == "Netscape" && navVer < 5) ? true : false
isNav6 = (isBrand == "Netscape" && navVer >= 5) ? true : false
isNav46 = ((isBrand == "Netscape") && (parseFloat(navigator.appVersion) >= parseFloat(4.6)) && (parseFloat(navigator.appVersion) < parseFloat(4.7))) ? true : false
isNav47 = ((isBrand == "Netscape") && (parseFloat(navigator.appVersion) >= parseFloat(4.7))) ? true : false

isIE = ((agt.indexOf("msie") != -1) && (parseInt(navVer) >= 4)) ? true : false

//construct object reference
var doc = document
var layers = doc.layers
var all = doc.all

if (layers)  
{
  whichDom = '["'
  styleObj = '"]'
} 
else if (all)  
	{
		whichDom = ".all."
		  styleObj = ".style"
	} 
	else 
	{
		whichDom = '.getElementById("'
		styleObj = '").style'
	}
	
	if (layers)  
	{
		howDom = '.'
		writeObj = '.'
	} 
	else if (all)  
		{
			howDom = ".all."
			writeObj = ""
		} 
		else 
		{
			howDom = '.getElementById("'
			writeObj = '")'
		}


//Css style object reference

function setObject(obj) 
{
	var theObj
	if (typeof obj == "string")
		theObj = eval("document" + whichDom + obj + styleObj)
	else		
		theObj = obj
	return theObj
}

//Content object reference

function objectForWriting(obj,nest) 
{
	var theObj	
	if (typeof obj == "string")
		if (n)//Navigator 4.x
			theObj = eval(nest + "document" + howDom + obj + writeObj + "document");
		else
			theObj = eval("document" + howDom + obj + writeObj);
	else 
		theObj = obj
	return theObj
}

/********************************************************************************
Here are the variables you must set: (this is the only part you have to change)
Remember that, if you wan't different size for the layers, different clip or anything
change that in the stylesheet.*/

//The number of news lines
var lines = 2;

//The current first news 
var currentNews=0;
betweendelay=3000
var loop=1
FontFace='verdana'
FontSize=11
fadeback=0

var idTimeout = -1

colors=new Array()
colors[0]='#FFFFFF'
colors[1]='#EEEEEE'
colors[2]='#E3E4F9'
colors[3]='#B8B9F0'
colors[4]='#24279C'
colors[5]='#1F2289'
colors[6]='#191970'

fadeInit=new Function("oNews=new makeObj('divNews','divCont'); fadeNews(0)");

function makeObj(obj,nest)
{
	nest=(!nest) ? '':'document.'+nest+'.'
	this.css=setObject('divNews');
	this.writeref=objectForWriting(obj, nest);
	this.fadeIt=b_fadeIt
    	this.obj = obj + "Object"; 	eval(this.obj + "=this")	
}

function b_fadeIt(font,size,speed,fn,num,c0,c1,c2,c3,c4,c5,c6)
{
	if(num<arguments.length && arguments[num]!=0)
	{	
		writetext = "<table valign=top id='tableNews' width='100%' border='0' bordercolor=red cellpadding='1' cellspacing='1' height='100%'>"
		var indiceSuperiore = lines
		
		if (ArrayNews.length <= lines)
			indiceSuperiore = ArrayNews.length
		
		for (var i=0; i<indiceSuperiore; i++) 
		{ 
			//write a newsline
			text=ArrayNews[(currentNews+i)%newsCounter]["titolo"];
			data=ArrayNews[(currentNews+i)%newsCounter]["data"];
			id=ArrayNews[(currentNews+i)%newsCounter]["id"]; 
			//writetext+='<tr height=29%><td ><font face="'+font+'" size="2" color="#296AA2"><b>News:&nbsp;</b></font><a href="javascript:ApriNews('+id+')" style="text-decoration:none; font-size:'+size+'px; color:Midnightblue">' + data + ' - '
			//writetext+='<tr height=29%><td ><a href="javascript: ApriNews('+id+');" onmouseout="javascript:Start();" onmouseover="javascript:Stop();" style="text-decoration:none; font-size:'+size+'px; color:#B22C1B"><b>' + data + '</b> - '
			writetext+='<tr height=29%><td ><a href="javascript: ApriNews('+id+');" style="text-decoration:none; font-size:'+size+'px; color:#B22C1B"><b>' + data + '</b> - '
			//writetext+='<font face="'+font+'" color="'+arguments[num]+'">'
			writetext+='<font face="'+font+'" color="#655745">'
			writetext+=text+'</font></a></td></tr>';
			//if (i<indiceSuperiore-1)
			//	writetext+='<tr height=1px><td align=center><img src="../images/lineanews.gif"></td></tr>';
		}	

	    writetext += "</table>"
		if(n)
		{
			this.writeref.write(writetext); 
			this.writeref.close()
		}
		if (isNav6) this.writeref.innerHTML=writetext;
		
		if(ie) this.writeref.innerHTML=writetext		
		
		num++

		idTimeout=setTimeout(this.obj+'.fadeIt("'+font+'",'+size+','+speed+',"'
		+fn+'",'+num+',"'+c0+'","'+c1+'","'+c2+'","'+c3+'","'+c4+'","'+c5+'","'+c6+'")',speed)
						
	}else 
		setTimeout('eval('+fn+')',betweendelay)
	if (num==12)
	{	
		if (ArrayNews.length <= lines)
			window.clearTimeout(idTimeout)
	}
}

function fadeNews(num)
{
   	if (ArrayNews.length > 0)
	{
   		currentNews=num;
		if(num<ArrayNews.length)
		{
			if (loop)
			{
				fn=fadeback?'fadeBack('+num+')':'fadeNews('+(num+1)+')';
				oNews.fadeIt(FontFace,FontSize,1,fn,7,
				colors[0],colors[1],colors[2],colors[3],colors[4],colors[5],colors[6])
			}
		}
		else 
			if(loop) 
				fadeNews(0)
	}
}

/*function Start()
{
	loop = 1
	currentNews --
	if (currentNews < 0) currentNews = 0
	fadeNews(currentNews)
}

function Stop()
{
	loop = 0
}*/

function fadeBack(num)
{
	if(num>=0){
		oNews.fadeIt(FontFace,FontSize,1,'fadeNews('+(num+1)
		+')',7,colors[6],colors[5],colors[4],colors[3],colors[2],colors[1],colors[0])
		}
}

