var msgarray=new Array
(
 '<font color="#4A9C96" size="2" face="Arial, Helvetica, sans-serif"><strong><a href=./news.html target=_blank>Consulta le ultime news</a></strong></font>',
 '<font color="#4A9C96" size="2" face="Arial, Helvetica, sans-serif"><strong><a href=./storiconews.html target=_blank>Visualizza lo storico delle news</a></strong></font>'
// '<font color="#4A9C96" size="2" face="Arial, Helvetica, sans-serif"><strong><a href="JavaScript:preferiti();">aggiungi il nostro sito ai tuoi preferiti</a></strong></font>'
);

var pausetime = 4000;  
var interval = 50;
var msginc = 10;

var direction = 'rand';
var direc = 'up';
var transition = 'rand';
var trans = 'cover';

var dpat = new Array('up','right','down','left');
var tpat = new Array('cover','uncover','contig');
tiepat = false;
var bgcolor = 'trasparent';
var dispv = 5;
var disph = 5;


mc=0; mcp=1; msgn=msgarray.length;
dpatc=0; tpatc=0; dpatm=0; tpatm=0;
d=document;
opsevbg = '';

if (tiepat)
{
 dar=dpat; tar=tpat; c=0;
 while(dpat.length < msgn) {dpat.push(dar[c]); c++; if (c >= dar.length) {c=0;}}
 c = 0;
 while(tpat.length < msgn) {tpat.push(tar[c]); c++; if (c >= tar.length) {c=0;}}
}

trans = (trans=='cover') ? trans : 'uncover';
if (direction=='althoz') {direc = (direc=='left') ? direc : 'right';}
else if (direction=='altver') {direc = (direc=='up') ? direc : 'down';}

mrqh=null; mrqw=null; mrqt=null; mrql=null;
mh=null; mw=null; mt=null; ml=null;
vt=0; vl=0; IID=0;

var appN = navigator.appName; var appV = navigator.appVersion.substring(0,1);
var ie = (appN=="Microsoft Internet Explorer" && appV >= 4) ? true : false;
var ns = (appN=="Netscape" && (appV >= 4 && appV < 5)) ? true : false;
var nsix = (appN=="Netscape" && appV >= 5) ? true : false;
var op = (navigator.userAgent.indexOf('Opera 6.') >= 0) ? true : false;
var opsev = (navigator.userAgent.indexOf('Opera 7.') >= 0) ? true : false;

if (!opsev) {dispv = 0; disph = 0;}


function beginmrq()
{
 if (op) {return;}
 if (ie||ns||nsix||opsev)
 {
  setupmrq();
  laymrq();
  laymsg();
  clearInterval(IID);
  pause();
 }
}


function insertdivs()
{
 if (op) {return;}
 if (ie||ns||nsix||opsev)
 {
  setupmrq();
  d.write('<div id="marquee" name="marquee" onMouseOver="javascript:clientpause(true);" onMouseOut="javascript:clientpause(false);" class="marquee">')
  for (i=0; i<msgarray.length; i++)
  {
   startmsg='<div id="message'+i+'" name="message'+i+'" class="message"><table width="'+mrqw+'" height="'+mrqh+'" border="0" cellspacing="0" cellpadding="0"><tr><td height="'+mrqh+'" width="'+mrqw+'" align="left" valign="center"' + opsevbg + '>';
   d.write(startmsg+msgarray[i]+'</td></tr><tr><td align="center"><img src="spacer.gif" width="'+mrqw+'" height="1"></td></tr></table></div>');
  }
  d.write('</div>');
 }
 beginmrq();
}

function setupmrq()
{
 if (ie||nsix||opsev)
 {
  mspace=d.mrqspacer;
  mrqt=mspace.offsetTop+dispv; mrql=mspace.offsetLeft+disph;
  mrqw=mspace.width; mrqh=mspace.height;
 } else {
  mspace=d.images.mrqspacer;
  mrqt=mspace.y+dispv; mrql=mspace.x+disph;
  mrqw=mspace.width; mrqh=mspace.height;
 }
 mw=mrqw; mh=mrqh; mt=mrqh;
}

function laymrq()
{
 if (ie||nsix||opsev)
 {
  with (d.getElementById('marquee').style)
  {
   top=mrqt; left=mrql; width=mrqw; height=mrqh;
   clip="rect(0px "+mrqw+"px "+mrqh+"px 0px)";
   visibility="visible";
  };
 } else {
  with (d.layers.marquee)
  {
   top=mrqt; left=mrql; width=mrqw; height=mrqh;
   clip.width=mrqw; clip.height=mrqh;
   visibility="show";
  };
 }
}

function laymsg()
{
 for (mc=0; mc < msgn; mc++)
 {
  if (ie||nsix||opsev)
  {
   with (d.getElementById("message"+mc).style)
   {
    width=mw; height=mh;
    if (mc) {top=-1000; left=-1000;} else {top=0; left=0;}
    vt=0;
    clip="rect(0px "+mrqw+"px "+mrqh+"px 0px)";
    visibility="visible";
   }
  } else {
   with (d.layers.marquee.document["message"+mc])
   {
    if (mc) {top=-1000; left=-1000;} else {top=0; left=0;}
    vt=0;
    clip.width=mw; clip.height=mh;
    visibility="show";
   }
  }
 }
 mc=0;
}


function timing()
{
 clearInterval(IID);
 IID=setInterval("movemsg()",interval);
}

