function handleSliderChange(e, ui) {
	var maxScroll = $("#scroll_content").attr("scrollHeight") - $("#scroll_content").height();
	$("#scroll_content").attr({scrollTop: maxScroll - ui.value * (maxScroll / 100) });
}

function handleSliderSlide(e, ui) {
	var maxScroll = $("#scroll_content").attr("scrollHeight") - $("#scroll_content").height();
	$("#scroll_content").attr({scrollTop: maxScroll - ui.value * (maxScroll / 100) });
}

function scroll(value) {
	if ($("#slider a.uplnk").data('scrolled')) {
		var maxScroll = $("#scroll_content").attr("scrollHeight") - $("#scroll_content").height();
		var scroll_to = $("#slider a.uplnk").data('scrolled') + value;
		
		// check if scroll is out of scroll area
		if (scroll_to < 1) { scroll_to = 1; }
		else if (scroll_to > maxScroll) {
			scroll_to = maxScroll;
		}
		
		//scroll to
		$("#slider a.uplnk").data('scrolled', scroll_to);
	} else {
	 	$("#slider a.uplnk").data('scrolled', value);
	}
	$("#scroll_content").attr({scrollTop: $("#slider a.uplnk").data('scrolled') });
	return false;
}


$(document).ready(function() {
	
	// attach full size button to images 
	$("img").fullsize();  
	
	// hide image within link	
	$('#home a').mouseover(function() {
		$(this).find('img:first').hide();
		return false;
	});

	// show image within link	
	$('#home a').mouseout(function() {
		$(this).find('img:first').show();
		return false;
	});

	// splash effect	
	$('#dont').click(function() {
		$('#dont img').attr('src', '/media/img/splash.jpg');
		$('#dont').trigger('mouseout');
		$('#dont').unbind('mouseover');
		$('#dont').addClass('notext');
		return false;
	});


	// remove the dotted surrounding
	$('#dont').mouseover(function() {
		this.blur();
	});

	// splash effect	
	$('#lmenu a').click(function() {
		this.blur();
	});

	// buzz/shake effect
	$('#buzz').click(function () {
      	$('#main').effect("shake", { times:10, distance: 3 }, 3);
      	($("#dont").focus())
      	this.blur();
	});

	// work move down
	$('.workl .down, .workl .up').livequery('click', function () {
      	$('#lpage').load(this.href);
      	return false;
 	});
 	
	if ($("#scroll_content").attr("scrollHeight") <= $("#scroll_content").height()) {
	 	$("#slider").hide();
	}
	
 	$("#slider a.uplnk").click(function() { scroll(-20) });

 	$("#slider a.downlnk").click(function() { scroll(20) });
	
	$(".inter_body, .linksr, .agende, .articles").mousewheel(function (event, delta) {
		if (delta > 0) {
			scroll(-20);
		} else {
			scroll(20);
		}
	});
	
	//collapse articles years
	$("#article_months ul ul").toggle();
	$("#article_months ul a.year").click(function() {
		$("#" + $(this).attr("rel")).toggle();
		return false;
	})
	
 	
}); 