function viewDocs(sectionNum,countSection) {
	var docsItem
	var i;

	for (i=1; i<=countSection; i++)
	{
  	docsItem = eval("document.getElementById('docs" + i + "')");
		if (sectionNum==i && docsItem.style.display=='none') {
			docsItem.style.display = '';
		}
		else {
			docsItem.style.display = 'none';
		}
  }

}

function checkAddNewsForm(theForm) {
  if( theForm.newsTitle.value == "" )
  {
    alert("Inserisci il titolo della news!");
    return false;
  }
  if( theForm.newsText.value == "" )
  {
    alert("Inserisci il corpo della news!");
    return false;
  }
  var theDate = new Date( theForm.newsYear.value, theForm.newsMonth.value-1, theForm.newsDay.value );
  var newsDay = theDate.getDate();
  var newsMonth = theDate.getMonth()+1;
  var newsYear = theDate.getYear();

  // FireFox ritorna sempre l'anno a partire dal 1900!
  if (newsYear<2000)
    newsYear = newsYear + 1900;

  if ( newsDay!=theForm.newsDay.value || newsMonth!=theForm.newsMonth.value || newsYear!=theForm.newsYear.value )
  {
    alert("Inserisci una data corretta!");
    return false;
  }

  theForm.submit();
}

function checkaddNormativaForm(theForm) {
  if( theForm.theFile.value == "" )
  {
    alert("Inserisci il documento da caricare!");
    return false;
  }

  theForm.submit();
}

function checkaddNewsDocForm(theForm) {
  if( theForm.theFile.value == "" )
  {
    alert("Inserisci il documento da caricare!");
    return false;
  }

  theForm.submit();
}

function checkaddConvenzioniDocForm(theForm) {
  if( theForm.theFile.value == "" )
  {
    alert("Inserisci il documento da caricare!");
    return false;
  }

  theForm.submit();
}

function checkModuloForm(theForm) {
  if( theForm.companyName.value == "" )
  {
    alert("Inserisci il Nome Azienda!");
    return false;
  }

  if( theForm.prov.value == "" )
  {
    alert("Inserisci la Provincia!");
    return false;
  }

  if( theForm.referenceName.value == "" )
  {
    alert("Inserisci Nome e Cognome della persona di riferimento!");
    return false;
  }
  if( theForm.phone.value == "" )
  {
    alert("Inserisci il Telefono!");
    return false;
  }
  theForm.submit();
}

function submitSearchCircolariForm(section) {

  // per le regioni - prendo solo la prima lettera della sezione (la R)
  var sectionLetter = section.substr(0,1);

  var searchCircolariForm = document.getElementById('searchCircolariForm');
  var search_year = document.getElementById('search_year'+sectionLetter);
  var search_title = document.getElementById('search_title'+sectionLetter);

  document.getElementById('search_year').value = search_year.value;
  document.getElementById('search_title').value = search_title.value;
  document.getElementById('search_section').value = section;

  searchCircolariForm.submit();
}
