Object.extend(Event,(function(){var a={};return{delegate:function(d,c){var g={};if(arguments[3]){g[arguments[2]]=arguments[3]}else{g=Object.extend({},arguments[2])}var e=$(d),f=c,h=e.identify?e.identify():"document";if(!a[h]){a[h]={"$observer":function(n){var m=n.element();if(a[h][n.type]){for(var l=0,k=a[h][n.type].length;l<k;l++){for(var j in a[h][n.type][l]){if(a[h][n.type][l][j][1].match(m)){a[h][n.type][l][j][0](n)
}}}}}}}if(!a[h][f]){a[h][f]=[];e.observe(f,a[h]["$observer"])}for(var b in g){g[b]=[g[b],new Selector(b)]}a[h][f].push(g);return e},stopDelegating:function(f,h){if(f===undefined){for(var b in a){Event.stopDelegating(b=="$document"?document:b)}a={};return true}var l=false;if(Object.isString(arguments[2])){l={};l[arguments[2]]=true}else{if(arguments[2]){l=arguments[2]}}var d=$(f),k=h,b=d.identify?d.identify():"$document";
if(a[b]){if(k&&a[b][k]){for(var g=0,j=a[b][k].length;g<j;g++){if(l){for(var e in l){delete a[b][k][g][e]}}if(!l||$H(a[b][k][g]).any()==false){d.stopObserving(k,a[b]["$observer"]);a[b][k][g]="r"}}a[b][k]=a[b][k].without("r")}else{for(var c in a[b]){if(c!="$observer"){d.stopObserving(c,a[b]["$observer"])}}delete a[b]}}return d}}})());Element.addMethods({delegate:Event.delegate,stopDelegating:Event.stopDelegating});
document.delegate=Event.delegate.curry(document);document.stopDelegating=Event.stopDelegating.curry(document);Event.observe(window,"unload",Event.stopDelegating);Comments={TOP_COMMENTS_CONTAINER:"commentsContainer",APPROVED_COMMENTS_CONTAINER:"commentList",UNAPPROVED_COMMENTS_CONTAINER:"unapprovedComments",RESPOND_FORM:"commentRespond",FILTERING_ELEMENT:"voteFilter",REUSABLE_ELEMENTS_CONTAINER:"reusableElements",VOTES_LIMIT:-5,resourceId:null,postingUrl:null,votingUrl:null,commentsManagementUrl:null,params:{},topContainer:null,container:null,replyForm:null,commentReplyRel:null,payForUnban:false,setParam:function(a,b){this.params[a]=b
},respond:function(a){if(message=this.checkBan()){if(this.payForUnban){if(confirm(message)){window.location.href="/abuse/index/unban"}return}else{alert(message);return}}if(oldLocation=this.replyForm.up("li")){oldLocation.down(".respond").show()}var b=this.replyForm.down("textarea").value="";a.element().hide();a.element().up("li").down(".content").insert(this.replyForm);this.replyForm.focusFirstElement();
this.commentReplyRel=a.element().readAttribute("rel")},vote:function(c){if(message=this.checkBan()){if(this.payForUnban){if(confirm(message)){window.location.href="/abuse/index/unban"}return}else{alert(message);return}}var b=c.element();var a=b.className.replace("vote ","").strip();var d={resourceId:this.resourceId,commentId:b.readAttribute("rel"),type:a};Object.extend(d,this.params);new Ajax.Request(this.votingUrl,{method:"post",parameters:Object.toQueryString(d),overlayer:{id:this.container},onSuccess:function(f){if(!parseInt(f.responseText)){return
}var g=b.adjacent("span").first();var e=parseInt(g.innerHTML);e+=(a=="pozitive"?1:-1);g.update((e>0?"+":"")+e).className=(e<0?"negativs":"pozitivs");if(e<this.VOTES_LIMIT&&!b.up("li").hasClassName("inappropiate")){b.up("li").addClassName("inappropiate")}}.bind(this)})},sendResponse:function(a){if(!this.replyForm.findFirstElement().value.strip().length){return}try{var b=Paginators.get("Comments").getCurrentPage()
}catch(c){var b=1}$("infoBox").hide();var d=this.replyForm.serialize(true);d.resourceId=this.resourceId;d.rel=this.commentReplyRel;d.page=b;Object.extend(d,this.params);new Ajax.Request(this.postingUrl,{method:"post",parameters:Object.toQueryString(d),overlayer:{id:this.overlayElement},onSuccess:function(e){$(this.REUSABLE_ELEMENTS_CONTAINER).insert(this.replyForm);$(this.container).update(e.responseText.evalJSON().results)
}.bind(this)})},sendComment:function(b){if(message=this.checkBan()){if(this.payForUnban){if(confirm(message)){window.location.href="/abuse/index/unban"}return}else{alert(message);return}}var a=b.element().up("form");if(!a.comment.value.strip().length){return}$("infoBox").hide();var c=a.serialize(true);c.resourceId=this.resourceId;Object.extend(c,this.params);new Ajax.Request(this.postingUrl,{method:"post",parameters:Object.toQueryString(c),overlayer:{id:this.overlayElement},onSuccess:function(d){$(this.container).update(d.responseText.evalJSON().results);
a.comment.value="";alert("Comentariul tau va aparea pe site dupa moderarea de catre administrator!")}.bind(this)})},cancelCommentResponse:function(a){a.element().up("li").down(".respond").show();$(this.REUSABLE_ELEMENTS_CONTAINER).insert(a.element().up("form"));this.commentReplyRel=null},showComment:function(a){a.element().up("li").toggleClassName("inappropiate")},approveComment:function(a){var b={resourceId:this.resourceId,commentId:a.findElement("a").readAttribute("rel"),task:"approve"};
Object.extend(b,this.params);new Ajax.Request(this.commentsManagementUrl,{method:"get",parameters:Object.toQueryString(b),overlayer:{id:this.overlayElement},onSuccess:function(d){var c=d.responseText;if(c.length){c=c.evalJSON();if(!Object.isUndefined(c.results)){$(this.container).update(c.results)}}this.removeUnapprovedComment(a,true)}.bind(this)})},deleteComment:function(a){var b={resourceId:this.resourceId,commentId:a.findElement("a").readAttribute("rel"),task:"delete"};
Object.extend(b,this.params);new Ajax.Request(this.commentsManagementUrl,{method:"get",parameters:Object.toQueryString(b),overlayer:{id:this.overlayElement},onSuccess:function(c){this.removeUnapprovedComment(a,true)}.bind(this)})},removeUnapprovedComment:function(a,c){var b=a.element().up("ol");if(b.childElements().size()==1&&c){b.up("div").hide()}a.element().up("li").remove()},setFilter:function(a){var c=Paginators.get("Comments");
var b=c.getParameters();b.set("resourceId",this.resourceId);b.set("properties",this.properties);b.set(this.FILTERING_ELEMENT,a.element().value);c.refresh(b)},checkBan:function(){var a=$("commentsBan").innerHTML;if(a){a=$("banMessage").innerHTML;if(/\|[0-9]+/.match(a)){a=a.replace(/\|[0-9]+/,"");this.payForUnban=true}}return a},attachListeners:function(a,b){this.container=(a||this.APPROVED_COMMENTS_CONTAINER);
this.unapprovedContainer=(b||this.UNAPPROVED_COMMENTS_CONTAINER);if(!$(this.container)){return}this.overlayElement=($(this.TOP_COMMENTS_CONTAINER)?this.TOP_COMMENTS_CONTAINER:this.container);$(document).delegate("click",{"a#sendComment span":this.sendComment.bindAsEventListener(this),"a.respond":this.respond.bindAsEventListener(this),"a.vote":this.vote.bindAsEventListener(this),"a.btnReply span":this.sendResponse.bindAsEventListener(this),"a.btnCancel span":this.cancelCommentResponse.bindAsEventListener(this),"a.btnApprove span":this.approveComment.bindAsEventListener(this),"a.btnDelete span":this.deleteComment.bindAsEventListener(this),"a.showComment":this.showComment});
if($(this.FILTERING_ELEMENT)){$(this.FILTERING_ELEMENT).observe("change",this.setFilter.bindAsEventListener(this))}this.replyForm=$(this.RESPOND_FORM)}};var Paginators={paginators:new Hash(),group:new Hash(),add:function(b,a){this.paginators.set(b,a);if(Object.isUndefined(this.group.get(b))){this.group.set(b,[a])}else{this.group.get(b).push(a)}return a},get:function(a){a=a||"default";return this.paginators.get(a)
},getGroup:function(a){a=a||"default";return this.group.get(a)}};var Paginator=Class.create({sliderMinWidth:20,STYLE_SEO:"pagination-seo",STYLE_CLASSIC:"pagination-lite",STYLE_SLIDER:"pagination-slider",initialize:function(e,f,b){this.group=e||"default";Paginators.add(this.group,this);this.uniqueId=this.group+f;this.handler=b;this.handler.parameters=$H(this.handler.parameters);this.currentPage=this.handler.config.currentPage;
this.totalPages=this.handler.config.totalPages;this.page=null;this.refreshPagination=false;this.loading=false;if(this.totalPages>1){this.visible=true}else{this.hide()}var d=new RegExp("(pagination-(seo|lite|slider))","g");var c=$("paginationContainer_"+this.uniqueId).className;var a=d.exec(c);if(a){this.style=a[1]}else{this.style=this.STYLE_SLIDER}if(this.style!=this.STYLE_SEO){this.goTo=$("goTo_"+this.uniqueId);
if(this.style==this.STYLE_SLIDER){this.initSlider()}}},initSlider:function(){this.navigationBar=$("navigationBar_"+this.uniqueId);this.slider=$("slider_"+this.uniqueId);this.leftArrow=$("left_"+this.uniqueId);this.rightArrow=$("right_"+this.uniqueId);this.pageNumber=$("pageNumber_"+this.uniqueId);if(this.visible){this.calculateWidths(true)}this.mouseXPos=0;this.clickXPos=0;this.startPos=0},calculateWidths:function(){this.barWidth=this.navigationBar.getWidth();
this.sliderWidth=this.barWidth/this.totalPages;if(this.sliderWidth<this.sliderMinWidth){this.sliderWidth=this.sliderMinWidth;this.stepWidth=(this.barWidth-this.sliderWidth)/this.totalPages}else{this.stepWidth=this.sliderWidth}this.slider.style.width=this.sliderWidth+"px";this.moveSlider("init",this.currentPage)},addListeners:function(a){if(this.style==this.STYLE_SEO){return}if(!a){this.bGoToPage=this.goToPage.bindAsEventListener(this)
}if(this.style==this.STYLE_CLASSIC){Event.observe("form_goTo_"+this.uniqueId,"submit",this.bGoToPage)}else{if(!a){this.bClickOnBar=this.clickOnBar.bindAsEventListener(this);this.bMoveLeft=this.moveLeft.bindAsEventListener(this);this.bMoveRight=this.moveRight.bindAsEventListener(this);this.bMouseDown=this.mouseDown.bindAsEventListener(this)}Event.observe(this.navigationBar.identify(),"mousedown",this.bClickOnBar);
Event.observe(this.leftArrow.identify(),"click",this.bMoveLeft);Event.observe(this.rightArrow.identify(),"click",this.bMoveRight);Event.observe("lnk_"+this.goTo.identify(),"click",this.bGoToPage);Event.observe(this.slider.identify(),"mousedown",this.bMouseDown)}},findPos:function(a){var b=curtop=0;if(a.offsetParent){b=a.offsetLeft;curtop=a.offsetTop;while((a=a.offsetParent)){b+=a.offsetLeft;curtop+=a.offsetTop
}}return[b,curtop]},getXOffset:function(){var b=this.findPos(this.navigationBar);var a=this.mouseXPos-b[0];if(a<0){a=0}if(a>=this.barWidth){a=this.barWidth}return a},getTargetPage:function(b){switch(b){case"click":var c=this.getXOffset();var d={page:Math.ceil(this.totalPages*(c/this.barWidth)),xOffset:c};if(d.page>this.currentPage){d.page=this.currentPage+1}if(d.page<this.currentPage){d.page=this.currentPage-1
}return d;break;default:var a;if((a=this.startPos+(this.mouseXPos-this.clickXPos))<=this.barWidth&&a>=18){a=(a<(this.barWidth/2)?a-9:a+9);return{page:Math.ceil(this.totalPages*((a-9)/this.barWidth))}}else{if(a<18){return{page:1}}return{page:this.totalPages}}break}},updateCaption:function(a){this.page=a;$(this.pageNumber).update(a+"/"+this.totalPages)},moveSlider:function(b,d){if(this.style!=this.STYLE_SLIDER){return
}var c=(d?{page:parseInt(d)}:this.getTargetPage(b,d));if(!c.page){return null}else{if(b=="click"||d){if(Object.isUndefined(this.stepWidth)){return}this.slider.style.left=(18+(c.page-1)*parseFloat(this.stepWidth))+"px"}else{var a;var e=(this.mouseXPos-this.clickXPos);if((a=this.startPos+e)>18&&a<(this.barWidth-this.sliderWidth+18)){this.slider.style.left=a+"px"}}}this.currentPage=d;this.updateCaption(c.page)
},clickOnBar:function(a){this.mouseXPos=Event.pointerX(a);this.moveSlider("click");this.go()},mouseDown:function(a){Event.stop(a);this.clickXPos=Event.pointerX(a);this.startPos=parseFloat(this.slider.style.left);this.bMouseMove=this.mouseMove.bindAsEventListener(this);this.bMouseUp=this.mouseUp.bindAsEventListener(this);Event.observe(document.body,"mousemove",this.bMouseMove);Event.observe(document.body,"mouseup",this.bMouseUp)
},mouseMove:function(a){this.mouseXPos=Event.pointerX(a);this.moveSlider()},mouseUp:function(a){Event.stopObserving(document.body,"mousemove",this.mouseMoveBinded);if(!this.page){return}Event.stopObserving(document.body,"mousemove",this.bMouseMove);Event.stopObserving(document.body,"mouseup",this.bMouseUp);this.slider.style.left=18+(this.page-1)*this.stepWidth+"px";this.go()},moveLeft:function(a){if(this.currentPage==1){Event.stop(a);
return}var b=this.currentPage;this.slider.style.left=18+(b-2)*this.stepWidth+"px";this.updateCaption(--b);this.go(b)},moveRight:function(a){if(this.currentPage==this.totalPages){Event.stop(a);return}var b=this.currentPage;this.slider.style.left=18+b*this.stepWidth+"px";this.updateCaption(++b);this.go(b)},goToPage:function(b){b.stop();var a=parseInt(this.goTo.value);if((0<a)&&(a<=this.totalPages)){this.moveSlider("goTo",a);
this.go(a)}else{this.goTo.select()}},go:function(page){if(this.loading){return}if(this.style==this.STYLE_CLASSIC){window.location.replace(this.handler.url+"?"+(this.handler.queryString.length?this.handler.queryString+"&":"")+"page="+page);return}this.loading=true;if(!page){page=this.page}var createHandler=eval(this.handler.onCreate)||Prototype.emptyFunction;var failureHandler=eval(this.handler.onFailure)||Prototype.emptyFunction;
this.handler.parameters.set("page",page);this.handler.parameters.set("paginator",this.group);if(this.refreshPagination){this.handler.parameters.unset("cacheId");this.handler.parameters.set("refreshPagination",this.group)}else{this.handler.parameters.unset("refreshPagination")}createHandler(this);this.handler.parameters.each(function(item){if(item.value&&item.value.toString()=="[object Object]"){this.unset(item.key);
$H(item.value).each(function(it){var newKey=item.key+"["+it.key+"][]";this.set(newKey,it.value)},this)}},this.handler.parameters);var ajaxParameters={method:"get",parameters:this.buildQueryString(this.handler.parameters),onSuccess:function(tr){var successHandler=!(Object.isFunction(this.handler.onSuccess))?eval(this.handler.onSuccess)||Prototype.emptyFunction:this.handler.onSuccess;var response=null;
try{response=tr.responseText.evalJSON()}catch(ex){if(window.console){window.console.error("The pagination response is not a valid JSON")}}this.loading=false;try{successHandler(tr,response);this.handleUpdate(response)}catch(ex){if(window.console){console.log(ex)}}}.bind(this),onFailure:function(tr){this.loading=false;failureHandler(tr)}};if(!Object.isUndefined(this.handler.parameters.get("overlayer"))){ajaxParameters.overlayer={id:this.handler.parameters.get("overlayer"),autoReposition:!this.handler.fixedHeight}
}else{if(this.handler.update){ajaxParameters.overlayer={id:this.handler.update,autoReposition:!this.handler.fixedHeight}}}if(this.handler.message){ajaxParameters.message=this.handler.message}new Ajax.Request(this.handler.url,ajaxParameters);this.currentPage=page;this.updateFriends(page)},handleUpdate:function(a){if(this.handler.update){$(this.handler.update).update(a.results)}if(this.refreshPagination){Paginators.getGroup(this.group).each(function(b){b.rewind(a.handler.config);
b.setParameters(a.handler.parameters)});this.refreshPagination=false}},refresh:function(a){this.refreshPagination=true;if(!Object.isUndefined(a)){if(!Object.isHash(a)){throw ("'newParameters' must be a Hash object!")}this.setParameters(a);this.currentPage=0;var b=a.get("page");if(Object.isUndefined(b)){this.go(1)}else{this.go(b)}}else{this.go(this.currentPage)}},getHandler:function(){return this.handler
},setHandler:function(a){this.handler=a},setParameters:function(a){this.handler.parameters=$H(a);this.handler.queryString=this.buildQueryString(this.handler.parameters)},getParameters:function(){return this.handler.parameters},getCurrentPage:function(){return this.currentPage},updateFriends:function(a){$A(Paginators.getGroup(this.group)).each(function(b){b.moveSlider("goTo",a)})},hide:function(){$("paginationContainer_"+this.uniqueId).hide();
this.visible=false},show:function(){if(this.visible==false){$("paginationContainer_"+this.uniqueId).show();this.visible=true}},rewind:function(a){if(parseInt(a.totalPages)<2){this.hide()}else{this.show();this.totalPages=a.totalPages;this.currentPage=(a.currentPage?a.currentPage:1);this.calculateWidths();this.moveSlider("rewind",(a.currentPage?a.currentPage:1))}},buildQueryString:function(a){var b=[];
$H(a).each(function(c){if(Object.isArray(c.value)){c.value.each(function(d){b.push(c.key+"[]="+encodeURIComponent(d))})}else{b.push(c.key+"="+encodeURIComponent(c.value))}});return b.join("&")},_garbageCollector:function(){Event.stopObserving(this.navigationBar.identify(),"mousedown",this.bClickOnBar);Event.stopObserving(this.leftArrow.identify(),"click",this.bMoveLeft);Event.stopObserving(this.rightArrow.identify(),"click",this.bMoveRight);
Event.stopObserving("lnk_"+this.goTo.identify(),"click",this.bGoToPage);Event.stopObserving(this.slider.identify(),"mousedown",this.bMouseDown)}});Event.observe(document,"dom:loaded",init);function init(){document.delegate("click",{"#createPermalink":createPermalink,"#verifyPermalink":verifyPermalink,"#insideFeedbackLink":toggleFeedbackForm})}function createPermalink(){if($F("title").length){var b=new RegExp(/[@#$%^&*=+|{}\[\]~`:;\"'<>\.,?!\s]+/ig);
var c=$F("title");var a=c.replace(b,"-").toLowerCase();$("permalink").value=a}}function verifyPermalink(){new Ajax.Request("/help/index/verify.ajax",{method:"POST",parameters:{object:"permalink",content:$("permalink").value},onSuccess:function(a){if(a.responseText=="ok"){alert("Permalink-ul generat este valid!")}else{alert("Permalink-ul generat NU este valid!")}}})}function searchUsingKeywords(){var a=$("oldUrl").value;
var b=$("myKeywords").value;url1=b.replace(/ /g,"+");url2=".html";window.location=a+url1+url2;return false}function addPost(a){$(a).submit()}function editPost(a){if($("permalink").value!=undefined){var d=$("permalink").value;if(d==""||d.match(/[@#$%^&*=+|{}\[\]~`:;\"'<>,?!\s]+/i)){$("error1").update("Campul autor accepta doar caracterele: [a-z], [A-Z], [0-9], [_-]!");b=0}}var e=$("title").value;var c=$("newContent").value;
var b=1;$("error1").update("");$("error2").update("");$("error3").update("");if(e==""||e.match(/[@#$%^&*=+|{}\[\]~`:;\'<>]+/i)){$("error2").update("Campul titlu accepta doar caracterele: [a-z], [A-Z], [0-9], [_-]!");b=0}if(b==1){$(a).submit()}}function voteItem(a,b){new Ajax.Request("/help/index/vote.ajax",{method:"POST",parameters:{item_id:a,mark:b},onSuccess:function(d){if(d.responseText=="VOTE_NOT_VALID"){alert("Nu ai voie sa dai mai mult de un vot pe zi!")
}else{var c=d.responseText.split("__");if(c[0]=="VOTED"){c=c[1].evalJSON();markStars(c);updateMarkData(c.average,c.nr_votes)}}}})}function updateMarkData(b,a){$("average_container").innerHTML=b;$("nr_votes_container").innerHTML=a}function markStars(b){try{var a=$w($("voteItem").className);$("voteItem").removeClassName(a[1]);$("voteItem").addClassName("star_"+b.mark);$("votesNr").innerHTML=b.nr_votes;
$("votesAvg").innerHTML=b.average}catch(c){}}function trim(a){newstring=a.replace(/^(\s)*/,"");newstring=newstring.replace(/(\s)*$/,"");return newstring}function deleteContent(b,d,c){var a=b+"/help/index/delete-content/?id="+c+"&redirect="+d+"&ytiruces="+deleteToken;if(confirm("Stergi acest articol ?")==true){window.location=a}else{return false}return false};
