function controlloContenuto(campo){

    if (campo.value=='' || campo.value==' '){
	
        alert('Il '+campo.name+' è vuoto');
        document.jsform.campo.select();
        document.jsform.campo.focus();
        return false

    }

}

function svuota(campo){
	
	document.forms[0].pulsanteInserisciConfermaInvia.disabled=false;

}

function controlloEMail(campo) {

	//var primoElemento=campo.value.indexOf('.');
	var secondoElemento=campo.value.indexOf(' ');
	var lunghezza=campo.value.length;
	var terzoElemento=campo.value.indexOf('@');
	
	//alert('primoElemento='+primoElemento+'\nterzoElemento='+terzoElemento+'\nlunghezza='+lunghezza+'\n');
	
	if((terzoElemento!=-1)&&(lunghezza!=0)){
	
		var primaParte=campo.value.substring(0,terzoElemento); 
		var secondaParte=terzoElemento; 
		var terzaParte=lunghezza;
	
	}else{
	
		alert('Controllo L\'E-Mail Che Hai Appena Inserito.');
		
		return;

	}
	
	//alert('primaParte='+primaParte+'\nsecondaParte='+secondaParte+'\nterzaParte='+terzaParte+'\n');
	
	//alert('primaParte.indexOf(\' \')='+primaParte.indexOf(' ')+'\nsecondaParte.indexOf(\' \')='+secondaParte.indexOf(' ')+'\nterzaParte.indexOf(\' \')='+terzaParte.indexOf(' ')+'\nterzaParte.length='+terzaParte.length+'\nterzaParte.indexOf(\'.\')='+terzaParte.indexOf('.')+'\nlunghezza='+lunghezza+'\n');
	
	if((primaParte.indexOf(' ')!=-1)||(secondaParte.indexOf(' ')!=-1)||(terzaParte.indexOf(' ')!=-1)||(terzaParte.length<=1)||(terzaParte.indexOf('.')!=-1)||(lunghezza==0)||(primaParte==0)||(secondaParte==0)||(terzaParte==0)) {
	
		alert('Controllo L\'E-Mail Che Hai Appena Inserito.');
	
	}
	
}

function numeriCaratteriEControlli(campoContato, numeroCaratteri, campoVisualizzazione){

	//alert('campoContato='+campoContato+'\nnumeroCaratteri='+numeroCaratteri+'\ncampoContato.value.length='+campoContato.value.length+'\n');

	caratteriDigitati = numeroCaratteri-campoContato.value.length; 
	
	if (caratteriDigitati < 0) { 
	
		campoContato.value = campoContato.value.substring(0, campoContato.value.length + caratteriDigitati); 
		caratteriDigitati = 0
	
	}
		
	if(campoContato.value.substring(campoContato.value.length-1,campoContato.value.length)=="\\"){
	
		alert('Carattere \\ Non Valido.');
		
		campoContato.value = campoContato.value.substring(0, campoContato.value.length-1);
		
		return campoVisualizzazione.value=caratteriDigitati+1;
		
	}
	
	if((campoContato.value.substring(campoContato.value.length-2,campoContato.value.length)=="//")&&(campoContato.value.substring(campoContato.value.length-7,campoContato.value.length)!="http://")){
	
		alert('Carattere // Non Valido.');
		
		campoContato.value = campoContato.value.substring(0, campoContato.value.length-1);
		
		return campoVisualizzazione.value=caratteriDigitati+1;
		
	}	
	
	if(campoContato.value.substring(campoContato.value.length-1,campoContato.value.length)=="<"){
	
		alert('Carattere < Non Valido.');
		
		campoContato.value = campoContato.value.substring(0, campoContato.value.length-1);
		
		return campoVisualizzazione.value=caratteriDigitati+1;
		
	}
	
	if(campoContato.value.substring(campoContato.value.length-1,campoContato.value.length)==">"){
	
		alert('Carattere > Non Valido.');
		
		campoContato.value = campoContato.value.substring(0, campoContato.value.length-1);
		
		return campoVisualizzazione.value=caratteriDigitati+1;
		
	}	

	return campoVisualizzazione.value=caratteriDigitati;

}

function controlloDueCampiObbligatori(campoPrimo,campoSecondo){

	//alert('document.forms[0].elements[0].name='+document.forms[0].elements[0].name+'\ndocument.forms[0].elements[2].name='+document.forms[0].elements[2].name+'\ndocument.forms[0].elements[4].name='+document.forms[0].elements[4].name+'\n');
	
	var primoCampo=false;
	var secondoCampo=false;
	
	if(campoPrimo.value.length==0){
	
		primoCampo=true;
	
	}
	
	if(campoSecondo.value.length==0){
	
		secondoCampo=true;
	
	}

	if((primoCampo)||(secondoCampo)){
	
		alert('Devi Riempire Tutti I Campi Obbligatori.');
		
		return false;
	
	}

}

