function externalLinksIndex() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
			anchor.target = "_blank"; 
	}
	
	return;
}

function externalLinks() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
			anchor.target = "_blank"; 
	}
	
	setLingua();
	
	return;
}

function setLanguage(lingua){	
	createCookie("language",lingua,365);
	
	//return;
}

function changeLanguage(newLanguage){
	
	lingua = readCookie("language");
	
	if ((!lingua) || (lingua != newLanguage)) {
		createCookie("language",newLanguage,365);
		
		// reload page
		location.reload( );

	}
	
	return;
	
}


function setLingua(){
	
	lingua = readCookie("language");
	
	//alert(lingua)
	
	if ((!lingua) || (lingua == 'ita')) return;
	
	if (document.getElementById('prev1') != null){
		document.getElementById('prev1').innerHTML = "previous page";
		document.getElementById('prev1').title = "Go to previous page";
	}
	
	if (document.getElementById('prev2') != null){
		document.getElementById('prev2').innerHTML = "previous page";
		document.getElementById('prev2').title = "Go to previous page";
	}
	
	if (document.getElementById('next1') != null){
		document.getElementById('next1').innerHTML = "next page";
		document.getElementById('next1').title = "Go to next page";
	}
	
	if (document.getElementById('next2') != null){
		document.getElementById('next2').innerHTML = "next page";
		document.getElementById('next2').title = "Go to next page";
	}
	
	if (document.getElementById('index1') != null){
		document.getElementById('index1').innerHTML = "index";
		document.getElementById('index1').title = "Go back to index";
		document.getElementById('index1').href = "index-en.html";
	}
	
	if (document.getElementById('index2') != null){
		document.getElementById('index2').innerHTML = "index";
		document.getElementById('index2').title = "Go back to index";
		document.getElementById('index2').href = "index-en.html";
	}
	
	if (document.getElementById('gadgets') != null){
		document.getElementById('gadgets').innerHTML = "gadgets";
		document.getElementById('gadgets').title = "Calendars, dvd and cards";
		document.getElementById('gadgets').href = "gadgets.html";
	}
	
	if (document.getElementById('gadgets2') != null){
		document.getElementById('gadgets2').innerHTML = "gadgets";
		document.getElementById('gadgets2').title = "Calendars, dvd and cards";
		document.getElementById('gadgets2').href = "gadgets.html";
	}
	
	if (document.getElementById('ricettive') != null){
		document.getElementById('ricettive').innerHTML = "lodges";
		document.getElementById('ricettive').title = "Hotel, Bed & Breakfast, Agriturismi, Restaurants and Campings in the Parco";
		document.getElementById('ricettive').href = "ricettivita.html";
	}
	
	if (document.getElementById('ricettive2') != null){
		document.getElementById('ricettive2').innerHTML = "lodges";
		document.getElementById('ricettive2').title = "Hotel, Bed & Breakfast, Agriturismi, Restaurants and Campings in the Parco";
		document.getElementById('ricettive2').href = "ricettivita.html";
	}
	
	
	if (document.getElementById('credits1') != null){
		document.getElementById('credits1').innerHTML = "credits";
		document.getElementById('credits1').title = "About this site";
		document.getElementById('credits1').href = "#credits";
	}
	
	
	if (document.getElementById('links1') != null){
		document.getElementById('links1').innerHTML = "useful links";
		document.getElementById('links1').title = "Go to useful links page";
	}
	
	if (document.getElementById('links2') != null){
		document.getElementById('links2').innerHTML = "useful links";
		document.getElementById('links2').title = "Go to useful links page";
	}
	
	if (document.getElementById('contact') != null){
		document.getElementById('contact').innerHTML = 'Contacts: <a class="license" href="mailto:info@escursionisibillini.it"><b>info@escursionisibillini.it</b>';
	}
	
	if (document.getElementById('credits') != null){
		document.getElementById('credits').innerHTML = 'Site & graphics by Paolo Grifantini<br />Texts & comments by Marco Scarinci<br />Photos by Paolo, Marco &amp; Roberto';
	}
	
	if (document.getElementById('paypal_text') != null){
		document.getElementById('paypal_text').innerHTML = 'Please, donate for the development of this site!';
	}
	
	if (document.getElementById('info_text') != null){
		document.getElementById('info_text').innerHTML = 'Click on images to see them at full size';
	}
	
	if (document.getElementById('follow') != null){
		document.getElementById('follow').childNodes[0].innerHTML = 'Continue';
	}
	
	if (document.getElementById('backhome') != null){
		document.getElementById('backhome').childNodes[0].innerHTML = 'Go back to index';
		document.getElementById('backhome').href = "index-en.html";
	}
	
	if (document.getElementById('elencoStagioni') != null){
		document.getElementById('elencoStagioni').options[0].text = 'Seasons...';
		document.getElementById('elencoStagioni').options[1].text = 'Spring';
		document.getElementById('elencoStagioni').options[2].text = 'Summer';
		document.getElementById('elencoStagioni').options[3].text = 'Fall';
		document.getElementById('elencoStagioni').options[4].text = 'Winter';
		
		document.getElementById('elencoStagioni').options[0].selected = true;
	}
	
	if (document.getElementById('elencoParoleChiave') != null){
		document.getElementById('elencoParoleChiave').options[0].text = 'Choose e category...';
		
		document.getElementById('elencoParoleChiave').options[0].selected = true;
	}
	
	if (document.getElementById('invia_ricerca') != null){
		document.getElementById('invia_ricerca').value = 'Find';
	}
	
	if (document.getElementById('subtitle') != null){				
		document.getElementById('subtitle').innerHTML = getLocalizedString(document.getElementById('subtitle').innerHTML);
	}
	
	if (document.getElementById('doSearch') != null){				
		document.getElementById('doSearch').innerHTML = getLocalizedString('doSearch');
	}
	
	if (document.getElementById('browserVecchio') != null){				
		document.getElementById('browserVecchio').innerHTML = getLocalizedString('browserVecchio');
	}
	
	if (document.getElementById('galleryEmpty') != null){				
		document.getElementById('galleryEmpty').innerHTML = getLocalizedString('notpreferite');
	}
	
	if (document.getElementById('otherWords') != null){				
		document.getElementById('otherWords').innerHTML = getLocalizedString('otherwords');
	}
	
	if (document.getElementById('camporicerca_gallery') != null){				
		document.getElementById('camporicerca_gallery').placeholder = getLocalizedString('camporicerca_gallery');
	}
	
	if (document.getElementById('title') != null){				
		document.getElementById('title').innerHTML = getLocalizedString(document.getElementById('title').innerHTML);
	}
	
	if (document.getElementById('invio_ricerca_google') != null){				
		document.getElementById('invio_ricerca_google').value = getLocalizedString('ricerca_google');
	}
		
	if (document.getElementById('announcement') != null){				
		document.getElementById('announcement').innerHTML = getLocalizedString('announcement');
	}
	
	if (document.getElementById('eat_near') != null){				
		document.getElementById('eat_near').innerHTML = getLocalizedString('eat_near');
	}
	
	if (document.getElementById('sleep_near') != null){				
		document.getElementById('sleep_near').innerHTML = getLocalizedString('sleep_near');
	}
	
	if (document.getElementById('inserzioni_bottom') != null){				
		document.getElementById('inserzioni_bottom').innerHTML = getLocalizedString('info_ads');
	}
	
	if (document.getElementById('inserzioni_database') != null){				
		document.getElementById('inserzioni_database').innerHTML = getLocalizedString('info_ads');
	}
	
	if (document.getElementById('elencoCategorieLabel') != null){
		document.getElementById('elencoCategorieLabel').innerHTML = getLocalizedString('elencoCategorieLabel');
	}
	
	if (document.getElementById('invia_ricerca_database') != null){
		document.getElementById('invia_ricerca_database').value = getLocalizedString('Cerca');
	}
	
	if (document.getElementById('elencoLocalitaLabel') != null){				
		document.getElementById('elencoLocalitaLabel').innerHTML = getLocalizedString('elencoLocalitaLabel');
	}
	
	if (document.getElementById('label_sortBy') != null){
		document.getElementById('label_sortBy').innerHTML = getLocalizedString('label_sortBy');
	}
	
	if (document.getElementById('radio_localita') != null){
		document.getElementById('radio_localita').innerHTML = getLocalizedString('radio_localita');
	}
	
	if (document.getElementById('radio_categoria') != null){				
		document.getElementById('radio_categoria').innerHTML = getLocalizedString('radio_categoria');
	}
	
	if (document.getElementById('mostra_limitrofe_text') != null){				
		document.getElementById('mostra_limitrofe_text').innerHTML = getLocalizedString('mostra_limitrofe_text');
	}
	
	if (document.getElementById('info_text_inserzioni') != null){				
		document.getElementById('info_text_inserzioni').innerHTML = getLocalizedString('info_text_inserzioni');
	}
	
	if (document.getElementById('goto_database') != null){				
		document.getElementById('goto_database').innerHTML = getLocalizedString('goto_database');
	}
	
	if (document.getElementById('back_escursione') != null){				
		document.getElementById('back_escursione').innerHTML = getLocalizedString('back_escursione');
	}
	
	if (document.getElementById('subtitle_ricettivita') != null){				
		document.getElementById('subtitle_ricettivita').innerHTML = getLocalizedString(document.getElementById('subtitle_ricettivita').innerHTML);
	}
	
	if (document.getElementById('galleryEmpty_inserzioni') != null){				
		document.getElementById('galleryEmpty_inserzioni').innerHTML = getLocalizedString('galleryEmpty_inserzioni');
	}
	/* devo settare i sottotitoli */
	
	
	
	if (document.getElementById('listaNavigazione') != null){				
		chapterList = document.getElementById('listaNavigazione');
				
		list = chapterList.childNodes[0].innerHTML;
		
		for(counter=0;counter< chapterList.childNodes.length; counter++){
			if (chapterList.childNodes[counter].innerHTML != null){
				if (chapterList.childNodes[counter].childNodes[0].innerHTML != null){
					chapterList.childNodes[counter].childNodes[0].innerHTML = getLocalizedString(chapterList.childNodes[counter].childNodes[0].innerHTML);
				}
				else {
					chapterList.childNodes[counter].innerHTML = getLocalizedString(chapterList.childNodes[counter].innerHTML);
				}
			
			}
		}
		
		
	}
	
	
}


