//---  confirm_DeleteNews(idStep, idNews) --------------------------------------
function confirm_DeleteUtente(idStep, idUtente, idStepDest,idTipoUtente)
{
	if (confirm("Sei sicuro di voler eliminare l'Utente?"))
	{
		window.location.href = "cmsUtenti.asp?idStep="+ idStep +"&idUtente="+ idUtente + "&idStepDest="+ idStepDest +"&idTipoUtente="+idTipoUtente;		
	}
}

//---  confirm_DeleteNews(idStep, idNews) --------------------------------------
function confirm_DeleteNews(idStep, idNews)
{
	if (confirm("Sei sicuro di voler eliminare la news?"))
	{
		window.location.href = "cmsNews.asp?idStep="+ idStep +"&idNews="+ idNews +"";
	}
}


//---  confirm_DeleteAttacher(idDoc) --------------------------------------
function confirm_DeleteAttacher(idDoc,idPage)
{	
	if (confirm("Sei sicuro di voler eliminare l'allegato?"))
	{
		location.href="cmsPage.asp?idStep=9&idDoc="+idDoc+"&idPage="+idPage+"";
	}
}


//---  confirm_DeleteOf(idStep, idOf) --------------------------------------
function confirm_DeleteOf(idStep, idOf)
{
	if (confirm("Sei sicuro di voler eliminare la voce?"))
	{
		window.location.href = "cmsOf.asp?idStep="+ idStep +"&idOf="+ idOf +"";
	}
}

//---  confirm_DeleteSezione(idStep, idSezione) --------------------------------------
function confirm_DeleteSezione(idStep, idSezione, idActSezione)
{
	if (confirm("Sei sicuro di voler eliminare la pagina?"))
	{
		window.location.href = "cmsPage.asp?idStep="+ idStep +"&idSezione="+ idSezione +"&idActSezione="+ idActSezione +"";
	}
}

//---  checkUpdateNews(theForm): Form di Modifica (PR)--------------------------------------
function checkUpdateNews(idNews, theForm, destStep)
{
	dataScadenza = theForm.cldcalendario1.value.split('/');
	if (IsDateNotValid(dataScadenza[0], dataScadenza[1], dataScadenza[2]))
	{
		alert("La data inserita nel campo \"Data\" è errata o incompleta.\nCorreggere grazie.");
		theForm.cldcalendario1.focus();
		return false;
	}
	
	if (IsStringEmpty(theForm.txtTitolo.value))
	{
		alert("Il campo \"Titolo\" è obbligatorio");
		theForm.txtTitolo.focus();
		return false;
	}
	
	//inizio @FG(9362)
	dataScadenza = theForm.cldcalendario2.value.split('/');
	if (IsDateNotValid(dataScadenza[0], dataScadenza[1], dataScadenza[2]))
	{
		alert("La data inserita nel campo \"Data inizio visualizzazione\" è errata o incompleta.\nCorreggere grazie.");
		theForm.cldcalendario2.focus();
		return false;
	}
	
	dataScadenza = theForm.cldcalendario3.value.split('/');
	if (IsDateNotValid(dataScadenza[0], dataScadenza[1], dataScadenza[2]))
	{
		alert("La data inserita nel campo \"Data fine visualizzazione\" è errata o incompleta.\nCorreggere grazie.");
		theForm.cldcalendario3.focus();
		return false;
	}
	
	var newsDate = new Date(theForm.cldcalendario2.value)	
	var newsDateFine = new Date(theForm.cldcalendario3.value)	
	
	if (newsDateFine < newsDate)
	{
		alert ("La data inserita nel campo \"Data fine visualizzazione\" deve essere uguale o successiva a quella di inizio.\nCorreggere grazie.");
		theForm.cldcalendario3.focus();
		return false;
	}
	//fine @FG(9362)

	if (theForm.rdbFocus[0].checked == true)
	{
		dataScadenza = theForm.cldcalendario4.value.split('/');
		if (IsDateNotValid(dataScadenza[0], dataScadenza[1], dataScadenza[2]))
		{
			alert("La data inserita nel campo \"Data inizio evidenza\" è errata o incompleta.\nCorreggere grazie.");
			theForm.cldcalendario4.focus();
			return false;
		}
		
		dataScadenza = theForm.cldcalendario5.value.split('/');
		if (IsDateNotValid(dataScadenza[0], dataScadenza[1], dataScadenza[2]))
		{
			alert("La data inserita nel campo \"Data fine evidenza\" è errata o incompleta.\nCorreggere grazie.");
			theForm.cldcalendario5.focus();
			return false;
		}	
		
		var newsDateEvid = new Date(theForm.cldcalendario4.value)	
		var newsDateFineEvid = new Date(theForm.cldcalendario5.value)	
		
		if (newsDateFineEvid < newsDateEvid)
		{
			alert ("La data inserita nel campo \"Data fine evidenza\" deve essere uguale o successiva a quella di inizio.\nCorreggere grazie.");
			theForm.cldcalendario5.focus();
			return false;
		}	


	}

	//--- PARAGRAFO 1
	beforeSave_1();	// @fg(9411)
	var text1Val = frames["message_1"].document.body.innerHTML;		
	document.getElementById("text1").value = text1Val;		
		
	if (IsStringEmpty(document.getElementById("text1").value))
	{
		alert("Il campo Testo è obbligatorio");
		return;
	}

	//--- Controlli superati
	theForm.action = "cmsNews.asp?idStep=4&idNews="+ idNews +"&destStep="+ destStep +"";
	theForm.submit();
}

