document.locus = locus;
document.locus.set = setLocus;
document.locus.dictionary = dictionary;
document.locus.iniziale = new Array();
document.locus.finale = new Array();

function locus() //ver 2.1 by marco
{
	var homePage = document.locus.homePage ? document.locus.homePage : "home";
	var homeIndex = document.locus.homeIndex ? document.locus.homeIndex : "index.htm";
	var dirIndex = document.locus.dirIndex ? document.locus.dirIndex : "index.htm";
	var separator = document.locus.separator ? document.locus.separator : " / ";
	var linkAttrib = document.locus.linkAttrib ? document.locus.linkAttrib : "";
	var textAttrib = document.locus.textAttrib ? document.locus.textAttrib : "";
	var begin = document.locus.begin ? document.locus.begin : "";
	var end = document.locus.end ? document.locus.end : "";
	var levels = new Array();
	var dirUp = "../";
	var backTmp = "";
	var navBar = "";
	var isIndex = 0;
	var url = document.httpUtl.getPagePath().replace(/\\/g,"/");
	
	if ( ( url == "/" + dirIndex ) || ( url == "/" ) || (!url) ) return //esce se la pagina attuale è l'indice del sito
	
	//rimuove l'url della pagina dalla stringa
		url = url.substr(1, url.lastIndexOf("/") - 1);
		
	//elimina gli underscore
	url = url.replace(/_/g," ");
	
	//effettua le sostituzioni del dizionario, se presenti
	if (document.locus.iniziale.length > 0)
		for (q = 0; q <= document.locus.iniziale.length; q ++ )
			url = url.replace(document.locus.iniziale[q], document.locus.finale[q])
	
	
	//se la pagina visualizzata è un directory index il flag viene impostato a true
	isIndex = document.location.pathname.replace(url, "").indexOf(dirIndex) != -1 ? 1 : 0
		
	//aggiunge il livello zero: la root
	url = url.length > 0 ? homePage + "/" + url : homePage;
	
	//scompone l'url nelle singole directory
	levels = url.split("/")
	
	for (q = 0; q < levels.length - isIndex; q ++)
		{
		backTmp = "";
		for (i = levels.length - 1; i > q; i --)
			backTmp += dirUp;
			levels[q] = levels[q].link(backTmp + ( q == 0 ? homeIndex : dirIndex))
		}
	
	navBar = levels.join(separator);
	
	if (linkAttrib.length > 0) 
		navBar = navBar.replace(/<A/g, "<A " + linkAttrib + " ");
		
	if (textAttrib.length > 0) 
		navBar = "<span " + textAttrib +" >" + navBar + "</span>";
	
	document.writeln ( begin + navBar + end )
}

function setLocus(param, value) //ver 1.0 by marco
{
	var allowedParam = /homeIndex|homePage|dirIndex|separator|linkAttrib|textAttrib|begin|end/;
	if (!allowedParam.test(param)) return;
	eval("document.locus." + param + "=\"" + value +"\"");
}

function dictionary(iniziale, finale)
{
	if (!iniziale && !finale) return;
	
	document.locus.iniziale[document.locus.iniziale.length] = iniziale;
	document.locus.finale[document.locus.finale.length] = finale;
}

//----------------------------------------------------
function cambiaImmagine(name,src,alt,x,y)
	{
	/* 
	Cambia il file sorgente di un immagine e la ridimensiona
    argomenti: name(nome assegnato al tag immagine) src(file sorgente) alt(campo facoltativo, che definisce l'alt)
	*/
	var img=document.images[name];
		
	//Se non esiste l'oggetto img o non è passato src si esce dalla funzione senza variazioni
	if (!img || !src) return;

	//Se vengono passati x e y allora imposta le nuove dimensioni
	if (x && y)
		{
		img.width=x;
		img.height=y;
		}	
	
	//imposta i nuovi attributi dell'immagine
	img.src=src;
	if (alt) img.alt=alt;
	}
//----------------------------------------------------

function formCookieMessage()
{
	var testCookie = new cookie("JSESSIONID");
    if (testCookie.getVal() == null) document.write('<p align="center" class="textRed"><b>ATTENZIONE:<br>Per poter inviare il modulo occorre abilitare i cookie</b></p>');
}
