﻿$(document).ready(function () {
	SetElementMaxHeight('.EventListDiv', 180);
	$('.ResponseListDiv,.ActionListDiv,.EventListDiv,.UserRotatorListDiv').d66ScrollPane();

	jQuery(function () {
		var scrollDiv = document.createElement('div');
		jQuery(scrollDiv).attr('id', 'toTopDiv').html('Terug naar boven').appendTo('body');
		jQuery(window).scroll(function () {
			if (jQuery(this).scrollTop() != 0) {
				jQuery('#toTopDiv').fadeIn();
			} else {
				jQuery('#toTopDiv').fadeOut();
			}
		});
		jQuery('#toTopDiv').click(function () {
			jQuery('body,html').animate({
				scrollTop: 0
			}, 400);
		});
	});
});

$.fn.d66ScrollPane = function () {
	return this.each(function () {
		var self = $(this);
		self.jScrollPane({
			mouseWheelSpeed: 20,
			trackClickRepeatFreq: 100,
			trackClickSpeed: 15
		});
	});
};

function SetElementMaxHeight(selector, maxHeight) {
	var $element = $(selector);
	if ($element) {
		var currentHeight = $element.height();

		if (currentHeight > maxHeight) {
			$element.css({
				'height': maxHeight,
				'overflow': 'hidden'
			});
		}
	}
};
