function loginSubmit(){$("#loginform").ajaxSubmit({success:function(a,b){$("#login").html(a);if($("#imp").html()!=null){location.href="/"}}});return false}function logout(){$("#login").load("/login.php?action=logout",{},function(){Com.manageRem();if($("#imp").html()!=null){location.href="/"}})}function rateSubmit(){$("#vote-echo").html(" ");if(!$("input.star:checked").length){alert("Вы не поставили оценку! Пожалуйста, поставте оценку и попробуйте снова.")}else{$("#rateForm").ajaxSubmit({success:function(a,b){$("#vote-echo").html(a);if($("#voteResAv").html()!=null){$("#voteAv").html($("#voteResAv").html())}if($("#voteResNum").html()!=null){$("#voteNum").html($("#voteResNum").html())}}})}}var Com={pages:1,items:0,conf:{min:3,max:8,pag:false,own:false},labels:{items:"Комментарии",all:"Все комментарии",left:"Оставить комментарий"},reply:function(a){$("#comText").val("[b]"+a+"[/b], "+$("#comText").val());$("#comText").focus()},submit:function(){$("#comSubmit").get(0).onclick=function(){};if($("#comText").val()==""){alert("Вы ничего не написали!");$("#comSubmit").get(0).onclick=function(){Com.submit()};return false}cText=$("#comText").val();if(Com.conf.pag&&Com.pages>1){Com.goPage(1)}$.post("/ajax.php?func=comAdd",{id_tb:Com.id_tb,tbname:Com.tbname,com:cText},function(a){parseData(a);if(a.echo){if(Com.conf.pag){if($("#comments > .com:gt("+Com.conf.max+")").length>0){$("#comments > .com:gt("+Com.conf.max+")").slideToggle("slow",function(){$("#comments > .com:gt("+Com.conf.max+")").remove();Com.get(a.echo);$("#com-pagination").remove();Com.items+=1;Com.pages=Math.floor((Com.items-1)/(Com.conf.max+2))+1;$(Com.pagination(1,Com.pages)).appendTo("#comments").slideDown("slow")})}else{Com.get(a.echo);Com.items+=1;Com.pages=Math.floor((Com.items-1)/(Com.conf.max+2))+1;if(Com.pages>1){$("#com-pagination").remove();$(Com.pagination(1,Com.pages)).appendTo("#comments").slideDown("slow")}}}else{if(document.URL.indexOf("/com/")==-1){if($("#comments > .com:gt("+Com.conf.min+")").length>0){$("#comments > .com:gt("+Com.conf.min+")").slideToggle("slow",function(){$("#comments > .com:gt("+Com.conf.min+")").remove();Com.get(a.echo);if($("#comments").parent().find(".showAll").html()==null){var c=(document.URL.indexOf("/pub/")==-1&&document.URL.indexOf("/actor/")==-1)?"serial/":"";var b=baseURL+"com/"+c+document.URL.substring(baseURL.length,document.URL.indexOf(".html"))+"/0/";$("#comments").after("<br /><a href='"+b+"' class='showAll'>"+Com.labels.all+"</a>")}})}else{Com.get(a.echo)}}else{if($("#comments > .com:gt("+Com.conf.max+")").length>0){$("#comments > .com:gt("+Com.conf.max+")").slideToggle("slow",function(){$("#comments > .com:gt("+Com.conf.max+")").remove();Com.get(a.echo)})}else{Com.get(a.echo)}}}}else{$("#comSubmit").get(0).onclick=function(){Com.submit()}}},"json")},update:function(a){$("#comSubmit").get(0).onclick=function(){};if($("#comText").val()==""){alert("Вы ничего не написали!");$("#comform > input[type='submit']").removeAttr("disabled");return false}$.post("/ajax.php",{func:"comUp",id:a,com:$("#comText").val()},function(b){parseData(b);$("#com-"+a).html(b.com);$("#comSubmit").get(0).onclick=function(){Com.submit()}},"json");this.modeAdd();return false},del:function(a){this.modeAdd();$.getJSON("/ajax.php",{func:"comDel",id:a,table:Com.tbname,own:Com.own},function(b){parseData(b);if(!b.error){if(!Com.conf.pag){$("#com-"+a).parent().parent().slideUp("slow",function(){$(this).remove();if($("div.com").length==0){$("#comwrap").html("")}})}else{Com.items-=1;Com.pages=Math.floor((Com.items-1)/(Com.conf.max+2))+1;Com.goPage(1)}}});return false},get:function(a){$.getJSON("/ajax.php",{func:"comGet",id:a},function(b){Com.manageRem();if($("#comments").html()!=null){$("#comments").prepend(b.echo)}else{$("#comwrap").html('<div class="block col3Left"><h3>'+Com.labels.items+'</h3><div id="comments">'+b.echo+"</div></div>")}$("#comments > .com:first").slideToggle("slow");$("#comText").val("");$("#comSubmit").get(0).onclick=function(){Com.submit()}})},spam:function(a){this.modeAdd();$.post("/spam.php",{com:a},function(b){parseData(b)},"json")},modeUp:function(a){$.getJSON("/ajax.php",{func:"comGetBB",id:a},function(b){$("#comText").val(b.echo)});$("#comText").focus();$("#comSubmit").get(0).onclick=function(){Com.update(a)};$("#comSubmit").html("Редактировать");$("#reAdd").show();$("#comText").focus();return false},modeAdd:function(){$("#comSubmit").get(0).onclick=function(){Com.submit()};$("#comText").val("");$("#comSubmit").html(this.labels.left);$("#reAdd").hide();return false},manageRem:function(){if(Com.conf.own){$(".comup").hide();$(".comup").remove()}else{$(".comup, .comdel").hide();$(".comup, .comdel").remove()}}};Com.pagination=function(b,a){pervpage="";page2left="";page1left="";page1right="";page2right="";nextpage="";if(b!=1){pervpage='<a href="javascript:Com.goPage(1);" title="Первая страница">&laquo;</a><a href="javascript:Com.goPage('+(b-1)+');" title="Предыдущая страница">&lsaquo;</a>'}if(b!=a){nextpage='<a href="javascript:Com.goPage('+(b+1)+');" title="Следующая страница">&rsaquo;</a><a href="javascript:Com.goPage('+(a)+');" title="Последняя страница">&raquo;</a>'}if(b-2>0){page2left='<a href="javascript:Com.goPage('+(b-2)+');" title="Страница '+(b-2)+'">'+(b-2)+"</a>"}if(b-1>0){page1left='<a href="javascript:Com.goPage('+(b-1)+');" title="Страница '+(b-1)+'">'+(b-1)+"</a>"}if(b+2<=a){page2right='<a href="javascript:Com.goPage('+(b+2)+');" title="Страница '+(b+2)+'">'+(b+2)+"</a>"}if(b+1<=a){page1right='<a href="javascript:Com.goPage('+(b+1)+');" title="Страница '+(b+1)+'">'+(b+1)+"</a>"}pages='<div style="display:none;margin-top:10px" id="com-pagination" class="pagination">'+pervpage+page2left+page1left+"<b>"+b+"</b>"+page1right+page2right+nextpage+"</div>";return pages};Com.goPage=function(a){Com.modeAdd();$.getJSON("/pags.php",{func:"comms",page:a,total:Com.pages,table:Com.tbname,tid:Com.id_tb,own:Com.conf.own},function(b){$("div.com").remove();$("#com-pagination").remove();$("#comments").append(b.echo);$("div.com").slideDown("slow");$(Com.pagination(a,Com.pages)).appendTo("#comments").slideDown("slow")})};function parseData(a){w="<ul>";if(a.error){w+='<li style="color:red">'+a.error+"</li>"}if(a.notice){w+='<li style="color:green">'+a.notice+"</li>"}w+="</ul>";warn(w)}function warn(a){if(!$("#warn").html()){$('<div id="warn">'+a+"</div>").appendTo("body").slideDown("normal")}else{$("#warn").html(a).slideDown("normal")}setTimeout(function(){$("#warn").slideUp("normal")},5000)}function slide(b,c){var a=$(b).attr("rel","title");$(b).attr("rel",$(b).html());$(b).html(a);$(c).slideToggle("slow")}function suggestions(c,b,a){$(c).autocomplete("/suggestions.php",{delay:10,matchContains:1,formatItem:a,maxItemsToShow:10,extraParams:{func:b}})}function searchSugg(){$("#search").autocomplete("/suggestions.php",{delay:10,matchContains:1,formatItem:li2c,maxItemsToShow:10,extraParams:{func:"getSugg"}})}function licR(c,b,a){return(parseInt(c[1])>0)?'<span style="width:100%;border-bottom:1px #fff dotted">'+c[0]+"</span>":c[0]}function lic(c,b,a){return c[0]}function li2c(c,b,a){return c[0]+" <span class='qnt'>("+c[1]+")</span>"}function li3c(c,b,a){return c[0]+"<br /> <span class='qnt'>"+c[1]+" "+c[2]+"</span>"}$(document).ready(function(){$("a.actor").mouseover(function(){var b=$(this).offset();var a=baseURL+"images/actors/small_"+$(this).attr("rel");if(typeof $("#actor-frame")[0]=="undefined"){$('<div id="actor-frame"></div>').appendTo("body")}$("#actor-frame").css({top:b.top+$(this).height(),left:b.left+Math.round($(this).width()/4)}).html('<img src="'+a+'" />').show()}).mouseout(function(){$("#actor-frame").hide()});$("a.serial").mouseover(function(){var b=$(this).offset();var a=baseURL+"images/posters/small_"+$(this).attr("rel");if(typeof $("#serial-frame")[0]=="undefined"){$('<div id="serial-frame"></div>').appendTo("body")}$("#serial-frame").css({top:b.top+$(this).height(),left:b.left+Math.round($(this).width()/4)}).html('<img src="'+a+'" />').show()}).mouseout(function(){$("#serial-frame").hide()})});