var maxHeight = 245;

$(document).ready(function(){
    
	 var $container = $('ul.dropdown > li'),
		 $list = $container.find("ul"),
		 $anchor = $container.find("a"),
		 height = $list.height() * 1.2,       // make sure there is enough room at the bottom
		 multiplier = height / maxHeight;     // needs to move faster if list is taller
	
	// need to save height here so it can revert on mouseout            
	//$container.data("origHeight", $container.height());
	$container.data("origHeight",25);
	
	// so it can retain it's rollover color all the while the dropdown is open
	$anchor.addClass("hover");
	
	// make sure dropdown appears directly below parent list item    
	$list
		.show()
		.css({
			//paddingTop: $container.data("origHeight")
			paddingTop: "26px"
		});
	
	// don't do any animation if list shorter than max
	//if (multiplier > 1) {
		$container
			.css({
				height: maxHeight,
				overflow: "hidden"
			})
			.mousemove(function(e) {
				var offset = $container.offset();
				var relativeY = ((e.pageY - offset.top) * multiplier) - ($container.data("origHeight") * multiplier);
				//alert(relativeY+"  --  "+$container.data("origHeight"));
				//$('#cords').html(relativeY+'>'+$container.data("origHeight"));
				if (relativeY > $container.data("origHeight")) {
					//$list.css("top", -relativeY + $container.data("origHeight"));
					//$(this).stop().animate({height:'50px'},{queue:false, duration:600, easing: 'easeOutBounce'}) 
					$list.stop().animate({top: -relativeY + $container.data("origHeight")},
																			{queue:false, duration:500, easing: 'easeOutQuart'});
				};
			});
	//}
        
    
});
