//Controllo form Motore di Ricerca Piccolo
function ControllaForm () {
//Messaggio di errore se il form è vuoto
if (document.FormMotoreDiRicerca.search.value=="")
{
alert("Inserire almeno una parola da cercare.\n\nInsert at least a word.");
document.FormMotoreDiRicerca.search.focus();
return false;
}
return true
}

//Controllo form Motore di Ricerca Principale
function ControllaForm2 () {
//Messaggio di errore se il form è vuoto
if (document.FormMotoreDiRicerca2.search.value=="")
{
alert("Inserire almeno una parola da cercare.\n\nInsert at least a word");
document.FormMotoreDiRicerca2.search.focus();
return false;
}
return true
}


// Controllo Compilazione Form per Accedere in Area Utente in BOX del Menu Sx
function VLogin(){
var re = new RegExp("^[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)*@[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)+$","i");

var email=document.Login.email.value;
if (email==""){
alert("Attenzione inserire Email\n\nAttention, Insert Email")
document.Login.email.focus()
return false
	}

if (!email.match(re)){
alert("Attenzione l\'Email non è valida!\n\nAttention, Email not correct.");
document.Login.email.select(); 
document.Login.email.focus()
return false
     }

var pass=document.Login.pass.value;
if (pass==""){
alert("Attenzione inserire la Password.\n\nAttention, Insert Password.")
document.Login.pass.focus()
return false
	}
for (var i = 0; i < pass.length; i++) {
      var ch1 = pass.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù")){
alert("Caratteri non consentiti nel campo Password.\n\nCharacters not allowed in the field Password.");
document.Login.pass.select()
document.Login.pass.focus()
return false
}
}
if (pass.length > 10) {
alert("La Password non può superare i 10 caratteri.\n\nThe Password can have max 10 characters.")
document.Login.pass.focus()
return false
}

}


// Controllo Compilazione FORM di Iscrizione alla MailingList
function validmail (){
var re = new RegExp("^[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)*@[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)+$","i");

var nome=document.FormMail.nome.value;
if (nome==""){
alert("Attenzione inserire il Nome\n\nAttention, Insert Name")
document.FormMail.nome.focus()
return false
	}
for (var i = 0; i < nome.length; i++) {
      var ch1 = nome.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("Caratteri non consentiti nel campo Nome.\n\nCharacters not allowed in the field Name.");
document.FormMail.nome.select()
document.FormMail.nome.focus()
return false
}
}

var nome=document.FormMail.nome.value;
if (nome=="Tuo Nome"){
alert("Attenzione inserire il Nome\n\nAttention, Insert Name")
document.FormMail.nome.focus()
return false
	}
var email=document.FormMail.email.value;
if (email==""){
alert("Attenzione inserire Email\n\nAttention, Insert Email")
document.FormMail.email.focus()
return false
	}
var email=document.FormMail.email.value;
if (email=="Tua-Mail.it"){
alert("Attenzione inserire Email\n\nAttention, Insert Email")
document.FormMail.email.focus()
return false
	}
if (!email.match(re)){
alert("Attenzione l\'Email non è valida!\n\nAttention, Email not correct.");
document.FormMail.email.select(); 
document.FormMail.email.focus()
return false
     }
}

// Controllo Compilazione FORM di RICHIESTA SUPPORTO STRUTTURE
function VFormSupporto(){
var re = new RegExp("^[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)*@[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)+$","i");
var nomestruttura=document.FormSupporto.nomestruttura.value;
if (nomestruttura==""){
alert("Attenzione inserire il Nome della Struttura")
document.FormSupporto.nomestruttura.focus()
return false
	}
for (var i = 0; i < nomestruttura.length; i++) {
      var ch1 = nomestruttura.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Nome Struttura.\nPer favore inserisci correttamente il Nome della Struttura.");
document.FormSupporto.nomestruttura.select()
document.FormSupporto.nomestruttura.focus()
return false
}
}
var cognome=document.FormSupporto.cognome.value;
if (cognome==""){
alert("Attenzione inserire il Cognome")
document.FormSupporto.cognome.focus()
return false
	}
for (var i = 0; i < cognome.length; i++) {
      var ch1 = cognome.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Cognome.\nPer favore inserisci correttamente il Cognome.");
document.FormSupporto.cognome.select()
document.FormSupporto.cognome.focus()
return false
}
}
var nome=document.FormSupporto.nome.value;
if (nome==""){
alert("Attenzione inserire il Nome")
document.FormSupporto.nome.focus()
return false
	}
for (var i = 0; i < nome.length; i++) {
      var ch1 = nome.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Nome.\nPer favore inserisci correttamente il Nome.");
document.FormSupporto.nome.select()
document.FormSupporto.nome.focus()
return false
}
}
var citta=document.FormSupporto.citta.value;
if (citta==""){
alert("Attenzione inserire la Città")
document.FormSupporto.citta.focus()
return false
	}
for (var i = 0; i < citta.length; i++) {
      var ch1 = citta.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Città.\nPer favore inserisci correttamente la Città.");
document.FormSupporto.citta.select()
document.FormSupporto.citta.focus()
return false
}
}
var provincia=document.FormSupporto.provincia.value;
if (provincia==""){
alert("Attenzione inserire la Provincia")
document.FormSupporto.provincia.focus()
return false
	}
for (var i = 0; i < provincia.length; i++) {
      var ch1 = provincia.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo Provincia.\nPer favore inserisci correttamente la Provincia.");
document.FormSupporto.provincia.select()
document.FormSupporto.provincia.focus()
return false
}
}
var telefono=document.FormSupporto.telefono.value;
if (telefono==""){
alert("Attenzione inserire N.Telefonico o Cell.")
document.FormSupporto.telefono.focus()
return false
	}
for (var i = 0; i < telefono.length; i++) {
      var ch1 = telefono.substring(i, i + 1);
      if ((ch1 < "0" || "9" < ch1) & ( ch1 != "+") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo Telefono.\nPer favore inserisci correttamente il N.Telefonico o Cell.");
document.FormSupporto.telefono.select()
document.FormSupporto.telefono.focus()
return false
}
}
var email=document.FormSupporto.email.value;
if (email==""){
alert("Attenzione inserire Email")
document.FormSupporto.email.focus()
return false
	}
if (!email.match(re)){
alert("Attenzione l\'Email non è valida!");
document.FormSupporto.email.select(); 
document.FormSupporto.email.focus()
return false
     }
var messaggio=document.FormSupporto.messaggio.value;
if (messaggio==""){
alert("Attenzione inserire il Messaggio")
document.FormSupporto.messaggio.focus()
return false
	}
}

