// JavaScript Document

function apri(url_foto,des_foto){
addr="redim.html?"+url_foto+"&"+escape(des_foto)
alt=300
lar=300
rszb=(document.layers)?1:0;
props='height='+alt+',width='+lar+',top='+parseInt((screen.availHeight-alt)/2)+',left='+parseInt((screen.availWidth-lar)/2)+',scrollbars=0,resizable='+rszb+',toolbar=0,menubar=0,location=0,status=0';
window.open(addr,'_blank',props);
}


function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function validateFormPreventivo() 
{
  if (document.preventivo.email.value.indexOf(".")==-1 | document.preventivo.email.value.indexOf("@")==-1 | document.preventivo.email.value.length <= 6 | document.preventivo.email.value == "E-mail") {
  alert("Inserire una e-mail valida, campo obbligatorio!");
  document.preventivo.email.focus();
  return false;
  }
  if (document.preventivo.nome.value == "" | document.preventivo.nome.value == "Nome") {
  alert("Inserire il nome, campo obbligatorio!");
  document.preventivo.nome.focus();
  return false;
  } 
  if (document.preventivo.cognome.value == "" | document.preventivo.cognome.value == "Cognome") {
  alert("Inserire il cognome, campo obbligatorio!");
  document.preventivo.cognome.focus();
  return false;
  }
  //if (document.preventivo.argomento.value == "none") {
  //alert("Scegliere il tipo di preventivo!");
  //document.preventivo.argomento.focus();
  //return false;
  //}
  if (document.preventivo.telefono.value == "" | document.preventivo.telefono.value == "Telefono") {
  alert("Inserire il telefono, campo obbligatorio!");
  document.preventivo.telefono.focus();
  return false;
  }
  if (document.preventivo.richiesta.value == "") {
  alert("Inserisci il testo della richiesta!");
  document.preventivo.richiesta.focus();
  return false;
  }
  if (document.preventivo.consenso.checked == false) {
  alert ("Bisogna dare il consenso al trattamento dei dati personali");
  document.preventivo.consenso.focus();
  return false;
  } else {
  return true;
  }
}

function validateFormRichiesta() 
{
  if (document.richiesta.email.value.indexOf(".")==-1 | document.richiesta.email.value.indexOf("@")==-1 | document.richiesta.email.value.length <= 6 | document.richiesta.email.value == "E-mail") {
  alert("Inserire una e-mail valida, campo obbligatorio!");
  document.richiesta.email.focus();
  return false;
  }
  if (document.richiesta.nome.value == "" | document.richiesta.nome.value == "Nome") {
  alert("Inserire il nome, campo obbligatorio!");
  document.richiesta.nome.focus();
  return false;
  } 
  if (document.richiesta.cognome.value == "" | document.richiesta.cognome.value == "Cognome") {
  alert("Inserire il cognome, campo obbligatorio!");
  document.richiesta.cognome.focus();
  return false;
  }
  //if (document.preventivo.argomento.value == "none") {
  //alert("Scegliere il tipo di preventivo!");
  //document.preventivo.argomento.focus();
  //return false;
  //}
  if (document.richiesta.telefono.value == "" | document.richiesta.telefono.value == "Telefono") {
  alert("Inserire il telefono, campo obbligatorio!");
  document.richiesta.telefono.focus();
  return false;
  }
  if (document.richiesta.richiesta.value == "") {
  alert("Inserisci il testo della richiesta!");
  document.richiesta.richiesta.focus();
  return false;
  }
  if (document.richiesta.consenso.checked == false) {
  alert ("Bisogna dare il consenso al trattamento dei dati personali");
  document.richiesta.consenso.focus();
  return false;
  } else {
  return true;
  }
}

function validateFormPreventivi() 
{
  if (document.preventivi.email.value.indexOf(".")==-1 | document.preventivi.email.value.indexOf("@")==-1 | document.preventivi.email.value.length <= 6 | document.preventivi.email.value == "E-mail") {
  alert("Inserire una e-mail valida, campo obbligatorio!");
  document.preventivi.email.focus();
  return false;
  }
  if (document.preventivi.nome.value == "" | document.preventivi.nome.value == "Nome") {
  alert("Inserire il nome, campo obbligatorio!");
  document.preventivi.nome.focus();
  return false;
  } 
  if (document.preventivi.cognome.value == "" | document.preventivi.cognome.value == "Cognome") {
  alert("Inserire il cognome, campo obbligatorio!");
  document.preventivi.cognome.focus();
  return false;
  }
  //if (document.preventivo.argomento.value == "none") {
  //alert("Scegliere il tipo di preventivo!");
  //document.preventivo.argomento.focus();
  //return false;
  //}
  if (document.preventivi.telefono.value == "" | document.preventivi.telefono.value == "Telefono") {
  alert("Inserire il telefono, campo obbligatorio!");
  document.preventivi.telefono.focus();
  return false;
  }
  if (document.preventivi.richiesta.value == "") {
  alert("Inserisci il testo della richiesta!");
  document.preventivi.richiesta.focus();
  return false;
  }
  if (document.preventivi.consenso.checked == false) {
  alert ("Bisogna dare il consenso al trattamento dei dati personali");
  document.preventivi.consenso.focus();
  return false;
  } else {
  return true;
  }
}