//---  checkInsertNews02(theForm): Form di Inserimento e Modifica --------------------------------------
function checkInsertNews02(theForm)
{
	if (IsStringEmpty(theForm.txaTesto_1.value))
	{
		alert("Il campo Testo del Paragrafo 1 è obbligatorio");
		//theForm.txaTesto_1.focus();
		return;
	}

	if (theForm.rdbFocus[0].checked == true)
	{
		if (IsStringEmpty(theForm.txtImmagineFocus.value))
		{
			alert("Se è stata selezionata l'opzione \"In evidenza\" è obbligatorio inserire una immagine");
			return;
		}
	}

	theForm.submit();
	theForm.btnSubmit.disabled = true;
}

//---  checkInsertNews03(theForm): Form di Inserimento e Modifica --------------------------------------
function checkInsertNews03(theForm)
{
	//--- Controlli superati		
	theForm.submit();
	theForm.btnSubmit.disabled = true;
}

function CMSnewLanguagePage(TheForm,lang)
{	
	TheForm.action="cmsPage.asp?idStep=1&idLang="+ lang +"";
	TheForm.submit();
}

function CMSeditLanguagePage(TheForm,page,lang)
{	
	TheForm.action="cmsPage.asp?idStep=3&idLang="+ lang +"&idPage="+ page +"";
	TheForm.submit();
}

function CMSnewLanguageNews(TheForm,lang)
{	
	TheForm.action="cmsNews.asp?idStep=1&idLang="+ lang +"";
	TheForm.submit();
}

function CMSeditLanguageNews(TheForm,page,lang)
{	
	TheForm.action="cmsNews.asp?idStep=3&idLang="+ lang +"&idnews="+ page +"";
	TheForm.submit();
}

//---  sendAttacher(idDoc, path) : Form di Inserimento e Modifica --------------------------------------
function sendAttacher(idDoc, path)
{
	if (document.theForm.txtTitolo.value=="") {
		alert("Il campo \"Titolo\" è obbligatorio");
		document.theForm.txtTitolo.focus();
		return true;
	}

	if (document.theForm.blob.value=="") {
		alert("Selezionare il file da allegare")
		document.theForm.blob.focus();
		return true;
	}
	
	//--- Controlli superati
	if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
	{
		var strAction
		strAction = 'fileAttacher.asp?step=2'
		strAction += '&idDoc=' + idDoc
		strAction += '&path='+ path
		strAction += '&txtTitolo='+ document.theForm.txtTitolo.value
		strAction += '&txtCod='+ document.theForm.txtCod.value		
		
		theForm.action = strAction
		theForm.submit();
		theForm.txtCod.disabled = true;
		theForm.txtTitolo.disabled = true;
		theForm.blob.disabled = true;
		theForm.btnClose.disabled = true;
		theForm.btnSubmit.disabled = true;		
	}
}

