$(document).ready(function() {

/* Hovery */
	$(".jsBox").hover(
		function() {
			$(this).stop(true, true).animate({ backgroundColor: "#f5f6f7" }, "slow");
		},
		function() {
			$(this).stop(true, true).animate({ backgroundColor: "#FFF" }, 800);
    });
	$(".jsBoxGray").hover(
			function() {
				$(this).stop(true, true).animate({ backgroundColor: "#afb3bd" }, "slow");
			},
			function() {
				$(this).stop(true, true).animate({ backgroundColor: "#f8f8f7" }, 800);
	    });

	$(".jsBtn").hover(
			function() {
				$(this).stop(true, true).animate({ backgroundColor: "#1C2D44", color: "#FFF" }, "slow");
			},
			function() {
				$(this).stop(true, true).animate({ backgroundColor: "#E4E7EA", color: "#5F677A" }, 800);
	    });

	var l = $('.jsText');
	l.each(function(){
		$(this).find('a').css({color: "#FFF"});
		$(this).hover(
			function(){
				$(this).find('a').stop(true, true).animate({color: "#60687B"},"slow");
			},
			function(){
				$(this).find('a').stop(true, true).animate({color: "#FFF"},"800");
			}
		);
	});

	var l = $('.jsArrow');
	l.each(function(){
		$(this).find('h5');
		$(this).hover(
				function(){
					$(this).find("h5").stop(true, true).addClass("jsArr", 10000);
				},
				function(){
					$(this).find("h5").stop(true, true).removeClass("jsArr", 1000);
				}
			);
	});
	var l = $('.jsCalTxt');
	l.each(function(){
		$(this).find('p, h5').css({color: "#60687B"});
		$(this).hover(
			function(){
				$(this).find('p, h5').stop(true, true).animate({color: "#FFF"},"slow");
			},
			function(){
				$(this).find('p, h5').stop(true, true).animate({color: "#60687B"},"800");
			}
		);
	});

	$(".box-hover li").click(function(){
    	window.location=$(this).find("a").attr("href");
    	return false;
	});
/*  */

/* Dzielimy wypuntkowania na kolumny */
	$('.list-split').easyListSplitter({
		colNumber: 2
	});


/* Walidacja forma */
	/* $('#contact form').validate({
		errorPlacement: function(error, element)
		{
			if(element.attr('name') == 'email' && $("#contact form .error").length == 1)
			{
				$("#contact form .form_message").text('Proszę wprowadzić poprawny adres e-mail...');
			}
			else
			{
				$("#contact form .form_message").text('Proszę uzupełnić wszystkie pola...');
			}
			$("#contact form .form_message").show();
		}
	});

/* Team profil */
	/* $('#team-list').find('a').click(function(){

		if( $(this).parent('li').hasClass('current'))
		{
			return false;
		}

		$('.team-company .img').stop(true,true);

		$('#team-list .current').removeClass('current');

		var target = $(this).attr('href');
		var current = $('.team-company .item.current');

		$(current).find('.desc').hide();
		$(current).find('.img').hide();

		$(target).find('.desc').show();

		$(target)
			.addClass('current')
			.find('.img')
			.hide()
			.css('z-index', '2')
			.fadeIn('slow', function(){
				$(current).removeClass('current');
			});

		$(this).parent('li').addClass('current');

		return false;
	});*/

});