function controlloTreCampiObbligatori(campoPrimo,campoSecondo,campoTerzo){

	//alert('document.forms[0].elements[0].name='+document.forms[0].elements[0].name+'\ndocument.forms[0].elements[2].name='+document.forms[0].elements[2].name+'\ndocument.forms[0].elements[4].name='+document.forms[0].elements[4].name+'\n');
	
	var primoCampo=false;
	var secondoCampo=false;
	var terzoCampo=false;
	
	if(campoPrimo.value.length==0){
	
		primoCampo=true;
	
	}
	
	if(campoSecondo.value.length==0){
	
		secondoCampo=true;
	
	}
	
	if(campoTerzo.value.length==0){
		
		terzoCampo=true;
	
	}

	if((primoCampo)||(secondoCampo)||(terzoCampo)){
	
		alert('Devi Riempire Tutti I Campi Obbligatori.');
		
		return false;
	
	}

}

function controlloFormatoData(campo){

	var primaParte=campo.value.substring(0,4);
	var secondaParte=campo.value.substring(4,5);
	var terzaParte=campo.value.substring(5,7);
	var quartaParte=campo.value.substring(7,8);
	var quintaParte=campo.value.substring(8,10);
	var contatore=0;
	var numero=0;
	
	//alert('campo.value.charAt(0)='+campo.value.charAt(0)+'\ncampo.value.charAt(1)='+campo.value.charAt(1)+'\ncampo.value.charAt(2)='+campo.value.charAt(2)+'\ncampo.value.charAt(3)='+campo.value.charAt(3)+'\ncampo.value.charAt(4)='+campo.value.charAt(4)+'\ncampo.value.charAt(5)='+campo.value.charAt(5)+'\ncampo.value.charAt(6)='+campo.value.charAt(6)+'\ncampo.value.charAt(7)='+campo.value.charAt(7)+'\ncampo.value.charAt(8)='+campo.value.charAt(8)+'\ncampo.value.charAt(9)='+campo.value.charAt(9)+'\n');
	
	while(contatore<4){
	
		if((primaParte.charAt(contatore)>='0')&&(primaParte.charAt(contatore)<='9')){
	
			numero=numero+1;
		
		}
		
		contatore=contatore+1;
	
	}
	
	contatore=0;
	
	while(contatore<2){
	
		if((terzaParte.charAt(contatore)>='0')&&(terzaParte.charAt(contatore)<='9')){
	
			numero=numero+1;
		
		}
		
		contatore=contatore+1;
	
	}
	
	contatore=0;
	
	while(contatore<2){
	
		if((quintaParte.charAt(contatore)>='0')&&(quintaParte.charAt(contatore)<='9')){
	
			numero=numero+1;
		
		}
		
		contatore=contatore+1;
	
	}
	
	if(((secondaParte.charAt(0)=='/')&&(quartaParte.charAt(0)=='/'))||((secondaParte.charAt(0)=='-')&&(quartaParte.charAt(0)=='-'))){
	
		numero=numero+2;
		
	}
	
	//alert('numero='+numero);
	
	if(!(numero==10)){
	
		alert('Controlla Il Formato Della Data Che Hai Appena Inserito Che Deve Essere Della Forma AAAA/MM/GG Oppure AAAA-MM-GG');

	}
	
	//alert('primaParte='+primaParte+'\nsecondaParte='+secondaParte+'\nterzaParte='+terzaParte+'\nquartaParte='+quartaParte+'\nquintaParte='+quintaParte+'\n');

}

