overlay={};function doPaneAction(D,A,F,H,G,C,B){var E=new Ajax("/"+A+"/"+F,{method:D,update:$(H),onRequest:function(){var J=$(H).getSize().size.x;var L=$(H).getSize().size.y;var K=$(H).getPosition().x;var I=$(H).getPosition().y;if(!B){overlayBgColor=$("body").getStyle("background-color");if((!overlayBgColor)||(overlayBgColor=="transparent")){overlayBgColor="#ffffff"}overlay[H]=new Element("div",{styles:{opacity:"0.8",width:J+"px",height:L+"px","text-align":"center","z-index":20000,position:"absolute",top:I+"px",left:K+"px","background-color":overlayBgColor}});if(C){overlay[H].setStyles({position:"relative",top:"0px",left:"0px"})}loadingImg=new Element("img",{id:"loadingImg",src:"/images/loading.gif"});loadingImg.injectInside(overlay[H]);if(!C){overlay[H].injectInside($("body"))}else{overlay[H].injectInside(H)}loadingImgHeight=66;loadingImgTop=(L-loadingImgHeight)/2;if(window.ie6){loadingImgTop=0}loadingImg.setStyles({position:"relative",top:loadingImgTop+"px"})}},onComplete:function(){if((!C)&&(!B)){overlay[H].remove()}},evalScripts:true,evalResponse:false,data:G}).request()}function doPaneActionMulti(C,A,E,F,G){var B=Ajax.extend({onComplete:function(){if(this.options.update){$each(this.options.update,function(I,H){I.empty().setHTML(this.response.text)},this)}if(this.options.evalScripts||this.options.evalResponse){this.evalScripts()}this.fireEvent("onComplete",[this.response.text,this.response.xml],20)}});var D=new B("/controller.php?model="+C+"&view="+A+"&action="+E+F,{method:"get",update:$$("#"+G),onRequest:function(){$(G).empty().setHTML('<img id="loadingImg" src="images/loading.gif" />');$("loadingImg").setStyle("position","absolute");$("loadingImg").setStyle("top",(window.getHeight()/3));$("loadingImg").setStyle("left",((window.getWidth()/2)-($("loadingImg").getCoordinates()["width"]/2)))},evalScripts:true,evalResponse:false}).request()}function obscure(B){var A=new Fx.Style(B,"opacity").start(1,0.2,{duration:500})}function unobscure(A){$(A).setOpacity(1)}function getCategories(B,A){doPaneAction("get","submit","categories","categoriesDiv",{articleTypeID:B,languageID:A,submission_method:$("submission_method").value,current_master_category_id:$("current_master_category_id").value})}function suffixToArticleTypeID(A,B){allowedExtensions=new Array();allowedExtensions[1]=["doc","txt","rtf","wps","docx","odt","wpd"];allowedExtensions[2]=["mpeg","mpg","avi","wmv","mov","3gp","mp4"];allowedExtensions[3]=["mp3","wav","wma"];allowedExtensions[4]=["jpg","jpeg","gif","png"];filename=$(A).value;suffix=filename.substring(filename.lastIndexOf(".")+1);suffix=suffix.toLowerCase();if(((filename=="")||(filename==null))&&($(B).value==null)){$(B).value=0;return false}else{for(i=1;i<=4;i++){if(allowedExtensions[i].contains(suffix)){$(B).value=i;return true}}}}function switchCategories(){if($("is_file").value=="1"){suffixToArticleTypeID("article_file","article_type_id")}getCategories($("article_type_id").value,$("language").value)}function confirmDeleteArticle(A,C,D,B){obscure(C);ret=confirm(A);if(ret){doPaneAction("post","content","delete-article",B,D)}else{unobscure(C)}}function confirmDeleteDraft(A,B,C){obscure(B);ret=confirm(A);if(ret){doPaneAction("post","content","delete-draft","draftsDiv",C)}else{unobscure(B)}}function confirmDeletePublishedArticle(A,B,C){obscure(B);ret=confirm(A);if(ret){doPaneAction("post","content","delete-published-article","publishedContentDiv",C)}else{unobscure(B)}}function confirmDeleteComment(A,B,C){obscure(B);ret=confirm(A);if(ret){doPaneAction("post","content","spam-comment","commentsDiv",C)}else{unobscure(B)}}function setIsFile(B,A){if($(A).value!=""){$(B).value="1"}else{$(B).value="0"}}function deleteWriterMessage(B){var A;var D={writer_message_id:B};var C=new Json.Remote("/community/delete-message",{method:"post",onComplete:function(E){A=E.success}}).send(D);return A}function confirmDeleteMessage(A,B,C){obscure(B);ret=confirm(A);if(ret){doPaneAction("post","community","delete-message","inboxDiv",C)}else{unobscure(B)}}function confirmBlockUserMessages(A,B,C){obscure(B);ret=confirm(A);if(ret){doPaneAction("post","community","block-user-messages","inboxDiv",C)}else{unobscure(B)}}function confirmRemoveFriend(A){ret=confirm(A);if(ret){return true}else{return false}}function messageSent(C,B,A){$$("#"+B).getLast().setHTML(A);setTimeout('messageSentRemove("'+C+'","'+B+'")',500)}function messageNotSent(C,B,A){$$("#"+B).getLast().setHTML(A)}function messageSentRemove(B,A){$$("#"+B).getLast().value="";$$("#"+A).getLast().empty();TB_remove()}function sendWriterMessage(K,B,G,H,D,E,C,I,J,F){if(G.trim()!=""){var A=new Ajax("/community/process-send-message/",{method:"post",onSuccess:function(){messageSent(C,I,J)},onFailure:function(){messageNotSent(C,I,F)},evalScripts:true,evalResponse:true,data:"from_writer_id="+K+"&to_writer_id="+B+"&body="+escape(G)+"&privacy_level="+H+"&reply_to_writer_message_id="+D}).request()}else{}}function turnToPassword(){$("shmasword").setStyle("display","none");$("password").setStyle("display","block");$("password").focus()}function markPayment(A){$$(".markedPayment").forEach(function(C,B){C.removeClass("markedPayment")});if($defined(A)){$(A).toggleClass("markedPayment")}}function saveDraft(){$("html").value=tinyMCE.activeEditor.getContent();$("submitForm").send({update:"draftSaveDiv",onComplete:draftSaved})}function draftSaved(){response=Json.evaluate($("draftSaveDiv").innerHTML);$("article_id").value=response.article_id;$("draftSaveMessageDiv").setHTML(response.message)};
