// JavaScript Document
<!--

function openWin(page,namePage,larghezza,altezza){
	var w = larghezza;
	var h = altezza;
	var l = Math.floor((screen.width-w)/2);
	var t = Math.floor((screen.height-h)/2);
	window.open(page,namePage,"width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

function CaricaIns(){

	document.frmPost.xIdLingua.value = window.opener.document.frmDetail.xIdLingua.value;
	document.frmPost.xLanguage.value = window.opener.document.frmDetail.xLanguage.value;
	document.frmPost.xData.value = window.opener.document.frmDetail.xData.value;
	document.frmPost.xDaOra.value = window.opener.document.frmDetail.xDaOra.value;
	document.frmPost.xAOra.value = window.opener.document.frmDetail.xAOra.value;
	document.frmPost.xDataCell.value = window.opener.document.frmDetail.xDataCell.value;
	document.frmPost.xOraCell.value = window.opener.document.frmDetail.xOraCell.value;
	document.frmPost.submit();

}

function CaricaFeedback(){

	document.frmPost.xid_feedback.value = window.opener.document.frmDetail.xid_feedback.value;
	document.frmPost.submit();

}

function ValIns(xIdLingua, xLanguage, xData, xDaOra, xAOra, xDataCell, xOraCell){

	document.frmDetail.xIdLingua.value = xIdLingua;
	document.frmDetail.xLanguage.value = xLanguage;
	document.frmDetail.xData.value = xData;
	document.frmDetail.xDaOra.value = xDaOra;
	document.frmDetail.xAOra.value = xAOra;
	document.frmDetail.xDataCell.value = xDataCell;
	document.frmDetail.xOraCell.value = xOraCell;
}

function chkEscluded(obj, sNumber, sId){
	z    = 1;
	Nobj = "";
	NR   = sNumber.toString() + "/R" ;
	
	if(!obj.checked){
		for (z=1;z<=4;z++){
			Nobj = sNumber.toString() + "/" + z.toString();
			//NR   = sNumber.toString() + "/R" ;
			if (obj.name!=Nobj){
				document.getElementById(Nobj).checked = false;
				document.getElementById(NR).value = obj.value + "|" + sId;
			}
		}
		
	} else {
		document.getElementById(NR).value = "|" + sId;
	}
}

function VisualTR(objFrm){
	
	tipologia = objFrm.value;
	
	if(tipologia=="AL"){
		document.getElementById("Preferenze").style.display = '';
		document.getElementById("Riga_1").style.display = '';
		document.getElementById("GenAllievo").style.display = '';
		document.getElementById("Riga_2").style.display = '';
		document.getElementById("TelAllievo").style.display = '';
		document.getElementById("Riga_3").style.display = '';
		document.getElementById("LanAllievo").style.display = '';
		document.getElementById("Riga_4").style.display = 'none';
		document.getElementById("LanInsegnante").style.display = 'none';
		document.getElementById("NickInsegnante").style.display = 'none';
		document.getElementById("Riga_5").style.display = '';
		document.getElementById("AziAllievo").style.display = '';
		document.getElementById("ScuolaAllievo").style.display = '';
	}
	
	if(tipologia=="IN"){
		document.getElementById("Preferenze").style.display = 'none';
		document.getElementById("Riga_1").style.display = 'none';
		document.getElementById("GenAllievo").style.display = 'none';
		document.getElementById("Riga_2").style.display = 'none';
		document.getElementById("TelAllievo").style.display = 'none';
		document.getElementById("Riga_3").style.display = 'none';
		document.getElementById("LanAllievo").style.display = 'none';
		document.getElementById("Riga_4").style.display = '';
		document.getElementById("LanInsegnante").style.display = '';
		document.getElementById("NickInsegnante").style.display = '';
		document.getElementById("Riga_5").style.display = 'none';
		document.getElementById("AziAllievo").style.display = 'none';
		document.getElementById("ScuolaAllievo").style.display = 'none';
	}
	
	if(tipologia=="AD"){
		document.getElementById("Preferenze").style.display = 'none';
		document.getElementById("Riga_1").style.display = 'none';
		document.getElementById("GenAllievo").style.display = 'none';
		document.getElementById("Riga_2").style.display = 'none';
		document.getElementById("TelAllievo").style.display = 'none';
		document.getElementById("Riga_3").style.display = 'none';
		document.getElementById("LanAllievo").style.display = 'none';
		document.getElementById("Riga_4").style.display = 'none';
		document.getElementById("LanInsegnante").style.display = 'none';
		document.getElementById("NickInsegnante").style.display = 'none';
		document.getElementById("Riga_5").style.display = 'none';
		document.getElementById("AziAllievo").style.display = 'none';
		document.getElementById("ScuolaAllievo").style.display = 'none';
	}
	
	if(tipologia=="SU"){
		document.getElementById("Preferenze").style.display = 'none';
		document.getElementById("Riga_1").style.display = 'none';
		document.getElementById("GenAllievo").style.display = 'none';
		document.getElementById("Riga_2").style.display = 'none';
		document.getElementById("TelAllievo").style.display = 'none';
		document.getElementById("Riga_3").style.display = 'none';
		document.getElementById("LanAllievo").style.display = 'none';
		document.getElementById("Riga_4").style.display = 'none';
		document.getElementById("LanInsegnante").style.display = 'none';
		document.getElementById("NickInsegnante").style.display = 'none';
		document.getElementById("Riga_5").style.display = 'none';
		document.getElementById("AziAllievo").style.display = 'none';
		document.getElementById("ScuolaAllievo").style.display = '';
	}
	
	//objFrm.onblur();
	
}


// controlli formali
function Len(string){
	
	if (string == null)
		return (false);

	return String(string).length;
}


function LTrim(String){
	
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++){
		if (String.substr(i, 1) != ' ' &&
		    String.substr(i, 1) != '\t')
			break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

function RTrim(String){
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for(j = String.length - 1; j >= 0; j--){
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}


function Trim(obj){
	
	stringa = obj.value
	if (stringa != "" ){
		obj.value = RTrim(LTrim(stringa));
	}
}

function Maiuscolo(obj){
	
	stringa = obj.value
	if (stringa != "" ){
		obj.value = stringa.toUpperCase();
	}
}


function Left(String, Length){
	
	if (String == null)
		return (false);

	return String.substr(0, Length);
}

function Right(String, Length){
	
	if (String == null)
		return (false);

    var dest = '';
    for (var i = (String.length - 1); i >= 0; i--)
		dest = dest + String.charAt(i);

	String = dest;
	String = String.substr(0, Length);
	dest = '';

    for (var i = (String.length - 1); i >= 0; i--)
		dest = dest + String.charAt(i);

	return dest;
}

function Mid(String, Start, Length){
	
	if (String == null)
		return (false);

	if (Start > String.length)
		return '';

	if (Length == null || Length.length == 0)
		return (false);

	return String.substr((Start - 1), Length);
}

function InStr(String1, String2){
	
	var a = 0;

	if (String1 == null || String2 == null)
		return (false);

	String1 = String1.toLowerCase();
	String2 = String2.toLowerCase();

	a = String1.indexOf(String2);
	if (a == -1)
		return 0;
	else
		return a + 1;
}

function Split(Expression, Delimiter){
	
	var temp = Expression;
	var a, b = 0;
	var array = new Array();

	if (Delimiter.length == 0){
		array[0] = Expression;
		return (array);
	}

	if (Expression.length == ''){
		array[0] = Expression;
		return (array);
	}

	Delimiter = Delimiter.charAt(0);

	for (var i = 0; i < Expression.length; i++){
		a = temp.indexOf(Delimiter);
		if (a == -1){
			array[i] = temp;
			break;
		}else{
			b = (b + a) + 1;
			var temp2 = temp.substring(0, a);
			array[i] = temp2;
			temp = Expression.substr(b, Expression.length - temp2.length);
		}
	}

	return (array);
}

function Replace(Expression, Find, Replace){
	
	var temp = Expression;
	var a = 0;

	for (var i = 0; i < Expression.length; i++){
		a = temp.indexOf(Find);
		if (a == -1)
			break
		else
			temp = temp.substring(0, a) + Replace + temp.substring((a + Find.length));
	}

	return temp;
}

function FMail(obj){
	mail = obj.value;
	mail = stringa.toLowerCase();
	if (mail!="" ){
		var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
		if (!espressione.test(mail)){
			obj.value="";
			alert("Il campo non è formalmente corretto. Deve essere un indirizzo e-mail.");
			obj.focus();
			return;
		}
	}
	obj.value = stringa.toLowerCase();
}

function fNumero(obj){
	
	num = obj.value;
	
	validi = "0123456789";
	for( i = 0; i < num.length; i=i+1 ){
		if( validi.indexOf(num.charAt(i)) == -1 ){
			obj.value="";
			alert("Il campo non è formalmente corretto. Il dato deve essere numerico.");
			obj.focus();
			return;
		}
	}
}

function fAlfabetico(obj){
	
	num = obj.value;
	
	validi = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM ";
	for( i = 0; i < num.length; i=i+1 ){
		if( validi.indexOf(num.charAt(i)) == -1 ){
			obj.value="";
			alert("Il campo non è formalmente corretto. Il dato deve essere di sole lettere.");
			obj.focus();
			return;
		}
	}
}

function fAlfabeticoPiu(obj){
	
	num = obj.value;
	
	validi = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM '";
	for( i = 0; i < num.length; i=i+1 ){
		if( validi.indexOf(num.charAt(i)) == -1 ){
			obj.value="";
			alert("Il campo non è formalmente corretto.");
			obj.focus();
			return;
		}
	}
}

function fIndirizzo(obj){
	
	num = obj.value;
	
	validi = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM ',0123456789/-";
	for( i = 0; i < num.length; i=i+1 ){
		if( validi.indexOf(num.charAt(i)) == -1 ){
			obj.value="";
			alert("Il campo non è formalmente corretto. Il dato deve essere numerico.");
			obj.focus();
			return;
		}
	}
}

function fCitta(obj){
	
	num = obj.value;
	
	validi = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM '.";
	for( i = 0; i < num.length; i=i+1 ){
		if( validi.indexOf(num.charAt(i)) == -1 ){
			obj.value="";
			alert("Il campo non è formalmente corretto.");
			obj.focus();
			return;
		}
	}
}

function fSoprannome(obj){
	
	num = obj.value;
	
	validi = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM _-1234567890";
	for( i = 0; i < num.length; i=i+1 ){
		if( validi.indexOf(num.charAt(i)) == -1 ){
			obj.value = "";
			alert("Il campo contiene caratteri non validi.");
			obj.focus();
			return;
		}
	}
}

function fUtente(obj){
	
	num = obj.value;
	
	validi = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890_-.";
	for( i = 0; i < num.length; i=i+1 ){
		if( validi.indexOf(num.charAt(i)) == -1 ){
			obj.value = "";
			alert("Inserito un carattere non valido.");
			obj.focus();
			return;
		}
	}
}

function fPassword(obj){
	
	num = obj.value;
	
	validi = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
	for( i = 0; i < num.length; i=i+1 ){
		if( validi.indexOf(num.charAt(i)) == -1 ){
			obj.value = "";
			alert("La pssword può contenere solo numeri e lettere.");
			obj.focus();
			return;
		}
	}
}

function fTelefono(obj){	

	strData = obj.value;
	validi = "0123456789/.-+ ";
	for( i = 0; i < strData.length; i++ ){
		if( validi.indexOf(strData.charAt(i)) == -1 ){
			alert("Il numero di telefono non è formalmente corretto.");
			obj.focus();
			return;
		}
	}
}

function fData1(objdata){
	
	valore = objdata.value;
	
	if (Len(valore)>0){
		
		if (Len(valore)==10){
	
			primacoppia   = valore.substr(0,2)
			secondacoppia = valore.substr(3,2)
			quadrupla     = valore.substr(6,4)
		
			numero  = parseInt(primacoppia)
			numero1 = parseInt(secondacoppia)
			numero2 = parseInt(quadrupla)
		
			primoslash   = valore.substr(2,1)
			secondoslash = valore.substr(5,1)
		
			primalunghezza   = primacoppia.length
			secondalunghezza = secondacoppia.length
			terzalunghezza   = quadrupla.length
			
			if ((primalunghezza=2)&&(primoslash=="/")&&(numero>=1)&&(numero<=31)&&(secondalunghezza=2)&&(secondoslash=="/")&&(numero1>=1)&&(numero1<=12)&&(quadrupla=4)&&(numero2>=1800)&&(numero2<=3000)){
				//alert("BRAVO");
			}else{
				objdata.value = "";
				alert("La data non è formalmente corretta.");
				objdata.focus();
			}
			
		}else{
			
			objdata.value = "";
			alert("La data non è formalmente corretta.");
			objdata.focus();
			return;
		}
	}
}

function fLezioni(objFrm){
	
	valore = objFrm.value;
	
	if (Len(valore)==5){
		
		validi = "0123456789/";
		for( i = 0; i < valore.length; i++ ){
			if( validi.indexOf(valore.charAt(i)) == -1 ){
				alert("Il campo non è formalmente corretto (es. 00/03)");
				objFrm.focus();
				return;
			}
		}

		prima   = valore.substr(0,2)
		seconda = valore.substr(3,2)
	
		prima   = parseInt(prima)
		seconda = parseInt(seconda)
		
		slash   = valore.substr(2,1)
	
		if ((slash!="/")){
			alert("Il campo non è formalmente corretto (es. 00/03)");
			objFrm.focus();
			return;
		}
		
	}else{
		if (Len(valore)!=0){
			alert("Il campo non è formalmente corretto (es. 00/03)");
			objFrm.focus();
			return;
		}else{
			objFrm.value="00/00";
			return;
		}
	}
} 


function OrdineDate(obj1,obj2){

	primaData = obj1.value
	secondaData = obj2.value

	var arrprimaData = primaData.split("/")
	primaData = arrprimaData[2] + arrprimaData[1] + arrprimaData[0]
	
	var arrsecondaData = secondaData.split("/")
	secondaData = arrsecondaData[2] + arrsecondaData[1] + arrsecondaData[0]
	
	if (primaData>secondaData){
		obj2.value = "";
		alert("Inserire un intervallo di date valido.")
		return;
	}
	
}

/*-------------------- formattaData ----------------------------------*/

function formattaData(campo){
   app = campo.value;
   lungh = app.length;

   // put the separator during the typing
   if(lungh == 2 || lungh == 5) 
      campo.value = campo.value + "/";
   } // formattaData

/*-------------------------- eDate ----------------------------------*/

function eDate(dateStr, mess){
   dateCrt = document.dateStr.value;
   var datePat = /^(\d{2})(\/|-)(\d{2})(\/|-)(\d{4})$/;
   var matchArray = document.dateCrt.match(datePat); // il formato è corretto?

   if(matchArray == null && dateCrt != ""){
      alert("Inserire la data nel formato ggmmaaaa.\n" + "Esempio: 01012001");
      document.dateStr.focus();
      return false;
   }
   if(matchArray != null){  
   
      day = matchArray[1];
      month = matchArray[3];
      year = matchArray[5];
	  
      var tmp = checkDataCalendarValue("" + day, "" + month, "" + year, mess) != "" ? true : false;
	  //return checkDataCalendarValue("" + day, "" + month, "" + year, mess) != "" 
	  //  ? true : false;
	  if (tmp == false)
			document.dateStr.focus();
	  return tmp;
   }
   return true;
} // eDate


/*---------------------------- checkDataCalendarValue ------------------------*/
function checkDataCalendarValue(valGG, valMM, valYY, mess){
   dataFormatted = "";
   if(valMM != "nessuna" && valGG != "nessuna" && valYY != "nessuna"){
      // 31 days
      if(valGG == "31"){
         if(valMM == "04" || valMM == "06" || valMM == "09" || valMM == "11"){
            alert ("Il mese selezionato nel campo " + mess + " non ha 31 giorni");
            return dataFormatted;
            }
         }
      if(valGG > "31" || valGG < "01" ){
         alert ("Nel campo " + mess + " il giorno è errato");
         return dataFormatted;
         }

	  // feb with 28 days
      if(valMM == "02"){
         // look if the number of days is 28 or 29 (leap year)
		   var data = new Date(valYY, parseInt(valMM), 1);
         data = new Date(data - (24 * 60 * 60 * 1000));
         numDaysInMonth = data.getDate();
			if(parseInt(valGG) > parseInt("" + numDaysInMonth)){
            alert ("Nel campo " + mess + " Febbraio non puo' avere " + valGG + " giorni");
            return dataFormatted;
            }
         }

      // check the month
      if(valMM < "01" || valMM > "12"){
         alert ("Nel campo " + mess + " il mese deve essere compreso tra 01 e 12");
         return dataFormatted;
         }
       
      }

   // returns the formatted data
   dataFormatted = valGG + "/" + valMM + "/" + valYY;
   return dataFormatted;
} // checkDataValue

function ChkForReg(objForm){
	
	msg    = "";
	cont   = 0;
	studio = 0;
	liv    = 0;

	if (objForm.cognome && objForm.cognome.value==""){msg = msg + "- Cognome\n" ;}
	if (objForm.nome && objForm.nome.value==""){msg = msg + "- Nome\n" ;}
	//if (objForm.nazionalita && objForm.nazionalita.value==""){msg = msg + "- Nazionalità\n" ;}
	//if (objForm.regione && objForm.regione.value==""){msg = msg + "- Regione\n" ;}
	//if (objForm.prov && objForm.prov.value==""){msg = msg + "- Sigla provincia\n" ;}
	//if (objForm.citta && objForm.citta.value==""){msg = msg + "- Città\n" ;}
	//if (objForm.cap && objForm.cap.value==""){msg = msg + "- C.A.P.\n" ;}
	//if (objForm.anno_nascita && objForm.anno_nascita.value==""){msg = msg + "- Data di nascita\n" ;}
	if (objForm.indirizzo_mail && objForm.indirizzo_mail.value==""){msg = msg + "- Indirizzo e-mail\n" ;}
	if (objForm.telefono_contatto && objForm.telefono_contatto.value==""){msg = msg + "- Telefono per essere contattato\n" ;}
	//if (objForm.titolo_studio && objForm.titolo_studio.value==""){msg = msg + "- Titolo di studio\n" ;}
	//if (objForm.professione && objForm.professione.value==""){msg = msg + "- Professione\n" ;}
	/*if (objForm.dove_pubbl){
		for (i=0;i<=3;i++){
			if(objForm.dove_pubbl.checked==true){
				studio=1;
			}
			if(objForm.dove_priv.checked==true){
				studio=1;
			}
			if(objForm.dove_sogg.checked==true){
				studio=1;
			}
			if(objForm.dove_altro.checked==true){
				studio=1;
			}
		}
		if (studio==0){msg = msg + "- Dove hai studiato\n" ;}
	}
	
	if (objForm.studio_livello){
		for (a=0;a<=7;a++){
			if(objForm.studio_livello[a].checked==true){
				liv=1;
			}
		}
		if (liv==0){msg = msg + "- Quale livello hai raggiunto\n" ;}
	} */
	if (objForm.fisso1 && objForm.fisso1.value=="" && objForm.fisso2.value=="" && objForm.fisso3.value=="" && objForm.skype1.value=="" && objForm.skype2.value=="" && objForm.mobile1.value=="" && objForm.mobile2.value=="" && objForm.mobile3.value==""){cont=8;}
	if (objForm.user && objForm.user.value==""){msg = msg + "- Utente\n" ;}
	if (objForm.pwd && objForm.pwd.value==""){msg = msg + "- Password\n" ;}
	if (objForm.privacy && objForm.privacy.checked==false){msg = msg + "- Privacy\n" ;}
	
	if (msg!=""){
		msg = "Compilare i seguenti campi obbligatori:\n" + msg;
	}
	if (cont==8){
		msg = msg + "\nInserire almeno un numero telefonico per le lezioni";
	}
	if (msg!=""){
		alert(msg);
		return;
	}else{
		objForm.ACTION.value='INS';
		objForm.submit();
	}
}

function ChkForRegADM(objForm){
	
	msg    = "";
	cont   = 0;
	studio = 0;
	liv    = 0;
	
	if (objForm.tipologia && objForm.tipologia.value==""){msg = msg + "- Tipologia utente\n" ;}
	if (objForm.cognome && objForm.cognome.value==""){msg = msg + "- Cognome\n" ;}
	if (objForm.nome && objForm.nome.value==""){msg = msg + "- Nome\n" ;}
	//if (objForm.nazionalita && objForm.nazionalita.value==""){msg = msg + "- Nazionalità\n" ;}
	//if (objForm.regione && objForm.regione.value==""){msg = msg + "- Regione\n" ;}
	//if (objForm.provincia && objForm.provincia.value==""){msg = msg + "- Provincia\n" ;}
	//if (objForm.prov && objForm.prov.value==""){msg = msg + "- Sigla provincia\n" ;}
	//if (objForm.citta && objForm.citta.value==""){msg = msg + "- Città\n" ;}
	//if (objForm.cap && objForm.cap.value==""){msg = msg + "- C.A.P.\n" ;}
	//if (objForm.anno_nascita && objForm.anno_nascita.value==""){msg = msg + "- Data di nascita\n" ;}
	if (objForm.indirizzo_mail && objForm.indirizzo_mail.value==""){msg = msg + "- Indirizzo e-mail\n" ;}
	if (objForm.telefono_contatto && objForm.telefono_contatto.value==""){msg = msg + "- Telefono per essere contattato\n" ;}
	
	if (objForm.tipologia.value=="IN"){
		if (objForm.nickname && objForm.nickname.value==""){msg = msg + "- Soprannome insegnante\n" ;}
	}

	if (objForm.tipologia.value=="AL"){
		/*if (objForm.titolo_studio && objForm.titolo_studio.value==""){msg = msg + "- Titolo di studio\n" ;}
		if (objForm.professione && objForm.professione.value==""){msg = msg + "- Professione\n" ;}
		if (objForm.dove_pubbl){
			for (i=0;i<=3;i++){
				if(objForm.dove_pubbl.checked==true){
					studio=1;
				}
				if(objForm.dove_priv.checked==true){
					studio=1;
				}
				if(objForm.dove_sogg.checked==true){
					studio=1;
				}
				if(objForm.dove_altro.checked==true){
					studio=1;
				}
			}
			if (studio==0){msg = msg + "- Dove hai studiato\n" ;}
		}
		
		if (objForm.studio_livello){
			for (a=0;a<=7;a++){
				if(objForm.studio_livello[a].checked==true){
					liv=1;
				}
			}
		}
		if (liv==0){msg = msg + "- Quale livello hai raggiunto\n" ;}*/
		if (objForm.fisso1 && objForm.fisso1.value=="" && objForm.fisso2.value=="" && objForm.fisso3.value=="" && objForm.skype1.value=="" && objForm.skype2.value=="" && objForm.mobile1.value=="" && objForm.mobile2.value=="" && objForm.mobile3.value==""){cont=8;}
	}
	if (objForm.user && objForm.user.value==""){msg = msg + "- Utente\n" ;}
	if (objForm.pwd && objForm.pwd.value==""){msg = msg + "- Password\n" ;}
	
	if (msg!=""){
		msg = "Compilare i seguenti campi obbligatori:\n" + msg;
	}
	if (cont==8){
		msg = msg + "\nInserire almeno un numero telefonico per le lezioni";
	}
	if (msg!=""){
		alert(msg);
		return;
	}else{
		objForm.ACTION.value='INS';
		objForm.submit();
	}

}



function ChkForEditAdm(objForm){
	
	msg    = "";
	cont   = 0;
	studio = 0;
	liv    = 0;
	
	if (objForm.cognome && objForm.cognome.value==""){msg = msg + "- Cognome\n" ;}
	if (objForm.nome && objForm.nome.value==""){msg = msg + "- Nome\n" ;}
	//if (objForm.nazionalita && objForm.nazionalita.value==""){msg = msg + "- Nazionalità\n" ;}
	//if (objForm.regione && objForm.regione.value==""){msg = msg + "- Regione\n" ;}
	//if (objForm.provincia && objForm.provincia.value==""){msg = msg + "- Provincia\n" ;}
	//if (objForm.prov && objForm.prov.value==""){msg = msg + "- Sigla provincia\n" ;}
	//if (objForm.citta && objForm.citta.value==""){msg = msg + "- Città\n" ;}
	//if (objForm.cap && objForm.cap.value==""){msg = msg + "- C.A.P.\n" ;}
	//if (objForm.anno_nascita && objForm.anno_nascita.value==""){msg = msg + "- Data di nascita\n" ;}
	if (objForm.indirizzo_mail && objForm.indirizzo_mail.value==""){msg = msg + "- Indirizzo e-mail\n" ;}
	if (objForm.telefono_contatto && objForm.telefono_contatto.value==""){msg = msg + "- Telefono per essere contattato\n" ;}
	
	if (objForm.tipologia.value=="IN"){
		if (objForm.nickname && objForm.nickname.value==""){msg = msg + "- Soprannome insegnante\n" ;}
	}

	if (objForm.tipologia.value=="AL"){
		/*if (objForm.titolo_studio && objForm.titolo_studio.value==""){msg = msg + "- Titolo di studio\n" ;}
		if (objForm.professione && objForm.professione.value==""){msg = msg + "- Professione\n" ;}
		if (objForm.dove_pubbl){
			for (i=0;i<=3;i++){
				if(objForm.dove_pubbl.checked==true){
					studio=1;
				}
				if(objForm.dove_priv.checked==true){
					studio=1;
				}
				if(objForm.dove_sogg.checked==true){
					studio=1;
				}
				if(objForm.dove_altro.checked==true){
					studio=1;
				}
			}
			if (studio==0){msg = msg + "- Dove hai studiato\n" ;}
		}
		
		if (objForm.studio_livello){
			for (a=0;a<=7;a++){
				if(objForm.studio_livello[a].checked==true){
					liv=1;
				}
			}
			if (liv==0){msg = msg + "- Quale livello hai raggiunto\n" ;}
		}*/
		if (objForm.fisso1 && objForm.fisso1.value=="" && objForm.fisso2.value=="" && objForm.fisso3.value=="" && objForm.skype1.value=="" && objForm.skype2.value=="" && objForm.mobile1.value=="" && objForm.mobile2.value=="" && objForm.mobile3.value==""){cont=8;}
	}
	
	if (msg!=""){
		msg = "Compilare i seguenti campi obbligatori:\n" + msg;
	}
	if (cont==8){
		msg = msg + "\nInserire almeno un numero telefonico per le lezioni";
	}
	if (msg!=""){
		alert(msg);
		return;
	}else{
		objForm.submit();
	}
}

function ChkForEditUser(objForm){
	
	msg    = "";
	cont   = 0;
	studio = 0;
	liv    = 0;

	if (objForm.cognome && objForm.cognome.value==""){msg = msg + "- Cognome\n" ;}
	if (objForm.nome && objForm.nome.value==""){msg = msg + "- Nome\n" ;}
	//if (objForm.nazionalita && objForm.nazionalita.value==""){msg = msg + "- Nazionalità\n" ;}
	//if (objForm.regione && objForm.regione.value==""){msg = msg + "- Regione\n" ;}
	//if (objForm.provincia && objForm.provincia.value==""){msg = msg + "- Provincia\n" ;}
	//if (objForm.prov && objForm.prov.value==""){msg = msg + "- Sigla provincia\n" ;}
	//if (objForm.citta && objForm.citta.value==""){msg = msg + "- Città\n" ;}
	//if (objForm.cap && objForm.cap.value==""){msg = msg + "- C.A.P.\n" ;}
	//if (objForm.anno_nascita && objForm.anno_nascita.value==""){msg = msg + "- Data di nascita\n" ;}
	if (objForm.indirizzo_mail && objForm.indirizzo_mail.value==""){msg = msg + "- Indirizzo e-mail\n" ;}
	if (objForm.telefono_contatto && objForm.telefono_contatto.value==""){msg = msg + "- Telefono per essere contattato\n" ;}
	//if (objForm.titolo_studio && objForm.titolo_studio.value==""){msg = msg + "- Titolo di studio\n" ;}
	//if (objForm.professione && objForm.professione.value==""){msg = msg + "- Professione\n" ;}
	/*if (objForm.dove_pubbl){
		for (i=0;i<=3;i++){
			if(objForm.dove_pubbl.checked==true){
				studio=1;
			}
			if(objForm.dove_priv.checked==true){
				studio=1;
			}
			if(objForm.dove_sogg.checked==true){
				studio=1;
			}
			if(objForm.dove_altro.checked==true){
				studio=1;
			}
		}
		if (studio==0){msg = msg + "- Dove hai studiato\n" ;}
	}
	
	if (objForm.studio_livello){
		for (a=0;a<=7;a++){
			if(objForm.studio_livello[a].checked==true){
				liv=1;
			}
		}
		if (liv==0){msg = msg + "- Quale livello hai raggiunto\n" ;}
	}*/
	if (objForm.fisso1 && objForm.fisso1.value=="" && objForm.fisso2.value=="" && objForm.fisso3.value=="" && objForm.skype1.value=="" && objForm.skype2.value=="" && objForm.mobile1.value=="" && objForm.mobile2.value=="" && objForm.mobile3.value==""){cont=8;}
	if (objForm.privacy && objForm.privacy.checked==false){msg = msg + "- Privacy\n" ;}
	
	if (msg!=""){
		alert("Compilare i seguenti campi obbligatori:\n" + msg);
		return;
	}else{
		objForm.ACTION.value='EDI';
		objForm.submit();
	}
}

function ChkForEditOtherUser(objForm){
	
	msg    = "";
	cont   = 0;
	studio = 0;
	liv    = 0;

	if (objForm.indirizzo_mail && objForm.indirizzo_mail.value==""){msg = msg + "- Indirizzo e-mail\n" ;}
	if (objForm.telefono_contatto && objForm.telefono_contatto.value==""){msg = msg + "- Telefono per essere contattato\n" ;}
	if (objForm.fisso1 && objForm.fisso1.value=="" && objForm.fisso2.value=="" && objForm.fisso3.value=="" && objForm.skype1.value=="" && objForm.skype2.value=="" && objForm.mobile1.value=="" && objForm.mobile2.value=="" && objForm.mobile3.value==""){cont=8;}
	
	if (msg!=""){
		alert("Compilare i seguenti campi obbligatori:\n" + msg);
		return;
	}else{
		objForm.ACTION.value='EDI';
		objForm.submit();
	}
}

function ChkForContratto(objForm){
	if(document.getElementById("descrizione").value=="" || document.getElementById("numero_lezioni").value=="00/00" || document.getElementById("data_inizio_contratto").value=="" || document.getElementById("data_fine_contratto").value==""){
		alert("Inserire tutti i valori legati al contratto o alle lezioni di prova");
		return false;
	}else{
		return;
	}
}

function ChkFPwd(objForm){
	msg  = "";
	
	if (objForm.user && objForm.user.value==""){msg = msg + "- Utente\n" ;}
	if (objForm.cognome && objForm.cognome.value==""){msg = msg + "- Cognome\n" ;}
	if (objForm.nome && objForm.nome.value==""){msg = msg + "- Nome\n" ;}

if (msg!=""){
		msg = "Compilare i seguenti campi obbligatori:\n" + msg;
		alert(msg);
		return;
	}else{
		objForm.submit();
	}

}

function ChkMPwd(objForm){
	msg  = "";
	
	if (objForm.pwd1 && objForm.pwd1.value==""){msg = msg + "- Vecchia password\n" ;}
	if (objForm.pwd2 && objForm.pwd2.value==""){msg = msg + "- Nuova Password\n" ;}
	if (objForm.pwd3 && objForm.pwd3.value==""){msg = msg + "- Conferma nuova password\n" ;}

	if (msg!=""){
		msg = "Compilare i seguenti campi obbligatori:\n" + msg;
		alert(msg);
		return;
	}else{
		objForm.submit();
	}

}

function ChkForAzienda(objForm){
	msg  = "";

	if (objForm.demonimazione && objForm.demonimazione.value==""){msg = msg + "- Ragione sociale\n" ;}
	if (objForm.referente && objForm.referente.value==""){msg = msg + "- Nominativo referente\n" ;}
	if (objForm.ntelefono1 && objForm.ntelefono1.value==""){msg = msg + "- Telefono per contatto\n" ;}
	
	if (msg!=""){
		alert("Compilare i seguenti campi obbligatori:\n" + msg);
		return;
	}else{
		objForm.submit();
	}
}

function ChkForUploadFile(objForm){
	msg  = "";
	if (objForm.Carica){objForm.Carica.disabled=true;}
	if (objForm.File_PathName && objForm.File_PathName.value==""){msg = msg + "- File\n" ;}
	if (objForm.File_Desc && objForm.File_Desc.value==""){msg = msg + "- Descrizione\n" ;}
	
	if (msg!=""){
		alert("Compilare i seguenti campi obbligatori:\n" + msg);
		return;
	}else{
		objForm.submit();
	}
}


function CheckComuni(frmUno){
	if (frmUno.ACTION){
		frmUno.ACTION.value='';
	}
	if (frmUno.regione){
		frmUno.regione.value='';
	}
	if (frmUno.provincia){
		frmUno.provincia.value='';
	}
	if (frmUno.prov){
		frmUno.prov.value='';
	}
	if (frmUno.citta){
		frmUno.citta.value='';
	}
	if (frmUno.cap){
		frmUno.cap.value='';
	}
	frmUno.submit();
}

function ConfirmAction(Msg,ObjForm)
{
	if (confirm(Msg) == false)
	{
		return false;
	}
	else
	{
		ObjForm.submit();
	}
}


//////////////////////////////////////////////////////////////////////

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
	
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate1(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(0,pos1)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false;
	}
return true
}

function fData(objdata){
	if (isDate1(objdata.value)==false && objdata.value!=''){
		objdata.value = "";
		alert("Inserire una data valida");
		objdata.focus();
	}
}
 
function checkAltroStudio(scheck, stext){
	alert(scheck.checked);
	if (scheck.checked==false){
		stext.value = "";
	}
}
 
function textAltroStudio(scheck, stext){
	if (stext.value!=""){
		scheck.checked = true;
	}
	if (stext.value==""){
		scheck.checked = false;
	}
}

function ConfirmSubmit(frmName, MsgDesc){
	var Risposta = confirm(MsgDesc);
	if(Risposta){
		frmName.submit();
	}else{
		return;
	}
}

-->