// Controllo Compilazione FORM Registrazione Nuova Struttura
function VNuovaStruttura(){
var re = new RegExp("^[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)*@[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)+$","i");
var Tipologia=document.NuovaStruttura.Tipologia.value;
if (Tipologia=="Null"){
alert("Attenzione inserire la Tipologia di Appartenenza")
document.NuovaStruttura.Tipologia.focus()
return false
	}
if(Tipologia=="Agriturismo"){
var Categoria=document.NuovaStruttura.Categoria.value;
if (Categoria=="0"){
alert("Attenzione inserire la Categoria di Appartenenza")
document.NuovaStruttura.Categoria.focus()
return false
	}
document.NuovaStruttura.Tipologia.focus()
	}

if(Tipologia=="B_B"){
var Categoria=document.NuovaStruttura.Categoria.value;
if (Categoria=="0"){
alert("Attenzione inserire la Categoria di Appartenenza")
document.NuovaStruttura.Categoria.focus()
return false
	}
document.NuovaStruttura.Tipologia.focus()
	}

if(Tipologia=="Campeggi"){
var Categoria=document.NuovaStruttura.Categoria.value;
if (Categoria=="0"){
alert("Attenzione inserire la Categoria di Appartenenza")
document.NuovaStruttura.Categoria.focus()
return false
	}
document.NuovaStruttura.Tipologia.focus()
	}

if(Tipologia=="Hotel"){
var Categoria=document.NuovaStruttura.Categoria.value;
if (Categoria=="0"){
alert("Attenzione inserire la Categoria di Appartenenza")
document.NuovaStruttura.Categoria.focus()
return false
	}
document.NuovaStruttura.Tipologia.focus()
	}

var nomestruttura=document.NuovaStruttura.nomestruttura.value;
if (nomestruttura==""){
alert("Attenzione inserire il Nome della Struttura")
document.NuovaStruttura.nomestruttura.focus()
return false
	}
for (var i = 0; i < nomestruttura.length; i++) {
      var ch1 = nomestruttura.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Nome Struttura.\nPer favore inserisci correttamente il Nome della Struttura.");
document.NuovaStruttura.nomestruttura.select()
document.NuovaStruttura.nomestruttura.focus()
return false
}
}
var n_camere=document.NuovaStruttura.n_camere.value;
if (n_camere=="00"){
alert("Attenzione inserire il N.delle Camere")
document.NuovaStruttura.n_camere.focus()
return false
	}

var indirizzo=document.NuovaStruttura.indirizzo.value;
if (indirizzo==""){
alert("Attenzione inserire l\'Indirizzo della Struttura")
document.NuovaStruttura.indirizzo.focus()
return false
	}
for (var i = 0; i < indirizzo.length; i++) {
      var ch1 = indirizzo.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != ",") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Indirizzo.\nPer favore inserisci correttamente l\'Indirizzo.");
document.NuovaStruttura.indirizzo.select()
document.NuovaStruttura.indirizzo.focus()
return false
}
}
var citta=document.NuovaStruttura.citta.value;
if (citta==""){
alert("Attenzione inserire la Città")
document.NuovaStruttura.citta.focus()
return false
	}
for (var i = 0; i < citta.length; i++) {
      var ch1 = citta.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Città.\nPer favore inserisci correttamente la Città.");
document.NuovaStruttura.citta.select()
document.NuovaStruttura.citta.focus()
return false
}
}
var provincia=document.NuovaStruttura.provincia.value;
if (provincia==""){
alert("Attenzione inserire la Provincia")
document.NuovaStruttura.provincia.focus()
return false
	}
for (var i = 0; i < provincia.length; i++) {
      var ch1 = provincia.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo Provincia.\nPer favore inserisci correttamente la Provincia.");
document.NuovaStruttura.provincia.select()
document.NuovaStruttura.provincia.focus()
return false
}
}
var cap=document.NuovaStruttura.cap.value;
if (cap==""){
alert("Attenzione inserire il Cap")
document.NuovaStruttura.cap.focus()
return false
	}
for (var i = 0; i < cap.length; i++) {
      var ch1 = cap.substring(i, i + 1);
      if ((ch1 < "0" || "9" < ch1) & ( ch1 != "+") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo Cap.\nPer favore inserisci correttamente il Cap.");
document.NuovaStruttura.cap.select()
document.NuovaStruttura.cap.focus()
return false
}
}

var catena=document.NuovaStruttura.catena.value;
for (var i = 0; i < catena.length; i++) {
      var ch1 = catena.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Catena.\nPer favore inserisci correttamente a quale Catena appartenete.");
document.NuovaStruttura.catena.select()
document.NuovaStruttura.catena.focus()
return false
}
}

var rag_sociale=document.NuovaStruttura.rag_sociale.value;
if (rag_sociale==""){
alert("Attenzione inserire la Ragione Sociale")
document.NuovaStruttura.rag_sociale.focus()
return false
	}
