	var win = null;
	var maxchar = 255;	
	
//	function popup(padre)
//			{
//				if (padre.value!="")
//					w = window.open("Categorie/Categorie_MENU.asp?action=" + inserimento + "&padre=" + padre + "","inserimento","status=yes,scrollBars=yes,resizable=yes,toolbar=yes,menubar=yes,location=no,directories=no,width=350,height=230")		
//				else
//					{
//						document.maschera.Categoria.value=""
//						document.maschera.padre.value=""						
//					}
//				return
//			}
			
	function popup(pagina,nomewindow,w,h,scroll,tool)
	 {
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		// LeftPosition = 30;
		// TopPosition = 20;
		// w = 400
		// h = 200
		settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=yes, status=yes, toolbar='+tool
		win = window.open(pagina,nomewindow,settings)
	 }

	function ctrl() {
		var f = document.mailing
		if (f.emailaddress.value.indexOf("@") == -1) {
			alert("E' necessario inserire un indirizzo E-Mail valido.")
			f.emailaddress.focus();
			return false;
		}	
		if (f.emailaddress.value.indexOf(".") == -1) {
			alert("E' necessario inserire un indirizzo E-Mail valido.")
			f.emailaddress.focus();
			return false;
		}		
	return true;
	}

//	function Esplodi(Pagina,id,action)
//	 {		
//		document.EsplodiProdotto.Pagina.value = Pagina;
//		document.EsplodiProdotto.id.value = id;
//		document.EsplodiProdotto.action.value = action;
//		document.EsplodiProdotto.submit();
//	 }

