jQuery.fn.boxForum=function(q){var l={};l.commentBlockClassName="postAddForm";l.commentAuthorFieldName="postAuthor";l.commentTextFieldName="postText";l.commentIdFieldName="parentId";l.spamIdFieldName="postId";l.postContentClassName="postContent";l.resetBlockIdFieldName="forumResetButton";l.commentAuthorEmptyValue="";l.commentTextEmptyValue="";l.spamTextEmptyValue="";l.commentAuthorMaxChars=255;l.commentTextMaxChars=3000;l.spamTextMaxChars=3000;l.listAjaxUrl=null;l.commentAjaxUrl=null;l.spamAjaxUrl=null;l.commentSuccessHtml="";l.commentErrorHtml="";l.spamSuccessHtml="";l.spamErrorHtml="";l.commentAuthorInvalidInfo="";l.commentTextInvalidInfo="";l.spamReasonInvalidInfo="";l.spamTextInvalidInfo="";l.slideSpeed=250;l.infoDelay=2000;l.userIsLogged=false;l.commentsReferers=null;var x=jQuery(this);var d=jQuery([]);var i=jQuery([]);var j=jQuery([]);var f=jQuery([]);var g=jQuery([]);var n=jQuery([]);var o=jQuery([]);var y=jQuery([]);var m=jQuery([]);var A=jQuery([]);var r=true;var v={};v.maxChars=function(C,D){C.keypress(function(F){var E=F.which;if(E>=33||E==13){if(jQuery(this).val().length>=D){F.preventDefault();return false}}})};var t=function(C){l=jQuery.extend(l,C);x.find("."+l.commentBlockClassName).not(".firstPost").hide();d=x.find("."+l.commentBlockClassName);i=d.find("form").not("#createThreadForm");j=jQuery(l.commentSuccessHtml?'<div id="postAddForm" class="postMessage messageSuccess"><div class="modBegin"><span></span></div>'+l.commentSuccessHtml+'<div class="modEnd"><span></span></div></div>':[]).insertBefore(d).hide();f=jQuery(l.commentErrorHtml?'<div id="postAddForm" class="postMessage messageError"><div class="modBegin"><span></span></div>'+l.commentErrorHtml+'<div class="modEnd"><span></span></div></div>':[]).insertBefore(d).hide();g=x.find(".postSpamForm").hide();n=g.find("form");o=jQuery(l.spamSuccessHtml?'<div class="postMessage messageSuccess"><div class="modBegin"><span></span></div>'+l.spamSuccessHtml+'<div class="modEnd"><span></span></div></div>':[]).insertBefore(g).hide();y=jQuery(l.spamErrorHtml?'<div class="postMessage messageError"><div class="modBegin"><span></span></div>'+l.spamErrorHtml+'<div class="modEnd"><span></span></div></div>':[]).insertBefore(g).hide();m=jQuery(l.spamErrorDataHtml?'<div class="postMessage messageError"><div class="modBegin"><span></span></div>'+l.spamErrorDataHtml+'<div class="modEnd"><span></span></div></div>':[]).insertBefore(g).hide();A=x.find("#"+l.resetBlockIdFieldName).hide();if(Inpl.User.isLoggedIn()){var D=Inpl.User.getNick();l.commentAuthorEmptyValue=D;i.find('.author input[type="text"]').val(D);n.find(".imageCodeImg").remove();jQuery("<input>").attr({type:"hidden",name:"userSess",id:"userSess",value:Inpl.User.getNick()}).appendTo(n)}i.find('.author input[type="text"]').val(l.commentAuthorEmptyValue).focus(function(){if(jQuery(this).val()===l.commentAuthorEmptyValue){jQuery(this).val("")}}).keydown(function(){if(jQuery(this).val()===l.commentAuthorEmptyValue){jQuery(this).val("")}}).blur(function(){if(jQuery(this).val()===""){jQuery(this).val(l.commentAuthorEmptyValue)}});i.find(".text textarea").val(l.commentTextEmptyValue).focus(function(){if(jQuery(this).val()===l.commentTextEmptyValue){jQuery(this).val("")}}).keydown(function(){if(jQuery(this).val()===l.commentTextEmptyValue){jQuery(this).val("")}}).blur(function(){if(jQuery(this).val()===""){jQuery(this).val(l.commentTextEmptyValue)}});n.find(".message textarea").val(l.spamTextEmptyValue).focus(function(){if(jQuery(this).val()===l.spamTextEmptyValue){jQuery(this).val("")}}).keydown(function(){if(jQuery(this).val()===l.spamTextEmptyValue){jQuery(this).val("")}}).blur(function(){if(jQuery(this).val()===""){jQuery(this).val(l.spamTextEmptyValue)}});v.maxChars(i.find('.author input[type="text"]'),l.commentAuthorMaxChars);v.maxChars(i.find(".text textarea"),l.commentTextMaxChars);v.maxChars(n.find(".message textarea"),l.spamTextMaxChars);i.find('.author input[type="text"], .text textarea').after('<div class="invalidInfo"></div>');n.find(".reason label").eq(0).add(".message textarea").add(".imageCodeImg #imageCodeImgRefresh").after('<div class="invalidInfo"></div>');if(l.userIsLogged){x.find(".addPost a").not('[rel="no-js"]').click(function(){c(jQuery(this).parents(".addPost").eq(0));return false});x.find(".list .functions .reply a").not('[rel="no-js"]').click(function(){p(jQuery(this).parents("."+l.postContentClassName).eq(0),jQuery(this).parents("li").eq(1));return false});x.find(".list .functions .quoteReply a").not('[rel="no-js"]').click(function(){p(jQuery(this).parents(".addPost").eq(0),jQuery(this).parents("li").eq(1),true);return false});try{if(location.pathname){jQuery(document).find('.list .functions .reply a[href="'+location.pathname+location.hash+'"]').click();jQuery(document).find('.list .functions .quoteReply a[href="'+location.pathname+location.hash+'"]').click();jQuery(document).find('.list .functions .spam a[href="'+location.pathname+location.hash+'"]').click();if(location.hash.indexOf("postAddForm")>-1||location.pathname.indexOf(",postAddForm")>-1){r=false;jQuery(".addPost a").eq(0).click()}}}catch(E){}i.submit(function(){k(jQuery(this));return false});i.find('input[type="reset"]').click(function(){e();return false})}else{h(x.find(".list .functions .reply"));h(x.find(".list .functions .quoteReply"));if(jQuery(".addPost a").is("a")){jQuery(".addPost a").setFloatbox({ajaxUrl:"/ajax/logowanie?referer="+l.commentsReferers.addPost.refererUrl+"&crc="+l.commentsReferers.addPost.crc,wrapperClass:"floatbox-loginForm",closeButtonHtml:'<div class="close-floatbox-button close-floatbox"><span>zamknij</span></div>',after:function(F){setTimeout(function(){jQuery("#login").focus()},1000);jQuery("#floatbox-box").find("a, input, textarea").not('[type="hidden"]').each(function(G){jQuery(this).attr("tabindex",G+1)})}},"login")}}x.find(".list .functions .spam a").not('[rel="no-js"]').click(function(){u(jQuery(this).parents("."+l.postContentClassName).eq(0),jQuery(this).parents("li").eq(1));return false});n.submit(function(){b(jQuery(this));return false});n.find('input[type="reset"]').click(function(){w();return false});n.find(".message").hide();n.find('.reason input[type="radio"]').click(function(){if(jQuery(this).is(":checked")){switch(jQuery(this).val()){case"3":n.find(".message").show().css("display","block");break;case"1":case"2":default:n.find(".message").hide()}}});jQuery.ajaxSetup({timeout:10000})};var h=function(C){for(a in C){if(C[a].tagName&&C[a].tagName.toLowerCase()=="li"){indx=jQuery(C[a]).parents("li").eq(0).attr("id").substring(1);jQuery(C[a]).setFloatbox({ajaxUrl:"/ajax/logowanie?referer="+l.commentsReferers[indx].refererUrl+"&crc="+l.commentsReferers[indx].crc,wrapperClass:"floatbox-loginForm",closeButtonHtml:'<div class="close-floatbox-button close-floatbox"><span>zamknij</span></div>',after:function(D){setTimeout(function(){jQuery("#login").focus()},1000);jQuery("#floatbox-box").find("a, input, textarea").not('[type="hidden"]').each(function(E){jQuery(this).attr("tabindex",E+1)})}},"login")}}};var c=function(C){if(d.prev().get(0)!==C.get(0)){d.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})}g.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed});o.hide();y.hide();n.show();d.queue(function(){jQuery(".messageSuccess").hide();jQuery(".messageError").hide();j.hide();f.hide();A.show();i.show();if(r){B()}i.find('input[name="'+l.commentIdFieldName+'"][type="hidden"]').val("");i.find('a[rel="floatbox[login_href]"]').attr("href","/logowanie?referer="+l.commentsReferers.addPost.refererUrl+"&crc="+l.commentsReferers.addPost.crc);jQuery(this).insertAfter(C);f.insertAfter(jQuery(this));j.insertAfter(jQuery(this));jQuery(this).dequeue()});d.animate({height:"show",opacity:"show"},{duration:l.slideSpeed});d.queue(function(){i.find('.author input[name="'+l.commentAuthorFieldName+'"][type="text"], .text textarea[name="'+l.commentTextFieldName+'"]').eq(0).focus().get(0).select();jQuery(this).dequeue()});jQuery(window).scrollTo(x)};var p=function(D,C,E){E=typeof(E)==="boolean"?E:false;g.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed});o.hide();y.hide();n.show();if(d.prev().get(0)!==D.get(0)){d.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})}d.queue(function(){jQuery(".messageSuccess").hide();jQuery(".messageError").hide();j.hide();f.hide();A.show();i.show();if(d.prev().get(0)!==D.get(0)){B();i.find('input[name="'+l.commentIdFieldName+'"][type="hidden"]').val(C.attr("id").substring(1));i.find('a[rel="floatbox[login_href]"]').attr("href","/logowanie?referer="+l.commentsReferers[C.attr("id").substring(1)].refererUrl+"&crc="+l.commentsReferers[C.attr("id").substring(1)].crc);jQuery(this).insertAfter(D);f.insertAfter(jQuery(this));j.insertAfter(jQuery(this))}if(E){z(C)}jQuery(this).dequeue()});d.animate({height:"show",opacity:"show"},{duration:l.slideSpeed});d.queue(function(){i.find('.author input[name="'+l.commentAuthorFieldName+'"][type="text"], .text textarea[name="'+l.commentTextFieldName+'"]').eq(0).focus().each(function(){if(!E){jQuery(this).get(0).select()}});jQuery(this).dequeue()});jQuery(window).scrollTo(x)};var z=function(E){var I=E.find("."+l.postContentClassName+" .postText");var D="";jQuery(I).contents().filter(function(){return !jQuery(this).hasClass("quo")}).each(function(){if(this.nodeType==3){D+=this.nodeValue}});var G=jQuery(I).find(".quo").get(0);if(G){G=jQuery(G).html()}else{G=""}var J=/<span\sclass="?user"?>([\w~\s]+)<\/span>/gi;G=G.replace(J,"[quote user=$1]");var C=/<span\sclass="?quo"?>/gi;G=G.replace(C,"");var F=/<\/span>/gi;G=G.replace(F,"[/quote]");if(G!=""){G=G+"[/quote]"}var H="[quote user="+E.find(".author .user cite").children().text()+"]"+D+G+"[/quote]";i.find(".text textarea").val(H+"\n")};var k=function(C){C.ajaxSubmit({url:l.commentAjaxUrl,dataType:"json",beforeSubmit:function(K,I,F){var H=true;var G=I.find('.author input[name="'+l.commentAuthorFieldName+'"][type="text"]');if(G.is('.author input[name="'+l.commentAuthorFieldName+'"][type="text"]')&&G.val().length>0&&G.val().length<=l.commentAuthorMaxChars){var E=G.val();if(E===""||E===l.commentAuthorEmptyValue){I.find(".author").addClass("invalid").find(".invalidInfo").text(l.commentAuthorInvalidInfo);H=false}else{I.find(".author").removeClass("invalid").find(".invalidInfo").text("")}}else{if(G.is('.author input[name="'+l.commentAuthorFieldName+'"][type="text"]')&&G.val().length>l.commentAuthorMaxChars){I.find(".author").addClass("invalid").find(".invalidInfo").text("Podpis przekracza dozwoloną długość.");H=false}}var J=I.find('.text textarea[name="'+l.commentTextFieldName+'"]');if(J.is('.text textarea[name="'+l.commentTextFieldName+'"]')&&J.val().length>0&&J.val().length<=l.commentTextMaxChars){var D=J.val();if(D===""||D===l.commentTextEmptyValue){I.find("li.text").addClass("invalid").find(".invalidInfo").text(l.commentTextInvalidInfo);H=false}else{I.find("li.text").removeClass("invalid").find(".invalidInfo").text("")}}else{if(J.is('.text textarea[name="'+l.commentTextFieldName+'"]')&&J.val().length>l.commentTextMaxChars){I.find("li.text").addClass("invalid").find(".invalidInfo").text("Treść przekracza dozwoloną długość.");H=false}}if(H===true){d.animate({opacity:0.5},{duration:l.slideSpeed});return true}return false},success:function(D){d.animate({opacity:1});d.hide();i.hide();switch(D.status){case"ok":B();j.show();setTimeout(function(){j.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})},l.infoDelay);break;case"error":if(D.code=="not logged"&&l.redirectPageUrl){location.href=l.redirectPageUrl;break}default:f.show();setTimeout(function(){f.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})},l.infoDelay);break}},error:function(D){d.animate({opacity:1});d.hide();i.hide();f.show();setTimeout(function(){d.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})},l.infoDelay)}})};var e=function(){d.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed});d.queue(function(){B();jQuery(this).dequeue()})};var B=function(){i.resetForm().find(".invalid").removeClass("invalid").end().find(".invalidInfo").text("").end().find('.author input[type="text"]').val(l.commentAuthorEmptyValue).end().find(".text textarea").val(l.commentTextEmptyValue)};var u=function(D,C){d.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed});j.hide();f.hide();m.hide();i.show();if(g.prev().get(0)!==D.get(0)){g.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})}g.queue(function(){jQuery(".messageSuccess").hide();jQuery(".messageError").hide();o.hide();y.hide();m.hide();n.show();if(g.prev().get(0)!==D.get(0)){s();n.find('input[name="'+l.spamIdFieldName+'"][type="hidden"]').val(C.attr("id").substring(1));jQuery(this).insertAfter(D);m.insertAfter(jQuery(this));y.insertAfter(jQuery(this));o.insertAfter(jQuery(this))}jQuery(this).dequeue()});g.animate({height:"show",opacity:"show"},{duration:l.slideSpeed});g.queue(function(){g.find('.reason input[name="reason"], .message textarea[name="message"]').eq(0).focus().get(0).select();jQuery(this).dequeue()})};var b=function(C){C.ajaxSubmit({dataType:"json",url:l.spamAjaxUrl,beforeSubmit:function(J,I,E){var G=true;var F=I.find('.reason input[type="radio"]:checked');if(F.length===0){I.find(".reason").addClass("invalid").find(".invalidInfo").text(l.spamReasonInvalidInfo);G=false;return false}else{I.find(".reason").removeClass("invalid").find(".invalidInfo").text("")}var D=I.find('.message textarea[name="message"]');if(F.length>0&&D.length>0){var H=D.val();if(F.val()==="3"&&(H===""||H===l.spamTextEmptyValue)){I.find(".message").addClass("invalid").find(".invalidInfo").text(l.spamTextInvalidInfo);G=false;return false}else{I.find(".message").removeClass("invalid").find(".invalidInfo").text("")}}if(jQuery("#imageCodeImg-input").val()==""){var K=I.find(".imageCodeImg").addClass("invalid").find(".invalidInfo").text("Przepisz kod z obrazka");G=false;return false}if(G===true){g.animate({opacity:0.5},{duration:l.slideSpeed});return true}return false},success:function(D){g.animate({opacity:1});g.hide();n.hide();switch(D.status){case"ok":s();o.show();setTimeout(function(){o.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})},l.infoDelay);break;case"error":if(D.code=="0"){m.show();setTimeout(function(){m.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})},l.infoDelay);break}default:y.show();setTimeout(function(){g.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})},l.infoDelay);break}},error:function(D,F,E){g.animate({opacity:1});g.hide();n.hide();y.show();setTimeout(function(){g.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed})},l.infoDelay)}})};var w=function(){g.animate({height:"hide",opacity:"hide"},{duration:l.slideSpeed});g.queue(function(){s();jQuery(this).dequeue()})};var s=function(){n.resetForm().find(".invalid").removeClass("invalid").end().find(".invalidInfo").text("").end().find(".message textarea").val(l.spamTextEmptyValue).end().find("#imageCodeImg-input").val("").end().find("#imageCodeImgRefresh").click()};jQuery(document).ready(function(){t(q)})};