	function getLayer(layerID)
	{
		if (document.getElementById)
		{
			return document.getElementById(layerID);
		} else {
			if (document.all)
			{
				return document.all[layerID];
			} else {
				return null;
			}
		}
	}

	function updateBar()
	{
		statLayer.innerHTML = loaded + "/" + total;
		var percent = Math.round(loaded/total * 100);
		
		if (cPercent != percent)
		{
			cPercent = percent;
			barLayer.style.width = (cPercent*3) +"px";
			percentLayer.innerHTML = cPercent + "%";
		}
		
		if (loaded == total)
		{
			doneMsgLayer.innerHTML = 'Caricamento completo. <a href="javascript:jump()">Apri</a>.';
			
			if (doConfirm && confirm("Caricamento completo, aprire la pagina?"))
			{
				done();
			}
			
			if (doConfirm == false)
			{
				done();
			}
		}
	}

	function startLoading() {
		if (document.getElementById || document.all)
		{
			barLayer = getLayer("bar");
			percentLayer = getLayer("percent");
			statLayer = getLayer("stat");
			doneMsgLayer = getLayer("doneMsg");
			
			for (i=0; i<pics.length; i++)
			{
				if (canSkip)
				{
					doneMsgLayer.innerHTML = '<a href="javascript:jump()">Salta</a> ';
				} else {
					doneMsgLayer.innerHTML = "";
				}
				
				doneMsgLayer.innerHTML = doneMsgLayer.innerHTML + pics[i];
				
				imgObjs[i] = new Image();
				imgObjs[i].onload = imgLoaded;
				imgObjs[i].onerror = imgFailed;
				imgObjs[i].src = pics[i];
			}
		} else {
			window.location.replace(url);
		}
	}

	function done()
	{
		//setTimeout('parent.window.location.replace(url);', 4000);
		setTimeout('jump();', 4000);
	}
	
	function jump()
	{
		document.location.replace(url);
	}

	function imgFailed()
	{
		//alert(this.src + " not found");
		loaded++;
		updateBar();
	}
	
	function imgLoaded()
	{
		loaded++;
		if (loaded>pics.length)
		{
			return
		}
	
		updateBar();
	}