//---  check_selectEvidenza(TheForm, maxCheck): Form di Inserimento e Modifica --------------------------------------
function check_selectEvidenza(TheForm, maxCheck)
{	
	/* Commentato perchè ritenuto non utile	
	var noSelected = true;
	var countChecked = 0;
	var i = 0;

	while ((noSelected) && (i < TheForm.chkEvidenza.length))
	{
		if (TheForm.chkEvidenza[i].checked) 
			{ countChecked ++ }
		i++;
	}
	
	if ((countChecked >= 0) && (countChecked <= maxCheck))
	{
	*/
		TheForm.action = "cmsNews.asp?idStep=11";
		TheForm.submit();
	/*
	}
	else
	{
		alert("E' necessario selezionare da 1 a "+ maxCheck +" news");	
		return;
	}
	*/
}

function check_UpdateNNewsEvidenza(TheForm)
{
	if (TheForm.txtNNewsEvidenza.value=="") {
		alert("Inserire un valore")
		TheForm.txtNNewsEvidenza.focus();
		return true;
	}

	if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
	{
		window.location.href = "cmsNews.asp?idStep=12&nNews="+ TheForm.txtNNewsEvidenza.value;
	}
}


function checkNAccessi(theForm)
{
	if (theForm.nAccessi.value == "" || isNaN(theForm.nAccessi.value) || theForm.nAccessi.value < 1)
	{
		alert("Compilare il campo con solo numeri positivi");
		theForm.nAccessi.focus();
		return true;
	}
	theForm.submit();
}


//---  active_SezioneCollegamento(theForm) --------------------------------------
function active_SezioneCollegamento(theForm)
{
	//--- ABILITA
	if (theForm.chkLink.checked)
	{
		theForm.rdbLink[0].disabled = false;
		theForm.rdbLink[1].disabled = false;
	}
	else //--- DISABILITA
	{
		theForm.rdbLink[0].disabled = true;
		theForm.rdbLink[1].disabled = true;				
		theForm.txtLink_Sito.disabled = true;
	}
	return;
}

//---  active_SezioneCollegamento_Doc(theForm) --------------------------------------
function active_SezioneCollegamento_Doc(theForm)
{	
	theForm.btnAddLink.disabled = false;
	theForm.hdnLinkId.disabled = false;
	
	theForm.txtLink_Sito.disabled = true;
}

//---  active_SezioneCollegamento_Sito(theForm) --------------------------------------
function active_SezioneCollegamento_Sito(theForm)
{
	theForm.btnAddLink.disabled = true;
	theForm.hdnLinkId.disabled = true;
	
	theForm.txtLink_Sito.disabled = false;
}

function checkUpdateFaqTipologia(TheForm)
{
	if (TheForm.txtAggiornaFaqTipologia.value=="")
	{
		alert("Inserire un valore")
		TheForm.txtAggiornaFaqTipologia.focus();
		return true;
	}

	if (TheForm.idFaqTipologia.value != "") { // MODIFICA		
		if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
		{
			TheForm.submit();
		}
	}
	else // INSERIMENTO
	{
		TheForm.submit();
	}	
}

//---  imposeMaxLength(TextArea Object, MaxLen) --------------------------------------
function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}

function checkUpdateFaq(TheForm)
{
	if (TheForm.lstFaq.value=="0")
	{
		alert("Selezionare una tipologia")
		TheForm.lstFaq.focus();
		return true;
	}
	
	if(TheForm.txtFaqDomanda.value.length<4)
	{
		alert("Inserire una domanda corretta")
		TheForm.txtFaqDomanda.focus();
		return true;
	}
	
	if(TheForm.txtFaqRisposta.value.length<4)
	{
		alert("Inserire una risposta corretta")
		TheForm.txtFaqRisposta.focus();
		return true;
	}
	if (TheForm.idFaq.value != "")	// MODIFICA
	{ 		
		if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
		{
			TheForm.submit();
		}
	}
	else	// INSERIMENTO
	{
		TheForm.submit();
	}
}