for (var i = 0; i < rag_sociale.length; i++) {
      var ch1 = rag_sociale.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`") & ( ch1 != "&")){
alert("\nCaratteri non consentiti nel campo Ragione Sociale.\nPer favore inserisci correttamente il dato.");
document.NuovaStruttura.rag_sociale.select()
document.NuovaStruttura.rag_sociale.focus()
return false
}
}

var p_iva=document.NuovaStruttura.p_iva.value;
if (p_iva==""){
alert("Attenzione inserire la P.Iva oppure il Cod.Fiscale.")
document.NuovaStruttura.p_iva.focus()
return false
	}
for (var i = 0; i < p_iva.length; i++) {
      var ch1 = p_iva.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo P.Iva-Cod.Fiscale.\nPer favore inserisci correttamente il dato.");
document.NuovaStruttura.p_iva.select()
document.NuovaStruttura.p_iva.focus()
return false
}
}

var indirizzo_legale=document.NuovaStruttura.indirizzo_legale.value;
if (indirizzo_legale==""){
alert("Attenzione inserire l\'Indirizzo della Sede Legale")
document.NuovaStruttura.indirizzo_legale.focus()
return false
	}
for (var i = 0; i < indirizzo_legale.length; i++) {
      var ch1 = indirizzo_legale.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != ",") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Indirizzo della Sede Legale.\nPer favore inserisci correttamente il dato.");
document.NuovaStruttura.indirizzo_legale.select()
document.NuovaStruttura.indirizzo_legale.focus()
return false
}
}
var citta_legale=document.NuovaStruttura.citta_legale.value;
if (citta_legale==""){
alert("Attenzione inserire la Città della Sede Legale.")
document.NuovaStruttura.citta_legale.focus()
return false
	}
for (var i = 0; i < citta_legale.length; i++) {
      var ch1 = citta_legale.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Città della Sede Legale.\nPer favore inserisci correttamente il dato.");
document.NuovaStruttura.citta_legale.select()
document.NuovaStruttura.citta_legale.focus()
return false
}
}
var provincia_legale=document.NuovaStruttura.provincia_legale.value;
if (provincia_legale==""){
alert("Attenzione inserire la Provincia della Sede Legale.")
document.NuovaStruttura.provincia_legale.focus()
return false
	}
for (var i = 0; i < provincia_legale.length; i++) {
      var ch1 = provincia_legale.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo Provincia della Sede Legale.\nPer favore inserisci correttamente il dato.");
document.NuovaStruttura.provincia_legale.select()
document.NuovaStruttura.provincia_legale.focus()
return false
}
}
var cap_legale=document.NuovaStruttura.cap_legale.value;
if (cap_legale==""){
alert("Attenzione inserire il Cap della Sede Legale.")
document.NuovaStruttura.cap_legale.focus()
return false
	}
for (var i = 0; i < cap_legale.length; i++) {
      var ch1 = cap.substring(i, i + 1);
      if ((ch1 < "0" || "9" < ch1) & ( ch1 != "+") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo Cap della Sede Legale.\nPer favore inserisci correttamente il dato.");
document.NuovaStruttura.cap_legale.select()
document.NuovaStruttura.cap_legale.focus()
return false
}
}

var proprietario=document.NuovaStruttura.proprietario.value;
if (proprietario==""){
alert("Attenzione inserire il Nome e Cognome del Proprietario della Struttura")
document.NuovaStruttura.proprietario.focus()
return false
	}
for (var i = 0; i < proprietario.length; i++) {
      var ch1 = proprietario.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Proprietario.\nPer favore inserisci correttamente il Nome e Cognome del Proprietario.");
document.NuovaStruttura.proprietario.select()
document.NuovaStruttura.proprietario.focus()
return false
}
}

var responsabile=document.NuovaStruttura.responsabile.value;
if (responsabile==""){
alert("Attenzione inserire il Nome e Cognome del Responsabile")
document.NuovaStruttura.responsabile.focus()
return false
	}
for (var i = 0; i < responsabile.length; i++) {
      var ch1 = responsabile.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & ( ch1 != "`")){
alert("\nCaratteri non consentiti nel campo Responsabile.\nPer favore inserisci correttamente il Nome e Cognome del Responsabile.");
document.NuovaStruttura.responsabile.select()
document.NuovaStruttura.responsabile.focus()
return false
}
}

var telefono=document.NuovaStruttura.telefono.value;
if (telefono==""){
alert("Attenzione inserire N.Telefonico o Cell.")
document.NuovaStruttura.telefono.focus()
return false
	}
for (var i = 0; i < telefono.length; i++) {
      var ch1 = telefono.substring(i, i + 1);
      if ((ch1 < "0" || "9" < ch1) & ( ch1 != "+") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo Telefono.\nPer favore inserisci correttamente il N.Telefonico o Cell.");
document.NuovaStruttura.telefono.select()
document.NuovaStruttura.telefono.focus()
return false
}
}

var fax=document.NuovaStruttura.fax.value;
for (var i = 0; i < fax.length; i++) {
      var ch1 = fax.substring(i, i + 1);
      if ((ch1 < "0" || "9" < ch1) & ( ch1 != "+") & (ch1 != ' ')){
alert("\nCaratteri non consentiti nel campo Fax.\nPer favore inserisci correttamente il N. di Fax.");
document.NuovaStruttura.fax.select()
document.NuovaStruttura.fax.focus()
return false
}
}

var sito_web=document.NuovaStruttura.sito_web.value;
for (var i = 0; i < sito_web.length; i++) {
      var ch1 = sito_web.substring(i, i + 1);
      if ((ch1 < "a" || "z" < ch1) && (ch1 < "A" || "Z" < ch1) & (ch1 < "0" || "9" < ch1) & ( ch1 != "à") & ( ch1 != "è") & ( ch1 != "ì") & ( ch1 != "ò") & ( ch1 != "ù") & (ch1 != ' ') & ( ch1 != "'") & (ch1 != ".") & ( ch1 != "`") & ( ch1 != "-") & ( ch1 != "_")){
alert("\nCaratteri non consentiti nel campo Sito Web.\nPer favore inserisci correttamente il sito\nnel seguente formato: www.tuodominio.it");
document.NuovaStruttura.sito_web.select()
document.NuovaStruttura.sito_web.focus()
return false
}
}


var email=document.NuovaStruttura.email.value;
if (email==""){
alert("Attenzione inserire Email")
document.NuovaStruttura.email.focus()
return false
	}
if (!email.match(re)){
alert("Attenzione l\'Email non è valida!");
document.NuovaStruttura.email.select(); 
document.NuovaStruttura.email.focus()
return false
     }
}

// Controllo Compilazione FORM di RICHIESTA VELOCE ALLOGGIO TRAMITE CONSULENZA
function VFastSearch(){
var re = new RegExp("^[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)*@[!#$&'*+/-9=?A-Z^-~-]+(\\.[!#$&'*+/-9=?A-Z^-~-]+)+$","i");

var cognome=document.FastSearch.cognome.value;
if (cognome==""){
alert("Attenzione inserire il Cognome !!\n\nAttention insert your First Name!!")
document.FastSearch.cognome.focus()
return false
	}
else if(cognome.toUpperCase()=="ON"){
alert("Attenzione Cognome errato !!\n\nAttention wrong First Name!!")
document.FastSearch.cognome.focus()
return false
	}

var nome=document.FastSearch.nome.value;
if (nome==""){
alert("Attenzione inserire il Nome !!\n\nAttention insert your Last Name !!")
document.FastSearch.nome.focus()
return false
	}
else if(nome.toUpperCase()=="ON"){
alert("Attenzione Nome errato !!\n\nAttention wrong Last Name!!")
document.FastSearch.nome.focus()
return false
	}

var email=document.FastSearch.email.value;
if (email==""){
alert("Attenzione inserire Email !!\n\nAttention insert your Email !!")
document.FastSearch.email.focus()
return false
	}

if (!email.match(re)){
alert("Attenzione l\'Email non è valida!!\n\nAttention your Email is wrong!!");
document.FastSearch.email.select(); 
document.FastSearch.email.focus()
return false
     }

var telefono=document.FastSearch.telefono.value;
if(telefono.toUpperCase()=="ON"){
alert("Attenzione Numero di Telefono errato !!\n\nAttention wrong Phone Number!!")
document.FastSearch.telefono.focus()
return false
	}

var persone=document.FastSearch.persone.value;
if (persone=="0"){
alert("Attenzione inserire il numero di persone!!\n\nAttention insert Number of People!!");
document.FastSearch.persone.focus()
return false
}
}


