  
/**************************************************************************\
	STRING PROTOTYPE
\**************************************************************************/

function replaceText(pattern, substitute)
{
	return this.split(pattern).join(substitute);
}
String.prototype.replaceText = replaceText;
function trim()
{
	var newstr = this + "";
	newstr = newstr.lTrim();
	newstr = newstr.rTrim();
	return newstr;
}
String.prototype.trim = trim;
function lTrim()
{
	var newstr = this + "";
	while(newstr.charAt(0) == " ") 
		newstr = newstr.substring(1, newstr.length);	
	return newstr;
}
String.prototype.lTrim = lTrim;
function rTrim()
{
	var newstr = this + "";
	while(newstr.charAt(newstr.length - 1) == " ") 
		newstr = newstr.substring(0, newstr.length - 1);	
	return newstr;
}
String.prototype.rTrim = rTrim;

/**************************************************************************\
	COOKIES
\**************************************************************************/
function setCookie(key, value, expirationdate)
{
	var c = key + "=" + escape(value) + ";";
	c += "path=/;";
	if(expirationdate)
		c += "expires=" + expirationdate.toUTCString() + ";";
        //c += "secure";
	document.cookie = c;
}
function getCookieList()
{
	var cl = document.cookie.split(";");
	var c = new Array();
	for(var i = 0; i < cl.length; i++)
	{
		var a = cl[i].split("=");
		if(a.length == 2)
			c[a[0].trim()] = escape(a[1].trim());
	}
	return c;
}
function getCookie(key)
{
	return getCookieList()[key];
}


/**************************************************************************\
	TEXT SIZE
\**************************************************************************/
var COOKIE_TEXT_SIZE_KEY = "textsize";
var TEXT_SIZE_LIST = 
{
	"s"				: "80%",
	"m"				: "100%",
	"l"				: "120%"
};
var DEFAULT_TEXT_SIZE = "m";

function getkey(e)
{
	if (window.event)
   		return window.event.keyCode;
	else if (e)
   		return e.keyCode;
	else
   		return null;
}

function setTextSize(s)
{
	setCookie(COOKIE_TEXT_SIZE_KEY, s, getCookieExpirationDate());
	document.location.reload();
}

function initTextSize()
{
	if(!document.getElementsByTagName)
		return;
	var cs = getCookie(COOKIE_TEXT_SIZE_KEY);
	s = (cs) ? cs : DEFAULT_TEXT_SIZE;
	document.getElementsByTagName("html")[0].style.fontSize = TEXT_SIZE_LIST[s];
}

/**************************************************************************\
	COMMONS
\**************************************************************************/
function getCookieExpirationDate()
{
	var dt = new Date();
	dt.setFullYear(dt.getFullYear() + 1);	
	return dt;
}

/**************************************************************************\
	EVENT HANDLER
\**************************************************************************/
function scriptError(msg, url, line)
{
	return true;
}
window.onerror = scriptError;

function initPage(e)
{
	initTextSize();
}
if(navigator.platform.toLowerCase().indexOf("mac") != -1)	
	window.onload = initPage;
else		
	initPage();	
	

/**************************************************************************\
 Label nell imput text
\**************************************************************************/

function alterNate(elm) {
    if (!elm.base) elm.base = elm.value
    if (elm.value == elm.base) elm.value = "";
    else if (elm.value == "") elm.value = elm.base;
}

/**************************************************************************\
 breadcrumbs () passaggio
\**************************************************************************/
function breadcrumbs() {
    sURL = new String;
    bits = new Object;
    var x = 0;
    var stop = 0;
    var output = "<a href=\"/\">Home</a>  >  ";
    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 += "";
        for (y = 1; y < x - i; y++) {
            output += "";
        }
        output += bits[i] + " >  ";
       

    }
    var title=document.title.substring(11);
    document.write(output + title);
    


}


