<!--

/* closure 
http://simon.incutio.com/archive/2004/05/26/addLoadEvent */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/* breadcrumbs() */
function breadcrumbs(){
	sURL = new String;
	bits = new Object;
	var x = 0;
	var stop = 0;
	var output = "<a href=\"/index.shtml\">"+"Home"+"</a>&nbsp;&raquo;&nbsp;&nbsp;";
	sURL = location.href;
	sURL = sURL.slice(8,sURL.length);
	chunkStart = sURL.indexOf("/");
	sURL = sURL.slice(chunkStart+1,sURL.length)
	while(!stop){
		chunkStart = sURL.indexOf("/");
		if (chunkStart != -1){
			bits[x] = sURL.slice(0,chunkStart);
			sURL = sURL.slice(chunkStart+1,sURL.length);
		}else{
			stop = 1;
		}
		x++;
	}
	/*for(var i in bits){
		output += "<a href=\"";
		for(y=1;y<x-i;y++){
			output += "../";
		}
		output += bits[i] + "/\">" + bits[i] + "</a>&nbsp;&raquo;&nbsp;&nbsp;";
	}*/
	for(var i in bits){
		output += "";
		for(y=1;y<x-i;y++){
			output += "";
		}
		output += bits[i] + "&nbsp;&raquo;&nbsp;&nbsp;";
	}
	document.write(output);
}

/* insDel() */
function insDel() {
	var iar = new Array();
	var dar = new Array();
	var idT; var itT; var icT;
	var ddT; var dtT; var dcT;
	var iend; var dend; var icTW; var dcTW;
	iar = document.getElementsByTagName("ins");
	dar = document.getElementsByTagName("del");
	// INS
	for (var i=0;i<iar.length;i++) {
		idTW = iar[i].getAttribute("dateTime");
		icTW = iar[i].getAttribute("cite");
		ichunk = iar[i].innerHTML;
		idT = iar[i].getAttribute("dateTime"); idT = (idT) ? "[<strong style='text-transform:uppercase;'>Aggiunto</strong>. <strong>Data</strong>: "+idT+". <strong>Nota</strong>: \"" : "";
		icT = iar[i].getAttribute("cite"); icT = (icT) ? icT : "";
		itT = iar[i].getAttribute("title"); itT = (itT) ? itT : "";
		if(idT!="" && itT!="") {iend="[fin qui]";} else {iend=""};
		if(iend!="") {if(icT!=""){icT="\" - (<em><a href='"+icTW+"' title='maggiori dettagli' class='ndrIns'>Rif.</a></em>)] ";} else {icT="";itT+="\"] ";}} else {iend="[fin qui]";idT="[<strong style='text-transform:uppercase;'>Aggiunto</strong>]&nbsp;";icT="";itT="";}
		iar[i].parentNode.innerHTML = "<span class='ndrIns'>"+idT+itT+icT+"</span><ins class='ins' datetime=\""+idTW+"\" cite=\""+icTW+"\" title=\""+itT+"\">"+ichunk+"</ins><span class='ndrIns'>&nbsp;"+iend+"</span>";
	}
	// DEL
	for (var d=0;d<dar.length;d++) {
		ddTW = dar[d].getAttribute("dateTime");
		dcTW = dar[d].getAttribute("cite");
		dchunk = dar[d].innerHTML;
		ddT = dar[d].getAttribute("dateTime"); ddT = (ddT) ? "[<strong style='text-transform:uppercase;'>Cancellato</strong>. <strong>Data</strong>: "+ddT+". <strong>Nota</strong>: \"" : "";
		dcT = dar[d].getAttribute("cite"); dcT = (dcT) ? dcT : "";
		dtT = dar[d].getAttribute("title"); dtT = (dtT) ? dtT : "";
		if(ddT!="" && dtT!="") {dend="[fin qui]";} else {dend=""};
		if(dend!="") {if(dcT!=""){dcT="\" - (<em><a href='"+dcTW+"' title='maggiori dettagli' class='ndrDel'>Rif.</a></em>)] ";} else {dcT="";dtT+="\"] ";}} else {dend="[fin qui]";ddT="";dcT="[<strong style='text-transform:uppercase;'>Cancellato</strong>]&nbsp;";dtT="";}
		dar[d].parentNode.innerHTML = "<span class='ndrDel'>"+ddT+dtT+dcT+"</span><del class='del' datetime=\""+ddTW+"\" cite=\""+dcTW+"\" title=\""+dtT+"\">"+dchunk+"</del><span class='ndrDel'>&nbsp;"+dend+"</span>";
	}
}


	function cambiaLinkEsterni(tranneQuestoHTTP) {
		var totLink = document.links.length; //alert("totLink: "+totLink); // totale link da controllare
		// controllo ogni link
		for (var i=0;i<totLink;i++) { 
			//document.links[i].setAttribute("title",document.links[i].href); // aggiungo tooltip
			// procedo solo se contiene "HTTP://"
			if(document.links[i].getAttribute("href").lastIndexOf("http://") != -1 || document.links[i].getAttribute("href").lastIndexOf("www.") != -1) {
				var ifIP = document.links[i].getAttribute("href"); // l'URL completo da controllare
				ifIP = ifIP.replace("http://", "") // tolgo "HTTP://"
				ifIP = ifIP.replace(ifIP.slice(ifIP.indexOf("/")), ""); // tengo solo fino al primo "/"
				ifIP = ifIP.split(".", 10); // elimino i "." e metto le sottostringhe in un array
				var ifIPOk= "";
				for (u=0;u<ifIP.length;u++) {
					ifIPOk = ifIPOk+ifIP[u]; // concateno i singoli pezzi in un'unica stringa (senza i punti)
				}
				var IPRegExpObj = /\d{4,}/; // pattern per controllare se ci sono piu' di 4 numeri... (num IP)
				// se ci sono pił di 4 numeri e se 
				// nella stringa non compare il dominio di questo sito
				if (ifIPOk.match(IPRegExpObj) || document.links[i].getAttribute("href").lastIndexOf(tranneQuestoHTTP) == -1) {
					// e se non e' un link 'javascript' o un'ancora "#"
					// allora cambio lo stile al link
					if (document.links[i].getAttribute("href").lastIndexOf("javascript:") == -1 || document.links[i].getAttribute("href") != "#") {
						//document.links[i].style.fontWeight = "bolder";  grassetto
						//document.links[i].style.fontSize = "97%"; // smaller
						//document.links[i].style.color = "#04306F";  colore
						//document.links[i].style.textDecoration = "underline"; // sottolineato
						document.links[i].setAttribute("title",""+document.links[i].href+""); // aggiungo tooltip (link esterno)
						document.links[i].setAttribute("target","_blank"); // apri in una nuova finestra
					}
				}
			}
		}
	}
	


