<!--

function ricarica_cat(page_to_load)
{	
	var id_categoria = document.ricerca_eventi.id_categoria.value;
	var id_locale = document.ricerca_eventi.id_locale.value;
	document.location = page_to_load+"?id_categoria="+id_categoria+"&id_locale="+id_locale;
}


function dettaglio(str) 
{
searchWin = window.open(str,'dettaglio','scrollbars=yes,resizable=yes,width=500,height=300,status=no,location=no,toolbar=no');
  //      searchWin.refer = self;
}

function CheckDiffData() {
	
	
	var day = new Date();
	day.setYear( parseInt(2002) );
	day.setMonth( parseInt(5) );
	day.setDate( parseInt(19) );
	day.setHours( parseInt(10) );
	day.setMinutes( parseInt(21) );

	var localDate = new Date();
	//alert(localDate.getTime() + " - " + serverDate.getTime());
	var diff = ( localDate.getTime() - day.getTime() );


	day.setTime( day.getTime - diff );
	var mese = day.getMonth();
	var giorno = day.getDate();
	var anno = day.getYear();
	if (giorno.length == 1)
		giorno = "0" + giorno;
	if (mese.length == 1)
		mese = "0" + mese;

	var d = document.ricerca_eventi.selday.options	[document.ricerca_eventi.selday.selectedIndex].text;
	var m = document.ricerca_eventi.selmonth.options	[document.ricerca_eventi.selmonth.selectedIndex].text;
	var y = document.ricerca_eventi.selyear.options	[document.ricerca_eventi.selyear.selectedIndex].text;
	var errore = "data non valida!";

	var mTemp = document.ricerca_eventi.selmonth.options[document.ricerca_eventi.selmonth.selectedIndex].text;

	var nmese = new Number(mese);

	if( parseInt( d ) == 31 ) {
		if( m=="Aprile" || m=="Giugno" || m=="Settembre" || m=="Novembre") {
			alert(errore);
			document.ricerca_eventi.selday.options[29].selected=true;
		}
	}


	if(m=="Febbraio") {
		if( Isbisestile(y) ) {
			if( parseInt( d ) > 29 ) {
				alert( errore);
				document.ricerca_eventi.selday.options[28].selected=true;
			}
		} else {
			if( parseInt( d )  > 28) {
				alert(errore);
				document.ricerca_eventi.selday.options[27].selected=true;

			}
		}
	}
}

function CheckDiffData2() {
	
	
	var day = new Date();
	day.setYear( parseInt(2002) );
	day.setMonth( parseInt(5) );
	day.setDate( parseInt(19) );
	day.setHours( parseInt(10) );
	day.setMinutes( parseInt(21) );

	var localDate = new Date();
	//alert(localDate.getTime() + " - " + serverDate.getTime());
	var diff = ( localDate.getTime() - day.getTime() );


	day.setTime( day.getTime - diff );
	var mese = day.getMonth();
	var giorno = day.getDate();
	var anno = day.getYear();
	if (giorno.length == 1)
		giorno = "0" + giorno;
	if (mese.length == 1)
		mese = "0" + mese;

	var d = document.ricerca_eventi.selday2.options	[document.ricerca_eventi.selday2.selectedIndex].text;
	var m = document.ricerca_eventi.selmonth2.options	[document.ricerca_eventi.selmonth2.selectedIndex].text;
	var y = document.ricerca_eventi.selyear2.options	[document.ricerca_eventi.selyear2.selectedIndex].text;
	var errore = "data non valida!";

	var mTemp = document.ricerca_eventi.selmonth2.options[document.ricerca_eventi.selmonth2.selectedIndex].text;

	var nmese = new Number(mese);

	if( parseInt( d ) == 31 ) {
		if( m=="Aprile" || m=="Giugno" || m=="Settembre" || m=="Novembre") {
			alert(errore);
			document.ricerca_eventi.selday2.options[29].selected=true;
		}
	}


	if(m=="Febbraio") {
		if( Isbisestile(y) ) {
			if( parseInt( d ) > 29 ) {
				alert( errore);
				document.ricerca_eventi.selday2.options[28].selected=true;
			}
		} else {
			if( parseInt( d )  > 28) {
				alert(errore);
				document.ricerca_eventi.selday2.options[27].selected=true;

			}
		}
	}
}

