function getCats(){var b=$("#cat_id_prev").val();$("#subcat-select").removeOption(/./);$("#cat-select").addOption(0,"(выберите раздел)");var a=0;for(a in cats){if(typeof cats[a]!="function"){$("#cat-select").addOption(a,cats[a])}}if(b==""){b="0"}$("#cat-select").selectOptions(b)}function getdCats(){var b=$("#dcat_id_prev").val();$("#dsubcat-select").removeOption(/./);$("#dcat-select").addOption(0,"(выберите раздел)");var a=0;for(a in dcats){if(typeof dcats[a]!="function"){$("#dcat-select").addOption(a,dcats[a])}}if(b==""){b="0"}$("#dcat-select").selectOptions(b)}function getAssociatedVendors(c,d){d=typeof(d)!="undefined"?d:false;var a;$(".fix-z-index").bgiframe();if($("#vendor-select").length>0){$("#vendor-select").removeOption(/./);$("#vendor-select").addOption(0,"(выберите производителя)");for(a in assoc_v){if(assoc_v[a]==c){$("#vendor-select").addOption(a,vendors[a])}}if(d==true){var b;b=$("#vendor_id_prev").val();if(b==""){b="0"}$("#vendor-select").selectOptions(b)}else{$("#vendor-select").selectOptions("0",true)}if(c==0){$("#vendor-select").removeOption(/./);$("#vendor-select").addOption(0,"(выберите раздел)");$("#vendor-select").attr("disabled","disabled")}else{$("#vendor-select").attr("disabled","")}}}function getdAssociated(c,d){d=typeof(d)!="undefined"?d:false;var a;$("#dsubcat-select").addOption(0,"(выберите раздел)");for(a in dassoc){if(dassoc[a]==c){$("#dsubcat-select").addOption(a,dsubcats[a])}}if(d==true){var b;b=$("#dsubcat_id_prev").val();if(b==""){b="0"}$("#dsubcat-select").selectOptions(b)}else{$("#dsubcat-select").selectOptions("0",true)}}function getAssociated(c,d){d=typeof(d)!="undefined"?d:false;var a;$("#subcat-select").addOption(0,"(выберите раздел)");for(a in assoc){if(assoc[a]==c){$("#subcat-select").addOption(a,subcats[a])}}if(d==true){var b;b=$("#subcat_id_prev").val();if(b==""){b="0"}$("#subcat-select").selectOptions(b)}else{$("#subcat-select").selectOptions("0",true)}}function setMaxLength(){var a=document.getElementsByTagName("textarea");var d=document.getElementsByName("title");var f=d[0];var b=document.createElement("div");b.className="textarea_counter";for(var c=0;c<a.length;c++){if(a[c].getAttribute("maxlength")){var e=b.cloneNode(true);e.innerHTML="<span>0</span> / "+a[c].getAttribute("maxlength");a[c].parentNode.insertBefore(e,a[c].nextSibling);a[c].relatedElement=e.getElementsByTagName("span")[0];a[c].onkeyup=a[c].onchange=checkMaxLength;a[c].onkeyup()}}if(f&&f.getAttribute("maxlength2")){var e=b.cloneNode(true);e.setAttribute("style","font-size:1px; position:relative; left:0");e.innerHTML='<div style="position:absolute; left:100%; bottom:3px; font-size:11px;"> <span style="padding-left:2px;">0</span></div>';f.parentNode.insertBefore(e,f.nextSibling);f.relatedElement=e.getElementsByTagName("span")[0];f.onkeyup=f.onchange=checkMaxLength2;f.onkeyup()}}function checkMaxLength2(){var a=this.getAttribute("maxlength2");var b=this.value.length;this.relatedElement.firstChild.nodeValue=b}function checkMaxLength(){var a=this.getAttribute("maxlength");var b=this.value.length;if(b>a){this.relatedElement.className="toomuch"}else{this.relatedElement.className=""}this.relatedElement.firstChild.nodeValue=b}function trim(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}$(document).ready(function(){setMaxLength();getAssociatedVendors(0,false);$("img[src$=.png]").pngfix();if($("#cat-select").length>0){getCats();getAssociated($("#cat-select").val(),true);getAssociatedVendors($("#cat-select").val(),true);if($("#cat-select").val()==0){$("#subcat-select").attr("disabled","disabled")}}$("#cat-select").livequery("change",function(){if(this.value){$("#subcat-select").attr("disabled","");$("#subcat-select").removeOption(/./);getAssociated(this.value);getAssociatedVendors(this.value);if($("#cat-select").val()==0){$("#subcat-select").attr("disabled","disabled")}}});if($("#dcat-select").length>0){getdCats();getdAssociated($("#dcat-select").val(),true);if($("#dcat-select").val()==0){$("#dsubcat-select").attr("disabled","disabled")}}$("#dcat-select").livequery("change",function(){if(this.value){$("#dsubcat-select").attr("disabled","");$("#dsubcat-select").removeOption(/./);getdAssociated(this.value);if($("#dcat-select").val()==0){$("#dsubcat-select").attr("disabled","disabled")}}});$("#choose-region").livequery("click",function(){$(".choose-region-list").toggle();return false});$(".switch-tab-all").livequery("click",function(){$(".control-tab").hide();$(".tabs li").removeClass("selected");$(this).parent("li").addClass("selected");$("#control-tab-all").show();return false});$(".switch-tab-bin").livequery("click",function(){$(".control-tab").hide();$(".tabs li").removeClass("selected");$(this).parent().addClass("selected");$("#control-tab-bin").show();return false});$(".switch-tab-drafts").livequery("click",function(){$(".control-tab").hide();$(".tabs li").removeClass("selected");$(this).parent("li").addClass("selected");$("#control-tab-drafts").show();return false});if($("#userselect-search").length){$("#userselect-search").autocomplete({serviceUrl:"/service/userlist",minChars:1,maxHeight:400,width:150,deferRequestBy:50,onSelect:function(c,b){$("#userselect-search").val(b)}})}$("a.confirm_delete").click(function(){return confirm("Подтвердите действие")});$("#schemes .vote, #books .vote").hover(function(){$(this).prevAll().addClass("voteactive");$(this).addClass("voteactive")},function(){$(this).prevAll().removeClass("voteactive");$(this).removeClass("voteactive")});$("#books .vote").click(function(){$.post($(this).attr("href"),{},function(b){$(".book-rating, .book-user-rate").fadeOut(function(){$(".book-rating").css("width",(parseInt(parseFloat(b)*16)+"px"));$(".book-rating, .book-user-rate").fadeIn()})},"text");return false});$("#schemes .vote").click(function(){$.post($(this).attr("href"),{},function(b){$(".scheme-rating, .scheme-user-rate").fadeOut(function(){$(".scheme-rating").css("width",(parseInt(parseFloat(b)*16)+"px"));$(".scheme-rating, .scheme-user-rate").fadeIn()})},"text");return false});$("#yandex").livequery("click",function(){if(this.checked){$("#yandex-text-holder").show()}else{$("#yandex-text-holder").hide()}});$(".select_items").livequery("click",function(){var b=this.checked;$("input[name='items[]']").each(function(){this.checked=b})});$("a.edit-delete-file").livequery("click",function(){if(confirm("Уверены, что хотите удалить файл?")){$.ajax({type:"get",url:$(this).attr("hhref"),success:function(b){$("#del"+b).parent().fadeOut();$("#del"+b).remove()}})}return false});$("#report_submit").click(function(){var b={report_uri:$("#report_uri").val(),report_comments:$("#report_comments").val()};$.ajax({cache:false,data:b,dataType:"text",url:"/service/feedback/",type:"POST",success:function(c,d){if(c=="OK"){$(".fillreport").fadeOut("fast",function(){$(".thanksforreport").fadeIn("fast").animate({opacity:1},1500).fadeOut("fast")})}else{$(".fillreport").fadeOut("fast")}}})});$("a.insert-image").livequery("click",function(){insertImage($(this).children("img").attr("original-src"),$(this).children("img").attr("full-src"));return false});$("a.reporterror").click(function(){$("div.fillreport").toggle();return false});$("a.edit-filename-save").livequery("click",function(){var b=$(this).siblings("#edit-filename-field").val();var c=$(this).parents(".file_f").children(".edit-filename-id").val();if(b!=""){$.ajax({type:"post",url:"/my/files/changename",dataType:"text",data:{newtitle:b,id:c},success:function(d){if(d=="ERROR"){$("#edit-filename-field").css("borderColor","#ff0000")}else{$("#edit-filename-field").css("borderColor","");$("#file"+c).text(d);$(".edit-filename-box").remove();$(".edit-filename-text").show()}},error:function(){$("#edit-filename-field").css("borderColor","#ff0000")}})}return false});$("a.edit-filename-cancel").livequery("click",function(){$(".edit-filename-box").remove();$(".edit-filename-text").show();return false});$("a.edit-filename-text").livequery("click",function(){insertFile($(this).attr("href"),$(this).text());return false});$("a.edit-filename-change").livequery("click",function(){$(".edit-filename-box").remove();var b=$(this).siblings(".edit-filename-text").text();$(this).parent().children().hide();$(this).parent().append('<div class="edit-filename-box"><input type="text" class="text" id="edit-filename-field" value="">  <a href="#" class="edit-filename-save">сохранить имя</a> &mdash; <a href="#" class="edit-filename-cancel">отменить</a></div>');$(this).siblings(".edit-filename-box").children("#edit-filename-field").val(b);return false});$("a.edit-edit-file").livequery("click",function(){$(".edit-filename").children().show();$(".edit-filename-box").remove();var b=$(this).siblings(".edit-filename").children(".edit-filename-text").text();$(this).siblings(".edit-filename").children().hide();$(this).siblings(".edit-filename").append('<div class="edit-filename-box"><input type="text" class="text" id="edit-filename-field" value="">  <a href="#" class="edit-filename-save">сохранить имя</a> &mdash; <a href="#" class="edit-filename-cancel">отменить</a></div>');$(this).siblings(".edit-filename").children(".edit-filename-box").children("#edit-filename-field").val(b);return false});if($(".fileman_form").length>0){$("#fileman_img_form").ajaxForm({type:"post",iframe:true,beforeSubmit:function(b,c,d){$(".fileman_form input:submit").attr("disabled","disabled");$(".fileman_form input").fadeTo("fast",0.5)},success:function(b){if(b!="INVALID_SESSION"&&b!="ERR"){$("#imagemanager").append(b)}else{}$(".fileman_form input").fadeTo("fast",1);$(".fileman_form input").attr("disabled","")},error:function(b){$(".fileman_form input").fadeTo("fast",1);$(".fileman_form input").attr("disabled","")}});$("#fileman_file_form").ajaxForm({type:"post",iframe:true,beforeSubmit:function(b,c,d){$(".fileman_form input:submit").attr("disabled","disabled");$(".fileman_form input").fadeTo("fast",0.5)},success:function(b){if(b!="INVALID_SESSION"&&b!="ERR"){$("#filemanager").append(b)}else{}$(".fileman_form input").fadeTo("fast",1);$(".fileman_form input").attr("disabled","")},error:function(b){$(".fileman_form input").fadeTo("fast",1);$(".fileman_form input").attr("disabled","")}});$(".fileman_form input").attr("disabled","")}$("a.forum_delete_topic").livequery("click",function(){var c=$("#topic_id").val();var b=$("#board_id").val();if(confirm("Подтвердите удаление")){$.ajax({url:"/forum/delete_topic/"+c+"/",type:"post",async:true,error:function(){},success:function(d){if(d=="OK"){window.location.href="/forum/board/"+b+"/"}}})}return false});$("a.forum_delete_post").click(function(){var c=$(this).attr("id");var b=$(this).parents(".post");b.fadeTo("fast",0.3);if(confirm("Подтвердите удаление")){b.fadeTo(0.3);$.ajax({url:"/forum/delete_post/"+c+"/",type:"post",async:true,error:function(){b.fadeTo("fast",1)},success:function(d){if(d=="OK"){b.fadeOut("fast",function(){$(this).remove()})}else{b.fadeTo("fast",1)}}})}return false});$("a.forum_save_topic").livequery("click",function(){var b=$("#topic_title_edit").val();var c=$("#topic_id").val();$(this).fadeTo("fast",0.3);$("#topic_title_edit").css("borderColor","");$.ajax({url:"/forum/edit_topic_title/"+c+"/",type:"post",async:true,data:{new_title:b+""},error:function(){},success:function(d){if(d=="ERR"){$("#topic_title_edit").css("borderColor","red");$("a.forum_save_topic").fadeTo("fast",1)}else{$("#topic_title").html(trim(d)+' <a href="#" class="forum_edit_topic"><img src="/i/fff/pencil.png"></a> <a href="#" class="forum_delete_topic"><img src="/i/fff/delete.png"></a>')}}})});$("a.forum_edit_topic").livequery("click",function(){var b=$("#topic_title").text();var c='<input id="topic_title_edit" style="width:450px" class="text" value="'+trim(b)+'"> <a href="#" class="forum_save_topic"><img class="fff" src="/i/fff/disk.png"></a> <a href="#" class="forum_cancel_topic"><img class="fff" src="/i/fff/cross.png"></a>';$("#topic_title").html(c);$("#topic_default_title").val(b);return false});$("a.forum_cancel_topic").livequery("click",function(){var b=$("#topic_default_title").val();$("#topic_title").html(trim(b)+' <a href="#" class="forum_edit_topic"><img src="/i/fff/pencil.png"></a> <a href="#" class="forum_delete_topic"><img src="/i/fff/delete.png"></a>');return false});$("a#reload_captcha").click(function(){$("#forum img.forum_reply_progress").show();$.ajax({url:"/forum/post/updatecaptcha/",type:"post",async:false,dataType:"json",error:function(){$("img.forum_reply_progress").hide();$("input.forum_reply_action").fadeTo("fast",1);$("input.forum_reply_action").attr("disabled","");$("#form_error").text("Ошибка. Попробуйте через несколько секунд.")},success:function(b){$("#forum img.forum_reply_progress").hide();$("#forum input.forum_reply_action").fadeTo("fast",1);$("#forum input.forum_reply_action").attr("disabled","");$("#form_error").text("Проверьте правильность заполнения полей");$("#form_error").text("");$("#clettrs").val("");$("#csessid").val(b.csessid);$("#csessimg").attr("src","/"+b.csessimg)}});return false});if($("#reply_form").length>0){$("#reply_form").ajaxForm({dataType:"json",beforeSubmit:function(b,d,e){var c=$("#type").val();var g=$("#reply_form").formSerialize();$("#form_error").text("");$(".forum_reply_action").attr("disabled","disabled");$(".forum_reply_progress").show();$(".forum_reply_action").fadeTo("fast",0.5);$("#form_error").text("Отправка...");ajaxResult=false;ajaxResult=true;return ajaxResult},success:function(b){if(b.error=="NO_ERROR"&&parseInt(b.post_id)>0){window.location.href="/forum/findpost/"+b.post_id+"/"}else{$("#form_error").text("");$(".forum_reply_progress").hide();$(".forum_reply_action").fadeTo("fast",1);$(".forum_reply_action").attr("disabled","");switch(b.error){case"WRONG_CAPTCHA":$("#form_error").text("Неверный код подтверждения");$("#clettrs").val("");$("#csessid").val(b.csessid);$("#csessimg").attr("src","/"+b.csessimg);break;case"FIELDS_NOT_FILLED":$("#form_error").text("Проверьте правильность заполнения полей");break;default:$("#form_error").text("Ошибка при публикации ответа")}}}})}$("div.addedhead a").click(function(){$("div.addedcatscont").slideToggle();return false});$("div.edit-filename2").hover(function(){$(".edit-filename-change").remove();if($(this).children(".edit-filename-box").length==0){$(this).append(' <a href="#" class="cat edit-filename-change">изменить</a>')}},function(){$(".edit-filename-change").hide()});$("a.preview-close").livequery("click",function(){$("#preview").fadeOut();$("#wrapper").fadeIn()});$("a.insert_quote").livequery("click",function(){var c=$(this).parents(".post").contents();var d=c.find(".user_name").text();c.find(".posttext").clone().hide().addClass("quotetodestroy").appendTo("body");$(".quotetodestroy blockquote").remove();var b=$(".quotetodestroy").html();$(".quotetodestroy").remove();if($.fck){var e=FCKeditorAPI.GetInstance("fck1");if(!e){var e=FCKeditorAPI.GetInstance("reply_text")}var f="<blockquote><div>"+d+" </div>"+b+" </blockquote>";e.InsertHtml(f)}return false});$("#openpreview").click(function(){$("#wrapper").hide();$("#ajaxload").fadeIn(1000);var d=$("input[name='title']").val();var e=$("textarea[name='teaser']").val();var c=FCKeditorAPI.GetInstance("fck1").GetHTML(true);if($("input[name='jevix']").is(":checked")){var b=1}else{var b=0}$.post("/my/preview/",{teaser:e,description:c,title:d,jevix:b},function(f){$("#ajaxload").fadeOut(function(){$("#preview").fadeIn()});$("#preview").html(f)})});$("#openforumpreview").click(function(){$("#wrapper").hide();$("#ajaxload").fadeIn(1000);var b=$("#topic_title").val();if($.fck){var c=FCKeditorAPI.GetInstance("reply_text").GetHTML(true)}$.post("/forum/preview/",{topic_title:b,reply_text:c},function(d){$("#ajaxload").fadeOut(function(){});$("#preview").fadeIn();$("#preview").html(d.preview);$("#topic_title").val(d.topic_title);FCKeditorAPI.GetInstance("reply_text").SetHTML(d.reply_text)},"json")});$("a.forum-drop-file").livequery("click",function(){var c=parseInt($("#max_files").val());var b=parseInt($("#cur_files").val());b=b-1;$("#cur_files").val(b);if(c>b){$(".forum-attach-file-link").appendTo("#attaches");$(".forum-attach-file-link").show()}else{$(".forum-attach-file-link").hide()}$(this).parent().remove();return false});$(".grey input[type=radio]").livequery("click",function(){$(".grey").removeClass("checked");$(this).parents(".grey").addClass("checked")});$(".grey input[type=radio]:checked").parents(".grey").addClass("checked");$(".grey").click(function(){$(".grey").removeClass("checked");$(this).addClass("checked");$(this).find("input[type=radio]").attr("checked","checked")});$("a.forum-attach-file").livequery("click",function(){var c=parseInt($("#max_files").val());var b=parseInt($("#cur_files").val());if(c>b){$("#attaches").append('<p><input type="file" name="file[]"> <a href="#" class="forum-drop-file ajax">- Удалить файл</a></p>');b++;$("#cur_files").val(b);if(c>b){$(".forum-attach-file-link").appendTo("#attaches");$(".forum-attach-file-link").show()}else{$(".forum-attach-file-link").hide()}}else{alert("Вы уже приложили максимальное количество файлов")}return false});if($.fck){var a=false;$.fck.config={path:"/js/fckeditor/",height:300};if($("textarea.fck").hasClass("fck_user")&&!a){$("textarea.fck").fck({toolbar:"User",height:200,width:590});a=true}if($("textarea.fck").hasClass("fck_guest")&&!a){$("textarea.fck").fck({toolbar:"Guest",height:200,width:590});a=true}if($("textarea.fck").hasClass("fck_comment")&&!a){$("textarea.fck").fck({toolbar:"Comment",height:150,width:590});a=true}if($("textarea.fck").hasClass("fck_admin")&&!a){$("textarea.fck").fck({toolbar:"Default",height:300,width:590});a=true}if(!a){$("textarea.fck").fck()}}});function insertImage(c,b,a){if($.fck){var e=FCKeditorAPI.GetInstance("fck1");if(!e){var e=FCKeditorAPI.GetInstance("reply_text")}if(b==c){var d='<img src="'+b+'">'}else{var d='<a href="'+c+'" target="_blank"><img src="'+b+'"></a>'}e.InsertHtml(d)}}function insertFile(c,b,a){if($.fck){var e=FCKeditorAPI.GetInstance("fck1");if(!e){var e=FCKeditorAPI.GetInstance("reply_text")}var d=' <a href="'+c+'" target="_blank">'+b+"</a> ";e.InsertHtml(d)}};