var gennaio= new Array("-", "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 febbraio= new Array("-", "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");
var febbraioo= new Array("-", "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");
var marzo= new Array("-", "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 aprile= new Array("-", "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");
var maggio= new Array("-", "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 giugno= new Array("-", "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");
var luglio= new Array("-", "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 agosto= new Array("-", "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 settembre= new Array("-", "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");
var ottobre= new Array("-", "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 novembre= new Array("-", "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");
var dicembre= new Array("-", "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");


function selezionaGiorni(meseScelto, annoScelto){

        var numeroIndice = window.document.registrazione.selezionaGiorno;
		
		if((annoScelto%4)==0){
		
			if(meseScelto=='febbraio'){ 

				//var elenco = new Array("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");
				
				meseScelto=febbraioo;
				
				var elenco = eval(meseScelto);
				
				//alert('elenco='+elenco);
			
			}else{
			
				var elenco = eval(meseScelto);
			
			}
		
		}else{
		
			var elenco = eval(meseScelto);
		
		}
		
        elencoGiorni(window.document.registrazione.selezionaGiorno,elenco);
		
}

function elencoGiorni(elemento, elencoScelto){

		elemento.length=elencoScelto.length;
		
        for (contatore=0; contatore < elencoScelto.length; contatore++){
		
                elemento.options[contatore].text = elencoScelto[contatore];
				
        }
		
}

function inizioMese(campo){

	campo.options[0].selected='-';

}

function comandoGrassetto(){

	valore=window.prompt('Grassetto','Inserisci La Parola Da Fare In Grassetto');
	
	//alert('valore='+valore);
	
	if((valore!='')&&(valore!=null)){
	
		document.forms[0].campoArgomento.value+=' <b>'+valore+'</b> ';
			
		//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
	
	}

}

function comandoCorsivo(){

	valore=window.prompt('Corsivo','Inserisci La Parola Scrivere In Corsivo');
	
	//alert('valore='+valore);
	
	if((valore!='')&&(valore!=null)){
	
		document.forms[0].campoArgomento.value+=' <u>'+valore+'</u> ';
			
		//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
	
	}

}

function comandoSottolineato(){

	valore=window.prompt('Sottolineato','Inserisci La Parola Da Sottolineare');
	
	//alert('valore='+valore);
	
	if((valore!='')&&(valore!=null)){
	
		document.forms[0].campoArgomento.value+=' <i>'+valore+'</i> ';
			
		//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
	
	}

}

function comandoFormattato(scelta){
	
	//alert('scelta='+scelta);
	
	if(scelta==1){
	
		valore=window.prompt('Allineamento A Sinistra','Inserisci Il Testo Da Allineare A Sinistra');
	
		if(valore!=null){
	
			document.forms[0].campoArgomento.value+=' <p align="left">'+valore+'</p> ';
				
			//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
		
		}
		
	}
	
	if(scelta==2){
	
		valore=window.prompt('Allineamento Al Centro','Inserisci Il Testo Da Allineare Al Centro');
	
		if(valore!=null){
	
			document.forms[0].campoArgomento.value+=' <p align="center">'+valore+'</p> ';
				
			//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
		
		}
		
	}
	
	if(scelta==3){
	
		valore=window.prompt('Allineamento A Destra','Inserisci Il Testo Da Allineare A Destra');
	
		if(valore!=null){
	
			document.forms[0].campoArgomento.value+=' <p align="right">'+valore+'</p> ';
				
			//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
		
		}
	
	}
	
	if(scelta==4){
	
		valore=window.prompt('Allineamento Giustificato','Inserisci Il Testo Da Giustificare');
	
		if(valore!=null){
	
			document.forms[0].campoArgomento.value+=' <p align="justify">'+valore+'</p> ';
				
			//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
		
		}
		
	}

}

function comandoCollegamento(){

	valore=window.prompt('Collegamento','Inserisci L\'Indirizzo');
	
	//alert('valore='+valore);
	
	if((valore!='')&&(valore!=null)){
	
		document.forms[0].campoArgomento.value+=' <a href="../%27+valore+%27" target="_blank">'+valore+'</a> ';
			
		//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
	
	}

}

function comandoImmagine(){

	valore=window.prompt('Immagine','Inserisci Il Nome E Formato Dell\'Immagine Inserita Nella Sezione Immagini');
	
	//alert('valore='+valore);
	
	if((valore!='')&&(valore!=null)){
	
		document.forms[0].campoArgomento.value+=' <a href="/public/fileImmagini/'+valore+'" target="_blank"><img name="campoImmagine" src="/public/fileImmagini/'+valore+'" width="10%" height="10%" border="0" id="campoImmagine"></a> ';
			
		//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
	
	}

}

function stampa(){

	window.print();
	
}

function controlloDueCampi(campoPrimo,campoSecondo){
	
	if((campoPrimo.value.length==0)||(campoSecondo.value.length==0)){
		
		alert('Campo UserName E\\O PassWord Vuoti\\o');	
		
	}
	
}


function comandoEMail(){
	
	valore=window.prompt('E-Mail','Inserisci L\'Indirizzo E-Mail');
	
	//alert('valore='+valore);
	
	if((valore!='')&&(valore!=null)){
	
		document.forms[0].campoArgomento.value+='<a href="mailTo:'+valore+'">';
			
		//alert('document.forms[0].campoArgomento.value='+document.forms[0].campoArgomento.value);
	
	}	
	
}

function invia(titolo,testo){

	window.location = "mailto:"+document.eMailer.address.value+"?subject="+"Ti Segnalo "+titolo+""+"&body="+testo+" "+window.location;
   
}


function copia(area){

	var appoggio=eval("document."+area);
	appoggio.focus();
	appoggio.select();
	intervallo = appoggio.createTextRange();
	intervallo.execCommand("Copy");


}

function recuperaPassWord(titolo,testo){

	window.location = "mailto:"+document.eMailer.address.value+"?subject="+"Ti Segnalo "+titolo+""+"&body="+testo+" "+window.location;
   
}

function svuotaCampi(campoPrimo,campoSecondo){
	
	campoPrimo.value="";
	campoSecondo.value="";
	
}

function numero(campo){
		
	return campo.value;
	
}