function checkUpdatePassword(TheForm)
{
	if(TheForm.txtVecchiaPassword.value.length<3)
	{
		alert("Inserire la vecchia password")
		TheForm.txtVecchiaPassword.focus();
		return true;
	}
	if(TheForm.txtNuovaPassword.value.length<3)
	{
		alert("Inserire la nuova password")
		TheForm.txtNuovaPassword.focus();
		return true;
	}
	if(TheForm.txtRipetiNuovaPassword.value.length<3)
	{
		alert("Ripetere la nuova password")
		TheForm.txtRipetiNuovaPassword.focus();
		return true;
	}
	
	if(TheForm.txtNuovaPassword.value!=TheForm.txtRipetiNuovaPassword.value)
	{
		alert("Le due nuove password sono diverse fra loro");
		TheForm.txtNuovaPassword.focus();
		return true;
	}
	
	if(TheForm.txtNuovaPassword.value==TheForm.txtVecchiaPassword.value)
	{
		alert("La nuova password è uguale a quella vecchia");
		TheForm.txtNuovaPassword.focus();
		return true;
	}
	
	if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
	{
		TheForm.submit();
	}
}

//---  confirm_DeleteTipologiaLink(idTipoLink) --------------------------------------
function confirm_DeleteTipologiaLink(idTipoLink)
{
	if (confirm("Sei sicuro di voler eliminare la voce selezionata?"))
	{
		window.location.href = "cmsSitiWeb.asp?idStep=4&idTipoLink="+ idTipoLink +"";		
	}
}

//---  confirm_DeleteLink(idLink) --------------------------------------
function confirm_DeleteLink(idLink)
{
	if (confirm("Sei sicuro di voler eliminare la voce selezionata?"))
	{
		window.location.href="cmsSitiWeb.asp?idStep=8&idLink="+ idLink +"";		
	}
}

//---  confirm_DeleteNewsletter(idNewsletter) --------------------------------------
function confirm_DeleteNewsletter(idNewsletter)
{
	if (confirm("Sei sicuro di voler eliminare la voce selezionata?"))
	{
		window.location.href="cmsNewsletter.asp?idStep=2&idNewsletter="+ idNewsletter +"";		
	}
}

//---  checkUpdateLinkTipologia(TheForm) --------------------------------------
function checkUpdateLinkTipologia(TheForm)
{
	if (TheForm.txtAggiornaLinkTipologia.value=="")
	{
		alert("Inserire un valore nel campo \"Descrizione\".")
		TheForm.txtAggiornaLinkTipologia.focus();
		return true;
	}	
	TheForm.submit();	
}

//---  checkUpdatePersonaleTipologia(TheForm) --------------------------------------
function checkUpdatePersonaleTipologia(TheForm)
{
	if (TheForm.txtAggiornaPersonaleTipologia.value=="")
	{
		alert("Inserire un valore")
		TheForm.txtAggiornaPersonaleTipologia.focus();
		return true;
	}	
	if (TheForm.idPersonaleTipologia.value != "")// MODIFICA
	{		
		if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
		{
			TheForm.submit();
		}
	}
	else // INSERIMENTO
	{
		TheForm.submit();
	}	
}

//---  confirm_DeleteTipologiaPersonale(idPersonaleTipologia) --------------------------------------
function confirm_DeleteTipologiaPersonale(idPersonaleTipologia)
{
	if (confirm("Sei sicuro di voler eliminare la voce selezionata?"))
	{
		window.location.href="cmsPersonale.asp?idStep=4&idPersonaleTipologia="+ idPersonaleTipologia +"";		
	}
}