window.onload = externalLinks;

function setNavigationLinks(paginaCorrente){

	linkstarget = externalLinks();
	
	links_string = getLocalizedString("links.html");
	index_string = getLocalizedString("index.html");
	
	indice = new Array();
	var n = 0; // cos“ quando levo una pagina nell'array non devo modificare l'indice delle successive
	var i = 0;
	
	indexType = readIndexType();
	
	if (indexType == 'default'){ // volendo gestisco vari tipi di indice
		//indice[n++] = "index-it.html";
		indice[n++] = index_string;
		indice[n++] = "piani1.html";
		indice[n++] = "piani2.html";
		indice[n++] = "piani3.html";
		indice[n++] = "piani4.html";
		indice[n++] = "mangiare_piani.html";
		indice[n++] = "dormire_piani.html";
		indice[n++] = "vettore1.html";
		indice[n++] = "vettore2.html";
		indice[n++] = "vettore3.html";
		indice[n++] = "mangiare_vettore.html";
		indice[n++] = "dormire_vettore.html";
		indice[n++] = "laghi1.html";
		indice[n++] = "laghi2.html";
		indice[n++] = "laghi3.html";
		indice[n++] = "laghi4.html";
		indice[n++] = "mangiare_laghi.html";
		indice[n++] = "dormire_laghi.html";
		indice[n++] = "creste1.html";
		indice[n++] = "creste2.html";
		indice[n++] = "creste3.html";
		indice[n++] = "creste4.html";
		indice[n++] = "creste5.html";
		indice[n++] = "mangiare_vettore.html";
		indice[n++] = "dormire_vettore.html";
		indice[n++] = "fioritura1.html";
		indice[n++] = "fioritura2.html";
		indice[n++] = "fioritura3.html";
		indice[n++] = "mangiare_fioritura.html";
		indice[n++] = "dormire_fioritura.html";
		indice[n++] = "jumenta1.html";
		indice[n++] = "jumenta2.html";
		indice[n++] = "vallelunga.html";
		indice[n++] = "mangiare_jumenta.html";
		indice[n++] = "dormire_jumenta.html";
		indice[n++] = "palazzoborghese.html";
		indice[n++] = "mangiare_palazzoborghese.html";
		indice[n++] = "dormire_palazzoborghese.html";
		indice[n++] = "lieto1.html";
		indice[n++] = "lieto2.html";
		indice[n++] = "lieto3.html";
		indice[n++] = "mangiare_lieto.html";
		indice[n++] = "dormire_lieto.html";
		indice[n++] = "passocattivo.html";
		indice[n++] = "bove1.html";
		indice[n++] = "bove2.html";
		indice[n++] = "bove3.html";
		indice[n++] = "bove4.html";
		indice[n++] = "mangiare_bove.html";
		indice[n++] = "dormire_bove.html";
		indice[n++] = "macereto.html";
		indice[n++] = "mangiare_macereto.html";
		indice[n++] = "dormire_macereto.html";
		indice[n++] = "riosacro1.html";
		indice[n++] = "riosacro2.html";
		indice[n++] = "riosacro3.html";
		indice[n++] = "riosacro4.html";
		indice[n++] = "riosacro5.html";
		indice[n++] = "mangiare_riosacro.html";
		indice[n++] = "dormire_riosacro.html";
		indice[n++] = "panico1.html";
		indice[n++] = "panico2.html";
		indice[n++] = "panico3.html";
		indice[n++] = "panico4.html";
		indice[n++] = "mangiare_panico.html";
		indice[n++] = "dormire_panico.html";
		indice[n++] = "infernaccio1.html";
		indice[n++] = "infernaccio2.html";
		indice[n++] = "infernaccio3.html";
		indice[n++] = "mangiare_infernaccio.html";
		indice[n++] = "dormire_infernaccio.html";
		indice[n++] = "mrotondo.html";
		indice[n++] = "mangiare_mrotondo.html";
		indice[n++] = "dormire_mrotondo.html";
		indice[n++] = "fargno1.html";
		indice[n++] = "fargno2.html";
		indice[n++] = "mangiare_fargno.html";
		indice[n++] = "dormire_fargno.html";
		indice[n++] = "fargnonov1.html";
		indice[n++] = "fargnonov2.html";
		indice[n++] = "mangiare_fargnonov.html";
		indice[n++] = "dormire_fargnonov.html";
		indice[n++] = "acquasanta.html";
		indice[n++] = "mangiare_acquasanta.html";
		indice[n++] = "dormire_acquasanta.html";
		indice[n++] = "lamerosse.html";
		indice[n++] = "mangiare_lamerosse.html";
		indice[n++] = "dormire_lamerosse.html";
		indice[n++] = "priora.html";
		indice[n++] = "mangiare_priora.html";
		indice[n++] = "dormire_priora.html";
		indice[n++] = "ambro1.html";
		indice[n++] = "ambro2.html";
		indice[n++] = "mangiare_ambro.html";
		indice[n++] = "dormire_ambro.html";
		indice[n++] = "regina.html";
		indice[n++] = "mangiare_priora.html";
		indice[n++] = "dormire_priora.html";
		indice[n++] = "montigno1.html";
		indice[n++] = "montigno2.html";
		indice[n++] = "montigno3.html";
		indice[n++] = "mangiare_montigno.html";
		indice[n++] = "dormire_montigno.html";
		indice[n++] = "monteprimo1.html";
		indice[n++] = "monteprimo2.html";
		indice[n++] = "monteprimo3.html";
		indice[n++] = "mangiare_monteprimo.html";
		indice[n++] = "dormire_monteprimo.html";
		indice[n++] = "panorama.html";
		indice[n++] = "camerino1.html";
		indice[n++] = "camerino2.html";
		indice[n++] = "camerino3.html";
		indice[n++] = "camerino4.html";
		indice[n++] = "camerino5.html";
		indice[n++] = "mangiare_camerino.html";
		indice[n++] = "dormire_camerino.html";
		indice[n++] = "sarnano.html";
		indice[n++] = "mangiare_sarnano.html";
		indice[n++] = "dormire_sarnano.html";
		indice[n++] = "ragnolo.html";
		indice[n++] = "ragnolo2.html";
		indice[n++] = "ragnolo3.html";
		indice[n++] = "ragnolo5.html";
		indice[n++] = "ragnolo4.html";
		indice[n++] = "ragnolo6.html";
		indice[n++] = "monteprata.html";
		indice[n++] = "monteprata2.html";
		indice[n++] = "monteprata3.html";
		indice[n++] = "monteprata5.html";
		indice[n++] = "monteprata4.html";
		indice[n++] = "monteprata6.html";
		indice[n++] = "montelago.html";
		indice[n++] = "mangiare_montelago.html";
		indice[n++] = "dormire_montelago.html";
		indice[n++] = "beatobernardo.html";
		indice[n++] = "mangiare_beatobernardo.html";
		indice[n++] = "dormire_beatobernardo.html";
		indice[n++] = "fuochi.html";
		indice[n++] = "mangiare_fuochi.html";
		indice[n++] = "dormire_fuochi.html";
		indice[n++] = "video.html";
		indice[n++] = "preferite.html";
		indice[n++] = "best.html";
		indice[n++] = "galleria.html";
		indice[n++] = "raggiungereisibillini.html";
		indice[n++] = "giropiangrandemountainbike.html";
		indice[n++] = "girocanatramountainbike.html";
		indice[n++] = "giroaccumulimountainbike.html";
		indice[n++] = "giromontedellerosemountainbike.html";
		indice[n++] = "giromaceretomountainbike.html";
		indice[n++] = "girocasalimountainbike.html";
		indice[n++] = "girocardosamountainbike.html";
		indice[n++] = "giropianipaomountainbike.html";
		indice[n++] = "girofargnoriosacromountainbike.html";
		indice[n++] = "giromassamountainbike.html";
		indice[n++] = "girominutellamountainbike.html";
		indice[n++] = "giropenninomountainbike.html";
		indice[n++] = "ricettivita.html";
		//indice[n++] = "gadgets.html";
		indice[n++] = links_string;
	}
	
	
	// ora trovo la posizione della paginaCorrente nell'indice
	
	while( (paginaCorrente != ((indice[i].split('.'))[0]) ) && (i<indice.length)) ++i;   
  	if (paginaCorrente == ((indice[i].split('.'))[0])){
  		paginaPrecedente = indice[i-1];
  		paginaSuccessiva = indice[i+1];
  	}
	
	if (navigator.userAgent.indexOf("MSIE") == -1){ // in IE devo accedere alla foto senza passara dal getElementById
		prev1 = document.getElementById("prev1");
		next1 = document.getElementById("next1");
		prev2 = document.getElementById("prev2");
		next2 = document.getElementById("next2");
	}
	
	
	prev1.href = paginaPrecedente;
	next1.href = paginaSuccessiva;
	
	prev2.href = paginaPrecedente;
	next2.href = paginaSuccessiva;
}