// funzione per la list box dinamica nella ricerca avanzata dell'alloggio

var Tipologia = new Array("Categoria");
var Null = new Array(" --- ");
var Agriturismo = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var BandB = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Campeggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Case = new Array(" --- ");
var Hotel = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Residence = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Villaggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");

function swap1(Categoria)
{
        var seleziona_numero = window.document.RicercaAlloggio.Categoria;
        var the_array = eval(Categoria);
        setOptionTesto(window.document.RicercaAlloggio.Categoria,the_array);
}

function setOptionTesto(the_select, the_array)
{
		the_select.length=the_array.length;
        for (c=0; c < the_array.length; c++)
        {
                the_select.options[c].text = the_array[c];
        }
}

// funzione per la list box dinamica nella ricerca normale dell'alloggio

var Tipologia = new Array("Categoria");
var Null = new Array(" --- ");
var Agriturismo = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var BandB = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Campeggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Case = new Array(" --- ");
var Hotel = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Residence = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Villaggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");

function swap2(Categoria)
{
        var seleziona_numero = window.document.CercaAlloggio.Categoria;
        var the_array = eval(Categoria);
        setOptionTesto2(window.document.CercaAlloggio.Categoria,the_array);
}

function setOptionTesto2(the_select, the_array)
{
		the_select.length=the_array.length;
        for (c=0; c < the_array.length; c++)
        {
                the_select.options[c].text = the_array[c];
        }
}

// funzione per la list box dinamica nel form di inserimento nuova struttura

var Tipologia = new Array("Categoria");
var Null = new Array(" --- ");
var Agriturismo = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var BandB = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Campeggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Case = new Array(" --- ");
var Hotel = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Residence = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Villaggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");

function swap3(Categoria)
{
        var seleziona_numero = window.document.NuovaStruttura.Categoria;
        var the_array = eval(Categoria);
        setOptionTesto3(window.document.NuovaStruttura.Categoria,the_array);
}

function setOptionTesto3(the_select, the_array)
{
		the_select.length=the_array.length;
        for (c=0; c < the_array.length; c++)
        {
                the_select.options[c].text = the_array[c];
        }
}

// funzione per la list box dinamica nel form di modifica struttura in Area Gestionale

var Tipologia = new Array("Categoria");
var Null = new Array(" --- ");
var Agriturismo = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Bandb = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Campeggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Case = new Array(" --- ");
var Hotel = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Residence = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Villaggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");

function swap4(Categoria)
{
        var seleziona_numero = window.document.ModStruttura.Categoria;
        var the_array = eval(Categoria);
        setOptionTesto4(window.document.ModStruttura.Categoria,the_array);
}

function setOptionTesto4(the_select, the_array)
{
		the_select.length=the_array.length;
        for (c=0; c < the_array.length; c++)
        {
                the_select.options[c].text = the_array[c];
        }
}

// funzione per la list box dinamica nel form di richiesta veloce struttura

var Tipologia = new Array("Categoria");
var Null = new Array(" --- ");
var Agriturismo = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var BandB = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Campeggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Case = new Array(" --- ");
var Hotel = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Residence = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");
var Villaggio = new Array(" --- ","1 *","2 **","3 ***","4 ****","5 *****","5 ***** L");

function swap5(Categoria)
{
        var seleziona_numero = window.document.FastSearch.Categoria;
        var the_array = eval(Categoria);
        setOptionTesto5(window.document.FastSearch.Categoria,the_array);
}

function setOptionTesto5(the_select, the_array)
{
		the_select.length=the_array.length;
        for (c=0; c < the_array.length; c++)
        {
                the_select.options[c].text = the_array[c];
        }
}

//funzione che serve a cancellare il campo NOME ESERCIZIO nel Motore Ricerca posto sul lato dx
function resetForm()
{
    document.CercaAlloggio.nome_esercizio.value = '';
    disableForm(false);
}

//funzione che Disattiva i vari Select List se scelgo di Utilizzare il Campo Nome Esercizio
function disableForm(isDisabled)
{
document.CercaAlloggio.Paese.disabled = isDisabled;
document.CercaAlloggio.Tipologia.disabled = isDisabled;
document.CercaAlloggio.Categoria.disabled = isDisabled;
}


//funzione che serve ad attivare i check box anche cliccando sul testo/immagine corrispondente
function changeBox(cbox) {
box = eval(cbox);
box.checked = !box.checked;
if (box.disabled==true){
box.checked = false;
}
}