//---  confirm_DeleteLink(idPersonale) --------------------------------------
function confirm_DeletePersonale(idPersonale)
{
	if (confirm("Sei sicuro di voler eliminare la voce selezionata?"))
	{
		window.location.href="cmsPersonale.asp?idStep=8&idPersonale="+ idPersonale +"";		
	}
}

//---  confirm_DeleteServizio(idServizio) --------------------------------------
function confirm_DeleteServizio(idServizio)
{
	if (confirm("Sei sicuro di voler eliminare la voce selezionata?"))
	{
		window.location.href="cmsServizi.asp?idStep=3&idServizio="+ idServizio +"";		
	}
}

//---  csvuotaTextServizi(idServizio) --------------------------------------
function svuotaTextServizi(idServizio)
{
	//--- Controlli superati	
	if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
	{		
		window.location.href="cmsServizi.asp?idStep=4&idServizio="+ idServizio;
	}	
}

function svuotaTextPersonale(idPersonale)
{
	//--- Controlli superati	
	if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
	{		
		window.location.href="cmsPersonale.asp?idStep=9&idPersonale="+ idPersonale;
	}	
}

//---  svuotaTextGruppo(idGruppo) --------------------------------------
function svuotaTextGruppo(idGruppo)
{
	//--- Controlli superati	
	if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
	{		
		window.location.href="cmsGruppiRicerca.asp?idStep=4&idGruppi="+ idGruppo;
	}	
}

//---  confirm_DeleteTipologiaDocumentazione(idTipoDoc) --------------------------------------
function confirm_DeleteTipologiaDocumentazione(idTipoDoc)
{
	if (confirm("Sei sicuro di voler eliminare la voce selezionata?"))
	{
		window.location.href="cmsDocumentazione.asp?idStep=4&idTipologia="+ idTipoDoc +"";		
	}
}

//---  checkUpdateDocTipologia(TheForm) --------------------------------------
function checkUpdateDocTipologia(TheForm)
{
	if (TheForm.txtAggiornaDocTipologia.value=="")
	{
		alert("Inserire un valore")
		TheForm.txtAggiornaDocTipologia.focus();
		return true;
	}	
	if (TheForm.idDocTipologia.value != "")// MODIFICA
	{		
		if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
		{
			TheForm.submit();
		}
	}
	else // INSERIMENTO
	{
		TheForm.submit();
	}	
}

//---  checkInsertDoc(theForm): Form di Inserimento e Modifica --------------------------------------
function checkInsertDoc(theForm)
{
	if (theForm.ddmTipoDoc.value == 0)
	{
		alert("Il campo \"Tipo Documento\" è obbligatorio");
		theForm.ddmTipoDoc.focus();
		return;		
	}
	
	if (IsStringEmpty(theForm.txtNome.value))
	{
		alert("Il campo \"Nome\" è obbligatorio");
		theForm.txtNome.focus();
		return;
	}
	if (IsStringEmpty(theForm.hdntxtDoc.value))
	{
		alert("Inserire un documento");
		theForm.btntxtDoc.focus();
		return;
	}
	//--- Conrolli superati	
	theForm.submit();
	theForm.btnSubmit.disabled = true;
}

//---  checkInsertNewsletter(theForm, destStep) --------------------------------------
function checkInsertNewsletter(theForm, destStep)
{
	if (theForm.txtOggetto.value == '')
	{
		alert('Il campo \"Oggetto\" è obbligatorio');
		theForm.txtOggetto.focus();
		return false;
	}

	if (theForm.rdbPostSend[1].checked == true)
	{
		dataScadenza = theForm.cldcalendario1.value.split('/');
		if (IsDateNotValid(dataScadenza[0], dataScadenza[1], dataScadenza[2]))
		{
			alert("La data inserita nel campo \"Data\" è errata o incompleta.\nCorreggere grazie.");
			theForm.cldcalendario1.focus();
			return false;
		}
	}
	
	beforeSave_1();	// @fg(9411)
	var text1Val = frames["message_1"].document.body.innerHTML;		
	document.getElementById("text1").value = text1Val;		
		
	if (IsStringEmpty(document.getElementById("text1").value))
	{
		alert("Il campo \"Testo\" è obbligatorio");
		return false;
	}
	
	/* Verifico lunghezza maggiore di 3000 Char */		
	if (document.getElementById("text1").value.length > 2500) 
	{
		alert("Il testo della Newsletter non deve essere superiore a 2500 caratteri spazi inclusi");
		return false;
	}

	if(destStep=="1")
	{
		theForm.action = "cmsNewsletter.asp?idStep=5&destStep=1";
		theForm.submit();
	}
	else if(destStep=="2")
	{
		alert('Attenzione! La newsletter verrà salvata prima di essere inviata.');
		theForm.action = "cmsNewsletter.asp?idStep=5&destStep=2";
		theForm.submit();
	}
	else
	{
		window.location = "cmsNewsletter.asp?idStep=0";
	}
}

