var alwaysVisible = null;

function keepVisible(id){
	alwaysVisible = id;
	showId(id);
}

function showId(id) {
	var e = document.getElementById(id);
	e.style.display='block';
	$(e).fadeTo(100, 1);
}

function hideId(id) {
	if(id==alwaysVisible)
		return;
	var e = document.getElementById(id);
	e.style.display='none';
}

function toggleId(id) {
	var e = "#"+id;
	$(e).slideToggle("slow");
	$(e).fadeTo(50, 1);
}

function truncateURL(url) {
	if(url==undefined || url==null) return;
	url = url.substr(url.lastIndexOf('/')+1);
	return (url == '' ? 'index.php' : url);
}

function menuAutoSelect(){
	var url = truncateURL(window.location.href);
	var li = document.getElementById('menu-principale').getElementsByTagName('a');
	var href;
	for(a in li){
		href = truncateURL(li[a].href);
		if(href == url)
			li[a].setAttribute('id','current');
	}
}

var viste = 1;

function move(pagine, direction){
	if(direction == 'avanti'){
		offset = '-=710';
		viste++;
	}else if(direction == 'indietro'){
		offset = '+=710';
		viste--;
	}
	pulsanti(pagine);
	$('#wrapper-siti').animate({'margin-left': offset}, 1000, 'easeOutBack');
}

function pulsanti(pagine){
	$('#avanti').removeAttr('disabled');
	$('#avanti').fadeTo(300, 1);
	$('#indietro').removeAttr('disabled');
	$('#indietro').fadeTo(300, 1);
	if(viste==pagine){
		$('#avanti').attr('disabled', 'disabled');
		$('#avanti').fadeTo(300, 0.5);
	}if(viste==1){
		$('#indietro').attr('disabled', 'disabled');
		$('#indietro').fadeTo(300, 0.5);
	}
}