// Inizio document.ready
$("document").ready ( function (){

/* SCROLLBAR CUSTOMIZZATA */
content = function(){
	$(".scroll-pane").jScrollPane({
		scrollbarMargin:15,
		maintainPosition: false
	});
}
elenco = function(){
	$(".elenco").jScrollPane({
		scrollbarMargin:15,
		maintainPosition: false
	});
}
detItem = function(){
	$(".dettaglio").jScrollPane({
		scrollbarMargin:15,
		maintainPosition: false
	});
}

/* ESEGUO LE FUNZIONI */
content();
elenco();


/* ALTRI LIBRI */
$(".linkCopertina").click( function() {
	var currentId = $(this).attr("id"); 
	currentId = "#" + currentId + "testo"; 	
	var scheda = $(this).parent().html();
	var testo = $(currentId).html();
	testo = "<p class=\"det\">" + testo + "</p>";
	var schedaDet = scheda + testo;
	var schedeLibro = $(".schedeLibro").html();
	$(".schedeLibro").fadeOut("slow", function(){
		$("#schedaDettaglio").html(schedaDet).fadeIn("slow");
		content();
		$(".back").fadeIn("slow");
	});
	return false;
});
		
/* ARTICOLI */
$(".archivio").click( function() {
	$(".elencoArchivio").fadeIn("fast",function(){
		$(".archivio").fadeOut("slow");
		elenco();
	});
	return false;
});

caricaItem = function(){
	$(".item").click( function() {
		$(".content").css("background","#faf8e1");
		$(".item").removeClass("selItem");
		$(this).addClass("selItem");
		var currentId = $(this).attr("id"); 
		var path = $("body").attr("id");
		currentId = "/" + path + "/" + currentId + ".shtml"; 	
		$(".dettaglio").fadeOut("slow",function(){
			$(".dettaglio").load(currentId, function(){
				$(".dettaglio").fadeIn("slow");
				detItem();
			});
		});
		return false;
	});
}

caricaItem();

/* RISTORANTI */
$(".archLocStra").click( function() {
	$(this).fadeOut("fast",function(){
		$("#ristSel").fadeIn("fast");
	});
	return false;
});

$(".menuRistoranti").change(selezLuogo);

function selezLuogo(){
	var selected = $(".menuRistoranti option:selected");			
	valore = selected.val();
	caricaValore = "/ristoranti/" + "ristoranti_" + valore + ".shtml";
	$(".sottoElenco").fadeOut("slow",function(){
		$(".sottoElenco").load(caricaValore, function(){
			$(".sottoElenco").fadeIn("slow");
			elenco();
			caricaItem();
		});
	});
}

/* IMMAGINI */
$(function() {
	$('.boxImg a').lightBox({fixedNavigation:true});
});





});
// Fine document.ready