function Isbisestile(anno) {
	//alert(anno);
	var isBisestile = false;
	anno = parseInt( anno, 10 );

	// every fourth year is a leap year

	if (anno%4 == 0) {
		isBisestile=true;

			if (anno%100 == 0) {
			isBisestile=false;

			if (anno%400 == 0) {
				isBisestile=true;
			   }
			}
	 }

	return isBisestile;
}


function controllo_nl(theForm){
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
var flag =true;

if (theForm.nome.value == "")
  {
    alert("Inserisci il Nome");
    theForm.nome.focus();
	return (false);
	
  }
if (theForm.cognome.value == "")
  {
    alert("Inserisci il Cognome");
    theForm.cognome.focus();
	return (false);
	
  }

  if (theForm.email.value == "")
  {
    alert("Insert E-MAIL.");
    theForm.email.focus();
    return (false);
  }
	if (theForm.email.value.length > 0 )
  {
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		ch = theForm.email.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{
		 if (ch == checkOK.charAt(j))
		 {
		    flag = true;
		    break;}
		 else {
		    flag = false;
		 }
		}
		if (flag==false) 
		{
			break; 
		}

	}
	
	if (flag == true)
	{
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		if (theForm.email.value.charAt(i) == '@')
		{
			flag = true;
		    break;}
		else {
		    flag = false;
		}
	}
	}
	
	if (flag == true)
	{
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		if (theForm.email.value.charAt(i) == '.')
		{
		    flag = true;
		    break;}
		else {
		    flag = false;
		}
	}
	}
	
	if (flag == false)
	{
		alert('E-Mail non corretta!!!');
		flag = false;
		theForm.email.focus();
	}
		    
	return flag;
   }
  return(true);

}


function controllo_contatti(theForm){
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
var flag =true;

if (theForm.nome.value == "")
  {
    alert("Inserisci il Nome");
    theForm.nome.focus();
	return (false);
	
  }
if (theForm.cognome.value == "")
  {
    alert("Inserisci il Cognome");
    theForm.cognome.focus();
	return (false);
	
  }

	if (theForm.messaggio.value == "")
	  {
		alert("Inserisci il Messaggio");
		theForm.messaggio.focus();
		return (false);
		
	  }
		check_autorizzazione = false;
		for ( i = 0; i < theForm.elements.length; i++  ){
			if ( theForm.elements[i].type == "checkbox" ){
				if ( theForm.elements[i].checked == true ){
					check_autorizzazione = true;
					break;
				}
			}
		}
		if ( check_autorizzazione == false ){
			alert("Devi autorizzare il Trattamento dei Dati");
			return false;
		}		


  if (theForm.email.value == "")
  {
    alert("Insert E-MAIL.");
    theForm.email.focus();
    return (false);
  }
	if (theForm.email.value.length > 0 )
  {
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		ch = theForm.email.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{
		 if (ch == checkOK.charAt(j))
		 {
		    flag = true;
		    break;}
		 else {
		    flag = false;
		 }
		}
		if (flag==false) 
		{
			break; 
		}

	}
	
	if (flag == true)
	{
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		if (theForm.email.value.charAt(i) == '@')
		{
			flag = true;
		    break;}
		else {
		    flag = false;
		}
	}
	}
	
	if (flag == true)
	{
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		if (theForm.email.value.charAt(i) == '.')
		{
		    flag = true;
		    break;}
		else {
		    flag = false;
		}
	}
	}
	
	if (flag == false)
	{
		alert('E-Mail non corretta!!!');
		flag = false;
		theForm.email.focus();
	}
		
		
		
	return flag;
   }
   
   
  return(true);

}

			

