/*Browsercheck:*/
ie=document.all?1:0 // Internet Explorer
n=document.layers?1:0 // Netscape 4.x

//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

/********************************************************************************
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 = 3;

//The current first news 
var currentNews=0;

//The delay between the fades (in milliseconds) smaller value gives less time:
betweendelay=4500

//Do you wan't it to start over on the first one when it's gone trought all the news?
//(set to 0 if not)
var loop=1

//What font do you wan't it use?
FontFace='verdana,arial,helvetiva'

//What font-size (in pixel)?
FontSize=11

//Do you wan't it to fade out aswell? 1 for on, 0 for off
fadeback=0

//Set the colors, first color is same as background, last color is the color it stops at:
//You can have upto 7 colors, set the ones you wan't use to 0
colors=new Array()
colors[0]='#FFFFFF'
colors[1]='#EEEEEE'
colors[2]='#CCCCCC'
colors[3]='#999999'
colors[4]='#666666'
colors[5]='#333333'
colors[6]='#000000'
/*Dont change anything below this!
*********************************************************************************/
var obj= null ;
// fadeInit = new Function("oNews=new makeObj('divNews1'); fadeNews(0)");
//fadeInit = new Function("fadeNews(0)");
oNews=new makeObj('divNews1'); 


//var objName = 'divNews1';
//if ((obj=MM_findObj(objName))!=null) with (obj) fadeIt=b_fadeIt;
//alert(obj.fadeIt.tostring());

function makeObj(obj){
	this.fadeIt=b_fadeIt;
	this.obj = MM_findObj(obj);
	return obj;
}

/*function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_setTextOfLayer(objName,x,newText) { //v3.0
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (navigator.appName=='Netscape'&&(document.layers)) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}
*/
/*
function makeObj(obj,nest){
    nest=(!nest) ?'':'document.'+nest+'.'
    this.css=setObject('divNews1');
	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=''
	// writetext='<hr size="1" color="#ffffff" width="100%">';
	//writetext='';
		for (var i=0; i<lines; i++) { //write a newsline
		    type=news[(currentNews+i)%newsCounter]["type"];
			time=news[(currentNews+i)%newsCounter]["time"];
			if (news[(currentNews+i)%newsCounter]["text"].length>60)
				text=news[(currentNews+i)%newsCounter]["text"].slice(0,60)+"...";
			else
				text=news[(currentNews+i)%newsCounter]["text"];
			link=news[(currentNews+i)%newsCounter]["link"];
			target="_blank";
			// target=news[(currentNews+i)%newsCounter]["target"];
			writetext+='<a href="'+link+'"'
			+' target="'+target+'"'
			+' style="text-decoration:none; width:240px; font-size:'+size+'px">'
			+'<font face="'+font+'" color="'+arguments[num]+'">'
			//+'<img src="'+type+'.gif"> '
			+'<font color="#0099cc"><b>'+time+' </b></font>'
			+text
			//+' [<b>'+type+'</b>]'
			+'</font></a><br>';
			//if (i+1<lines)
			writetext+='<br>'
			//writetext+='<hr size="1" color="#ffffff" width="100%">';
	    }
		scrivi('divNews1',writetext);
		//MM_setTextOfLayer('divNews1','',writetext);
		//if(n) MM_setTextOfLayer('divNews1','',writetext);
		//if(isNav6) MM_setTextOfLayer('divNews1','',writetext);
		//if(ie) MM_setTextOfLayer('divNews1','',writetext);
		//if(n){this.writeref.write(writetext); this.writeref.close()}
		//if (isNav6) this.writeref.innerHTML=writetext;
		//if(ie) this.writeref.innerHTML=writetext
		num++;
		setTimeout('oNews.fadeIt("'+font+'",'+size+','+speed+',"'
		+fn+'",'+num+',"'+c0+'","'+c1+'","'+c2+'","'+c3+'","'+c4+'","'+c5+'","'+c6+'")',speed)
	}
	else setTimeout('eval('+fn+')',betweendelay);
}
function fadeNews(num){
	currentNews=num;
	if(num<news.length){
		fn=fadeback?'fadeBack('+num+')':'fadeNews('+(num+1)+')';
		oNews.fadeIt(FontFace,FontSize,100,fn,7,
		colors[0],colors[1],colors[2],colors[3],colors[4],colors[5],colors[6])}
	else if(loop)fadeNews(0)
}

function fadeBack(num){
	if(num>=0){
		oNews.fadeIt(FontFace,FontSize,100,'fadeNews('+(num+1)
		+')',7,colors[6],colors[5],colors[4],colors[3],colors[2],colors[1],colors[0])
	}
}
//setTimeout('document.writeln("fdjghlsd")',1000);
fadeNews(0);
/*End of fadescript
**********************************************************************************/

