	var win = null;
	var maxchar = 255;	
	
	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 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 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.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 ValidateManifestazioni(form)
		{
			if (form.Titolo.value=="" || form.Descrizione.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Titolo.focus();
				}
			else
				valore = true;
			return valore
		}			

	function ValidateLink(form)
		{
			if (form.Titolo.value=="" || form.Descrizione.value=="" || form.URL.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Titolo.focus();
				}
			else
				valore = true;
			return valore
		}						
					
		
	function ValidateUtenti(form)
		{
			if (form.Cognome.value=="" || form.Nome.value=="" || form.Indirizzo.value=="" || form.Citta.value=="" || form.Provincia.value=="" || form.cap.value=="" || form.Telefono.value=="" || form.id_Comune.value=="" || form.Login.value=="" || form.Password.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Cognome.focus();
				}
			else
				valore = true;
			return valore
		}						

	function ValidateTipologia(form)
		{
			if (form.Descrizione.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Descrizione.focus();
				}
			else
				valore = true;
			return valore
		}						

	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.bordercolor = 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;
		}		

	function popupVersione()
		{
			LeftPosition = (screen.width) ? (screen.width-350)/2 : 0;
			TopPosition = (screen.height) ? (screen.height-230)/2 : 0;		
			window.open("popup_versione.asp","versione","top=" + TopPosition + ",left=" + LeftPosition + ",scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=350,height=230")		
			return
		}	

