<!--

function preloadImages() {

  if (document.images) {
  
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    
    document.WM.loadedImages = new Array();
    var argLength = preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {

      document.WM.loadedImages[arg] = new Image();

      document.WM.loadedImages[arg].src = preloadImages.arguments[arg];
    }
  }
}


//Controllo form Contatti
function checkContatto(nomeForm) {

	errore = false;
	var email = nomeForm.email.value;
	var messaggio = nomeForm.messaggio.value;
	errorestr = "Attenzione, controllare i seguenti campi:";
	errore = false;

	if (email == "") {
		errore = true;
		errorestr += "\n- il campo email è obbligatorio";
	} else {
		mailok = testEmail(email)
		if (!mailok) {
			errore = true;
			errorestr += "\n- l'indirizzo email inserito non è valido"
		}
	  }
	if (messaggio == "") {
		errore = true;
		errorestr += "\n- il campo messaggio è obbligatorio";
	}
	
	if (errore) {
		alert(errorestr);
		return false;
	} else {
		return true;
	  }
}


// Controllo validità indirizzo email inserito
function testEmail(txtemail) {
	offset = txtemail.indexOf('@');
	if (offset == -1) {
		return false;
	}
	else if (txtemail.indexOf('@', offset + 1) != -1) {
		return false;
	}
	if (txtemail.indexOf(' ') != -1) {
		return false;
	}
	if (txtemail.indexOf(',') != -1) {
		return false;
	}
	if (offset == 0) {
		return false;
	}
	if (txtemail.substring(offset - 1, offset) == '.' || txtemail.substring(offset + 1, offset + 2) == '.') {
		// . just before or just after the @ symbol
		return false;
	}
	if (txtemail.indexOf('.', offset + 2) == -1) {
		return false;
	}
	while (offset != -1) {
		offset = txtemail.indexOf('.', offset + 1)
		if (txtemail.substring(offset + 1, offset + 2) == '.') {
			return false;
		}
	}
	return true;
}

// Conferma eliminazione record
function confermaEliminazione() {

	if(confirm("Eliminare definitivamente il record selezionato?")){
		return true;
	} else {
		return false;
	  }
}

// Controllo inserimento/modifica Titolo di menù 
function checkTitolo() {
	errore = false;
	var descrizione = document.forms[0].descrizione.value;
	var posizione = document.forms[0].posizione.value;
	errorestr = "Attenzione, controllare i seguenti campi:";
	errore = false;
	
	if (descrizione == "") {
		errore = true;
		errorestr += "\n- il campo descrizione è obbligatorio";
	}
	if (posizione == "") {
		errore = true;
		errorestr += "\n- il campo posizione è obbligatorio";
	} else {
		posizioneInt = parseInt(posizione);
		if (isNaN(posizioneInt)){
			errore = true;
			errorestr += "\n- il campo posizione deve essere numerico";			
		}
		if (posizione.indexOf(",")!=-1) {
			errore = true;
			errorestr += "\n- il campo posizione non è valido";
		}
	}
	if (errore) {
		alert(errorestr);
		return false;
	} else {
		return true;
	  }
} 

// Controllo inserimento/modifica Voce di menù 
function checkVoce() {
	errore = false;
	var descrizione = document.forms[0].descrizione.value;
	var titolo = document.forms[0].titolo.value;
	errorestr = "Attenzione, controllare i seguenti campi:";
	errore = false;
	
	if (descrizione == "") {
		errore = true;
		errorestr += "\n- il campo descrizione è obbligatorio";
	}
	if (titolo == "") {
		errore = true;
		errorestr += "\n- impossibile inserire una voce in assenza di titoli";
	} 
	
	if (errore) {
		alert(errorestr);
		return false;
	} else {
		return true;
	  }
}

-->