//---  confirm_DeleteNewsletter(idNewsletter) --------------------------------------
function confirm_DeleteNewsletter(idNewsletter)
{
	if (confirm("Sei sicuro di voler eliminare la voce selezionata?"))
	{
		window.location.href="cmsNewsletter.asp?idStep=7&idNewsletter="+ idNewsletter +"";		
	}
}

//---  confirm_DeleteNewsletterUtente(idUtente) --------------------------------------
function confirm_DeleteNewsletterUtente(idUtente)
{
	if (confirm("Sei sicuro di voler eliminare l'utente selezionato?"))
	{
		window.location.href="cmsNewsletter.asp?idStep=2&idUtente="+ idUtente +"";		
	}
}

//---  confirm_DeleteNewsletterIndice(idIndice) --------------------------------------
function confirm_DeleteNewsletterIndice(idIndice)
{
	if (confirm("Sei sicuro di voler eliminare l'indice selezionato?"))
	{
		window.location.href="cmsNewsletter.asp?idStep=9&idIndice="+ idIndice +"";		
	}
}

//---  ismaxlength(obj) --------------------------------------
function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
	if (obj.getAttribute && obj.value.length>mlength)
	{
		obj.value=obj.value.substring(0,mlength);
	}
	if (document.getElementById("txtCarDisp"))
	{
		document.getElementById("txtCarDisp").value = mlength - obj.value.length;
	}
}

//---  checkUpdateNewsletterIndici(TheForm) --------------------------------------
function checkUpdateNewsletterIndici(TheForm)
{
	if (TheForm.txtAggiornaNewsletterIndici.value=="")
	{
		alert("Inserire un valore")
		TheForm.txtAggiornaNewsletterIndici.focus();
		return false;
	}	
	if (TheForm.hdnNewsletterIndici.value != "")// MODIFICA
	{		
		if (confirm("Attenzione: \n\nSei sicuro di voler procedere?"))
		{
			TheForm.submit();
		}
	}
	else // INSERIMENTO
	{
		TheForm.submit();
	}	
}

//---  confirm_DeleteMultimediaNews(campo,idNews) --------------------------------------
function confirm_DeleteMultimediaNews(campo,idNews)
{
	if (confirm("Sei sicuro di voler eliminare l'elemento multimediale selezionato?"))
	{
		window.location.href="cmsNews.asp?idStep=14&idNews=" +idNews+ "&campo=" +campo+ "";		
	}
}

//---  confirm_DeleteMultimediaPage(campo,idPage) --------------------------------------
function confirm_DeleteMultimediaPage(campo,idPage)
{
	if (confirm("Sei sicuro di voler eliminare l'elemento multimediale selezionato?"))
	{
		window.location.href="cmsPage.asp?idStep=12&idPage=" +idPage+ "&campo=" +campo+ "";		
	}
}


//==========================================================================================================
//---  Funzioni della Repository ---------------------------------------------------------------------------