/*************************************************
**  jQuery Masonry version 1.3.2
**  Copyright David DeSandro, licensed MIT
**  http://desandro.com/resources/jquery-masonry
**************************************************/
(function(e){var n=e.event,o;n.special.smartresize={setup:function(){e(this).bind("resize",n.special.smartresize.handler)},teardown:function(){e(this).unbind("resize",n.special.smartresize.handler)},handler:function(j,l){var g=this,d=arguments;j.type="smartresize";o&&clearTimeout(o);o=setTimeout(function(){jQuery.event.handle.apply(g,d)},l==="execAsap"?0:100)}};e.fn.smartresize=function(j){return j?this.bind("smartresize",j):this.trigger("smartresize",["execAsap"])};e.fn.masonry=function(j,l){var g=
{getBricks:function(d,b,a){var c=a.itemSelector===undefined;b.$bricks=a.appendedContent===undefined?c?d.children():d.find(a.itemSelector):c?a.appendedContent:a.appendedContent.filter(a.itemSelector)},placeBrick:function(d,b,a,c,h){b=Math.min.apply(Math,a);for(var i=b+d.outerHeight(true),f=a.length,k=f,m=c.colCount+1-f;f--;)if(a[f]==b)k=f;d.applyStyle({left:c.colW*k+c.posLeft,top:b},e.extend(true,{},h.animationOptions));for(f=0;f<m;f++)c.colY[k+f]=i},setup:function(d,b,a){g.getBricks(d,a,b);if(a.masoned)a.previousData=
d.data("masonry");a.colW=b.columnWidth===undefined?a.masoned?a.previousData.colW:a.$bricks.outerWidth(true):b.columnWidth;a.colCount=Math.floor(d.width()/a.colW);a.colCount=Math.max(a.colCount,1)},arrange:function(d,b,a){var c;if(!a.masoned||b.appendedContent!==undefined)a.$bricks.css("position","absolute");if(a.masoned){a.posTop=a.previousData.posTop;a.posLeft=a.previousData.posLeft}else{d.css("position","relative");var h=e(document.createElement("div"));d.prepend(h);a.posTop=Math.round(h.position().top);
a.posLeft=Math.round(h.position().left);h.remove()}if(a.masoned&&b.appendedContent!==undefined){a.colY=a.previousData.colY;for(c=a.previousData.colCount;c<a.colCount;c++)a.colY[c]=a.posTop}else{a.colY=[];for(c=a.colCount;c--;)a.colY.push(a.posTop)}e.fn.applyStyle=a.masoned&&b.animate?e.fn.animate:e.fn.css;b.singleMode?a.$bricks.each(function(){var i=e(this);g.placeBrick(i,a.colCount,a.colY,a,b)}):a.$bricks.each(function(){var i=e(this),f=Math.ceil(i.outerWidth(true)/a.colW);f=Math.min(f,a.colCount);
if(f===1)g.placeBrick(i,a.colCount,a.colY,a,b);else{var k=a.colCount+1-f,m=[];for(c=0;c<k;c++){var p=a.colY.slice(c,c+f);m[c]=Math.max.apply(Math,p)}g.placeBrick(i,k,m,a,b)}});a.wallH=Math.max.apply(Math,a.colY);d.applyStyle({height:a.wallH-a.posTop},e.extend(true,[],b.animationOptions));a.masoned||setTimeout(function(){d.addClass("masoned")},1);l.call(a.$bricks);d.data("masonry",a)},resize:function(d,b,a){a.masoned=!!d.data("masonry");var c=d.data("masonry").colCount;g.setup(d,b,a);a.colCount!=c&&
g.arrange(d,b,a)}};return this.each(function(){var d=e(this),b={};b.masoned=!!d.data("masonry");var a=b.masoned?d.data("masonry").options:{},c=e.extend({},e.fn.masonry.defaults,a,j),h=a.resizeable;b.options=c.saveOptions?c:a;l=l||function(){};g.getBricks(d,b,c);if(!b.$bricks.length)return this;g.setup(d,c,b);g.arrange(d,c,b);!h&&c.resizeable&&e(window).bind("smartresize.masonry",function(){g.resize(d,c,b)});h&&!c.resizeable&&e(window).unbind("smartresize.masonry")})};e.fn.masonry.defaults={singleMode:false,
columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true,animate:false,animationOptions:{}}})(jQuery);

$(function(){
    var
      speed = 500,   // animation speed
      $wall = $('#calendar').find('.wrap');
    $wall.masonry({
      columnWidth: 255,
      itemSelector: '.item:not(.invis)',
      animate: true,
      animationOptions: {
        duration: speed,
        queue: false
      }
    });

    $('#calendar-nav a').click(function(){
      var colorClass = '.' + $(this).attr('class');
      if(colorClass=='.all') {
        $wall.children('.invis')
          .toggleClass('invis').fadeIn(speed);
      } else {
        $wall.children().not(colorClass).not('.invis')
          .toggleClass('invis').fadeOut(speed);
        $wall.children(colorClass+'.invis')
          .toggleClass('invis').fadeIn(speed);
      }

      $("#calendar-nav a.clicked").removeClass("clicked");
      $(this).addClass("clicked");

      $wall.masonry();
      return false;
    });

  });

