//Animazione flash
function animazione_flash() {
      document.write("<object type='application/x-shockwave-flash' data='slide.swf' width='250' height='188' id='filmato'> ");
      document.write("<param name='movie' value='slide.swf' /> ");
      document.write("<param name='quality' value='high' /><param name='wmode' value='transparent' /> ");
      document.write("</object> ");
}

// Controllo lunghezza campi
function MaxCaratteri(Object,MaxLen)
{return (Object.value.length<=MaxLen);}

// Controllo campi obbligatori
function formCheck(formobj){
	//1) Inserisci il nome che hai assegnato ai tuoi campi con name
	var fieldRequired = Array("nome","citta","telefono","mail","data1","data2","posti","messaggio");
	//2) Inserisci la descrizione del campo da riempire che appare nel messaggio a video
	var fieldDescription = Array("Nome e Cognome", "Citta", "Telefono", "E-mail", "Periodo -dal-", "Periodo -al-", "Posti", "Messaggio");
	//3) Inserisci il messagio che deve precedere l'elenco dei campi non inseriti.
	var alertMsg = "Per favore, riempi i seguenti campi:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

// Controllo email corretta
function ControllaMail(){
   EmailAddr = document.modulo.mail.value;
   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (Filtro.test(EmailAddr))
      return true;
   else
      {
		  if(EmailAddr != ""){
			  alert("Indirizzo e-mail non valido!");
			  document.modulo.mail.focus();
			  return false;
		}
      }
}