//---  openCMSRepositoryUploadPopUp(theForm) --------------------------------------
function openCMSRepositoryUploadPopUp(theForm)
{
	tipoFile = theForm.hdnTipoFile.value;
	
	if (IsStringEmpty(theForm.txtNome.value))
	{
		alert("Il campo \"Nome\" è obbligatorio");
		theForm.txtNome.focus();
		return false;
	}
	
	var reg = /^[\w-.!&()=+ °àòùèéì]+$/;
	if (!reg.test(theForm.txtNome.value))
	{
		alert("Il campo \"Nome\" deve contenere solo lettere e numeri.");
		theForm.txtNome.focus();
		return false;
	}
	
	if( tipoFile > 0 && tipoFile < 6 )
	{
		window.open('cmsRepository.asp?idStep=3&path=R&nomeCampo=txtUpload&doc='+ tipoFile +'&idCampoNascosto=hdnUpload&nomeFile='+ document.theForm.txtNome.value, 'txtUpload', 'scrollbars=yes, width=450, height=250, status=yes');
		return true;
	}
	else
	{
		alert("Impossibile caricare il file");
		return false;
	}
}

//---  openCMSRepositoryUploadPopUpModifica(theForm) --------------------------------------
function openCMSRepositoryUploadPopUpModifica(theForm, nomeDoc, descrEstensione, idRepository)
{
	tipoFile = theForm.hdnTipoFile.value;
	
	if( tipoFile > 0 && tipoFile < 6 )
	{
		window.open('cmsRepository.asp?idStep=3&path=R&nomeCampo=txtUpload&doc='+ tipoFile +'&ext='+ descrEstensione +'&idCampoNascosto=hdnUpload&nomeFile='+ nomeDoc +'&idRepository='+ idRepository, 'txtUpload', 'scrollbars=yes, width=450, height=250, status=yes');
		return true;
	}
	else
	{
		alert("Impossibile caricare il file");
		return false;
	}
}

//---  chackInsertRepository(theForm, idRepository) --------------------------------------
function checkInsertRepository(theForm, idRepository)
{
	if (theForm.txtNome)
	{
		if (IsStringEmpty(theForm.txtNome.value))
		{
			alert("Il campo \"Nome\" è obbligatorio");
			theForm.txtNome.focus();
			return false;
		}
		
		var reg = /^[\w-.!&()=+ °àòùèéì]+$/;
		if (!reg.test(theForm.txtNome.value))
		{
			alert("Il campo \"Nome\" deve contenere solo lettere e numeri.");
			theForm.txtNome.focus();
			return false;
		}
	}

	if (theForm.cldcalendario1.value != '')
	{
		dataScadenza = theForm.cldcalendario1.value.split('/');
		if (IsDateNotValid(dataScadenza[0], dataScadenza[1], dataScadenza[2]))
		{
			alert("La data inserita nel campo \"Data\" è errata o incompleta.\nCorreggere grazie.");
			theForm.cldcalendario1.focus();
			return false;
		}
	}
	
	if (IsStringEmpty(theForm.txtDescr.value))
	{
		alert("Il campo \"Descrizione\" è obbligatorio");
		theForm.txtDescr.focus();
		return false;
	}
	
	if (idRepository == 0)
	{	
		if (IsStringEmpty(theForm.hdnUpload.value))
		{
			alert("Non è stato inserito nessun file");
			theForm.btnUpload.focus();
			return false;
		}
		theForm.btnUpload.disabled = true;
		theForm.txtNome.disabled = false;
	}
	
	//--- Conrolli superati	
	theForm.submit();
}

//---  checkInsertDir(theForm) --------------------------------------
function checkInsertDir(theForm)
{	
	
	if (IsStringEmpty(theForm.txtDescr.value))
	{
		alert("Il campo \"Nome\" è obbligatorio");
		theForm.txtDescr.focus();
		return false;
	}
	
	//--- Conrolli superati	
	theForm.btnSubmit.disabled = true;
	theForm.submit();
}