function readIndexType(){
	return 'default';
}

function resize(){
	// mostra la foto in grande
	
	if (navigator.userAgent.indexOf("MSIE") == -1){ // in IE devo accedere alla foto senza passara dal getElementById
		foto = document.getElementById("foto");}
	
	if (big=="true"){
		foto.width=foto.width/1.28;
		foto.height=foto.height/1.28;
		foto.title="Fai click per ingrandire la foto";
		
		big = "false";
	}
	else {
		foto.width=foto.width*1.28;
		foto.height=foto.height*1.28;
		foto.title="Fai click per tornare al formato cartolina";
		
		
		big = "true";
	}
}


function aprivideo(url){
	w=380;
	h=320;
	t = (screen.height - h) / 2;
	if (t<0) t = 0;
	l = (screen.width - w) / 2;
	if (l<0) l = 0;
	
	window.open('video/' + url,'','toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, scrollbars=no,'+'width='+w+',height='+h+',top='+t+',left='+l);
}

function aprifoto(type,url){
	//numFinestre++ ;
	if (type == 'wide') {h = 660;w = 850;} else {h = 850;w = 720;}
	
	// setto a seconda dello stile del sito
	
	t = (screen.height - h) / 2;
	if (t<0) t = 0;
	l = (screen.width - w) / 2;
	if (l<0) l = 0;
	
	if (w > screen.width) {w = screen.width}
	if (h > screen.height) {h = screen.height}
	
	window.open('foto/' + url,'','width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=1,resizable=1');
}

