function clip() {
 	// width of the banner container
 	var contWidth = 250;
 	// height of the banner container
 	var contHeight = 66;

 	var id1 = document.getElementById('slideA');
 	var id2 = document.getElementById('slideB');
 	var height = id1.offsetHeight;

 	id1.style.top = parseInt(id1.style.top)-1 + 'px';

 	document.getElementById('slideCont').style.height = contHeight + "px";
 	document.getElementById('slideCont').style.clip = 'rect(auto,'+ contWidth +'px,' + contHeight +'px,auto)';
 	id2.style.display = '';
 	if(parseFloat(id1.style.top) == -(height/2)) {
  		id1.style.top = '0px';
 	}
 	setTimeout(clip,50)
}

// Multiple onload function created by: Simon Willison
// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  if(document.getElementById('slideCont'))clip();
});

//==============================================================================

var banAD=new Array();
var banADlink=new Array();
var adNum=0;
banAD[0]="immagini/corriere_546x80.gif";
banADlink[0]="http://www.corrieredicaserta.net/";
banAD[1]="immagini/cronache_546x80.gif";
banADlink[1]="http://www.cronachedinapoli.org";
banAD[2]="immagini/centoeventi_546x80.gif";
banADlink[2]="http://www.granfondodelvolturno.it";
banAD[3]="immagini/snoopysport_546x80.gif";
banADlink[3]="http://www.snoopysport.it";
banAD[4]="immagini/martino_546x80.gif";
banADlink[4]="http://www.martinopubblicita.it";
banAD[5]="immagini/pr-sport_546x80.gif";
banADlink[5]="http://www.granfondodelvolturno.it";
var preloadedimages=new Array();
for (i=1;i<banAD.length;i++){
  preloadedimages[i]=new Image();
  preloadedimages[i].src=banAD[i];
}
function setTransition(){
  if(document.all){
    banADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);
    banADrotator.filters.revealTrans.apply();
  }
}
function playTransition(){
  if(document.all)
    banADrotator.filters.revealTrans.play()
}
function nextlallet(){
  if(adNum<banAD.length-1) adNum++ ;
  else adNum=0;
  setTransition();
  document.images.banADrotator.src=banAD[adNum];
  playTransition();
  theTimer=setTimeout("nextlallet()", 3000);
}
function jump2url(){
  jumpUrl=banADlink[adNum];
  window.open(jumpUrl,'blank','','status=1,resizable=1,scrollbars=1,toolbar=1,location=1,menubar=1');
}

//==============================================================================

      var line=new Array();
      line[1]="organizzata da";
      line[2]="Associazione CENTOEVENTI";
      line[3]="in collaborazione con";
      line[4]="CORRIERE di CASERTA";
      line[5]="CRONACHE di NAPOLI";
      line[6]="";

      var ts_fontsize="18px";
      var longestmessage=1;
      for(i=2;i<line.length;i++){
        if(line[i].length>line[longestmessage].length)
          longestmessage=i;
      }
      var tscroller_width=line[longestmessage].length+2;
      lines=line.length-1;
      temp="";
      nextchar=-1;
      nextline=1;
      cursor="\\"

      function animate(){
        if(temp==line[nextline] & temp.length==line[nextline].length & nextline!=lines){
          nextline++;
          nextchar=-1;
          document.getElementById('bannerform').banner.value=temp;
          temp="";
          setTimeout("nextstep()",1000); //intervallo di tempo tra ogni line
        }
        else if(nextline==lines & temp==line[nextline] & temp.length==line[nextline].length){
          nextline=1;
          nextchar=-1;


          document.getElementById('bannerform').banner.value=temp;
          temp="";
          setTimeout("nextstep()",5000); //intervallo di tempo tra un'animazione e l'altra
        }
        else{
          nextstep();
        }
      }

      function nextstep(){
        if(cursor=="\\"){
          cursor="|";
        }
        else if(cursor=="|"){
          cursor="/";
        }
        else if(cursor=="/"){
          cursor="-";
        }
        else if(cursor=="-"){
          cursor="\\";
        }

        nextchar++;
        temp+=line[nextline].charAt(nextchar);
        document.getElementById('bannerform').banner.value=temp+cursor;
        setTimeout("animate()",25); //velocità con cui compaiono le lettere
      }

//==============================================================================