function controllo_reg(theForm){
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
var flag =true;

if (theForm.nome.value == "")
  {
    alert("Inserisci il Nome");
    theForm.nome.focus();
	return (false);
	
  }
if (theForm.cognome.value == "")
  {
    alert("Inserisci il Cognome");
    theForm.cognome.focus();
	return (false);
	
  }

if (theForm.citta.value == "")
  {
    alert("Inserisci la Città");
    theForm.citta.focus();
	return (false);
	
  }
if (document.reg.id_provincia.options[0].selected==true)
  {
    alert("Seleziona una provincia");
    theForm.id_provincia.focus();
	return (false);
	
  }

if (theForm.telefono.value == "")
  {
    alert("Inserisci un numero di telefono");
    theForm.telefono.focus();
	return (false);
	
  }
if (theForm.cellulare.value == "")
  {
    alert("Inserisci un numero di telefono cellulare");
    theForm.cellulare.focus();
	return (false);
	
  }

if (theForm.nickname.value == "")
  {
    alert("Inserisci un nickname");
    theForm.nickname.focus();
	return (false);
	
  }

	if (theForm.piva_cf.value == ""){
		alert("Inserisci PIVA o CF.");
		theForm.piva_cf.focus();
		return false;
	}


	if (theForm.piva_cf.value != ""){

		if (theForm.piva_cf.value.length == 16){

			var validi, i, s, set1, set2, setpari, setdisp;
			cf = theForm.piva_cf.value;
			cf = cf.toUpperCase();
			if( cf.length != 16 ){
				alert("La lunghezza del codice fiscale non è \n corretta: il codice fiscale deve essere lungo\nesattamente 16 caratteri.\n");
				theForm.piva_cf.focus();
				return false;
			}
			validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
			for( i = 0; i < 16; i++ ){
				if( validi.indexOf( cf.charAt(i) ) == -1 ){
					alert("Il codice fiscale contiene un carattere non valido `" + cf.charAt(i) + "'.\nI caratteri validi sono le lettere e le cifre.\n");
					theForm.piva_cf.focus();
					return false;
				}
			}
			set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
			set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
			setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
			setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
			s = 0;
			for( i = 1; i <= 13; i += 2 )
				s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
			for( i = 0; i <= 14; i += 2 )
				s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
			if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) ){
				alert("Il codice fiscale non è corretto:\nil codice di controllo non corrisponde.\n");
				theForm.piva_cf.focus();
				return false;
			}

		}else if (theForm.piva_cf.value.length == 11){

			pi = theForm.piva_cf.value;
			if( pi.length != 11 ){
				alert("La lunghezza della partita IVA non è\ncorretta: la partita IVA dovrebbe essere lunga\nesattamente 11 caratteri.\n");
				theForm.piva_cf.focus();
				return false;
			}
			validi = "0123456789";
			for( i = 0; i < 11; i++ ){
				if( validi.indexOf( pi.charAt(i) ) == -1 ){
					alert("La partita IVA contiene un carattere non valido `" + pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n");
					theForm.piva_cf.focus();
					return false;
				}
			}
			s = 0;
			for( i = 0; i <= 9; i += 2 )
				s += pi.charCodeAt(i) - '0'.charCodeAt(0);
			for( i = 1; i <= 9; i += 2 ){
				c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
				if( c > 9 )  c = c - 9;
				s += c;
			}
			if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) ){
				alert("La partita IVA non è valida:\nil codice di controllo non corrisponde.\n");
				theForm.piva_cf.focus();
				return false;
			}

		}else{

			alert("Il codice introdotto non e' valido:\n\n  - un codice fiscale deve essere lungo 16 caratteri;\n\n  - una partita IVA deve essere lunga 11 caratteri.\n");
			theForm.piva_cf.focus();
			return false;

		}

	}



  if (theForm.email.value == "")
  {
    alert("Insert E-MAIL.");
    theForm.email.focus();
    return (false);
  }
	if (theForm.email.value.length > 0 )
  {
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		ch = theForm.email.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		{
		 if (ch == checkOK.charAt(j))
		 {
		    flag = true;
		    break;}
		 else {
		    flag = false;
		 }
		}
		if (flag==false) 
		{
			break; 
		}

	}
	
	if (flag == true)
	{
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		if (theForm.email.value.charAt(i) == '@')
		{
			flag = true;
		    break;}
		else {
		    flag = false;
		}
	}
	}
	
	if (flag == true)
	{
	for (i = 0;  i < theForm.email.value.length;  i++)
	{
		if (theForm.email.value.charAt(i) == '.')
		{
		    flag = true;
		    break;}
		else {
		    flag = false;
		}
	}
	}
	
	if (flag == false)
	{
		alert('E-Mail non corretta!!!');
		flag = false;
		theForm.email.focus();
	}
		
		
		
	return flag;
   }
   
   
  return(true);

}

			

-->
