function AddBookMark() {
	var url = "http://www.comunemonclassico.it";
	var title = "Comune di Monclassico";
	if (window.sidebar) {
		window.sidebar.addPanel(title,url,'')
	}
	if (document.all) {
		window.external.AddFavorite(url,title);
	}
}
/* styleswitcher - taken from www.alistapart.com */
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

/* end styleswitcher */

/*  write clock and date by torcuato tejada  and raenkrus*/
function TimeOutfunc() {
	timeout = window.setTimeout("TimeOutfunc()", 1000);
	var today = new Date();
	day = today.getDate();
	var d = new Array("Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato");
	var hora=new Date();
	var meses = new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
	dia=hora.getDate();
	month=hora.getMonth();
	ano=hora.getFullYear();
	mes=meses[month];
	horas=hora.getHours();
	minutos= hora.getMinutes();
	segundos=hora.getSeconds();
	if(segundos<=9) segundos= "0" + segundos;
	if(minutos<=9) minutos= "0" + minutos;
	if(horas<=9) horas= "0" + horas;
	document.date_time.showme.value = d[today.getDay()]+" "+dia+" "+mes+" "+ano+" "+horas+":"+minutos+" "+segundos;
}

function OpenLoginWin() {
	if (!(area_ris = open("./entra.php","","menubar=no,status=no,scrollbars=no,width=220,height=170"))) {
		alert("ATTENZIONE\n\nIl tuo browser non permette l'apertura di finestre popup.\nE' necessario disattivare quest'opzione per poter accedere all'area riservata.");
	} else {
		area_ris.moveTo(400,330);
	}
}
function Chk_Form_search_mod() {
	if (document.search_mod.settore.selectedIndex != 0) {
		document.search_mod.action = './?hl=moduli';
		document.search_mod.submit();
	}
}

function Chk_Form_Iscriz() {
	var i, n, err;
	n = document.iscrizione.elements;
	for (i=0;i<n.length;i++) {
		if (n[i].value == "") {
				err = 1;
			}
	}
	if (err == 1) {
		alert("ATTENZIONE\n\nRiempire tutti i campi.");
		return false;
	} 
	if (document.iscrizione.conf_pass.value != document.iscrizione.passw.value) {
		alert("ATTENZIONE\n\nLe password inserite non coincidono.");
		return false;
	}
	if (document.iscrizione.inf_priv.checked == false) {
		alert("ATTENZIONE\n\nE\' necessario accettare l\'informativa sulla privacy.");
		return false;
	} else 	{
		document.iscrizione.action = './?hl=iscriz&b=ok';
		document.iscrizione.submit();
	}
}

function Chk_FD_Login() {
	var err, i, n = document.fd_login.elements;
	for (i=0;i<n.length;i++) {
		if (n[i].value == "") {
			err = 1;
		}
	}
	if (err == 1) {
		alert("ATTENZIONE\n\nRiempire tutti i campi.");
		return false;
	} else {
		document.fd_login.action = './?hl=filod&do=login';
		document.fd_login.submit();
	}
}

function Chk_Form_Ins_Fd() {
	if (document.ins_fd.fd_testo.value == "") {
		alert("ATTENZIONE\n\nImpossibile memorizzare un messaggio vuoto.");
		return false;
	} else {
		document.ins_fd.action = "./ins_fd.php";
		document.ins_fd.submit();
	}
}
function Chk_Form_RP() {
	RegEx = /^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$/;
	if (document.rp.email.value == "") {
		alert("ATTENZIONE\n\nInserire un indirizzo email.");
		return false;
	} else if (!RegEx.test(document.rp.email.value)) {
		alert("ATTENZIONE\n\nL\'indirizzo email inserito non è valido.");
		return false;
	} else {
		document.rp.action = './?hl=rp&b=go';
		document.rp.submit();
	}
}
function Do_Search(valore) {
	if (location.search.indexOf('search') != -1) {
		var vai_a = location.href.substr(0,location.href.length-4);
		self.location.href = vai_a + valore;
	} else {
		self.location.href = location.href+"&search="+valore;
	}
}
function Search_Prot(id_prot) {
		var Regex = new RegExp("^[0-9]$",'g');
		var num_value = document.src_prot.num_prot.value;
		if (num_value) {
			document.src_prot.action = location.href;
			document.src_prot.submit();
		} else {
			alert('ATTENZIONE\n\nImmettere un numero.');
			return false;
		}
		
}