$(document).ready(function() {
	//--Скрол на #content вместо окна браузера
	noScroll();
	$(window).resize(function() {
		noScroll();
		});
	
	function noScroll() {
		var viewportH = $(window).height();
		var subMenuH = $('#sub-menu').outerHeight(true);
		var mainHeaderH = $('.main-h').outerHeight(true);
		var footerH = $('#footer').outerHeight(true);
		var calendarH = 0;
		if ($('body').hasClass('has-calendar')){var calendarH = 42;};
		var blocksH = 207 + subMenuH + mainHeaderH + footerH + calendarH;
		
		var contentH = viewportH - blocksH;
		$('#content').css('height', contentH);
		};
		
		
	$(".ci-control").hover(
		function () {
			$(this).parent().addClass('ci-hide');
			}
		,
		function () {
			$(this).parent().removeClass('ci-hide');
			}
	);
	
	$(".ci-event").hover(
			function () {
				var calendarH = $(this).next('.calendar-event').text();
				
				$('.calendar-h').text(calendarH).removeClass('calendar-h-hide');
				}
			,
			function () {
				$('.calendar-h').addClass('calendar-h-hide');
				}
		);
	

	$('.calendar-slider').each(function() {
	    $(this).jCarouselLite({
	        btnNext: ".slider-control-next",
	        btnPrev: ".slider-control-prev",
	        visible: 1,
	        vertical:false,
	        circular:false,
	        speed: 500
	    });
	});


	$(function(){
		$('.scroll-pane').each(
			function(){
				$(this).jScrollPane({
					showArrows: $(this).is('.arrow')
				});
				var api = $(this).data('jsp');
				var throttleTimeout;
				$(window).bind(
					'resize',
					function() {
						if ($.browser.msie) {
							// IE fires multiple resize events while you are dragging the browser window which
							// causes it to crash if you try to update the scrollpane on every one. So we need
							// to throttle it to fire a maximum of once every 50 milliseconds...
							if (!throttleTimeout) {
								throttleTimeout = setTimeout(
									function()
									{
										api.reinitialise();
										throttleTimeout = null;
									},
									50
								);
							}
						} else {
							api.reinitialise();
						}
					}
				);
			}
		)
	});

});


$(window).load(function() {
	noScroll();
	function noScroll() {
		var viewportH = $(window).height();
		var subMenuH = $('#sub-menu').outerHeight(true);
		var mainHeaderH = $('.main-h').outerHeight(true);
		var footerH = $('#footer').outerHeight(true);
		var calendarH = 0;
		if ($('body').hasClass('has-calendar')){var calendarH = 42;};
		var blocksH = 207 + subMenuH + mainHeaderH + footerH + calendarH;
		
		var contentH = viewportH - blocksH;
		$('#content').css('height', contentH);
	};
	$(function(){
		$('.scroll-pane').each(
			function(){
				$(this).jScrollPane({
					showArrows: $(this).is('.arrow')
				});
				var api = $(this).data('jsp');
				var throttleTimeout;
				$(window).bind(
					'resize',
					function() {
						if ($.browser.msie) {
							// IE fires multiple resize events while you are dragging the browser window which
							// causes it to crash if you try to update the scrollpane on every one. So we need
							// to throttle it to fire a maximum of once every 50 milliseconds...
							if (!throttleTimeout) {
								throttleTimeout = setTimeout(
									function()
									{
										api.reinitialise();
										throttleTimeout = null;
									},
									50
								);
							}
						} else {
							api.reinitialise();
						}
					}
				);
			}
		)
	});
});
