jQuery(function(){
	
	
	/*
	jQuery('#listing-container #category-posts-mod').jcarousel({
	        vertical: true,
	        scroll: 2
	    });
	*/	
	
	});

 function noCache(){
       return null;
 }

function makeScrollable(wrapper, scrollable){
	
$('#sidebar').append('<img src="/content/wp-content/themes/mimbo/images/up_arrow_large.png" id="arrow_up" />');
$('#sidebar').append('<img src="/content/wp-content/themes/mimbo/images/down_arrow_large.png" id="arrow_down" />');
	
	$('#arrow_up').fadeOut();
	
  // Get jQuery elements
  var wrapper = $(wrapper), scrollable = $(scrollable);
	// Remove scrollbars
	wrapper.css({overflow: 'hidden'});                                              
	
	scrollable.slideDown('slow', function(){
	  enable();
	});

  function enable(){
  // height of area at the top at bottom, that don't respond to mousemove
  var inactiveMargin = 100;
  // Cache for performance
  var wrapperWidth = wrapper.width();
  var wrapperHeight = wrapper.height();
  // Using outer height to include padding too
  var scrollableHeight = scrollable.outerHeight() + 2*inactiveMargin;
  // Do not cache wrapperOffset, because it can change when user resizes window
  // We could use onresize event, but it's just not worth doing that
  // var wrapperOffset = wrapper.offset();

  //When user move mouse over menu
  wrapper.mousemove(function(e){
    var wrapperOffset = wrapper.offset();
    // Scroll menu
    var top = (e.pageY -  wrapperOffset.top) * (scrollableHeight - wrapperHeight) / wrapperHeight  - inactiveMargin;

	
	
    if (top < 0){
      top = 0;
	  
	  $('#arrow_up').fadeOut();
    } else {
		 $('#arrow_up').fadeIn();	
	}

	//console.log(top +' == '+(scrollableHeight - wrapperHeight - inactiveMargin - 30));	
	
	if(top >= (scrollableHeight - wrapperHeight - inactiveMargin - 50)){
		$('#arrow_down').fadeOut();
	} else {
		$('#arrow_down').fadeIn();	
	}
	

    wrapper.scrollTop(top);
  });
}
}
