function invia(valore) {
document.modulo.variabile.value=valore;
}

function validazione(){
with(document.modulo) {
	if(Nome.value=="") {
	alert("Insert your name");
	Nome.focus();
	return false;
	}
	if(Cognome.value=="") {
	alert("Insert your surname");
	Cognome.focus();
	return false;
	}
	if(Indirizzo.value=="") {
	alert("Insert your address");
	Indirizzo.focus();
	return false;
	}
	if(Citta.value=="") {
	alert("Insert your city");
	Citta.focus();
	return false;
	}
	if(Provincia.value=="") {
	alert("Insert your province");
	Provincia.focus();
	return false;
	}
	if(Stato.value=="") {
	alert("Insert your state");
	Stato.focus();
	return false;
	}
	if(cod0.value=="") {
	alert("Insert the articles code");
	cod0.focus();
	return false;
	}
	if(desc0.value=="") {
	alert("Insert articles description");
	desc0.focus();
	return false;
	}
	if(quant0.value=="") {
	alert("Insert quantity");
	quant0.focus();
	return false;
	}
	if(prez0.value=="") {
	alert("Insert articles unit price");
	prez0.focus();
	return false;
	}
	if(Autorizzazione.checked=="") {
	alert("Authorization necessary for personal data managing");
	Autorizzazione.focus();
	return false;
	}
	
	if(Email.value=="") {
	alert("Insert your e-mail");
	Email.focus();
	return false;
	}
	var stato=true;
	if(Email.value.indexOf(" ")!=-1) {
	Email.focus();
	stato=false;
	}
	var chiocciola=Email.value.indexOf("@");
	if(chiocciola<2) {
	Email.focus();
	stato=false;
	}
	var punto=Email.value.indexOf(".", chiocciola);
	if(punto<chiocciola+3) {
	Email.focus();
	stato=false;
	}
	var lung=Email.value.length;
	if(lung-punto<3) {
	Email.focus();
	stato=false;
	}
	
	//if(stato) {
		//alert("E-mail valida");
	//}else{	

	if(stato==false) {
		alert("E-mail not valid");
	return stato;
	}
}

// invia numero dei campi prodotti inseriti
javascript: invia(num)
return true;
}

// aggiungi-rimuovi articolo

var num=1;
function accoda(){
	if(document.createElement && document.getElementById && document.getElementsByTagName) {
		// crea elementi
		var oTr=document.createElement("TR");
		var oTd1=document.createElement("TD");
        var oTd2=document.createElement("TD");
        var oTd3=document.createElement("TD");
        var oTd4=document.createElement("TD");
		var oField1=document.createElement("INPUT");
        var oField2=document.createElement("INPUT");
        var oField3=document.createElement("INPUT");
        var oField4=document.createElement("INPUT");

		// setta attributi
  		oField1.setAttribute("type","text");
		oField1.setAttribute("name","cod"+num);
		oField1.setAttribute("size","10");
        oField2.setAttribute("type","text");
		oField2.setAttribute("name","desc"+num);
		oField2.setAttribute("size","25");		
        oField3.setAttribute("type","text");
		oField3.setAttribute("name","quant"+num);
		oField3.setAttribute("size","5");		
        oField4.setAttribute("type","text");
		oField4.setAttribute("name","prez"+num);
		oField4.setAttribute("size","10");		

		// appendi al relativo padre
		oTd1.appendChild(oField1);
        oTd2.appendChild(oField2);
        oTd3.appendChild(oField3);
        oTd4.appendChild(oField4);
		oTr.appendChild(oTd1);
        oTr.appendChild(oTd2);
        oTr.appendChild(oTd3);
        oTr.appendChild(oTd4);
		document.getElementById('tabella').getElementsByTagName('TBODY')[0].appendChild(oTr);

		// incrementa variabile globale
		num++
	}
}

function rimuovi(){
	if(document.removeChild && document.getElementById && document.getElementsByTagName) {
		// se non e' la prima riga
		if(num>1){
			// riferimento al tbody
			var tb=document.getElementById('tabella').getElementsByTagName('TBODY')[0];
			// riferimento all' ultimo TR
			var lastTr=tb.getElementsByTagName('TR')[(tb.getElementsByTagName('TR').length)-1]
			// rimuovi
			tb.removeChild(lastTr);
			// decrementa variabile globale
			num--
		}
	}
}