function addLoader() {
	var loading = Builder.node('DIV', {id: 'loadingDiv', style: 'position:absolute; top: 0; left:0; width: 3000px; height: 2000px; background:#000; z-index: 999999999; padding-top: 200px; text-align:center; color:#FFF'});
	loading.innerHTML = "<strong>Loading</strong>";
	Element.setOpacity(loading, .7);
	$$('BODY')[0].style.overflow = 'hidden';
	document.body.appendChild(loading);
}

function removeLoader() {
	if (document.all)  {
		if (BrowserDetect.browser == "Firefox") {
			$$('BODY')[0].style.overflow = 'auto';
			
		}
		else {
			$$('BODY')[0].style.overflow = 'hidden';
		}
		
	}	
	else {
		$$('BODY')[0].style.overflow = 'auto';
	}
	new Effect.Fade('loadingDiv', {duration: .5})
}

// JavaScript Document
function showPlus(a)
	{
		document.getElementById(a).style.visibility="visible";
	}
function hidePlus(b)
	{
		document.getElementById(b).style.visibility="hidden";
	}
function makeVisible(a) {
	var l = document.getElementById(a);
	l.style.visibility="visible";
	//l.style.zIndex=1001;
	//if(l.offsetTop < l.parentNode.offsetTop) l.style.top = l.parentNode.offsetTop + 'px';
}

var hideMes = false;

function hideMe(elem) {
	hideMes = true;
	if(!h) {
		var h = setInterval(function(){
			if(hideMes) new Effect.Fade('slideshowPopup');
			clearInterval(h);
		}, 1000);
	}
}

function dontHideMe() {
	hideMes = false;
}


function makeVisible2(elem, parent, imageSrc, params) {
	
	hideMes = false;
	if($('slideshowPopup')) Element.remove('slideshowPopup');
	
	var popup = Builder.node('DIV', {id: 'slideshowPopup', className: 'preview', onmouseover: 'dontHideMe()', onmouseout: 'hideMe()'}, [
		Builder.node('IMG', {src: imageSrc}),
		Builder.node('A', {href: 'lamostralesezioni4.php'+params, className: 'slideShow'}, [
			Builder.node('IMG', {src: 'images/vizualizaSlideShow.jpg'})
		])
	]);
	popup.style.left = ((parent.offsetLeft > 400) ? parent.offsetLeft - 125 + 'px' : parent.offsetLeft - 65 + 'px' );
	popup.style.top = ((parent.offsetTop < 10) ? parent.offsetTop - 20 + 'px' : parent.offsetTop - 60 + 'px');
	$('panelContainer').appendChild(popup);
	
}

function closeThis(e) {
	if(e) Element.remove(e)
}

function makeIvisible(b) {
	document.getElementById(a).style.visibility="hidden";
}
function unfade(id)
	{
		if (navigator.appName == "Microsoft Internet Explorer")
		{
			document.getElementById(id).filters.alpha.opacity=0;
		} else { 
			document.getElementById(id).style.opacity=0;
		}
	}
function fade(id)
	{
		if (navigator.appName == "Microsoft Internet Explorer")
		{
			document.getElementById(id).filters.alpha.opacity=60;
		} else { 
			document.getElementById(id).style.opacity=60;
		}

	}
function lighten(id)
	{
		document.getElementById(id).style.color='#acc3ec';
	}
function unlighten(id)
	{
		document.getElementById(id).style.color='#2c4169';
	}
	
function addSlider(id) {
	// vertical slider control
	var slider1 = new Control.Slider('handle'+id, 'track'+id, {
		axis: 'vertical',
		onSlide: function(v) { scrollVertical(v, $('scrollable'+id), slider1);  },
		onChange: function(v) { scrollVertical(v, $('scrollable'+id), slider1); }
	});
	
	// scroll the element vertically based on its width and the slider maximum value
	function scrollVertical(value, element, slider) {
		element.scrollTop = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));
	}
	
	// disable vertical scrolling if text doesn't overflow the div
	if ($('scrollable'+id).scrollHeight <= $('scrollable'+id).offsetHeight) {
		slider1.setDisabled();
		$('track'+id).hide();
	}
	
}