//	function Pag(Pagina,Categoria,Sottocategoria,id)
//		{
//			document.maschera.Pagina.value = Pagina;	
//			document.maschera.id.value = id;
//			document.maschera.Categoria.value = Categoria;
//			document.maschera.Sottocategoria.value = Sottocategoria;
//			document.maschera.submit();
//		}

	function Cerca(Ricerca)
	 {		
		document.formRicerca.Ricerca.value = Ricerca;
		document.formRicerca.submit();
	 }

  function CampoNumerico(form, stringa)
    {    
	    var Lunghezza = document.all[stringa].value.length;
	    var Carattere = document.all[stringa].value.substring(Lunghezza,Lunghezza-1);
	    var TipoStringa = "0123456789";
	    var s = TipoStringa.indexOf(Carattere);
	    cont = 0;
	    for(i=0;i<Lunghezza;i++)
	      {
	        Testo = document.all[stringa].value;
	        Testo = Testo.split("");
	        if (TipoStringa.indexOf(Testo[i]) == -1)
	          {
	            document.all[stringa].value = document.all[stringa].value.substring(0,i)
	          }
	        if (Testo[i] == '.') cont++;                 
	        if (cont>1)
	          {
	            document.all[stringa].value = document.all[stringa].value.substring(0,i)
	            break;
	          }
	      }
	  }


	function calcCharLeft(Target) {
		StrLen = Target.value.length;
		if (StrLen > maxchar ) {
			Target.value = Target.value.substring(0,maxchar);
			CharsLeft = 0;
			window.alert("Lunghezza stringa eccessiva di: " + (StrLen-maxchar) + " carattere/i\nNon è possibile inserire più di " + maxchar + " caratteri.");
		} else {
			CharsLeft = maxchar - StrLen;
		}
		Target.form.Descrizione_char.value = maxchar - Target.value.length;
	}
	
	function isEmailAddr(email)
	{
	  var result = false
	  var theStr = new String(email)
	  var index = theStr.indexOf("@");
	  if (index > 0)
	  {
	    var pindex = theStr.indexOf(".",index);
	    if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	  }
	  return result;
	}
	
	function FormEmailValidator(theForm)
	{
	  if (theForm.E_mail.value == "")
	  {
	    alert("Inserire un indirizzo email.");
	    theForm.E_mail.focus();
	    theForm.E_mail.blur();
	    theForm.E_mail.select();
	    return (false);
	  }
	  if (!isEmailAddr(theForm.E_mail.value))
	  {
	    alert("Inserire un indirizzo email completo: tuonome@tuodominio.com");
	    theForm.E_mail.focus();
	    theForm.E_mail.blur();
	    theForm.E_mail.select();
	    return (false);
	  }
	  if (theForm.E_mail.value.length < 3)
	  {
	    alert("Inserire almeno 3 caratteri nel campo email.");
	    theForm.E_mail.focus();
	    theForm.E_mail.blur();
	    theForm.E_mail.select();
	    return (false);
	  }
	  return (true);
	}

	function ValidateLength(field) {
		if (field.value.length < 6) {
				alert("Attenzione il campo " + field.name + " è richiesto e non deve essere inferiore a 6 caratteri!");
				field.focus();
//				field.blur();
//				field.select();
				return false;
			}
		return true;
	}

	function ValidateCampoVuoto(field) {
		if (field.value.length != 0) {
			if (!ValidateLength(field)) 
				return false;
			}
		return true;
	}

	function ValidateUtentiReg(form)
		{
//			if (form.Cognome.value=="" || form.Nome.value=="" || form.Indirizzo.value=="" || form.Citta.value=="" || form.Provincia.value=="" || form.CAP.value=="" || form.E_mail.value=="" || form.Domanda.value=="" || form.Risposta.value=="")
			if (form.Cognome.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.Cognome.focus();
					return false;
				}
			if (form.Nome.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.Nome.focus();
					return false;
				}
			if (form.Indirizzo.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.Indirizzo.focus();
					return false;
				}
			if (form.Citta.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.Citta.focus();
					return false;
				}
			if (form.Provincia.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.Provincia.focus();
					return false;
				}
			if (form.CAP.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.CAP.focus();
					return false;
				}
			if (form.Domanda.value=="" || form.Risposta.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.Domanda.focus();
					return false;
				}
			if (form.Risposta.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.Risposta.focus();
					return false;
				}
				
			if (!FormEmailValidator(form))
					return false;
				
			if (form.Username.value=="" || form.Username.value.length < 6)
				{						
					alert("E' necessario inserire l'Username; minimo 6 caratteri.");
			    form.Username.focus();
					return false;
				}

			if (form.Password.value=="" || form.Password.value.length < 6)
				{						
					alert("E' necessario inserire la Password; minimo 6 caratteri.");			
			    form.Password.focus();
					return false;
				}
			if (form.Password.value != form.Rpassword.value)
				{						
					alert("Le due password non corrisposndono, ridigitarle nuovamente.");			
			    form.Password.focus();
					return false;
				}
			return true;
		}						

	function ValidatePassword(form)
		{
			if (form.Login.value=="" || form.Password.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Login.focus();
				}
			else
				valore = true;
			return valore
		}						

	function ValidateNews(form)
		{
			if (form.id_Riv.value=="-1" || form.Titolo.value=="" || form.Descrizione.value=="" || form.TipoNews.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Titolo.focus();
				}
			else
				valore = true;
			return valore
		}						

	function ValidateFAQ(form)
		{
			if (form.Domanda.value=="" || form.Risposta.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Domanda.focus();
				}
			else
				valore = true;
			return valore
		}			

	function ValidatePrimopiano(form)
		{
			if (form.Descrizione.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Descrizione.focus();
				}
			else
				valore = true;
			return valore
		}			

	function ValidateLink(form)
		{
			if (form.Categoria.value=="" || form.Titolo.value=="" || form.URL.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Categoria.focus();
				}
			else
				valore = true;
			return valore
		}						
	
	function ValidateForm(form)
		{
			if (form.id_Riv.value=="" || form.id_Riv.value=="-1" || form.Categoria.value=="" || form.Titolo.value=="" || form.Descrizione.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.id_Riv.focus();
				}
			else
				{
					if ((form.Categoria.value=="Editoriale" || form.Categoria.value=="Altro" || form.Categoria.value=="Dossier" || form.Categoria.value=="ENTIcap" || form.Categoria.value=="VitaAssociativa") && form.id_Riv.value=="0")
						{
							alert(form.Categoria.value + " è una sezione della rivista, pertanto è impossibile assegnarla a Fuori Rivista");
							valore = false;
							form.id_Riv.focus();
						}
					else
						{
						valore = true;
						}
				}
			return valore
		}						
					
	function ValidateDownload(form)
		{
			if (form.Categoria.value=="" || form.Sottocategoria.value=="" || form.Titolo.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Categoria.focus();
				}
			else
				valore = true;
			return valore
		}						
		
	function ValidateRivista(form)
		{
			if (form.Numero.value=="" || form.Mese.value=="" || form.Anno.value=="" || form.Foto.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Numero.focus();
				}
			else
				valore = true;
			return valore
		}						

	function ValidateRivistaModifica(form)
		{
			if (form.Numero.value=="" || form.Mese.value=="" || form.Anno.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Numero.focus();
				}
			else
				valore = true;
			return valore
		}						

	function ValidateMailing_List(form)
		{
			if (!FormEmailValidator(form))
					return false;

			if (form.Professione.value=="" || form.Professione.value=="-1")
				{
					alert("E' necessario inserire la professione.");
					valore = false;
					form.Professione.focus();
				}
			else
				valore = true;
			return valore
		}			

	function ValidateGestioneEmail(theForm)
		{
		  if (theForm.EUR.value == "" || theForm.EML.value == "" || theForm.EAB.value == "" ||theForm.EAR.value == "")
		  {
		    alert("Inserire un indirizzo email.");
		    if (theForm.EUR.value == "") 
		    	theForm.EUR.focus();
		    else
			    if (theForm.EML.value == "") 
			    	theForm.EML.focus();
			    else
				    if (theForm.EAB.value == "") 
				    	theForm.EAB.focus();
				    else
				    	theForm.EAR.focus();
		    return (false);
		  }
		  if (!isEmailAddr(theForm.EUR.value))
		  {
		    alert("Inserire un indirizzo email completo: tuonome@tuodominio.com");
		    theForm.EUR.focus();
		    return (false);
		  }
		  if (!isEmailAddr(theForm.EML.value))
		  {
		    alert("Inserire un indirizzo email completo: tuonome@tuodominio.com");
		    theForm.EML.focus();
		    return (false);
		  }
		  if (!isEmailAddr(theForm.EAB.value))
		  {
		    alert("Inserire un indirizzo email completo: tuonome@tuodominio.com");
		    theForm.EAB.focus();
		    return (false);
		  }
		  if (!isEmailAddr(theForm.EAR.value))
		  {
		    alert("Inserire un indirizzo email completo: tuonome@tuodominio.com");
		    theForm.EAR.focus();
		    return (false);
		  }
		  if (theForm.EUR.value.length < 3)
		  {
		    alert("Inserire almeno 3 caratteri nel campo email.");
		    theForm.EUR.focus();
		    return (false);
		  }
		  if (theForm.EML.value.length < 3)
		  {
		    alert("Inserire almeno 3 caratteri nel campo email.");
		    theForm.EML.focus();
		    return (false);
		  }
		  if (theForm.EAB.value.length < 3)
		  {
		    alert("Inserire almeno 3 caratteri nel campo email.");
		    theForm.EAB.focus();
		    return (false);
		  }
		  if (theForm.EAR.value.length < 3)
		  {
		    alert("Inserire almeno 3 caratteri nel campo email.");
		    theForm.EAR.focus();
		    return (false);
		  }
	  return (true);
	}			

	function MM_jumpMenu(targ,selObj,restore){ //v3.0
		if (selObj.options[selObj.selectedIndex].value!="")
			{	
			  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
			  if (restore) selObj.selectedIndex=0;
			}
	}

	function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
		newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
		newWindow.document.open();
		newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
		newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt='+alt+'>'); 
		newWindow.document.write('</body></html>');
		newWindow.document.close();
		newWindow.focus();
	}
				