var duree = 75; // La durée du mélange
var vitesse = 60; // La vitesse du mélange
var speciaux = new Array(" ",",",".","_","-","!","?","'","\"","&","$","@"); // Les caractères qui ne seront pas mélangés
var texte = "3^ GRAN FONDO DEL VOLTURNO"; // Le texte final
var c = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");

var i = 0;
var x = 0;
var texte2 = "";
var ajouter = "";

function effet(){
  if(i < duree){
    i++;
    x += texte.length/duree;
    texte2 += texte.substring(0,Math.floor(x));
    for(n = Math.floor(x); n < texte.length; n++){
      for(s = 0; s < speciaux.length; s++){
        if(texte.charAt(n) != speciaux[s]){
          ajouter = c[Math.floor(Math.random()*c.length)];
        }
        else{
          ajouter = speciaux[s]; s = speciaux.length;
        }
      }
      texte2 += ajouter;
    }
  }
  else{
    clearInterval(timer); texte2 = texte;
    animate();
  }
  document.getElementById('texte').innerHTML = texte2;
  texte2 = "";
}

//==============================================================================

var rows=11; // must be an odd number
var speed=1; // lower is faster
var reveal=2; // between 0 and 2 only. The higher, the faster the word appears
var effectalign="center" //enter "center" to center it.

var w3c=document.getElementById && !window.opera;;
var ie45=document.all && !window.opera;
var ma_tab, matemp, ma_bod, ma_row, x, y, columns, ma_txt, ma_cho;
var m_coch=new Array();
var m_copo=new Array();
function avviaMatrix() {
	if (!w3c && !ie45) return
  var matrix=(w3c)?document.getElementById("matrix"):document.all["matrix"];
  ma_txt=(w3c)?matrix.firstChild.nodeValue:matrix.innerHTML;
  ma_txt=" "+ma_txt+" ";
  columns=ma_txt.length;
  if (w3c) {
    while (matrix.childNodes.length) matrix.removeChild(matrix.childNodes[0]);
    ma_tab=document.createElement("table");
    ma_tab.setAttribute("border", 0);
    ma_tab.setAttribute("align", effectalign);
    ma_tab.style.backgroundColor="#f6f6f6";
    ma_bod=document.createElement("tbody");
    for (x=0; x<rows; x++) {
      ma_row=document.createElement("tr");
      for (y=0; y<columns; y++) {
        matemp=document.createElement("td");
        matemp.setAttribute("id", "Mx"+x+"y"+y);
        matemp.className="matrix";
        matemp.appendChild(document.createTextNode(String.fromCharCode(160)));
        ma_row.appendChild(matemp);
      }
      ma_bod.appendChild(ma_row);
    }
    ma_tab.appendChild(ma_bod);
    matrix.appendChild(ma_tab);
  } else {
    ma_tab='<ta'+'ble align="'+effectalign+'" border="0" style="background-color:#FFFFFF">';
    for (var x=0; x<rows; x++) {
      ma_tab+='<t'+'r>';
      for (var y=0; y<columns; y++) {
        ma_tab+='<t'+'d class="matrix" id="Mx'+x+'y'+y+'">&nbsp;</'+'td>';
      }
      ma_tab+='</'+'tr>';
    }
    ma_tab+='</'+'table>';
    matrix.innerHTML=ma_tab;
  }
  ma_cho=ma_txt;
  for (x=0; x<columns; x++) {
    ma_cho+=String.fromCharCode(32+Math.floor(Math.random()*94));
    m_copo[x]=0;
  }
  ma_bod=setInterval("mytricks()", speed);
}

