addEvent(window,'load',preloadImg);

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='/images/ico_ind_list.gif';
	tipDiv1 = new Image(); tipDiv1.src='/images/tipDiv_bkg.gif';
	tipDiv2 = new Image(); tipDiv2.src='/images/tipDivInner_bkg.gif';
	tipDiv2 = new Image(); tipDiv2.src='/images/ico_load.gif';
}

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=820,location=no,menubar=no,resizable=yes,scrollbars=yes');
	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;
}

