window.onload = function(e) {
link_apri();
link_apri_img();
}

function link_apri() { 
prop=''; 
a = document.getElementsByTagName('A');
for(i=0;a[i];i++) if(a[i].className == "esterno") {
if(a[i].title) {a[i].title += " [il collegamento apre una nuova finestra]";}
else {a[i].title =a[i].innerHTML.replace(/\n|\r/g,'') + " [il collegamento apre una nuova finestra]";}
a[i].onclick = function () {window.open(this.href, '_blank',prop);return false;};
a[i].onkeypress = function (e) {k = (e) ? e.keyCode : window.event.keyCode; if(k==13) {Window.open(this.href,'_blank',prop); return false;}}
}}

//JS per galleria fotografica: ogni ancora con class="apri_img" deve puntare all'img ingrandita e avere un title
function link_apri_img() {
var modo = 'toolbar=no,location=no, directories=no, status=no, menuBar=no, scrollbars=no, resizable=yes, width=1, height=1, top=20, left=20';
a = document.getElementsByTagName('A');
for(i=0;a[i];i++) 
 if(a[i].className.match(/apri_img/g) == 'apri_img') {
	 if (a[i].childNodes[2]){
		 copy = a[i].childNodes[2].innerHTML;
	 }
	 else {
	 copy = '';
	 }
	 
	 if (a[i].childNodes[3]){
		 autore = a[i].childNodes[3].innerHTML;
	 }
	 else {
	 autore = '';
	 }
	 a[i].href=a[i].href+'&'+a[i].firstChild.title+'&'+a[i].firstChild.alt+'&'+copy+'&'+autore;
   a[i].firstChild.title += " [il collegamento apre una nuova finestra]";

   a[i].onclick = function () { popup=window.open('', '_blank', modo);popup.location.href='/js/template.htm'+'?'+this.href; return false;};
   a[i].onkeypress = function (e) {k = (e) ? e.keyCode : window.event.keyCode;if(k==13) {popup=window.open('', '_blank', modo);popup.location.href='/js/template.htm'+'?'+this.href; return false;}}
}}	    