//	function Go(id_Comune, id_Tipologia)
//		{
//			document.Galleria.id_Comune.value = id_Comune;
//			document.Galleria.id_Tipologia.value = id_Tipologia;
//			document.Galleria.submit();
//		}
		
	function xin(src,colore) {
		if (!src.contains(event.fromElement)) {
		   	src.bgColor = colore;	
	    	src.style.cursor = 'hand';
	    }
	}
	 
	 function xout(src,cancella){
		if (!src.contains(event.toElement)){
			src.style.cursor = 'default';
			src.bgColor = cancella;
		}
	 }
	 
	 function xclk(src){ 
		if(event.srcElement.tagName=='TD'){
			src.children.tags('A')[0].click();
		}
	 }
	 
		function PermessiIntranet(livello)
			{
				switch(livello)
					{
						case 1:
							if(document.maschera.Admin_Intranet.checked)
								valore = true;
							else
								valore = false;						
							document.maschera.Admin_Bacheca.checked = valore;
							document.maschera.Bacheca_GAL.checked = valore;
							document.maschera.Bacheca_COMUNE.checked = valore;
							document.maschera.Admin_Forum.checked = valore;
							document.maschera.Forum.checked = valore;
							document.maschera.Intranet.checked = valore;
							break;

						case 2:
							if(document.maschera.Admin_Bacheca.checked)								
								{
									document.maschera.Bacheca_GAL.checked = true;
									document.maschera.Bacheca_COMUNE.checked = true;
									document.maschera.Intranet.checked = true;
								}
							if(!document.maschera.Admin_Bacheca.checked)
								{
									document.maschera.Admin_Intranet.checked = false;
									document.maschera.Bacheca_GAL.checked = false;
									document.maschera.Bacheca_COMUNE.checked = false;
									if(document.maschera.Admin_Forum.checked || document.maschera.Forum.checked)
										document.maschera.Intranet.checked = true;
									else
										document.maschera.Intranet.checked = false;
								}									
							break;
							
						case 21:
							if(document.maschera.Bacheca_GAL.checked)								
								{
									if(document.maschera.Bacheca_COMUNE.checked)								
										document.maschera.Admin_Bacheca.checked = true;
									else
										document.maschera.Admin_Bacheca.checked = false;
									document.maschera.Intranet.checked = true;
								}
							if(!document.maschera.Bacheca_GAL.checked)
								{
									document.maschera.Admin_Intranet.checked = false;
									document.maschera.Admin_Bacheca.checked = false;
									if(document.maschera.Bacheca_COMUNE.checked || document.maschera.Admin_Forum.checked || document.maschera.Forum.checked)
										document.maschera.Intranet.checked = true;
									else
										document.maschera.Intranet.checked = false;
								}									
							break;

						case 22:
							if(document.maschera.Bacheca_COMUNE.checked)								
								{
									if(document.maschera.Bacheca_GAL.checked)								
										document.maschera.Admin_Bacheca.checked = true;
									else
										document.maschera.Admin_Bacheca.checked = false;
									document.maschera.Intranet.checked = true;
								}
							if(!document.maschera.Bacheca_COMUNE.checked)
								{
									document.maschera.Admin_Intranet.checked = false;
									document.maschera.Admin_Bacheca.checked = false;
									if(document.maschera.Bacheca_GAL.checked || document.maschera.Admin_Forum.checked || document.maschera.Forum.checked)
										document.maschera.Intranet.checked = true;
									else
										document.maschera.Intranet.checked = false;
								}									
							break;
							
						case 3:
							if(document.maschera.Admin_Forum.checked)								
								{
									document.maschera.Forum.checked = true;
									document.maschera.Intranet.checked = true;
								}
							if(!document.maschera.Admin_Forum.checked)
								{
									document.maschera.Admin_Intranet.checked = false;
									document.maschera.Forum.checked = false;
									if(document.maschera.Admin_Bacheca.checked || document.maschera.Bacheca_GAL.checked || document.maschera.Bacheca_COMUNE.checked)
										document.maschera.Intranet.checked = true;
									else
										document.maschera.Intranet.checked = false;
								}									
							break;

						case 31:
							if(document.maschera.Forum.checked)								
								{
									document.maschera.Intranet.checked = true;
								}
							if(!document.maschera.Forum.checked)
								{
									document.maschera.Admin_Intranet.checked = false;
									document.maschera.Admin_Forum.checked = false;
									if(document.maschera.Admin_Bacheca.checked || document.maschera.Bacheca_GAL.checked || document.maschera.Bacheca_COMUNE.checked)
										document.maschera.Intranet.checked = true;
									else
										document.maschera.Intranet.checked = false;
								}									
							break;
						
						case 4:
							if(!document.maschera.Intranet.checked)
								{
									document.maschera.Admin_Intranet.checked = false;
									document.maschera.Admin_Bacheca.checked = false;
									document.maschera.Bacheca_GAL.checked = false;
									document.maschera.Bacheca_COMUNE.checked = false;
									document.maschera.Admin_Forum.checked = false;
									document.maschera.Forum.checked = false;
								}
							break;

							

					}
			}
								
	function InsLogin(valore)
		{
			document.maschera.Login.value = valore;
		}		


