	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 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 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.Testo.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Titolo.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 ValidateI_Nostri_Clienti(form)
		{
			if (form.Titolo.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Titolo.focus();
				}
			else
				valore = true;
			return valore
		}			

	function ValidateServizi(form)
		{
			if (form.Titolo.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Titolo.focus();
				}
			else
				valore = true;
			return valore
		}						

	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 ValidateContatti(form)
		{
			if (form.NomeCognome.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					form.NomeCognome.focus();
			    form.NomeCognome.blur();
			    form.NomeCognome.select();
					return false;
				}
				
			if (!FormEmailValidator(form)) 
				return false;
				
			return true;
		}						

	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 ValidateForm(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 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 ValidateOfferte(form)
		{
			if (form.Titolo.value=="")
				{
					alert("E' necessario inserire i campi contrassegnati con *");
					valore = false;
					form.Titolo.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.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;
		}		


