// controlloDati.js - funzioni per il controllo delle forms

function campoUpload()
{
	//alert(formArt.fileUploaded.value);
	formInserimento.pathFile.value=formInserimento.fileUploaded.value;

	return true;
}
////
//!Controlla i campi di inserimento delle strutture
function controlloCampiStrutture(){
  	if(document.formInserimento.NOME.value == "")
  	{
    	alert("E' necessario inserire il nome.");
    	return false;
  	}
	if(document.formInserimento.INDIRIZZO.value == "")
  	{
    	alert("E' necessario inserire l'indirizzo.");
    	return false;
  	}
	if(document.formInserimento.COMUNE.value == "")
  	{
    	alert("E' necessario inserire il comune.");
    	return false;
  	}
	
  	document.formInserimento.submit();
	return true
}
////
//!controlla i campi di inserimento faq
function controlloCampiFaq(){
  if(document.formInserimento.DOMANDA.value == "")
  {
    alert("E' necessario inserire la domanda.");
    return false;
  }
    if(document.formInserimento.RISPOSTA.value == "")
  {
    alert("E' necessario inserire la risposta.");
    return false;
  }
	document.formInserimento.submit();
	return true
}

////
//!
function controlloCampiDownloads(){
  if(document.formInserimento.LABEL.value == "")
  {
    alert("E' necessario inserire l'etichetta.");
    return false;
  }
    if(document.formInserimento.DESCRIZIONE.value == "")
  {
    alert("E' necessario inserire una descrizione.");
    return false;
  }
  if(document.formInserimento.FILE.value == "")
  {
    alert("E' necessario selezionare un file.");
    return false;
  }
	document.formInserimento.submit();
	return true
}
function controlloCampiLink() {
if(document.formInserimento.TITOLO.value == "")
  {
    alert("E' necessario inserire un titolo.");
    return false;
  }
    if(document.formInserimento.DESCRIZIONE.value == "")
  {
    alert("E' necessario inserire una descrizione.");
    return false;
  }
  else if(document.formInserimento.DESCRIZIONE.value.length>512){
    alert("La descrizione puņ contenere al massimo 512 caratteri.\nNe sono stati inseriti "+document.formArt.DESCRIZIONE.value.length);
    return false;
  }
  if(document.formInserimento.URL.value == "")
  {
    alert("E' necessario inserire l'Url.");
    return false;
  }
  document.formInserimento.submit();
	return true
} 
function controlloCampi(){
	if(bIs_html) document.composeForm.TESTO.value = GetHtml();
  if(document.composeForm.TITOLO.value == "")
  {
    alert("E' necessario inserire un titolo.");
    return false;
  }
    if(document.composeForm.DESCRIZIONE.value == "")
  {
    alert("E' necessario inserire una descrizione.");
    return false;
  }
  else if(document.composeForm.DESCRIZIONE.value.length>512){
    alert("La descrizione puņ contenere al massimo 512 caratteri.\nNe sono stati inseriti "+document.composeForm.DESCRIZIONE.value.length);
    return false;
  }
  if(document.composeForm.SOTTOTITOLO!=null&&document.composeForm.SOTTOTITOLO.value == "")
  {
    alert("E' necessario inserire un sottotitolo.");
    return false;
  }
  
    if(document.composeForm.TESTO.value == "")
  {
    alert("E' necessario inserire un testo.");
    return false;
  }
  else if(document.composeForm.TESTO.value.length>4000){
    alert("Il testo puņ contenere al massimo 4000 caratteri.\nNe sono stati inseriti "+document.composeForm.TESTO.value.length);
    return false;
  }
  enviar();
	//document.formInserimento.submit();
	return true
}

function controlloCampiNewsletter(){
  if(document.formInserimento.TITOLO.value == "")
  {
    alert("E' necessario inserire un titolo.");
    return false;
  }
  if(document.formInserimento.SOTTOTITOLO!=null&&document.formInserimento.SOTTOTITOLO.value == "")
  {
    alert("E' necessario inserire un sottotitolo.");
    return false;
  }
  
    if(document.formInserimento.TESTO.value == "")
  {
    alert("E' necessario inserire un testo.");
    return false;
  }
  else if(document.formInserimento.TESTO.value.length>4000){
    alert("Il testo puņ contenere al massimo 4000 caratteri.\nNe sono stati inseriti "+document.formArt.TESTO.value.length);
    return false;
  }
	document.formInserimento.submit();
	return true
}


function campiDomandaSondaggio(){
if(document.formSondaggio.TITOLO.value == "")
  {
    alert("E' necessario inserire un titolo.");
    return false;
  }
  if(document.formSondaggio.TESTO_DOMANDA.value == "")
  {
    alert("E' necessario inserire il testo della domanda.");
    return false;
  }
  if(document.formSondaggio.N_RISP.value == "")
  {
    alert("E' necessario inserire il numero di risposte ammesse.");
    return false;
  }
  document.formSondaggio.inserisci.value="domanda";
  document.formSondaggio.submit();
  return true  
}

function campiRispostaSondaggio(){
  if(document.formSondaggio.TESTO_RISPOSTA.value == "")
  {
    alert("E' necessario inserire il testo della risposta.");
    return false;
  }
  document.formSondaggio.inserisci.value="risposta";
  document.formSondaggio.submit();
  return true  
}


function elimina(formObj){
	formObj.azione.value="elimina";
	//document.formInserimento.fileUploaded.value="";
	//alert(document.formInserimento.azione.value);
	formObj.submit();
}