function pause()
{
 clearInterval(IID);
 TID=setTimeout("clearTimeout(TID);timing()",pausetime);

 laymrq();

 if (direction == 'rand')
 {
  rn=Math.random()*3;
  rn=Math.round(rn);
  dar = new Array('up','down','left','right');
  direc = dar[rn];
 }

 if (direction == 'pattern')
 {
  if (tiepat)
  {
   direc = dpat[mc];
  } else {
   direc = dpat[dpatc];
   dpatc++;
   if (dpatc >= dpat.length) {dpatc = 0;}
  }
 }
 if (direction == 'althoz') {direc = (direc == 'left') ? 'right' : 'left';}
 if (direction == 'altver') {direc = (direc == 'up') ? 'down' : 'up';}
 if (direction != 'rand' && direction != 'altver' && direction != 'althoz' && direction != 'pattern')  {direc = direction;}

 if (transition == 'rand')
 {
  rn=Math.random()*2;
  rn=Math.round(rn);
  tar = new Array('contig','cover','uncover');
  trans = tar[rn];
 }
 if (transition == 'pattern')
 {
  if (tiepat)
  {
   trans = tpat[mc];
  } else {
   trans = tpat[tpatc];
   tpatc+=1;
   if (tpatc >= tpat.length) {tpatc = 0;}
  }
 }
 if (transition == 'alt') {trans = (trans == 'cover') ? 'uncover' : 'cover';}
 if (transition != 'rand' && transition != 'alt' && transition != 'pattern')  {trans = transition;}
}

function repos()
{
 clearInterval(IID);
 clearTimeout(TID);
 if (ie||nsix||opsev)
 {
  TID=setTimeout("clearTimeout(TID);clearInterval(IID);setupmrq();laymrq();timing()",1500);
 } else {
  window.location.reload();
 }
}


function st(mn,pos)
{
 if (ie||nsix||opsev) {d.getElementById("message"+mn).style.top=pos;} else {d.layers.marquee.document["message"+mn].top=pos;}
}

function sl(mn,pos)
{
 if (ie||nsix||opsev) {d.getElementById("message"+mn).style.left=pos;} else {d.layers.marquee.document["message"+mn].left=pos;}
}

function sz(mn,zin)
{
 if (ie||nsix||opsev) {d.getElementById("message"+mn).style.zIndex=zin;} else {d.layers.marquee.document['message'+mn].zIndex=zin;}
}

function sv(mn,tf)
{
 if (ie||nsix||opsev) {d.getElementById("message"+mn).style.visibility = (tf) ? 'visible' : 'hidden';} else {d.layers.marquee.document['message'+mn].visibility = (tf) ? 'show' : 'hide';}
}


function movemsg()
{
 if (direc == 'up') {vt -= (mh/msginc);}
 if (direc == 'down') {vt += (mh/msginc);}
 if (direc == 'left') {vl -= (mw/msginc);}
 if (direc == 'right') {vl += (mw/msginc);}

 sv(mc,true);

 if (trans == 'contig' || trans == 'uncover')
 {
  if (direc == 'up') {st(mc,vt);}
  if (direc == 'left') {sl(mc,vl);}
  if (direc == 'down') {st(mc,vt);}
  if (direc == 'right') {sl(mc,vl);}
 } else {
  sl(mc,0); st(mc,0);
 }

 if (trans == 'uncover') {sz(mc,2);} else {sz(mc,0);}

 mcp=mc+1;
 if (mcp >= msgn) {mcp=0;}

 sv(mcp,true);

 if (trans == 'contig' || trans == 'cover')
 {
  if (direc == 'up') {st(mcp,vt+mh); sl(mcp,vl);}
  if (direc == 'left') {sl(mcp,vl+mw); st(mcp,vt);}
  if (direc == 'down') {st(mcp,vt-mh); sl(mcp,vl);}
  if (direc == 'right') {sl(mcp,vl-mw); st(mcp,vt);}
 } else {
  sl(mcp,0); st(mcp,0);
 }

 if (trans == 'uncover') {sz(mcp,0);} else {sz(mcp,2);}

 stepflag = false;

 if (direc == 'up' && vt <= 0-mh) {st(mc,-1000); stepflag = true;}
 if (direc == 'down' && vt >= mh) {st(mc,-1000); stepflag = true;}
 if (direc == 'left' && vl <= 0-mw) {sl(mc,-1000); stepflag = true;}
 if (direc == 'right' && vl >= mw) {sl(mc,-1000); stepflag = true;}

 if (stepflag)
 {
  sv(mc,false);
  vl = 0; vt = 0;
  mc++;
  if (mc >= msgn) {mc=0;}
  mcp=mc+1;
  if (mcp >= msgn) {mcp=0;}
  sl(mc,vl); st(mc,vt);
  pause();
 }
}


function clientpause(tf)
{
 if (op) {return;}
 if (tf)
 {
  clearInterval(IID); clearTimeout(TID);
 } else {
  pause(); return;
 }
 vl = 0; vt = 0;
 sl(mc,vl); st(mc,vt); sz(mc,2);
 sl(mcp,-1000); st(mcp,-1000); sz(mcp,0);
}


function clientstep(stepd)
{
 if (op) {return;}
 if (stepd == 'back') {mc-=1;} else {mc+=1;} if (mc >= msgn) {mc=0;} if (mc < 0) {mc=msgn-1;}
 mcp=mc+1; if (mcp >= msgn) {mcp=0;} if (mcp < 0) {mcp=msgn-1;}
 for (cz=0; cz < msgn; cz++) {sl(cz,-1000); st(cz,-1000); sz(cz,0); sv(mc,false)};
 vl = 0; vt = 0;
 sl(mc,vl); st(mc,vt); sz(mc,2); sv(mc,true);
}

document.write('<style><!-- .marquee,.message {visibility: hidden; position: absolute; z-index: 1; background-color: ' + bgcolor + '; layer-background-color: ' + bgcolor + ';} --></style>');

