// COMMENTS - MOUSE WHEEL & SLIDER // 10.07.09
/*jQuery.fn.rx_scrollComment = function(o) {
	if ($.browser.mozilla) { _wheel_coef = 39; } else if($.browser.safari) { _wheel_coef = 29; } else { _wheel_coef = 34; }

	// mouse wheel over the comments area
	$(o.n_scroll).bind('mousewheel', function(event, delta) {
			var node = $(this).find(o.n_hiding);

			if ( node.attr('scrollHeight') > node.outerHeight() ) {
				var speed = node.height() / node.attr('scrollHeight') * (_wheel_coef);
				var nv = node.scrollTop() - delta * speed;
				node.scrollTop(nv);
				var s_hande =  node.scrollTop() / ( node.attr('scrollHeight') -  node.height() ) * 100;

      $(this).parents(o.n_parent).find(o.n_slider).slider('option', 'value', -s_hande );
				return false;
			}
			return true;
	});

	// slide comments
	$(o.n_slider).each(function() {
		$(this).slider({
			animate: false,
			orientation: "vertical",
			min: -100,
			max: 0,
			slide: function(event, ui) {

				var node = $(this).parents(o.n_parent).find(o.n_hiding);
				if ( node.attr('scrollHeight') > node.outerHeight() ) {
					var ratio = node.attr("scrollHeight") - node.height();
					node.attr( { scrollTop: -ui.value * (ratio / 100) } );
				} else {
					return false;
				}
				return true;
			}
		});
	});
}*/

jQuery.fn.rx_scrollComment = function() {
	
	if ($.browser.mozilla) { _wheel_coef = 39; } else if($.browser.safari) { _wheel_coef = 29; } else { _wheel_coef = 34; }

	// mouse wheel over the comments area
	$('.w-comment-list').bind('mousewheel', function(event, delta) {
			var node = $(this).find('.w-hide');
			if ( node.attr('scrollHeight') > node.outerHeight() ) {
				var speed = node.height() / node.attr('scrollHeight') * (_wheel_coef);
				var nv = node.scrollTop() - delta * speed;
				node.scrollTop(nv);
				var s_hande =  node.scrollTop() / ( node.attr('scrollHeight') -  node.height() ) * 100;
				$(this).parents('.x-comment').find('.slide-comment').slider('option', 'value', -s_hande );
				return false;
			}
			return true;
	});

	// slide comments
	$('.slide-comment').each(function() {
		$(this).slider({
			animate: false,
			orientation: "vertical",
			min: -100,
			max: 0,
			slide: function(event, ui) {
				var node = $(this).parents('.x-comment').find('.w-hide');
				if ( node.attr('scrollHeight') > node.outerHeight() ) {
					var ratio = node.attr("scrollHeight") - node.height();
					node.attr( { scrollTop: -ui.value * (ratio / 100) } );
				} else {
					return false;
				}
				return true;
			}
		});
	});
}
//

// BLOG JS
$(document).ready(function(){
	
	$().rx_scrollComment();
	/*
	$().rx_scrollComment({
    n_parent: '#entry-actions',
    n_scroll: '#entry-comments',
    n_hiding: 'ul',
    n_slider: '#entry-slider'
  });
	*/

});
//
