// TOP
// Numero di banner che sono contemporaneamente in rotazione
var nBanner = 3;
// Secondi tra la visualizzazione di un banner ed il successivo
var nInterval = 15;
// n rappresenta il numero del banner da cui iniziare la visualizzazione
var n;

// Eseguita all'onload del body
function initBanner(){
	// n rappresenta il numero del banner da visualizzare
	n = (Math.ceil(Math.random(90) * nBanner));        
	eval("document.getElementById('banner0" + n + "').style.display = 'block';");
	setTimeout('rotationBanner()',nInterval * 1000);
}

function rotationBanner(){   
if (n == nBanner)
  n = 1;
else
  n++;
for (i = 1; i <= nBanner; i++){
  if (i == n){        
	eval("document.getElementById('banner0" + i + "').style.display = 'block';");
  }
  else{                
	eval("document.getElementById('banner0" + i + "').style.display = 'none';");
  }
}
setTimeout('rotationBanner()',nInterval * 1000);
}
// FINE TOP

// NEWS SCROLL
// posizione iniziale  maggiore o uguale all'altezza del div 'news'
var dn_startpos=120; 	
// posizione finale  +o- altezza di UL 'ul_news'
var dn_endpos= -120;
var dn_speed=35;
var dn_newsID='news';

var scrolling=true

function stopDOMnews(){
  clearInterval(dn_interval);
  var n=document.getElementById(dn_newsID);
  n.className='';
  return false;
}

function scrollDOMnews(){
  var n=document.getElementById(dn_newsID).getElementsByTagName('ul')[0];
  n.style.top=dn_scrollpos+'px';	
  if(dn_scrollpos==dn_endpos){dn_scrollpos=dn_startpos;}
  dn_scrollpos--;	
}

// Eseguita all'onload del body (solo per index.jsp che contiene lo scroll delle news)
function scrollOnload(){
  if(!document.getElementById || !document.createTextNode){return;}
  //dn_endpos= -(document.getElementById(dn_newsID).scrollHeight);
  dn_endpos= -(document.getElementById("ul_news").offsetHeight)
  initDOMnews();
}

var dn_scrollpos=dn_startpos;
function initDOMnews(){	
  var n=document.getElementById(dn_newsID);
  if(!n){return;}
  dn_interval=setInterval("scrollDOMnews()",dn_speed);
  n.onmouseover=function(){    		
	clearInterval(dn_interval);
  }
  n.onmouseout=function(){
	if(scrolling)
	  dn_interval=setInterval("scrollDOMnews()",dn_speed);
  }
}
//FINE NEWS SCROLL

// JavaScript Document
function num(a){
	if ((a=="1")||(a=="2")||(a=="3")||(a=="4")||(a=="5")||(a=="6")||(a=="7")||(a=="8")||(a=="9")||(a=="0")){return true}	
	else{return false}
}
function isNumberDate(app,type){
	for(i=0;i<app.length;i++){				
		var a = app.substring(i,i+1)		
		if (!num(a)){
			return false
		}
    }
	if(type=="dd" && app<=31)
		return true
	if(type=="mm" && app<=12)
		return true
	if(type=="aa" && app<=2011)
		return true
	return false
	
}	
function check(){
	var msg = "";  
  
  // nome
  app = document.formNome.nome.value;
  var b = true;
  for(i=0;i<app.length;i++){				
    var a = app.substring(i,i+1)		
    if (num(a)){b=false}				
  }
  if ((app=="")||(b==false)){msg = "Inserire il proprio nome!";}
    
  if (msg == ""){
    // cognome
    app = document.formNome.cognome.value;
    var b = true;
    for(i=0;i<app.length;i++){				
      var a = app.substring(i,i+1)		
      if (num(a)){b=false}				
    }
    if ((app=="")||(b==false)){msg = "Inserire il proprio cognome!";}
  }
  
  if (msg == ""){
    // data
	app = document.formNome.textData.value;
	var b = true;
    if(app=="" || app.length<10 || 
		!isNumberDate(app.substring(0,2),'dd') || !isNumberDate(app.substring(3,5),'mm') || !isNumberDate(app.substring(6,10),'aa') ||		
		app.substring(2,3)!="/" || app.substring(5,6)!="/")
		b=false;
	if (b==false){msg = "Inserire un giorno di nascita valido nel formato gg/mm/aaaa!";}		
  }  
  
  if (msg == ""){
    // luogo
    app = document.formNome.luogo.value;
    var b = true;
    for(i=0;i<app.length;i++){				
      var a = app.substring(i,i+1)		
      if (num(a)){b=false}				
    }
    if ((app=="")||(b==false)){msg = "Inserire la località di nascita!";}
  }
	
	if (msg ==""){
		document.formNome.submit();
	}else{
		SuperAlert.alert(msg);
		return false;
	}
}

// Funzione per ricerca
function cercaSmorfia(){
	if (document.formSmorfia.textFrase.value == ""){
		SuperAlert.alert("Inserisci almeno una parola");
		return false;
	}else{
		document.formSmorfia.submit();	
	}
}
function cercaCabala(){
	if (isNaN(document.formCabala.textNumero.value)){
		SuperAlert.alert("Il numero deve essere compreso tra 1 e 90");
		return false;
	}
	if ((document.formCabala.textNumero.value < 1) || (document.formCabala.textNumero.value > 90)){
		SuperAlert.alert("Il numero deve essere compreso tra 1 e 90");
		return false;
	}	
	document.formCabala.submit();
}
function cercaPerData(){	
	data = document.form1.textData.value
	if (data==''){
		SuperAlert.alert("Seleziona la data del concorso");
	}else{
		window.open("../page/estrazione.asp?data=" + data,"_self");					
	}
}	
function cercaPerConcorso(){
	if (isNaN(document.form2.textConcorso.value) || document.form2.textConcorso.value == ""){
		SuperAlert.alert("Numero Concorso non valido");
		document.form2.textConcorso.focus();
		return false;
	}	
	if (document.form2.selectAnno.value == ""){
		SuperAlert.alert("Anno non valido");
		document.form2.selectAnno.focus();
		return false;
	}			
	window.open("../page/estrazione.asp?anno=" + document.form2.selectAnno.value + "&concorso=" + document.form2.textConcorso.value,"_self");		
}

// Funzione per determinare se è installato Flash
function flashInstalled() {     
  var v; 
  if (navigator.plugins && navigator.plugins.length > 0) { 
      var type = 'application/x-shockwave-flash'; 
      var mimeTypes = navigator.mimeTypes; 
      if (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description) { 
          v = mimeTypes[type].enabledPlugin.description.replace(/^.*?([0-9]+)\.([0-9])+.*$/, '$1,$2').split(','); 
      } 
  } 
  else { 
      var flashObj = null; 
      try { flashObj = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); } catch (ex) { return false; } 
      if (flashObj != null) { 
          var fV; 
          try { fV = flashObj.GetVariable("$version"); } catch (err) { return false; } 
          v = fV.replace(/^.*?([0-9]+,[0-9]+).*$/, '$1').split(','); 
      } 
  } 
  if (v) { 
    return true; 
  } 
  return false; 
} 

var months = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"]
var days = ["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"]
var sett = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"]

