﻿jQuery.noConflict();

(function($) {

$(function() {
	var subBox = $(".sub_box:first");
	
	var subList = subBox.find("ul");
	var listItems = subBox.find("li");
	
	var speed = 700;
	
	if(listItems.length > 10) { // mach bei mehr als 10 Einträgen eine Scrollbox
		var height = subList.outerHeight() / listItems.length;
		
		subBox.height(height * 10 + 18);
		
		subList.css({
			borderBottom: "none",
			left: "0px",
			position: "absolute",
			top: "9px"
		})
		.find("li:last")
		.removeClass("last");
		
		subBox
			.find(".scroll-to-top, .scroll-to-bottom")
			.css("display", "block");
			
		var posTop = height * (listItems.length - 10) - 12;
			
		subBox.find(".scroll-to-bottom").hover(
			function() {
				subList.animate({ top: "-"+posTop+"px" }, speed, "swing");
			},
			function() {
				subList.stop();
			}
		)
		.end().find(".scroll-to-top").hover(
			function() {
				subList.animate({ top: "9px" }, speed, "swing");
			},
			function() {
				subList.stop();
			}
		);
	}
});
})(jQuery);