function mytricks() {
  x=0;
  for (y=0; y<columns; y++) {
    x=x+(m_copo[y]==100);
    ma_row=m_copo[y]%100;
    if (ma_row && m_copo[y]<100) {
      if (ma_row<rows+1) {
        if (w3c) {
          matemp=document.getElementById("Mx"+(ma_row-1)+"y"+y);
          matemp.firstChild.nodeValue=m_coch[y];
        }
        else {
          matemp=document.all["Mx"+(ma_row-1)+"y"+y];
          matemp.innerHTML=m_coch[y];
        }
        matemp.style.color="#999";
        matemp.style.fontWeight="bold";
        matemp.style.fontSize="18px";
      }
      if (ma_row>1 && ma_row<rows+2) {
        matemp=(w3c)?document.getElementById("Mx"+(ma_row-2)+"y"+y):document.all["Mx"+(ma_row-2)+"y"+y];
        matemp.style.fontWeight="normal";
        matemp.style.color="#FFBE00";
        matemp.style.fontSize="18px";
      }
      if (ma_row>2) {
          matemp=(w3c)?document.getElementById("Mx"+(ma_row-3)+"y"+y):document.all["Mx"+(ma_row-3)+"y"+y];
        matemp.style.color="#D6D8E1";
      }
      if (ma_row<Math.floor(rows/2)+1) m_copo[y]++;
      else if (ma_row==Math.floor(rows/2)+1 && m_coch[y]==ma_txt.charAt(y)) zoomer(y);
      else if (ma_row<rows+2) m_copo[y]++;
      else if (m_copo[y]<100) m_copo[y]=0;
    }
    else if (Math.random()>0.9 && m_copo[y]<100) {
      m_coch[y]=ma_cho.charAt(Math.floor(Math.random()*ma_cho.length));
      m_copo[y]++;
    }
  }
  if (x==columns) clearInterval(ma_bod);
}

function zoomer(ycol) {
  var mtmp, mtem, ytmp;
  if (m_copo[ycol]==Math.floor(rows/2)+1) {
    for (ytmp=0; ytmp<rows; ytmp++) {
      if (w3c) {
        mtmp=document.getElementById("Mx"+ytmp+"y"+ycol);
        mtmp.firstChild.nodeValue=m_coch[ycol];
      }
      else {
        mtmp=document.all["Mx"+ytmp+"y"+ycol];
        mtmp.innerHTML=m_coch[ycol];
      }
      mtmp.style.color="#000000";
      mtmp.style.fontWeight="bold";
      matemp.style.fontSize="18px";
    }
    if (Math.random()<reveal) {
      mtmp=ma_cho.indexOf(ma_txt.charAt(ycol));
      ma_cho=ma_cho.substring(0, mtmp)+ma_cho.substring(mtmp+1, ma_cho.length);
    }
    if (Math.random()<reveal-1) ma_cho=ma_cho.substring(0, ma_cho.length-1);
    m_copo[ycol]+=199;
    setTimeout("zoomer("+ycol+")", speed);
  }
  else if (m_copo[ycol]>200) {
    if (w3c) {
      mtmp=document.getElementById("Mx"+(m_copo[ycol]-201)+"y"+ycol);
      mtem=document.getElementById("Mx"+(200+rows-m_copo[ycol]--)+"y"+ycol);
    }
    else {
      mtmp=document.all["Mx"+(m_copo[ycol]-201)+"y"+ycol];
      mtem=document.all["Mx"+(200+rows-m_copo[ycol]--)+"y"+ycol];
    }
    mtmp.style.fontWeight="normal";
    mtem.style.fontWeight="normal";
    setTimeout("zoomer("+ycol+")", speed);
  }
  else if (m_copo[ycol]==200) m_copo[ycol]=100+Math.floor(rows/2);
  if (m_copo[ycol]>100 && m_copo[ycol]<200) {
    if (w3c) {
      mtmp=document.getElementById("Mx"+(m_copo[ycol]-101)+"y"+ycol);
      mtmp.firstChild.nodeValue=String.fromCharCode(160);
      mtem=document.getElementById("Mx"+(100+rows-m_copo[ycol]--)+"y"+ycol);
      mtem.firstChild.nodeValue=String.fromCharCode(160);
    }
    else {
      mtmp=document.all["Mx"+(m_copo[ycol]-101)+"y"+ycol];
      mtmp.innerHTML=String.fromCharCode(160);
      mtem=document.all["Mx"+(100+rows-m_copo[ycol]--)+"y"+ycol];
      mtem.innerHTML=String.fromCharCode(160);
    }
    setTimeout("zoomer("+ycol+")", speed);
  }
}

function apricombo(){
  if(document.getElementById("combo1").style.visibility=='visible')
    document.getElementById("combo1").style.visibility='hidden';
  else
    document.getElementById("combo1").style.visibility='visible';
}

function apriFinestra(pagina){
  var w=screen.availWidth;
  var h=screen.availHeight;
  window.open(pagina,'_blank','top=0,left=0,height='+h+',width='+w+',status=no,resizable=1,scrollbars=1,toolbar=0,menubar=1,location=0');
}

