function isBlank(s)
  {
  for (var i = 0; i < s.length; i++) {
    var c = s.charAt(i);
	if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
  return true;
  }
  
  
//Funzione di verifica
function verify(f)
  {
  var msg;
  var Empty_Fields = "";
  var errors = "";
//Ciclo attraverso il form sugli elementi text e textarea non optional.
//Il test controlla se i campi sono vuoti e se numerici ne controlla i valori min e max
//infine genera un messaggio di errore
  for (var i = 0; i < f.length; i++) {
    var e = f.elements[i];
	if (((e.type == "text") || (e.type == "textarea") || (e.type == "password")) && !e.optional) {
	  //controllo sul campo vuoto
	  if ((e.value == null) || (e.value == "") || isBlank(e.value)) {
	    Empty_Fields += "\n - Il campo [" + e.name + "] è obbligatorio";
		continue;
	    }
		
	//test mail		
    if (e.name == "EMail") {
	var ve = e.value;
		if ((ve.indexOf('@') == -1) || (ve.indexOf('.') == -1)) {
		  Empty_Fields += "\n - La mail inserita (" + e.value + ") risulta errata";
		}
	  }
	
	}
		
	
	  //controllo campi numerici
	if (e.numeric && e.value != "") {
	  if (e.numeric || (e.min != null) || (e.max != null)) {
	    var v = parseFloat (e.value);
		  if (isNaN(v) || ((e.min != null) && (v < e.min)) || ((e.max != null) && (v > e.max))) {
			errors += " - Il campo [" + e.name + "] deve essere un numero";
			if (e.min != null)
			  errors += " maggiore di " + e.min;
			if (e.max != null && e.min != null)
			  errors += " e minore di " + e.max;
			else if (e.max != null)
			  errors += " minore di " + e.max;
			errors += ".\n"
			}
		}
	}
  }
 
//Generazione del messaggio
//valore False se il modulo non deve essere processato
if (!Empty_Fields && !errors) return true;

msg = "__________________________________________________________\n\n"
msg += "Il modulo non è stato inviato.\n";
msg += "Si prega di correggere gli errori e inviarlo nuovamente.\n";
msg = "__________________________________________________________\n\n"

if (Empty_Fields) {
  msg += "I seguenti campi richiesti risultano vuoti o errati:\n" + Empty_Fields + "\n";
  if (errors) msg += "";
  }
msg += errors;

alert(msg);
return false;
}


function p45tv() {
		objWin = window.open("p45tv.asp","","width=590,height=540, menubar=no,fullscreen=no,scrollbars=no,resizable=no,menubar=no,toolbar=no,");
	}

function spot45() {
		objWin = window.open("http://www.srweb.it/parallelo45/parallelo.asp","","width=400,height=400, menubar=no,fullscreen=no,scrollbars=no,resizable=no,menubar=no,toolbar=no,");
	}
