function handleSliderChange(e, ui) {
	var maxScroll = $("#fancy_title_content").attr("scrollHeight")
			- $("#fancy_title_content").height();
	var slide = 100 - ui.value;
	$("#fancy_title_content").animate({
				scroll : slide * (maxScroll / 100)
			}, 1000);
}

function handleSliderSlide(e, ui) {
	var maxScroll = $("#fancy_title_content").attr("scrollHeight")
			- $("#fancy_title_content").height();
	var slide = 100 - ui.value;
	var scrollH = slide * (maxScroll / 100);

	$("#fancy_title_content").attr({
				scrollTop : scrollH
			});
}

function prepareTable() {
	$('#maptable img').hover(function() {
				$(this).fadeTo("fast", 1);
			}, function() {
				$(this).fadeTo("def", 0);
			}

	);
	$('#maptable a').fancybox({
				'overlayOpacity' : 0.7,
				'overlayColor' : '#666',
				'hideOnContentClick' : true,
				'zoomOpacity' : true
			});
	$('#maptable a').click(resetSlider);

	$('#maptable img').fadeTo(0, 0.01);
	$('#maptable').show('def');
}

function prepareSlider() {
	$("#slider").slider({
				orientation : "vertical",
				change : handleSliderChange,
				slide : handleSliderSlide
			});
}

function resetSlider() {
	$('#slider').slider('option', 'value', 100);
}

$(document).ready(function() {

			prepareSlider();
			prepareTable();
		});

