$(document).ready(function(){
	//var clicks = 0;
	var body_class = $.cookie('body_class');
	if(body_class) {
	   $('body').addClass(body_class);
	}else {
	   $.removeCookie('body_class');
	}
	$('.contrast-btn').click(function() {
	  var clicks = $(this).data('clicks');
	  if (clicks) {
		  $("body").removeClass("contrast");
		 //$.cookie('body_class', "smb");
		 $.removeCookie('body_class', {path: '/' });
	  } else {
		 $("body").addClass("contrast");
		 $.cookie('body_class', "contrast", {path: '/' });
	  }
	  $(this).data("clicks", !clicks);
	});
});

// JavaScript Document
if ($(window).width() > 1000) {
	$('#submenu .collapse').on('shown.bs.collapse', function (e) {
		$('#submenu .collapse').not(this).removeClass('in');     
	});

	$('#topmenu [data-toggle=collapse]').hover(function (e) {
		$('#topmenu [data-toggle=collapse]').parent('li').removeClass('active');
		$(this).parent('li').toggleClass('active');     
		$($(this).data('target')).collapse('show');   
	});

	$('#division-item .collapse').on('shown.bs.collapse', function (e) {
		$('#division-item .collapse').not(this).removeClass('in');     
	});

	$('#topsubmenu [data-toggle=collapse]').hover(function (e) {
		$('#topsubmenu [data-toggle=collapse]').parent('li').removeClass('active');
		$(this).parent('li').toggleClass('active');     
		$($(this).data('target')).collapse('show');   
	});

	$(window).scroll(function() {
		if($(window).scrollTop() >= 150) {  
			$('.scroll-menu').fadeIn('fast');
		}else if($(window).scrollTop() <= 149){
			$('.scroll-menu').fadeOut('fast');
		}
	});   

	$('.navbar-static-top ul.nav.navbar-nav li.dropdown a').mouseover(function() {
	  $('.color-box').css('visibility', 'hidden');
	});
	$('.navbar-static-top ul.nav.navbar-nav li.dropdown a').mouseout(function() {
	  $('.color-box').css('visibility', 'visible');
	});  

	$(document).ready(function() {
		$(".tx-tdcalendar-pi1 .tdcalendar_list h3").dotdotdot({
		/* The text to add as ellipsis. */
		ellipsis : '... ',
		 
		/* How to cut off the text/html: 'word'/'letter'/'children' */
		wrap : 'word',
		 
		/* Wrap-option fallback to 'letter' for long words */
		fallbackToLetter: true,
		 
		/* jQuery-selector for the element to keep and put after the ellipsis. */
		after : null,
		 
		/* Whether to update the ellipsis: true/'window' */
		watch : false,
		/* Optionally set a max-height, if null, the height will be measured. */
		height : 40,
		 
		/* Deviation for the height-option. */
		tolerance : 0,
		 
		/* Callback function that is fired after the ellipsis is added,
		receives two parameters: isTruncated(boolean), orgContent(string). */
		callback : function( isTruncated, orgContent ) {},
		 
		lastCharacter : {
		 
		/* Remove these characters from the end of the truncated text. */
		remove : [ ' ', ',', ';', '.', '!', '?' ],
		 
		/* Don't add an ellipsis if this array contains
		the last character of the truncated text. */
		noEllipsis : []
		}
		});
	});  
}

$('.tooltip1').tooltip({parent: '.tooltip-links'});

$('.carousel').carousel();

$('.selectpicker').selectpicker();


// INACTIVE "WYDZIAŁY" ITEM
//$(document).ready(function() {
//   $(".navbar-static-top ul.nav.navbar-nav li.dropdown a").click(function() {
//     return false;
//   });
//});

$(document).ready(function(){
  $('.share-button').popover({
    html : true,
    content: function() {
      return $('#popover_content_wrapper').html();
    }
  });
  
  // Usuwanie dodatkowego bloku na miniaturki do galerii w przypadku gdy został wygenerowany
  $('#thumbcarousel .carousel-inner .item').not(':has(.col-sm-2)').remove();
  
});
  
window.onresize = function() {
  var x = $('.bg-box').width();
    $('.bg-box').css(
        {'height': x + 'px'}
    );
  var x = $('.min-bg-box').width();
    $('.min-bg-box').css(
        {'height': x + 'px', 'line-height': x + 'px'}
    );
};  

$(window).resize(function(){
    // If there are multiple elements with the same class, "main"
    $('.color-boxes .image').each(function() {
        $(this).height($(this).width());
    });
}).resize();
  
$(document).ready(function() {
  $('#incfont').click(function(){    
        curSize= parseInt($('.site-wrapper, #topmenu, .sub-nav').css('font-size')) + 2;
  if(curSize<=18)
        $('.site-wrapper, #topmenu, .sub-nav').css('font-size', curSize);
        });  
  $('#decfont').click(function(){    
        curSize= parseInt($('.site-wrapper, #topmenu, .sub-nav').css('font-size')) - 2;
  if(curSize>=12)
        $('.site-wrapper, #topmenu, .sub-nav').css('font-size', curSize);
        });
});

$('#grid thead').affix({
    offset: {
      top: 50
    }
  });

$('.scroll-menu').affix({
    offset: {
      top: 140
    }
});