function apripano(url,w,h){
	//numFinestre++ ;
	
	h += 190;

	
	t = (screen.height - h) / 2;
	if (t<0) t = 0;
	l = (screen.width - w) / 2;
	if (l<0) l = 0;
	
	if (w > screen.width) {w = screen.width}
	if (h > screen.height) {h = screen.height}
		
	//window.open('panorami/' + url,'','width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=1,resizable=1');
	
	w = open('panorami/' + url,'','width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=1,resizable=1');
	
}

function aprivr(url,w,h){
	//numFinestre++ ;
	
	t = (screen.height - h) / 2;
	if (t<0) t = 0;
	l = (screen.width - w) / 2;
	if (l<0) l = 0;
	
	window.open('panorami/pano/' + url,'','width='+w+',height='+h+',top='+t+',left='+l);
}


function preparaCartolina(){
	big = "false";
	
	if (navigator.userAgent.indexOf("MSIE") == -1){ // in IE devo accedere alla foto senza passara dal getElementById
		foto = document.getElementById("foto");}
	
	filepath = foto.src;
	filenamearray = filepath.split("/");
	filename = filenamearray[filenamearray.length - 1];
	filename = filename.split(".");
	value = filename[0];
	
	if (navigator.userAgent.indexOf("MSIE") == -1){ // in IE devo accedere alla foto senza passara dal getElementById
		checkbox = document.getElementById("checkbox");}
	
	checkbox.checked = getPreferiti(value); // se la foto ¸ nei preferiti setta il checkbox
	
	if (document.getElementById('photocheckbox') != null){				
		document.getElementById('photocheckbox').innerHTML = getLocalizedString('photocheckbox');
	}
}

