/*** Questa funzione e' necessaria perche' IE perde il riferimento a "THIS" quando si usa attachEvent ***/
function addEvent( obj,type,fn )
{
	if ( obj.attachEvent )
	{
		obj['e'+type+fn] = fn; // This makes the function a child of the specified object. The key, which is placed in the object hash, is (hopefully) unique and won't collide with any other function additions.
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );} // This line creates an anonymous function who, once executed, will fire the previously attached function - passing it the global event object. This whole function is being attached to the object so that it can be removed later, using the removeEvent() function.
		obj.attachEvent( 'on'+type, obj[type+fn] );
	} else
	{
		obj.addEventListener( type, fn, false );
	}
}
function removeEvent( obj,type,fn )
{
	if ( obj.detachEvent ) {
		obj.detachEvent( 'on'+type, obj[type+fn] );
		obj[type+fn] = null;
	} else {
		obj.removeEventListener( type, fn, false );
	}
}


function preloadImg()
{
	ind_list = new Image(); ind_list.src='/im/ico_ind_list.gif';
	tipDiv1 = new Image(); tipDiv1.src='/im/tipDiv_bkg.gif';
	tipDiv2 = new Image(); tipDiv2.src='/im/tipDivInner_bkg.gif';
	tipDiv2 = new Image(); tipDiv2.src='/im/ico_load.gif';
}
addEvent(window,'load',preloadImg);

function getElementsByClassName(classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = this.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
document.getElementsByClassName=getElementsByClassName; // Activate this function as a method of "document" object. For other objects, it will have to be activated time by time.

function openPopup(myUrl)
{
	popName = 'eggPopup' + Math.floor(Math.random()*1001); // 1001 dictates that the random number will fall between 0-1000.
	myPop = window.open(myUrl,popName,'width=840,location=no,menubar=no,resizable=yes,scrollbars=yes');
	myPop.focus();
}

function openPopupNoResizable(myUrl,width,height)
{
	popName = 'eggPopup' + Math.floor(Math.random()*1001); // 1001 dictates that the random number will fall between 0-1000.
	myPop = window.open(myUrl,popName,'width='+width+',height='+height+',location=no,menubar=no,resizable=no,scrollbars=no,status=no');
	myPop.focus();
}

function getPopup(myLink)
{
	if (!myLink.converted)
	{
		myLink.dest = myLink.href;
		myLink.href = "javascript:openPopup('" +myLink.dest+ "');";
		myLink.converted = true;
	}
}

function noLink(myLink)
{
	myLink.removeAttribute("href");
}

function findPos()
{
	obj = this;
	/*** Qs funzione serve perche', a volte, offsetLeft e offsetTop di un oggetto sono solo relativi al padre! A noi invece servono quelli assoluti, rispetto alla pagina. ***/
	myLeft = 0;
	myTop = 0;
	if (obj.offsetParent) // Tutti gli oggetti, a parte "window" (che non ha padre)
	{
		myLeft = obj.offsetLeft;
		myTop = obj.offsetTop;
		while (obj = obj.offsetParent) // La funzione corrente viene richiamata finche' "obj" non ha nessun padre (ovvero, fino all'oggetto "window".
		{
			myLeft += obj.offsetLeft;
			myTop += obj.offsetTop;
		}
	}
	this.posLeft = myLeft;
	this.posTop = myTop;
}

function showBookm()
{
	mySpan = document.getElementById('bookmarks').getElementsByTagName('span')[0];
	mySpan.style.display = 'block';
	mySpan.style.filter = "alpha(opacity=90)";
	mySpan.style.MozOpacity = 0.9;
	mySpan.style.opacity = 0.9;
}
function hideBookm()
{
	mySpan = document.getElementById('bookmarks').getElementsByTagName('span')[0];
	setTimeout("mySpan.style.display = 'none'",150); //little delay to allow link href
}