//---  check_selectRepositoryEvidenza(TheForm, maxCheck): controlla file da eliminare --------------------------------------
function check_selectRepositoryEvidenza(TheForm, maxCheck)
{	
	var noSelected = true;
	var countChecked = 0;
	var i = 0;
	var strIdFile = ""
	
	if (maxCheck > 0)
	{
		if (!TheForm.chkCancFile.length)
		{
			if (TheForm.chkCancFile.checked)
			{
				if (confirm("Attenzione: i files potrebbero essere pubblicati sul portale.\nSei sicuro di volerli eliminare?"))
				{
					strIdFile = TheForm.chkCancFile.value + ",";
					TheForm.action="cmsRepository.asp?idStep=6&strIdFile=" +strIdFile+ "";
					TheForm.submit();
					return true;
				}
			}
		}
		else
		{	
			while ((noSelected) && (i < TheForm.chkCancFile.length))
			{
				if (TheForm.chkCancFile[i].checked) 
					{ 
						countChecked ++ ;
						strIdFile += TheForm.chkCancFile[i].value + ",";
					}
				i++;
			}
			if ((countChecked > 0) && (countChecked <= maxCheck))
			{
				if (confirm("Attenzione: i files potrebbero essere pubblicati sul portale.\nSei sicuro di volerli eliminare?"))
				{
					TheForm.action="cmsRepository.asp?idStep=6&strIdFile=" +strIdFile+ "";
					TheForm.submit();
					return true;
				}
			}
			else
			{	
				return;
			}
		}
	}
	else
	{	
		return;
	}
}


//---  confirm_DeleteUploadFileFromRepository(nomeTabella, nomeCampoFile, idSezoTipo, nomePagina, idStepDest, strNomeId) --------------------------------------
function confirm_DeleteUploadFileFromRepository(nomeTabella, nomeCampoFile, idSezoTipo, nomePagina, idStepDest, strNomeId)
{
	if (confirm("Sei sicuro di voler eliminare il file?"))
	{
		var strDestinazione = "cmsRepository.asp?idStep=7&nomeTabella="+ nomeTabella +"&nomeCampo="+ nomeCampoFile +"&idSez="+ idSezoTipo +"&nomePagina="+ nomePagina +"&idStepDest="+ idStepDest +"&strNomeId="+ strNomeId;
		window.location.href = strDestinazione;
	}
}

//---  confirm_DeleteUploadFileFromRepositoryNotSQL(nomeCampo) --------------------------------------
function confirm_DeleteUploadFileFromRepositoryNotSQL(nomeCampo)
{
	if (confirm("Sei sicuro di voler eliminare il file?"))
	{
		var campoId = document.getElementById(nomeCampo);
		var span = document.getElementById("spanRepository");
		campoId.setAttribute('value','');
		span.style.display = 'none';	
	}
}

function chkFind()
{
	if(document.getElementById('txtRicerca').value == '')
	{
		alert('Compilare il campo di ricerca');
		return false;
	}
	document.getElementById('hdnRicerca').value = document.getElementById('txtRicerca').value;
	document.theForm.submit();
}

function hideTRCommentiNews(idCommento)
{
	var trName = 'trCommentoNews' + idCommento;
	var row = document.getElementById(trName);
	row.style.display = 'none';
}

function removeCommentoNews(idCommento)
{
	var postData = "idStep=15&idCommento="+idCommento;
	http.open("POST", "cmsNews.asp", true);
	http = setXHRProperties(http,postData);
	http.onreadystatechange = function() { hideTRCommentiNews(idCommento); };
	http.send(postData);
	
	var numFind;
	numFind = 0;
	
	for(var i=0; i<document.getElementById("tableCommentoNews").tBodies[0].rows.length; i++)
	{
		if(document.getElementById("tableCommentoNews").tBodies[0].rows[i].style.display == "none")
		{
			numFind++;
		}
	}
	
	if(numFind == i)
	{
		var tr1Obj = document.createElement("tr");
		var tr1td1Obj = document.createElement("td");
		tr1td1Obj.appendChild(document.createTextNode('Nessun commento presente'));
		tr1td1Obj.setAttribute('colSpan','3');
		tr1Obj.appendChild(tr1td1Obj);
		document.getElementById("tableCommentoNews").tBodies[0].appendChild(tr1Obj);
	}
}