function getPreferiti(titolo){
	
	var cookie = readCookie("preferred");
	
	if (!cookie) return false;
	
	photoList = cookie.split(",");
	
	for(var i=0;i < photoList.length;i++) {
    	if (photoList[i] == titolo) {return true;}
    }
    
}

function setPreferiti(){
	
	if (navigator.userAgent.indexOf("MSIE") == -1){ // in IE devo accedere alla foto senza passara dal getElementById
		checkbox = document.getElementById("checkbox");}
	
	if (navigator.userAgent.indexOf("MSIE") == -1){ // in IE devo accedere alla foto senza passara dal getElementById
		foto = document.getElementById("foto");}
	
	filepath = foto.src;
	filenamearray = filepath.split("/");
	filename = filenamearray[filenamearray.length - 1];
	filename = filename.split(".");
	value = filename[0];
	
	
	// vediamo se ¸ selezionato o no
	if(checkbox.checked){
		// metti nei preferiti
		
		// leggo il cookie, se non esiste lo creo; aggiungo la voce al cookie
		
		var cookie = readCookie("preferred");
		
		
		if (!cookie) {createCookie("preferred",value,365);}
		else {
			var photoList = cookie + "," + value;
			
			createCookie("preferred",photoList,365);
		}
	}
	else {
		// togli dai preferiti
		
		
		var cookie = readCookie("preferred");
		
		
		var nuovaLista = "";
		
		if (!cookie) return null;
		
		photoList = cookie.split(",");
		
		for(var i=0;i < photoList.length;i++) {
    		if (photoList[i] != value) {nuovaLista = photoList[i] + "," ; }
    	}
    	
    	createCookie("preferred",nuovaLista,365);
		
	}
	
	
}