//funzione che serve a disabilitare i check box quando seleziono dalla ricerca la voce CASE ESTIVE
function disableform(){
var Tipologia=document.RicercaAlloggio.Tipologia.value;
if (Tipologia=="Case"){
document.RicercaAlloggio.srv[0].disabled=true;
document.RicercaAlloggio.srv[0].checked=false;
document.RicercaAlloggio.srv[3].disabled=true;
document.RicercaAlloggio.srv[3].checked=false;
document.RicercaAlloggio.srv[4].disabled=true;
document.RicercaAlloggio.srv[4].checked=false;
document.RicercaAlloggio.srv[8].disabled=true;
document.RicercaAlloggio.srv[8].checked=false;
document.RicercaAlloggio.srv[10].disabled=true;
document.RicercaAlloggio.srv[10].checked=false;
document.RicercaAlloggio.srv[11].disabled=true;
document.RicercaAlloggio.srv[11].checked=false;
document.RicercaAlloggio.srv[22].disabled=true;
document.RicercaAlloggio.srv[22].checked=false;
document.RicercaAlloggio.srv[25].disabled=true;
document.RicercaAlloggio.srv[25].checked=false;
document.RicercaAlloggio.srv[27].disabled=true;
document.RicercaAlloggio.srv[27].checked=false;
document.RicercaAlloggio.srv[28].disabled=true;
document.RicercaAlloggio.srv[28].checked=false;
document.RicercaAlloggio.srv[29].disabled=true;
document.RicercaAlloggio.srv[29].checked=false;
document.RicercaAlloggio.srv[30].disabled=true;
document.RicercaAlloggio.srv[30].checked=false;
document.RicercaAlloggio.srv[32].disabled=true;
document.RicercaAlloggio.srv[32].checked=false;
document.RicercaAlloggio.srv[33].disabled=true;
document.RicercaAlloggio.srv[33].checked=false;
document.RicercaAlloggio.srv[34].disabled=true;
document.RicercaAlloggio.srv[34].checked=false;
document.RicercaAlloggio.srv[35].disabled=true;
document.RicercaAlloggio.srv[35].checked=false;
document.RicercaAlloggio.srv[36].disabled=true;
document.RicercaAlloggio.srv[36].checked=false;
document.RicercaAlloggio.srv[37].disabled=true;
document.RicercaAlloggio.srv[37].checked=false;
document.RicercaAlloggio.srv[38].disabled=true;
document.RicercaAlloggio.srv[38].checked=false;
document.RicercaAlloggio.srv[39].disabled=true;
document.RicercaAlloggio.srv[39].checked=false;
document.RicercaAlloggio.srv[40].disabled=true;
document.RicercaAlloggio.srv[40].checked=false;
document.RicercaAlloggio.srv[41].disabled=true;
document.RicercaAlloggio.srv[41].checked=false;
document.RicercaAlloggio.srv[42].disabled=true;
document.RicercaAlloggio.srv[42].checked=false;
document.RicercaAlloggio.srv[43].disabled=true;
document.RicercaAlloggio.srv[43].checked=false;
document.RicercaAlloggio.srv[45].disabled=true;
document.RicercaAlloggio.srv[45].checked=false;
document.RicercaAlloggio.srv[47].disabled=true;
document.RicercaAlloggio.srv[47].checked=false;
document.RicercaAlloggio.srv[48].disabled=true;
document.RicercaAlloggio.srv[48].checked=false;
document.RicercaAlloggio.srv[49].disabled=true;
document.RicercaAlloggio.srv[49].checked=false;
document.RicercaAlloggio.srv[50].disabled=true;
document.RicercaAlloggio.srv[50].checked=false;
document.RicercaAlloggio.srv[51].disabled=true;
document.RicercaAlloggio.srv[51].checked=false;
document.RicercaAlloggio.srv[52].disabled=true;
document.RicercaAlloggio.srv[52].checked=false;
document.RicercaAlloggio.srv[53].disabled=true;
document.RicercaAlloggio.srv[53].checked=false;
document.RicercaAlloggio.srv[54].disabled=true;
document.RicercaAlloggio.srv[54].checked=false;
document.RicercaAlloggio.srv[57].disabled=true;
document.RicercaAlloggio.srv[57].checked=false;
document.RicercaAlloggio.srv[58].disabled=true;
document.RicercaAlloggio.srv[58].checked=false;

}
else if (Tipologia!=="Case"){ 
document.RicercaAlloggio.srv[0].disabled=false;
document.RicercaAlloggio.srv[3].disabled=false;
document.RicercaAlloggio.srv[4].disabled=false;
document.RicercaAlloggio.srv[8].disabled=false;
document.RicercaAlloggio.srv[10].disabled=false;
document.RicercaAlloggio.srv[11].disabled=false;
document.RicercaAlloggio.srv[22].disabled=false;
document.RicercaAlloggio.srv[25].disabled=false;
document.RicercaAlloggio.srv[27].disabled=false;
document.RicercaAlloggio.srv[28].disabled=false;
document.RicercaAlloggio.srv[29].disabled=false;
document.RicercaAlloggio.srv[30].disabled=false;
document.RicercaAlloggio.srv[32].disabled=false;
document.RicercaAlloggio.srv[33].disabled=false;
document.RicercaAlloggio.srv[34].disabled=false;
document.RicercaAlloggio.srv[35].disabled=false;
document.RicercaAlloggio.srv[36].disabled=false;
document.RicercaAlloggio.srv[37].disabled=false;
document.RicercaAlloggio.srv[38].disabled=false;
document.RicercaAlloggio.srv[39].disabled=false;
document.RicercaAlloggio.srv[40].disabled=false;
document.RicercaAlloggio.srv[41].disabled=false;
document.RicercaAlloggio.srv[42].disabled=false;
document.RicercaAlloggio.srv[43].disabled=false;
document.RicercaAlloggio.srv[45].disabled=false;
document.RicercaAlloggio.srv[47].disabled=false;
document.RicercaAlloggio.srv[48].disabled=false;
document.RicercaAlloggio.srv[49].disabled=false;
document.RicercaAlloggio.srv[50].disabled=false;
document.RicercaAlloggio.srv[51].disabled=false;
document.RicercaAlloggio.srv[52].disabled=false;
document.RicercaAlloggio.srv[53].disabled=false;
document.RicercaAlloggio.srv[54].disabled=false;
document.RicercaAlloggio.srv[57].disabled=false;
document.RicercaAlloggio.srv[58].disabled=false;
document.RicercaAlloggio.Tipologia.focus()
return false
	}
}

// funzioni per inserire link e mail nella sezione mailinglist
function DoLink(){
alert('Come inserire un link nel messaggio:\nEsempio:\n\n[URL=http://www.tuosito.it/]Testo del Link\[/URL]')
etext = prompt("Inserite il titolo della pagina", "");
if ((etext != null) && (etext != "") && (code = "URL")){
insertCode = prompt("Inserire l\'url del Link che desiderate aggiungere", "http://");
if ((insertCode != null) && (insertCode != "") && (insertCode != "http://")){
document.theform.messaggio.value += "[" + code + "=" + insertCode + "]" + etext + "[/" + code + "]";
}
}
document.theform.messaggio.focus();
}

function DoMail(){
alert('Come inserire un\'indirizzo Email nel messaggio:\nEsempio:\n\n[MAIL=tuamail@address.com]Questa è la mia E-Mail[/MAIL]')
etext = prompt("Inserisci la tua e-mail", "");
etext2 = prompt("Inserisci il nome della tua e-mail\n(Se non inserisci un nome verrà inserito il nome della e-mail)", "");
if (etext != null && etext != ""){
	if (etext2 != null && etext2 != ""){
	document.theform.messaggio.value += ("[MAIL=" + etext + "]" + etext2 + "[/MAIL]");
	}
	else{
	document.theform.messaggio.value += ("[MAIL=" + etext + "]" + etext + "[/MAIL]");
	}
}
document.theform.messaggio.focus();
}


// funzione per inserire nei form funzioni tipo [B][/B] - [i][/i] - smile ed altro
function addPic(picName){
document.theform.messaggio.value = document.theform.messaggio.value + picName;
document.theform.messaggio.focus();
}

// funzione per far comparire il pop-up che cancella la foto delle news dal db
var winOpenNOFOTO;
function apriFinestra(page){
winOpened=window.open(page,"NOFOTO","directories=no,status=no,statusbar=no,resizable=no,menubar=no,noscrollbars,toolbar=no,width=400,height=160,left=150,top=200");
}

