(function($){$.fn.remainCharactersCounter=function(options){options=$.extend({},$.fn.remainCharactersCounter.defaults,options);input=$(this).find(options.inputPath);counterWrapper=$(this).find(options.counterWrapperPath);counter=$(this).find(options.counterPath);setRemained=function(){remained=(parseInt(options.max)-input.val().length);counter.text(remained);return remained;}
checkLength=function(){remained=setRemained();if(remained<0){input.val(input.val().substr(0,options.max));setRemained();}}
setRemained();input.keypress(checkLength);input.click(checkLength);input.mouseup(checkLength);input.mousedown(checkLength);input.mousemove(checkLength);};$.fn.remainCharactersCounter.defaults={max:100,inputPath:'input',counterWrapperPath:'.counter-wrapper',counterPath:'.counter'};})(jQuery);;(function($){$.fn.comments={};$.fn.comments.defaults={commentsFormTrigger:'.commentsFormTrigger',commentsFormContainer:'.commentsFormContainer',commentsFormContent:'#commentsFormContent',commentsFormContentMaxChars:500,commentsFormButtonAdd:'#commentsFormButtonAdd',commentsFormButtonCancel:'.commentsFormButtonCancel',commentsListContainer:'.commentsList',commentsListButtonDelete:'.commentsListButtonDelete',commentsListButtonShowMore:'.commentsListButtonShowMore',commentsAnimationDuration:200};$.fn.comments.options={};$.fn.comments.init=function(options){$.fn.comments.options=options=$.extend($.fn.comments.defaults,options);$.fn.comments.commentsFormTrigger=$('body').find($.fn.comments.options.commentsFormTrigger);$.fn.comments.commentsFormContainer=$('body').find($.fn.comments.options.commentsFormContainer);$.fn.comments.commentsFormForm=$($.fn.comments.commentsFormContainer).find('form');$.fn.comments.commentsFormContent=$($.fn.comments.commentsFormContainer).find($.fn.comments.options.commentsFormContent);$.fn.comments.commentsFormButtonAdd=$($.fn.comments.commentsFormContainer).find($.fn.comments.options.commentsFormButtonAdd);$.fn.comments.commentsFormButtonCancel=$($.fn.comments.commentsFormContainer).find($.fn.comments.options.commentsFormButtonCancel);$.fn.comments.commentsListContainer=$('body').find($.fn.comments.options.commentsListContainer);$.fn.comments.commentsList=$.fn.comments.commentsListContainer.find('ul');$.fn.comments.commentsListButtonShowMore=$($.fn.comments.commentsListContainer).find($.fn.comments.options.commentsListButtonShowMore);$.fn.comments.commentsFormContent.reset=function(){$(this).val('');$(this).attr('disabled',false);$.fn.comments.commentsFormButtonAdd.attr('disabled',false);};$('body').delegate($.fn.comments.options.commentsFormTrigger,'click',$.fn.comments.commentsFormTriggerClick);$.fn.comments.commentsFormContainer.delegate($.fn.comments.options.commentsFormContent,'keyup',$.fn.comments.commentsFormContentKeyup);$.fn.comments.commentsFormContainer.delegate($.fn.comments.options.commentsFormButtonCancel,'click',$.fn.comments.commentsFormButtonCancelClick);$.fn.comments.commentsFormContainer.delegate($.fn.comments.options.commentsFormButtonAdd,'click',$.fn.comments.commentsFormButtonAddClick);$.fn.comments.commentsListContainer.delegate($.fn.comments.options.commentsListButtonDelete,'click',$.fn.comments.commentsListButtonDeleteClick);$.fn.comments.commentsListContainer.delegate($.fn.comments.options.commentsListButtonShowMore,'click',$.fn.comments.commentsListButtonShowMoreClick);};$.fn.comments.animationShow=function(element){$(element).css({opacity:0});$(element).slideDown($.fn.comments.options.commentsAnimationDuration,function(){$(element).animate({opacity:1},{duration:$.fn.comments.options.commentsAnimationDuration}).removeClass('hide');});};$.fn.comments.animationHide=function(element){$(element).animate({opacity:0},{duration:$.fn.comments.options.commentsAnimationDuration,complete:function(){$(this).slideUp($.fn.comments.options.commentsAnimationDuration,function(){$(this).addClass('hide');})}});};$.fn.comments.animationToggle=function(element){if($(element).hasClass('hide')){$.fn.comments.animationShow(element);}else{$.fn.comments.animationHide(element);}};$.fn.comments.ajaxAddComment=function(){data={commentsFormContent:$.fn.comments.commentsFormContent.val(),isSend_commentAdd:'1'};if($('#fancybox-content').find('#captcha-input').val()!==undefined){data.captchaInput=$('#fancybox-content').find('#captcha-input').val();data.captchaId=$('#fancybox-content').find('input#captcha-id').val();}
if($.trim(data.commentsFormContent)==''){$.fn.comments.commentsFormContent.reset();return false;}
$.ajax({url:$.fn.comments.commentsFormForm.attr('action'),type:$.fn.comments.commentsFormForm.attr('method'),data:data,success:$.fn.comments.ajaxAddCommentSuccess,error:$.fn.comments.ajaxError});};$.fn.comments.ajaxAddCommentSuccess=function(response){if(response.captcha!=undefined){response.captcha='
';$.fancybox(response.captcha,{padding:'10px',enableEscapeButton:true,showCloseButton:false});$('#fancybox-content').find('.commentCaptchaSubmit').css({margin:'10px'});$('#fancybox-content').find('#captcha-input-label').css({padding:'10px'});$('#fancybox-content').find('#captcha-element img').css({padding:'10px'});$('#fancybox-content').find('#captcha-element input').css({margin:'10px'});$('#fancybox-content').find('.commentCaptchaSubmit').click(function(e){e.preventDefault();$.fancybox.close();setTimeout($.fn.comments.ajaxAddComment,300);});}else{if($.fn.comments.commentsList.html()==null){$.fn.comments.commentsListContainer.html('');$.fn.comments.commentsList=$.fn.comments.commentsListContainer.find('ul');}
if(response.OK!=undefined){for(var i in response.OK){$.fn.comments.commentsList.prepend(response.OK[i]);li=$.fn.comments.commentsList.find('li:first');li.addClass('hide');$.fn.comments.animationShow(li);$.fn.comments.commentsFormContent.reset();}}else{$.fn.comments.ajaxError(response);}};};$.fn.comments.ajaxDelete=function(){$.ajax({url:$.fn.comments.tempCommentToDelete.find($.fn.comments.options.commentsListButtonDelete).attr('href'),error:$.fn.comments.ajaxError,success:$.fn.comments.ajaxDeleteSuccess});};$.fn.comments.ajaxDeleteSuccess=function(response){if(response.OK!=undefined){$.fn.comments.tempCommentToDelete.after(response.OK);deletedComment=$.fn.comments.tempCommentToDelete.next();deletedComment.addClass('hide');$.fn.comments.tempCommentToDelete.remove();$.fn.comments.animationShow(deletedComment);return true;};$.fn.comments.ajaxError();};$.fn.comments.ajaxError=function(){alert('Niestety wystąpił nieokreślony błąd. Prosimy spróbować później.');};$.fn.comments.commentsFormTriggerClick=function(event){event.preventDefault();$.fn.comments.animationToggle($.fn.comments.commentsFormContainer);};$.fn.comments.commentsFormContentKeyup=function(event){if($(this).val().length>$.fn.comments.options.commentsFormContentMaxChars){$(this).val($(this).val().substr(0,$.fn.comments.options.commentsFormContentMaxChars));}};$.fn.comments.commentsFormButtonCancelClick=function(event){event.preventDefault();$.fn.comments.animationToggle($.fn.comments.commentsFormContainer);};$.fn.comments.commentsFormButtonAddClick=function(event){event.preventDefault();$.fn.comments.commentsFormButtonAdd.attr('disabled',true);$.fn.comments.commentsFormContent.attr('disabled',true);setTimeout($.fn.comments.ajaxAddComment,2*$.fn.comments.options.commentsAnimationDuration);};$.fn.comments.commentsListButtonDeleteClick=function(event){event.preventDefault();if(!confirm('Czy na pewno chcesz skasować komentarz?'))
return false;$.fn.comments.tempCommentToDelete=$(this).parents('li');$.fn.comments.animationHide($.fn.comments.tempCommentToDelete);setTimeout($.fn.comments.ajaxDelete,2*$.fn.comments.options.commentsAnimationDuration);};$.fn.comments.commentsListButtonShowMoreClick=function(event){event.preventDefault();offset=$.fn.comments.commentsList.find('li').size();publicationId=parseInt($.trim($(this).attr('class').replace($.fn.comments.options.commentsListButtonShowMore.replace('.',''),'')));url='/komentarze/'+publicationId+'/'+offset;$.ajax({url:url,error:$.fn.comments.ajaxError,success:$.fn.comments.commentsListButtonShowMoreAjaxSuccess});};$.fn.comments.commentsListButtonShowMoreAjaxSuccess=function(response){if(response.noMoreComments==true){$.fn.comments.animationHide($.fn.comments.commentsListButtonShowMore);}
if(response.comments!=undefined){for(var i in response.comments){ccmmentHtml=response.comments[i];$.fn.comments.commentsList.append(ccmmentHtml);comment=$.fn.comments.commentsList.find('li:last');comment.addClass('hide');$.fn.comments.animationShow(comment);}}}})(jQuery);;$(document).ready(function(){$('body').delegate('ul#contest-content-tabs li a','click',function(event){event.preventDefault();$(this).parents('li').addClass('selected').siblings('.selected').removeClass('selected');tabToShowClass=('.'+$(this).attr('class').replace(' tabButton','')+'.tab');$('.tab').not(tabToShowClass).fadeOut(200,function(){$(tabToShowClass).fadeIn(200);});});$('body').comments.init();$('.publication-options .buttonDelete').click(function(event){if(!confirm('Czy na pewno chcesz usunąć publikację?')){event.preventDefault();}});$('.publication-gallery-photo a.big').fancybox({'transitionIn':'elastic','transitionOut':'elastic','speedIn':400,'speedOut':200,'overlayShow':true,'titleShow':false,afterLoad:function(){ga('send','pageview',this.href);ga('send','event','Lightbox','Open',this.href);}});$('#form-common-comment-add textarea').autoResize({onResize:function(){},animateCallback:function(){},animate:true,animateDuration:3000,extraSpace:0});$().openClose({trigger:'.commentsFormTrigger',container:'.comment-form',animation:250});$("#carousel2").each(function(){$(this).carouFredSel({circular:false,infinite:false,auto:false,items:6,scroll:6,prev:{button:".publication-gallery .prev_carousel2",key:"left"},next:{button:".publication-gallery .next_carousel2",key:"right"}});});$("#carousel1").each(function(){$(this).carouFredSel({circular:false,infinite:false,auto:false,items:6,scroll:6,prev:{button:".publication-gallery .prev_carousel1",key:"left"},next:{button:".publication-gallery .next_carousel1",key:"right"}});});$('fieldset.comment-form-content').remainCharactersCounter({max:500,inputPath:'textarea'});$('._hide').addClass('hide');})