var tabs_api;function comment_mistify(){var a=Math.floor(Math.random()*1133771);$("div.post_comment form").append("<input type='hidden' value='"+a+"' name='mistify' /> ")}$(function(){function a(){$("span.help img").tooltip({bodyHandler:function(){return $(this).nextAll("span.help_data:first").html()},showURL:false,delay:0,top:0,left:15});$(".comment_tooltip").tooltip({bodyHandler:function(){return $(this).nextAll("span.help_data:first").html()},showURL:false,delay:0,top:0,left:15})}a();$("a.fatal").live("click",function(){var d=$(this).attr("title");if(confirm(d)){return true}else{return false}});if($("select#authors_select").is(":visible")&&$("select#letters_select").is(":visible")){function b(e,d){$.ajax({type:"post",url:"/authors/aj_authors_select",data:"initial="+e+"&author="+d,success:function(f){$("select#authors_select").html(f)}})}$("select#letters_select").change(function(){var d=$(this).find(":selected").text();b(d)})}if(location.hash.match(/^#comment/)){$("div.comments").css("display","block");location.hash=location.hash}$("a.comments_release").live("click",function(){if($("div.comments").is(":visible")){$("div.comments").slideUp("fast")}else{$("div.comments").slideDown("fast")}});$("a.comment_remove").live("click",function(){var f=$(this).parent("div.comment").attr("id");var d=$("div.post_comment form input[name=object]").val();var e=$("div.post_comment form input[name=type]").val();f=f.split("_");f=f[1];$.ajax({type:"post",url:"/comments/remove",data:"type="+e+"&object="+d+"&id="+f,success:function(g){if(g.match(/^error/)){alert(g)}else{$("div#comments_container").html(g);setTimeout("comment_mistify();",6000)}}})});$("div.post_comment form input#comment_submit").live("click",function(){var e=$("div.post_comment form input[name=object]").val();var d=$("div.post_comment form input[name=mistify]").val();var f=$("div.post_comment form input[name=type]").val();var g=$("div.post_comment form textarea[name=text]").val();$.ajax({type:"post",url:"/comments/submit",data:"text="+g+"&type="+f+"&object="+e+"&mistify="+d,success:function(h){if(h.match(/^error/)){alert(h)}else{$("div#comments_container").html(h);setTimeout("comment_mistify();",6000)}}})});setTimeout("comment_mistify();",6000);$("a.actions_plan, a.actions_reading, a.actions_red_it").click(function(){var g=$(this);var f=$(this).attr("class");var d=new Array();d.actions_red_it=1;d.actions_reading=2;d.actions_plan=4;var e=$("form.values input[name=object]").val();$.ajax({type:"post",url:"/books/aj_actions",data:"book_id="+e+"&action="+d[f],success:function(i){if(i.match(/^error/)){alert(i)}else{$("span#action_icons").html(i);a();for(var h in d){if(d[f]<=d[h]){$("a[class="+h+"]").remove()}}}}})});$("a.list_book_out").click(function(){var e=$(this);var d=$(this).attr("rel");$.ajax({type:"post",url:"/books/aj_actions",data:"book_id="+d+"&action=7",success:function(f){if(f.match(/^error/)){alert(f)}else{$(e).parent("li").remove()}}})});$("a[href^=k://]").each(function(){var e=$(this).attr("href");var d=$(this).text();e=e.replace("(?*)","@");e=e.replace("k://","");$(this).text(e);$(this).attr("href","mailto:"+e)});if($("ul.search_tabs").is(":visible")){var c=0;if($("div.panes div.pane:eq(0)").is(":has(ul)")){c=0}else{if($("div.panes div.pane:eq(1)").is(":has(ul)")){c=1}else{if($("div.panes div.pane:eq(2)").is(":has(ul)")){c=2}}}$(function(){$("ul.tabs").tabs("div.panes > div",{initialIndex:c})})}if($("ul.user_pages_tabs").is(":visible")){$("ul.tabs").tabs("div.panes > div.pane")}$("form.navigation_form").submit(function(){if($(this).find("input[name=search]").val()=="Търсене..."||$(this).find("input[name=search]").val()==undefined||$(this).find("input[name=search]").val()==""){alert("Въведете дума за търсене");return false}});$("form.navigation_form input[name=search]").focus(function(){if($(this).val()=="Търсене..."){$(this).attr("value","")}});if($("ul.messages_tabs").is(":visible")){tabs_api=$("ul.tabs").tabs("div.panes > div.pane",{api:true})}$("ul.messages_tabs li a").click(function(){$("div.form_message").slideUp("fast")});$("a.target_new").attr("target","_blank");$("a.message_inbox_delete").click(function(){if(!confirm("Изтриване на съобщението?")){return false}var d=$(this).attr("rel");$.ajax({type:"post",url:"/user/ajax_mark_message_deleted",data:({who:"receiver",id:d}),dataType:"text",success:function(e){$("a[rel=#message_inbox_"+d+"]").parent("li").remove()}})});$("a.message_sent_delete").click(function(){if(!confirm("Изтриване на съобщението?")){return false}var d=$(this).attr("rel");$.ajax({type:"post",url:"/user/ajax_mark_message_deleted",data:({who:"sender",id:d}),dataType:"text",success:function(e){$("a[rel=#message_sent_"+d+"]").parent("li").remove()}})});$("#touched_authors_full_switch").click(function(){$(this).hide();$(this).nextAll("li.touched_authors_full").each(function(d){$(this).show()})})});