// funzione per far comparire la pop-up per anterpima della news appena scritta
function OpenPreviewWindow(){
if (document.theform.messaggio.length != 0 && document.theform.messaggio.value != ''){
document.cookie ='News_testo = ' + escape(document.theform.messaggio.value);
window.open('anteprima_news.asp', 'preview', 'scrollbars=yes,width=600,height=400,left=80')
}
else{
alert("Per visualizzare un\'anteprima,\ndovresti inserire del testo..\nNon credi..!?!?");
return false
}
}

// funzione per far comparire una pop-up con all'interno una foto di dimensioni variabili
function popimmagine(str){
searchWin = window.open(str,'Guardafoto','scrollbars=auto,resizable=no,status=no,location=no,toolbar=no');
}

// funzione per far comparire una popup con dimensione da fissare e scrollbar visibile o no(vedi mailinglist)
function popup(popupfile,winwidth,winheight,scrollbars){
open(popupfile,"PopupWindow","resizable=no,height=" + winheight + ",width=" + winwidth + ",scrollbars=" + scrollbars);
}


// funzione per far apparire il sottomenu delle varie risorse (questo per quelli che hanno problemi nella visualizzazione del menu in DHTML

function menurisorse(submenu){
menuWin = window.open(submenu,"popupmenu","directories=no,status=no,statusbar=no,resizable=no,menubar=no,noscrollbars,toolbar=no,width=350,height=200,left=8,top=10");
}

// funzione per far apparire la descrizione delle immagini in + lingue
function sH(str,event) {
		if (document.all) {
			document.all["Desc"].innerHTML = "" + str;
			document.all["Desc"].style.pixelLeft = (document.body.scrollLeft + event.clientX) + 10;
			document.all["Desc"].style.pixelTop = (document.body.scrollTop + event.clientY) + 10;
			document.all["Desc"].style.visibility = "visible";
		} else if (document.getElementById) {
			document.getElementById("Desc").innerHTML = "" + str;
			document.getElementById("Desc").style.left = event.pageX + 10;
			document.getElementById("Desc").style.top = event.pageY + 10;
			document.getElementById("Desc").style.visibility = "visible";
		}
	}

	function hH() {
      document.getElementById("Desc").innerHTML = "";
      document.getElementById("Desc").style.visibility="hidden";
	}


// Controllo form invio Dati Carta di Credito in Area Utenti
//Checks all fields in form by array an relative functions
function check_form(oForm){
var error=false;
var obj=null;

obj = eval( 'oForm.titolare' );
if (!check_value(obj))  {
alert("Non hai inserito il nome del titolare.\n\nAttention, Insert Holder.");
error=true;
obj.focus();
return !error;
}

obj = eval( 'oForm.num_cc' );
if (!check_value(obj))  {
alert("Non hai inserito il numero della carta di credito.\n\nAttention, Insert Credit Card Number.");
error=true;
obj.focus();
return !error;
}

obj = eval( 'oForm.num_cc' );
// check number 
if (!isValidCardNumber(obj.value))  {
alert("Il numero di carta di credito non è valido\n\nCredit Card Number not correct.");
error=true;
obj.focus();
obj.select();
return !error;
}
// check type 
		               

obj = eval( 'oForm.mese_cc' );
if (!check_value(obj))  {
alert("Non hai inserito il mese di scadenza della carta di credito.\n\nAttention, Insert Month of Expiration");
error=true;
obj.focus();
return !error;
}

obj = eval( 'oForm.anno_cc' );
if (!check_value(obj))  {
alert("Non hai inserito l'anno di scadenza della carta di credito.\n\nAttention, Insert Year of Expiration.");
error=true;
obj.focus();
return !error;
}


// CC VERIFICATION CODE
if(oForm.code_cc.value.length==0) {
alert("Non hai inserito il numero di sicurezza della carta di credito.\n\nAttention, Insert Security Code");
oForm.code_cc.focus();
return false;
}
else
if((oForm.cc.value == 'AMEX' && oForm.code_cc.value.length!=4) ||
    (oForm.cc.value != 'AMEX' && oForm.code_cc.value.length!=3)) 
        {
          alert("Lunghezza del campo non corretta\n\nField Lenght not correct.");
          oForm.code_cc.focus();
          return false;
        }
}

function trimZeros( value ) {
while( value.length>1 && value.charAt(0)=='0' ) value = value.substr(1);
return parseInt(value);
} 
   

	function trim(inputString) 
	{
		// Removes leading and trailing spaces from the passed string. Also removes
		// consecutive spaces and replaces it with one space. If something besides
		// a string is passed in (null, custom object, etc.) then return the input.
		if (typeof inputString != "string") { return inputString; }
		var retValue = inputString;
		var ch = retValue.substring(0, 1);
		while (ch == " ") { // Check for spaces at the beginning of the string
			retValue = retValue.substring(1, retValue.length);
			ch = retValue.substring(0, 1);
		}
		ch = retValue.substring(retValue.length-1, retValue.length);
		while (ch == " ") { // Check for spaces at the end of the string
			retValue = retValue.substring(0, retValue.length-1);
			ch = retValue.substring(retValue.length-1, retValue.length);
		}
		while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
			retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
		}
		return retValue; // Return the trimmed string back to the user
	} // Ends the "trim" function

	// Check if field value is right
	function check_value(obj) 
	{
		if (obj.type.substring(0,6)=="select"){
			val=obj.options[obj.selectedIndex].value;
			if(val=="--") val = "";
		}else {
			val=obj.value;
		}
	   			
		val.replace(/^\s+/,"");
		val.replace(/\s+$/,"");

		if (val=="" || val==0) {
			return false;
		}
		else {
			return true;
		}
	}
    
      
    // ************************************************************************
    // CREDIT CARD VALIDATION 
    // ************************************************************************ //
	function isValidCardNumber (strNum) 
	{
      var digit = true;
      var i;
      if( strNum.length<12 ) return false;

      for( i=0; i<strNum.length && digit; i++ ) {
        digit = digit & isDigit(strNum.charAt(i));
      } 

      return digit;
	}
	
	function isDigit (c)
	{
	   var strAllowed = "1234567890";
	   return (strAllowed.indexOf (c) != -1);
	}
	
	function isCardTypeCorrect (strNum, type)
	{
	   var nLen = 0;
	   for (n = 0; n < strNum.length; n++)
	   {
	      if (isDigit (strNum.substring (n,n+1)))
	         ++nLen;
	   }
	   
	   if (type == 'VISA')
	      return ((strNum.substring(0,1) == '4') && (nLen == 13 || nLen == 16));
	   else if (type == 'AMEX')
	      return ((strNum.substring(0,2) == '34' || strNum.substring(0,2) == '37') && (nLen == 15));
	   else if (type == 'MASTERCARD')
	      return ((strNum.substring(0,2) == '51' || strNum.substring(0,2) == '52'
	              || strNum.substring(0,2) == '53' || strNum.substring(0,2) == '54'
	              || strNum.substring(0,2) == '55') && (nLen == 16));
	   else
	      return true;
	   
	}
