/*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

//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
}

/********************************************************************************
*/

//The current first news 
var currentNews=0;

//The delay between the fades (in milliseconds) smaller value gives less time:
betweendelay=5000

//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

//Do you wan't it to fade out aswell? 1 for on, 0 for off
fadeback=0

/*Dont change anything below this!
*********************************************************************************/
fadeInit=new Function("oNews=new makeObj('divNews1','divCont'); fadeNews(0)");

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(speed,fn,num){
	if(num<arguments.length && arguments[num]!=0){
		for (var i=0; i<1; i++) { //write a newsline
		    type=news[(currentNews+i)%newsCounter]["type"];
			PaeseOrig=news[(currentNews+i)%newsCounter]["IdPaese"];
			ContinOrig=news[(currentNews+i)%newsCounter]["IdCont"];
			Offerta=news[(currentNews+i)%newsCounter]["Id"];
			Paese=news[(currentNews+i)%newsCounter]["Paese"];
			Destinazione=news[(currentNews+i)%newsCounter]["Destinazione"];
			Inizio=news[(currentNews+i)%newsCounter]["Inizio"];
			Giorni=news[(currentNews+i)%newsCounter]["Giorni"];
			Notti=news[(currentNews+i)%newsCounter]["Notti"];
			Costo=news[(currentNews+i)%newsCounter]["Costo"];
			Hotel=news[(currentNews+i)%newsCounter]["Hotel"];
			Categoria=news[(currentNews+i)%newsCounter]["Categoria"];
			Linea = ' • ';
			if (Destinazione==Paese){
				Destinazione = '';
				Linea = ''
			}
			writetext = "<table cellpadding=2 cellspacing=0 border=1 align=center background=http://www.ultimominuto.net/immagini/sf_sito.jpg width=468 height=60><tr><td align=left><font face=Arial, Helvetica, sans-serif size=1 color=blue><b><font size=2><a href=" + '"' + "javascript:apri('" + PaeseOrig + "','" + Offerta + "')" + '"' + ">"+Paese+Linea+Destinazione+"</a> - </font></b><font size=2 color=black>partenza il "+Inizio+", "+Giorni+" giorni e "+Notti+" notti, &euro;: <font color=#AFBEF5>_</font>"+Costo+" - Hotel "+Hotel+" ("+Categoria+") - <a href=" + '"' + "javascript:apri('" + PaeseOrig + "','" + Offerta + "')" + '"' + ">Dettagli e prenotazione </a> </font></font> </td><td align=center style=font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-weight: bold>Servizio<br>Offerto da:<br><a href=http://www.ultimominuto.net target=_blank><img src=http://www.ultimominuto.net/immagini/UmServizio3.gif width=95 height=20 border=0 alt=Il tuo Network per Viaggi e Vacanze></a></td><tr></table>";
	    }

		if(n){this.writeref.write(writetext); this.writeref.close()}
		if (isNav6) this.writeref.innerHTML=writetext;
		if(ie) this.writeref.innerHTML=writetext		
		num++

		setTimeout(this.obj+'.fadeIt('+speed+',"'+fn+'",'+num+')',speed)
	}else setTimeout('eval('+fn+')',betweendelay)
}
function fadeNews(num){
	if (top.news==null) {
		alert("Warning: news file not loaded! Reload the page.");
		return;
	}
    currentNews=num;
	if(num<news.length){
		fn=fadeback?'fadeBack('+num+')':'fadeNews('+(num+1)+')';
		oNews.fadeIt(100,fn,0)
	}else if(loop)fadeNews(0)
}

function fadeBack(num){
	if(num>=0){
		oNews.fadeIt(100,'fadeNews('+(num+1)+')',0)
	}
}

function apri(PaeseOrig,Offerta)
{
	Link = 'http://www.ultimominuto.net/ricerca/Note.asp?paeseorig='+PaeseOrig+'&ordinorig=Destinaz&CodOfferta='+Offerta
	javascript:window.open(Link,'UltimoMinuto','resizable=no, scrollbars=yes, width=650, height=400, top=20,left=20')

}

/*End of fadescript
**********************************************************************************/