function pulisciCampo(questoCampo) {
	if (questoCampo.value == questoCampo.defaultValue) {
		questoCampo.value = ""
	}
}

var l_object = new Object();
function checkDefaultValue(obj, val) {
	var value = obj.value;
	if(val == undefined){
		if(value == ''){
			obj.value = l_object.value;
		}
	} else{
		if(value == val){
			obj.value = '';
		}
		l_object.value = val;
	}
}

function Ricerca() { 
	var site = "avvisopubblico.it"; 
	var termine = document.getElementById("ricerca").cerca.value; 
	top.location.href = "http://www.google.it/search?as_q=" + termine + "&num=10&hl=it&ie=UTF-8&btnG=Cerca+con+Google&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=" + site; 
}

function emailAT() { // utilizzo: window.onload = function() {emailAT();}
	var regExpTxt = new RegExp("{AT}", "g");
	var regExpHref = new RegExp(escape("{AT}"), "g");
	var w = document.body.innerHTML;
	w = w.replace(regExpTxt, "@"); // txt
	w = w.replace(regExpHref, "@"); // href
	document.body.innerHTML = w;
}


	/* 'aggiungiZebra()' */ 
	
	// bug in IE 
	function hasClass(obj) { 
		var result = false; 
		if (obj.getAttributeNode("class") != null) { 
			result = obj.getAttributeNode("class").value; 
		} 
		return result; 
	}

	function aggiungiZebra(id) { 
		var even = false; 
		// colori di default 
		var evenColor = arguments[1] ? arguments[1] : "#fffff4"; 
		var oddColor = arguments[2] ? arguments[2] : "#eeeee4"; 
		// riferimento alla tabella desiderata 
		var table = document.getElementById(id); 
		if (! table) { return; } 
		var tbodies = table.getElementsByTagName("tbody"); 
		for (var h = 0; h < tbodies.length; h++) { 
			var trs = tbodies[h].getElementsByTagName("tr"); 
			for (var i = 0; i < trs.length; i++) { 
				// evita le colonne o le righe che hanno 
				// gią un riempimento di colore 
				if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) { 
					var tds = trs[i].getElementsByTagName("td"); 
					for (var j = 0; j < tds.length; j++) { 
						var mytd = tds[j]; 
						// evita le celle che hanno 
						// gią una classe o stile assegnati 
						if (! hasClass(mytd) && ! mytd.style.backgroundColor) { 
							mytd.style.backgroundColor = even ? evenColor : oddColor; 
						} 
					} 
				} 
				even =  ! even; 
			} 
		} 
	}


/* 'startclock()' */ 	
// based on http://www.pageresource.com/jscript/jclock2.htm // NS 4.6+, IE 5+ 
function startclock() {
	var thetime=new Date();
	var nhours=thetime.getHours(); var nmins=thetime.getMinutes(); var nsecn=thetime.getSeconds(); var nday=thetime.getDay(); 
	var nmonth=thetime.getMonth(); var ntoday=thetime.getDate(); var nyear=thetime.getYear(); var AorP=" ";
	
	if (nhours>=12) AorP="pm"; else AorP="am";
	if (nhours>=24) nhours-=24;
	/*if (nhours==0) nhours=12;*/
	if (nsecn<10) nsecn="0"+nsecn;
	if (nmins<10) nmins="0"+nmins;

	if (nday==0) nday="dom"; if (nday==1) nday="lun"; if (nday==2) nday="mar"; if (nday==3) nday="mer"; 
	if (nday==4) nday="gio"; if (nday==5) nday="ven"; if (nday==6) nday="sab";
	
	nmonth+=1;	
	if (nmonth==1) nmonth="gen"; if (nmonth==2) nmonth="feb"; if (nmonth==3) nmonth="mar"; if (nmonth==4) nmonth="apr"; 
	if (nmonth==5) nmonth="mag"; if (nmonth==6) nmonth="giu"; if (nmonth==7) nmonth="lug"; if (nmonth==8) nmonth="ago"; 
	if (nmonth==9) nmonth="set"; if (nmonth==10) nmonth="ott"; if (nmonth==11) nmonth="nov"; if (nmonth==12) nmonth="dic";
	
	if (nyear<=99) nyear= "19"+nyear; if ((nyear>99) && (nyear<2000)) nyear+=1900;
	
	//document.clockform.clockspot.value=nday + " " + ntoday + " " + nmonth + " " + nyear + ", " + "ore " + nhours + ":" + nmins; 
	document.getElementById("clockspot").value=nday + " " + ntoday + " " + nmonth + " " + nyear + ", " + "ore " + nhours + ":" + nmins; 
	setTimeout('startclock()',1000);
}
//-->