//Fine controllo invio dati carta di credito

// rimozione spazi iniziali e finali e funzione di inserire la prima lettere in maiuscolo
/*
* Remove trailing and ending spaces
*/
function inputTrim(obj) {
var re = /^\s*|\s*$/g;
obj.value = obj.value.replace(re,'');
return obj;
}
/*
* First Char Upper 
* Convert first character in a string to uppercase 
*/
function fcup(obj) {
if(obj.value.length>0) {
var a = String('a').charCodeAt(0);
var z = String('z').charCodeAt(0);
var ch = obj.value.charCodeAt(0);
if( ch >= a && ch <= z ) {
ch = ch-a + String('A').charCodeAt(0);
obj.value= String.fromCharCode(ch) + obj.value.substr(1);
}
}
} 
function fmtEmail( obj ) {
inputTrim(obj);
obj.value = obj.value.toLowerCase();
}
function fmtInt( obj, n ) {
inputTrim(obj);
if( !isNaN(obj.value) ) 
while( String(obj.value).length<n ) obj.value = String('0') + obj.value;  
}
// fine spazi e iniziali maiuscole



//Funzione per il calcolo del preventivo che la Struttura presenta al Cliente dietro richiesta
function calcolasomma(TotNotti)
{
  for( i = somma = 0 ; i < document.forms["FormPreventivo"].elements.length ; i++ )
    {
      with(document.forms["FormPreventivo"].elements[i])
        {
          // parseFloat() utilizza "0" + value per prevenire l'invalidazione
          // della somma in caso un campo sia vuoto, NaN (Not a Number)
          if (type == "text" && name.indexOf("prezzo") == 0) somma += parseFloat("0"+value) * parseInt(alt) * parseInt(TotNotti);
        }
}
  // La funzione round() è utile per avere un arrotondamento personalizzato,
  // per esempio, i Franchi svizzeri non hanno più i centesimi, il minimo è 5 ct.
  // in questo caso basterebbe usare Math.round(somma * 20) / 20; per approssimare
  // al 5 ct. più vicino
  // esempio: document.forms["FormPreventivo"].risultato.value = Math.round(somma * 100) / 100;
somma = (Math.round(somma * 100) / 100).toString();
n = somma.lastIndexOf(".");
if (n < 0) somma += ".00";
else if ((n + 2) >= somma.length) somma += "0";
document.forms["FormPreventivo"].risultato.value = somma;

var sconto=document.forms["FormPreventivo"].sconto.options[document.forms["FormPreventivo"].sconto.options.selectedIndex].value;
risconto = somma / 100 * sconto;
totsconto = somma - risconto;
totsconto = (Math.round(totsconto * 100)/100).toString();
s = totsconto.lastIndexOf(".");
if (s < 0) totsconto += ".00";
else if ((s + 2) >= totsconto.length) totsconto += "0";

document.forms["FormPreventivo"].totsconto.value = totsconto;
}


