﻿// Funkce spouštěné při načítání stránky


	// Fce pro vytvoreni bezpecneho odkazu
	inCMS.initLinks = function() {
		var mailList = $('span.link');
		mailList.each(function(){
			var mail = $(this).html().replace('(zavinac)','@');
			mail = mail.replace(/\(tecka\)/g,'.');
			$(this).html('<a href="mailto:'+mail+'" title="'+mail+'">' + mail +'</a>');
		});
	}
inCMS.initLinks();

// Close other menu items
$('#menuList-v1 > li > span').click(function () {
    var actualItem = $(this);
    var parentItem = $(this).parent();
    var list = $(parentItem).parent();

    $(actualItem).addClass('actual');

    list.children().children('span').each(function () {
        if (!$(this).hasClass('actual')) {
            $(this).parent().children("ul").hide();
        }
    });

    $(actualItem).removeClass('actual');
});

// List hover effect
$('.listItem').fadeTo(0,0.7).hover(function () {
    $(this).fadeTo('slow',1);
}, function () {
    $(this).fadeTo('slow',0.7);
  });

  // Set list item height, do it twice for sure
  $('.list .listItem').each(function () {
    var boxHeight = $(this).height();
    var imageEl = $(this).find('.image');    
    $(imageEl).height(boxHeight);
  });
  $('.list .listItem').each(function () {
    var boxHeight = $(this).height();
    var imageEl = $(this).find('.image');    
    $(imageEl).height(boxHeight);
  });

  // Center calendar list titles
  $('.listCalendar .listItem').each(function () {
    var boxHeight = $(this).height();
    var titleEl = $(this).find('h3');
    var authorEl = $(this).find('.buttonLink');

    /*$(titleEl).css({
      position: 'relative',
      top: (boxHeight / 2 - $(titleEl).height() / 2) + 'px'
    });*/
    $(authorEl).css({
      position: 'relative',
      top: (boxHeight / 2 - $(authorEl).height() / 2) + 'px'
    });
  });