function setFotoPreferite(){
	// setta la classe delle foto nella galleria
	var n,immagine;
	
	
	for(n=0; (immagine = document.getElementsByTagName("img")[n]); n++) {
		var filepath = immagine.getAttribute("src");
		
		filenamearray = filepath.split("/");
		filename = filenamearray[filenamearray.length - 1];
		filename = filename.split(".");
		nomefoto = filename[0];
		
		
		if (getPreferiti(nomefoto)) {
			//alert(nomefoto + "preferita!");
			immagine.setAttribute("pref","preferred");
 			
			immagine.pref = "preferred";
			
			immagine.style.border = "1px dotted red";
			
			//alert(immagine.getAttribute("pref"));
		}
	}
	
	//alert(document.getElementsByTagName("img")[0].pref);
}


function display_listaNavigazione(evt)
{
	if (navigator.userAgent.indexOf("MSIE") == -1){ // in IE devo accedere alla foto senza passara dal getElementById
		listaNavigazione_wrapper = document.getElementById("listaNavigazione_wrapper");}
	
	listaNavigazione_wrapper.style.display = "block";
}

function hide_listaNavigazione(evt)
{
	if (navigator.userAgent.indexOf("MSIE") == -1){ // in IE devo accedere alla foto senza passara dal getElementById
		wrapper = document.getElementById("listaNavigazione_wrapper");}
	
	wrapper.style.display = "none";
}

function whereAmI(who,wch)
{
	var L=0, R=0;
	var pa=who;
	while(pa.parentNode){
	L+= ( pa.offsetLeft)? pa.offsetLeft: 0;
	R+= (pa.offsetTop)? pa.offsetTop: 0; 
	
	if(pa==document.body || wch===false)break;
	pa= pa.parentNode;
	
	}
	var A=[L,R];
	return(wch===1 || wch=== 2)? A[wch]: A;
}

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}