//funzione che crea il calendario per inserimento date nella sezione strutture x listino prezzi
function show_calendar(str_target, lang, str_datetime){
if (lang=="en"){
var arr_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var week_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
}
else{
var arr_months = ["Gennaio", "Febbario", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"];
var week_days = ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"];
}

var n_weekstart = 0; // day week starts from (normally 0 or 1)
 
var dt_datetime = ((str_datetime == null || str_datetime == "") ? new Date() : str2dt(str_datetime));
 
var dt_prev_month = new Date(dt_datetime);
dt_prev_month.setMonth(dt_datetime.getMonth() - 1);
 
var dt_next_month = new Date(dt_datetime);
dt_next_month.setMonth(dt_datetime.getMonth() + 1);
 
var dt_firstday = new Date(dt_datetime);
dt_firstday.setDate(1);
dt_firstday.setDate(1 - (7 + dt_firstday.getDay() - n_weekstart) % 7);
 
var dt_lastday = new Date(dt_next_month);
dt_lastday.setDate(0);
 
  // html generation (feel free to tune it for your particular application)
  // print calendar header
  var str_buffer = new String("<html>\n" +
                              "<head>\n" +
                              "<title>Calendar</title>\n" +
					"<LINK rel=\"stylesheet\" href=\"../font.css\" type=\"text/css\">\n" +
                              "</head>\n" +
                              "<body bgcolor=\"#CDDAA4\">\n" +
                              "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n<Tbody>\n" +
                              "<tr><td bgcolor=\"#FFFFFF\">\n" +
                              "<table cellspacing=\"1\" cellpadding=\"2\" border=\"0\" width=\"100%\">\n" +
                              "<tr class=\"corpo\" >\n <td bgcolor=\"#0053A1\" align=\"center\" valign=\"middle\"><a href=\"javascript:window.opener.show_calendar('" +
                              str_target +
					"', '"+ lang +"', '" +
                              dt2dtstr(dt_prev_month) +
                              " ' + document.cal.time.value);\""+
                              " title=\"" +
                              arr_months[dt_datetime.getMonth()-1] +
                              "\"><font color=\"#ffff00\">&laquo;</font></a></td>\n" +
                              " <td bgcolor=\"#0053A1\" colspan=\"5\" align=\"center\" valign=\"middle\">" +
                              "<font color=\"#ffffff\">" +
                              arr_months[dt_datetime.getMonth()] +
                              " " +
                              dt_datetime.getFullYear() +
                              "</font></td>\n" +
                              " <td bgcolor=\"#0053A1\" align=\"center\" valign=\"middle\"><a href=\"javascript:window.opener.show_calendar('" +
                              str_target +
					"', '"+ lang +"', '" +
                              dt2dtstr(dt_next_month) +
                              " ' + document.cal.time.value);\"" +
                              " title=\"" +
                              arr_months[dt_datetime.getMonth()+1] +
                              "\"><font color=\"#ffff00\">&raquo;</font></a></td>\n</tr>\n");
 
  var dt_current_day = new Date(dt_firstday);
 
  // print weekdays titles
  str_buffer += "<tr>\n";
 
  for ( var n = 0 ; n < 7 ; n++)
    str_buffer += " <td bgcolor=\"#CCCCCC\">" +
    "<font color=\"white\" class=\"corpo\">" +
    week_days[(n_weekstart + n) % 7] +
    "</font></td>\n";
 
  // print calendar table
  str_buffer += "</tr>\n";
  while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
         dt_current_day.getMonth() == dt_firstday.getMonth())
    {
      // print row heder
      str_buffer += "<tr>\n";
 
      for ( var n_current_wday = 0 ; n_current_wday < 7 ; n_current_wday++)
        {
          if (dt_current_day.getDate() == dt_datetime.getDate() &&
              dt_current_day.getMonth() == dt_datetime.getMonth())
              // print current date
              str_buffer += " <td bgcolor=\"#FF0000\" align=\"right\">";
          else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
                   // weekend days
                   str_buffer += " <td bgcolor=\"#E0ECE8\" align=\"right\">";
          else // print working days of current month
               str_buffer += " <td bgcolor=\"white\" align=\"right\">";

          if (dt_current_day.getMonth() == dt_datetime.getMonth())
              // print days of current month

              str_buffer += "<a href=\"javascript:window.opener." +
                            str_target +
                            ".value='" + dt2dtstr(dt_current_day) + "'; window.close();\">" +
                            "<font color=\"black\" class=\"corpo\">";
          else // print days of other months
               str_buffer += "<a href=\"javascript:window.opener." +
                             str_target +
                             ".value='" + dt2dtstr(dt_current_day) + "'; window.close();\">" +
                             "<font color=\"gray\" class=\"corpo\">";
 
          str_buffer += dt_current_day.getDate() + "</font></a></td>\n";
          dt_current_day.setDate(dt_current_day.getDate() + 1);
        }
 
      // print row footer
      str_buffer += "</tr>\n";
    }
 
  // print calendar footer
  str_buffer += "<form name=\"cal\">\n<tr><td colspan=\"7\" style=\"margin:0px;\">" +
                "<input type=\"hidden\" name=\"time\" value=\""+dt2tmstr(dt_datetime) +
                "\"></td></tr>\n</form>\n" +
                "</Tbody>\n</table>\n" +
                "</td>\n</tr>\n</Tbody>\n</table>\n" +
                "</body>\n" +
                "</html>\n";

 
  var vWinCal = window.open("", "Calendario", "width=250,height=190,status=no,resizable=yes,top=200,left=200");
  vWinCal.opener = self;
  var calc_doc = vWinCal.document;
  calc_doc.write(str_buffer);
  calc_doc.close();
}
 
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt(str_datetime)
{
  var re_date = /^(\d{1,2})\/(\d{1,2})\/(\d{2})\s+(\d{1,2})\:(\d{1,2})\:(\d{1,2})$/;
 
  if (!re_date.exec(str_datetime)) return(alert("Invalid Datetime format: " + str_datetime));
 
  var year = parseInt(RegExp.$3) + 1900;
  if (year < 1970) year += 100;
 
  return(new Date(year, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}


function dt2dtstr(dt_datetime)
{
var day = dt_datetime.getDate();
var month = dt_datetime.getMonth() + 1;
var year = dt_datetime.getFullYear() + "";

var dt = ((day < 10) ? "0" + day : day) + "/";
dt += ((month < 10) ? "0" + month : month);
dt += "/" + year.substr(2);

return(dt);
}

function dt2tmstr(dt_datetime){
var dt = dt_datetime.getHours() + ":";
dt += ((dt_datetime.getMinutes() < 10) ? "0" + dt_datetime.getMinutes() : dt_datetime.getMinutes()) + ":";
dt += ((dt_datetime.getSeconds() < 10) ? "0" + dt_datetime.getSeconds() : dt_datetime.getSeconds());
return(dt);
}

//questa piccola funzione mi serve per modificare la fattura presente in area admin
//riguardante le fatture delle strutture affiliate
function modfattura(){
var importo = document.FormAdmin.importo_preno.value;
var commissione = document.FormAdmin.comm.options[document.FormAdmin.comm.options.selectedIndex].value;
var sconto = document.FormAdmin.sconto.options[document.FormAdmin.sconto.options.selectedIndex].value;
document.FormAdmin.impcomm.value = Math.round(importo * commissione)/ 100;
document.FormAdmin.impsconto.value = Math.round(importo * sconto)/ 100;
}


//Funzione per un'eventuale modifica ad una prenotazione nella sezione admin
function modificasomma(TotNotti)
{
for( i = somma = 0 ; i < document.forms["FormModifica"].elements.length ; i++ )
    {
      with(document.forms["FormModifica"].elements[i])
        {
//var nroom = document.forms["FormModifica"].elements[i].indexOf("rm_");
//alert(NCamere);
if (type == "text" && name.indexOf("rm_") == 0) NCamere = document.forms["FormModifica"].elements[i].value

if (type == "text" && name.indexOf("prezzo") == 0) somma += parseFloat("0" + value) * parseFloat("0"+ NCamere)

alert(somma += parseFloat("0" + value) * parseFloat("0"+NCamere));
        }
}
somma *= parseInt(TotNotti);
somma = (Math.round(somma * 100) / 100).toString();
n = somma.lastIndexOf(".");
if (n < 0) somma += ".00";
else if ((n + 2) >= somma.length) somma += "0";
document.forms["FormModifica"].totale.value = somma;

var sconto=document.forms["FormModifica"].sconto.value;
if (sconto!="" && sconto !=0)
{
risconto = somma / 100 * sconto;
totsconto = somma - risconto;
totsconto = (Math.round(totsconto * 100)/100).toString();
s = totsconto.lastIndexOf(".");
if (s < 0) totsconto += ".00";
else if ((s + 2) >= totsconto.length) totsconto += "0";
document.forms["FormModifica"].tot_sconto.value = totsconto;
}
}

//funzione per contare i caratteri e fermare inserimento nella textarea (vedi OFFERTAMESE)
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) {
field.value = field.value.substring(0, maxlimit);
} else {
countfield.value = maxlimit - field.value.length;
}
}


//funzione che mi setta il calendario della disponibilità in modo veloce
function settacal(NomeForm,Valore){
for(i=0;i<document.forms[NomeForm].ngiorno.length;i++){
document.forms[NomeForm].ngiorno[i].value = Valore;
}
}



//funzione che mi serve per far funzionare il box di ricerca presente in tutte le pagine
function chiudi(nome)
{
  var stato = document.getElementById("tbl" + nome).style.display;
 
  if (stato != "none") 
    {
      // Nascondo la riga
      document.getElementById("tbl" + nome).style.display = "none";
    }
}
function apri(nome)
{
  var statoapri = document.getElementById("tbl" + nome).style.display;
 
  if (statoapri == "none")
    {
      // Visualizzo la riga
      document.getElementById("tbl" + nome).style.display = "";
    }
}