var n_cache=[],c_cache=[],comm_id,comm_edit_id,s_id,e_id;function IPMenu(a,c,b,d){var e=[];e[0]='<a href="https://www.nic.ru/whois/?ip='+a+'" target="_blank">'+c+"</a>";e[1]='<a href="'+dle_root+dle_admin+"?mod=iptools&ip="+a+'" target="_blank">'+b+"</a>";e[2]='<a href="'+dle_root+dle_admin+"?mod=blockip&ip="+a+'" target="_blank">'+d+"</a>";return e}function ajax_cancel_for_edit(a){if(n_cache[a]!="")document.getElementById("news-id-"+a).innerHTML=n_cache[a];return false}
function whenCompletedSave(){n_cache[e_id]=""}
function ajax_save_for_edit(a,c){var b=new dle_ajax,d=0,e="";if(document.getElementById("allow_br_"+a).checked)d=1;e_id=a;b.onShow("");e=quick_wysiwyg=="1"?b.encodeVAR($("#dleeditnews"+a).html()):b.encodeVAR(document.getElementById("dleeditnews"+a).value);var f=b.encodeVAR(document.getElementById("edit-title-"+a).value);e="news_txt="+e;b.setVar("id",a);b.setVar("allow_br",d);b.setVar("title",f);b.setVar("reason",b.encodeVAR(document.getElementById("edit-reason-"+a).value));b.setVar("field",c);b.setVar("action",
"save");b.requestFile=dle_root+"engine/ajax/editnews.php";b.method="POST";b.element="news-id-"+a;b.onCompletion=whenCompletedSave;b.sendAJAX(e);return false}function whenCompleted(){setTimeout(function(){$("html:not(:animated)"+(!$.browser.opera?",body:not(:animated)":"")).animate({scrollTop:$("#news-id-"+s_id).position().top-70},700)},100)}
function ajax_prep_for_edit(a,c){if(!n_cache[a]||n_cache[a]=="")n_cache[a]=document.getElementById("news-id-"+a).innerHTML;var b=new dle_ajax;s_id=a;b.onShow("");b.setVar("id",a);b.setVar("field",c);b.setVar("action","edit");b.requestFile=dle_root+"engine/ajax/editnews.php";b.method="GET";b.element="news-id-"+a;b.execute=true;b.onCompletion=whenCompleted;b.sendAJAX("");return false}
function whenCompletedCommentsEdit(){setTimeout(function(){$("html:not(:animated)"+(!$.browser.opera?",body:not(:animated)":"")).animate({scrollTop:$("#comm-id-"+comm_id).position().top-70},700)},100)}function MenuCommBuild(a,c){var b=[];b[0]="<a onclick=\"ajax_comm_edit('"+a+"', '"+c+'\'); return false;" href="#">'+menu_short+"</a>";b[1]='<a href="'+dle_root+"?do=comments&action=comm_edit&id="+a+"&area="+c+'">'+menu_full+"</a>";return b}
function ajax_comm_edit(a,c){if(!c_cache[a]||c_cache[a]=="")c_cache[a]=document.getElementById("comm-id-"+a).innerHTML;var b=new dle_ajax;comm_id=a;b.onShow("");b.setVar("id",a);b.setVar("area",c);b.setVar("action","edit");b.requestFile=dle_root+"engine/ajax/editcomments.php";b.method="GET";b.element="comm-id-"+a;b.execute=true;b.onCompletion=whenCompletedCommentsEdit;b.sendAJAX("");return false}
function ajax_cancel_comm_edit(a){if(n_cache[a]!="")document.getElementById("comm-id-"+a).innerHTML=c_cache[a];return false}function whenCompletedSaveComments(){c_cache[comm_edit_id]=""}
function ajax_save_comm_edit(a,c){var b=new dle_ajax,d="";comm_edit_id=a;b.onShow("");d=dle_wysiwyg=="yes"?b.encodeVAR($("#dleeditcomments"+a).html()):b.encodeVAR(document.getElementById("dleeditcomments"+a).value);d="comm_txt="+d;b.setVar("id",a);b.setVar("area",c);b.setVar("action","save");b.requestFile=dle_root+"engine/ajax/editcomments.php";b.method="POST";b.element="comm-id-"+a;b.onCompletion=whenCompletedSaveComments;b.sendAJAX(d);return false}
function whenCommentsDeleted(a){a=parseInt(a);if(!isNaN(a)){$("html"+(!$.browser.opera?",body":"")).animate({scrollTop:$("#comment-id-"+a).position().top-70},700);setTimeout(function(){$("#comment-id-"+a).hide("blind",{},1400)},700)}}
function DeleteComments(a,c){DLEconfirm(dle_del_agree,dle_confirm,function(){var b=new dle_ajax;b.onShow("");var d="id="+a;b.setVar("dle_allow_hash",c);b.requestFile=dle_root+"engine/ajax/deletecomments.php";b.method="GET";b.onCompletion=whenCommentsDeleted;b.sendAJAX(d)})}
function doFavorites(a,c){var b=new dle_ajax;b.onShow("");var d="fav_id="+a;b.setVar("action",c);b.setVar("skin",dle_skin);b.requestFile=dle_root+"engine/ajax/favorites.php";b.method="GET";b.element="fav-id-"+a;b.sendAJAX(d);return false}function CheckLogin(){var a=new dle_ajax,c=a.encodeVAR(document.getElementById("name").value);a.onShow("");a.requestFile=dle_root+"engine/ajax/registration.php";a.method="POST";a.element="result-registration";a.sendAJAX("name="+c);return false}
function doCalendar(a,c,b){var d=new dle_ajax;d.onShow("");d.setVar("year",c);d.setVar("month",a);d.requestFile=dle_root+"engine/ajax/calendar.php";d.method="GET";d.effect=b;d.element="calendar-layer";d.sendAJAX("")}function ShowBild(a){window.open(dle_root+"engine/modules/imagepreview.php?image="+a,"","resizable=1,HEIGHT=200,WIDTH=200, top=0, left=0, scrollbars=yes")}
function doRate(a,c){var b=new dle_ajax;b.onShow("");var d="go_rate="+a;b.setVar("news_id",c);b.setVar("skin",dle_skin);b.requestFile=dle_root+"engine/ajax/rating.php";b.method="GET";b.element="ratig-layer";b.sendAJAX(d)}function dleRate(a,c){var b=new dle_ajax;b.onShow("");var d="go_rate="+a;b.setVar("news_id",c);b.setVar("skin",dle_skin);b.setVar("mode","short");b.requestFile=dle_root+"engine/ajax/rating.php";b.method="GET";b.element="ratig-layer-"+c;b.sendAJAX(d)}
function doAddComments(){var a=document.getElementById("dle-comments-form"),c=new dle_ajax;if(dle_wysiwyg=="yes"){document.getElementById("comments").value=$("#comments").html();c.setVar("editor_mode","wysiwyg")}if(a.comments.value==""||a.name.value==""){DLEalert(dle_req_field,dle_info);return false}c.onShow("");var b="post_id="+a.post_id.value;c.setVar("comments",c.encodeVAR(a.comments.value));c.setVar("name",c.encodeVAR(a.name.value));c.setVar("mail",c.encodeVAR(a.mail.value));c.setVar("skin",dle_skin);
a.sec_code&&c.setVar("sec_code",a.sec_code.value);if(a.allow_subscribe)a.allow_subscribe.checked==true?c.setVar("allow_subscribe","1"):c.setVar("allow_subscribe","0");c.requestFile=dle_root+"engine/ajax/addcomments.php";c.method="POST";c.execute=true;c.effect="blind";c.element="dle-ajax-comments";c.sendAJAX(b)}
function dle_copy_quote(a){dle_txt="";if(window.getSelection)dle_txt=window.getSelection();else if(document.selection)dle_txt=document.selection.createRange().text;if(dle_txt!="")dle_txt="[quote="+a+"]"+dle_txt+"[/quote]\n"}
function dle_ins(a){if(!document.getElementById("dle-comments-form"))return false;var c=document.getElementById("dle-comments-form").comments;if(dle_wysiwyg=="no")c.value+=dle_txt!=""?dle_txt:"[b]"+a+"[/b],\n";else tinyMCE.execInstanceCommand("comments","mceInsertContent",false,dle_txt!=""?dle_txt:"<b>"+a+"</b>,<br />",true)}
function ShowOrHide(a){var c=$("#"+a);a=document.getElementById("image-"+a)?document.getElementById("image-"+a):null;if(c.css("display")=="none"){c.show("blind",{},1000);if(a)a.src=dle_root+"templates/"+dle_skin+"/dleimages/spoiler-minus.gif"}else{c.hide("blind",{},1000);if(a)a.src=dle_root+"templates/"+dle_skin+"/dleimages/spoiler-plus.gif"}}
function ckeck_uncheck_all(){for(var a=document.pmlist,c=0;c<a.elements.length;c++){var b=a.elements[c];if(b.type=="checkbox")b.checked=a.master_box.checked==true?false:true}a.master_box.checked=a.master_box.checked==true?false:true}function confirmDelete(a){DLEconfirm(dle_del_agree,dle_confirm,function(){document.location=a})}function setNewField(a,c){if(a!=selField){fombj=c;selField=a}}
function dle_news_delete(a){DLEconfirm(dle_del_agree,dle_confirm,function(){document.location=dle_root+"index.php?do=deletenews&id="+a+"&hash="+dle_login_hash})}
function MenuNewsBuild(a,c){var b=[];b[0]="<a onclick=\"ajax_prep_for_edit('"+a+"', '"+c+'\'); return false;" href="#">'+menu_short+"</a>";if(dle_admin!="")b[1]='<a href="'+dle_root+dle_admin+"?mod=editnews&action=editnews&id="+a+'" target="_blank">'+menu_full+"</a>";if(allow_dle_delete_news)b[2]="<a onclick=\"dle_news_delete ('"+a+'\'); return false;" href="#">'+dle_del_news+"</a>";return b}
function DLEalert(a,c){$("#dlepopup").remove();$("body").append("<div id='dlepopup' title='"+c+"' style='display:none'><br />"+a+"</div>");$("#dlepopup").dialog({autoOpen:true,width:470,buttons:{Ok:function(){$(this).dialog("close");$("#dlepopup").remove()}}})}
function DLEconfirm(a,c,b){var d={};d[dle_act_lang[1]]=function(){$(this).dialog("close");$("#dlepopup").remove()};d[dle_act_lang[0]]=function(){$(this).dialog("close");$("#dlepopup").remove();b&&b()};$("#dlepopup").remove();$("body").append("<div id='dlepopup' title='"+c+"' style='display:none'><br />"+a+"</div>");$("#dlepopup").dialog({autoOpen:true,width:470,buttons:d})}
function DLEprompt(a,c,b,d){var e={};e[dle_act_lang[3]]=function(){$(this).dialog("close")};e[dle_act_lang[2]]=function(){if($("#dle-promt-text").val().length<1)$("#dle-promt-text").addClass("ui-state-error");else{var f=$("#dle-promt-text").val();$(this).dialog("close");$("#dlepopup").remove();d&&d(f)}};$("#dlepopup").remove();$("body").append("<div id='dlepopup' title='"+b+"' style='display:none'><br />"+a+"<br /><br /><input type='text' name='dle-promt-text' id='dle-promt-text' class='ui-widget-content ui-corner-all' style='width:97%; padding: .4em;' value='"+
c+"'/></div>");$("#dlepopup").dialog({autoOpen:true,width:470,show:"blind",hide:"blind",buttons:e})}var dle_user_profile="",dle_user_profile_link="";
function ShowPopupProfile(a){var c={};c[menu_profile]=function(){document.location=dle_user_profile_link};if(dle_group!=5)c[menu_send]=function(){document.location=dle_root+"index.php?do=pm&doaction=newpm&username="+dle_user_profile};if(dle_group==1)c[menu_uedit]=function(){$(this).dialog("close");window.open(""+dle_root+dle_admin+"?mod=editusers&action=edituser&user="+dle_user_profile+"","User","toolbar=0,location=0,status=0, left=0, top=0, menubar=0,scrollbars=yes,resizable=0,width=540,height=500")};
$("#dleprofilepopup").remove();$("body").append(a);$("#dleprofilepopup").dialog({autoOpen:true,show:"fade",hide:"fade",buttons:c,width:450});return false}
function ShowProfile(a,c){if(dle_user_profile==a&&document.getElementById("dleprofilepopup")){$("#dleprofilepopup").dialog("open");return false}var b=new dle_ajax;dle_user_profile=a;dle_user_profile_link=c;b.onShow("");b.setVar("name",a);b.setVar("skin",dle_skin);b.requestFile=dle_root+"engine/ajax/profile.php";b.method="GET";b.onCompletion=ShowPopupProfile;b.sendAJAX("");return false}
function FastSearch(){$("#story").attr("autocomplete","off");$("#story").blur(function(){$("#searchsuggestions").fadeOut()});$("#story").keyup(function(){var a=$(this).val();if(a.length==0)$("#searchsuggestions").fadeOut();else if(dle_search_value!=a&&a.length>3){clearInterval(dle_search_delay);dle_search_delay=setInterval(function(){dle_do_search(a)},600)}})}
function dle_do_search(a){clearInterval(dle_search_delay);$("#searchsuggestions").remove();$("body").append("<div id='searchsuggestions' style='display:none'></div>");$("#searchsuggestions").css({position:"absolute"});$("#searchsuggestions").position({my:"left top",at:"left bottom",of:"#story",collision:"fit flip"});$.post(dle_root+"engine/ajax/search.php",{query:""+a+""},function(c){$("#searchsuggestions").fadeIn();$("#searchsuggestions").html(c)});dle_search_value=a};


//-----------------------------------
//START COMMENTS RATING
//-----------------------------------
function comRate( rate, id ) {
var ajax = new dle_ajax();
ajax.onShow ('');
var varsString = "go_rate=" + rate;
ajax.setVar("comm_id", id);
ajax.setVar("skin", dle_skin);
ajax.requestFile = dle_root + "engine/ajax/comm_rating.php";
ajax.method = 'GET';
ajax.element = 'cratig-layer-' + id;
ajax.sendAJAX(varsString);
};
//-----------------------------------
// END COMMENTS RATING
//-----------------------------------

function doRate(a,c){var b=new dle_ajax;b.onShow("");var d="go_rate="+a;b.setVar("news_id",c);b.setVar("skin",dle_skin);b.requestFile=dle_root+"engine/ajax/rating.php";b.method="GET";b.element="ratig-layer";b.sendAJAX(d)}function dleRate(a,c){var b=new dle_ajax;b.onShow("");var d="go_rate="+a;b.setVar("news_id",c);b.setVar("skin",dle_skin);b.setVar("mode","short");b.requestFile=dle_root+"engine/ajax/rating.php";b.method="GET";b.element="ratig-layer-"+c;b.sendAJAX(d)}
function blogDoRate(a,c){var b=new dle_ajax;b.onShow("");var d="go_rate="+a;b.setVar("news_id",c);b.setVar("skin",dle_skin);b.requestFile=dle_root+"engine/ajax/blograting.php";b.method="GET";b.element="ratig-layer";b.sendAJAX(d)}function dleRate(a,c){var b=new dle_ajax;b.onShow("");var d="go_rate="+a;b.setVar("news_id",c);b.setVar("skin",dle_skin);b.setVar("mode","short");b.requestFile=dle_root+"engine/ajax/blograting.php";b.method="GET";b.element="ratig-layer-"+c;b.sendAJAX(d)}
function doAddComments(){var a=document.getElementById("dle-comments-form"),c=new dle_ajax;if(dle_wysiwyg=="yes"){document.getElementById("comments").value=$("#comments").html();c.setVar("editor_mode","wysiwyg")}if(a.comments.value==""||a.name.value==""){DLEalert(dle_req_field,dle_info);return false}c.onShow("");var b="post_id="+a.post_id.value;c.setVar("comments",c.encodeVAR(a.comments.value));c.setVar("name",c.encodeVAR(a.name.value));c.setVar("mail",c.encodeVAR(a.mail.value));c.setVar("skin",dle_skin);
a.sec_code&&c.setVar("sec_code",a.sec_code.value);if(a.allow_subscribe)a.allow_subscribe.checked==true?c.setVar("allow_subscribe","1"):c.setVar("allow_subscribe","0");c.requestFile=dle_root+"engine/ajax/addcomments.php";c.method="POST";c.execute=true;c.effect="blind";c.element="dle-ajax-comments";c.sendAJAX(b)}
function dle_copy_quote(a){dle_txt="";if(window.getSelection)dle_txt=window.getSelection();else if(document.selection)dle_txt=document.selection.createRange().text;if(dle_txt!="")dle_txt="[quote="+a+"]"+dle_txt+"[/quote]\n"}
function dle_ins(a){if(!document.getElementById("dle-comments-form"))return false;var c=document.getElementById("dle-comments-form").comments;if(dle_wysiwyg=="no")c.value+=dle_txt!=""?dle_txt:"[b]"+a+"[/b],\n";else tinyMCE.execInstanceCommand("comments","mceInsertContent",false,dle_txt!=""?dle_txt:"<b>"+a+"</b>,<br />",true)}
function ShowOrHide(a){var c=$("#"+a);a=document.getElementById("image-"+a)?document.getElementById("image-"+a):null;if(c.css("display")=="none"){c.show("blind",{},1000);if(a)a.src=dle_root+"templates/"+dle_skin+"/dleimages/spoiler-minus.gif"}else{c.hide("blind",{},1000);if(a)a.src=dle_root+"templates/"+dle_skin+"/dleimages/spoiler-plus.gif"}}
function ckeck_uncheck_all(){for(var a=document.pmlist,c=0;c<a.elements.length;c++){var b=a.elements[c];if(b.type=="checkbox")b.checked=a.master_box.checked==true?false:true}a.master_box.checked=a.master_box.checked==true?false:true}function confirmDelete(a){DLEconfirm(dle_del_agree,dle_confirm,function(){document.location=a})}function setNewField(a,c){if(a!=selField){fombj=c;selField=a}}
function dle_news_delete(a){DLEconfirm(dle_del_agree,dle_confirm,function(){document.location=dle_root+"index.php?do=deletenews&id="+a+"&hash="+dle_login_hash})}
function MenuNewsBuild(a,c){var b=[];b[0]="<a onclick=\"ajax_prep_for_edit('"+a+"', '"+c+'\'); return false;" href="#">'+menu_short+"</a>";if(dle_admin!="")b[1]='<a href="'+dle_root+dle_admin+"?mod=editnews&action=editnews&id="+a+'" target="_blank">'+menu_full+"</a>";if(allow_dle_delete_news)b[2]="<a onclick=\"dle_news_delete ('"+a+'\'); return false;" href="#">'+dle_del_news+"</a>";return b}
function DLEalert(a,c){$("#dlepopup").remove();$("body").append("<div id='dlepopup' title='"+c+"' style='display:none'><br />"+a+"</div>");$("#dlepopup").dialog({autoOpen:true,width:470,buttons:{Ok:function(){$(this).dialog("close");$("#dlepopup").remove()}}})}
function DLEconfirm(a,c,b){var d={};d[dle_act_lang[1]]=function(){$(this).dialog("close");$("#dlepopup").remove()};d[dle_act_lang[0]]=function(){$(this).dialog("close");$("#dlepopup").remove();b&&b()};$("#dlepopup").remove();$("body").append("<div id='dlepopup' title='"+c+"' style='display:none'><br />"+a+"</div>");$("#dlepopup").dialog({autoOpen:true,width:470,buttons:d})}
function DLEprompt(a,c,b,d){var e={};e[dle_act_lang[3]]=function(){$(this).dialog("close")};e[dle_act_lang[2]]=function(){if($("#dle-promt-text").val().length<1)$("#dle-promt-text").addClass("ui-state-error");else{var f=$("#dle-promt-text").val();$(this).dialog("close");$("#dlepopup").remove();d&&d(f)}};$("#dlepopup").remove();$("body").append("<div id='dlepopup' title='"+b+"' style='display:none'><br />"+a+"<br /><br /><input type='text' name='dle-promt-text' id='dle-promt-text' class='ui-widget-content ui-corner-all' style='width:97%; padding: .4em;' value='"+
c+"'/></div>");$("#dlepopup").dialog({autoOpen:true,width:470,show:"blind",hide:"blind",buttons:e})}var dle_user_profile="",dle_user_profile_link="";
function ShowPopupProfile(a){var c={};c[menu_profile]=function(){document.location=dle_user_profile_link};if(dle_group!=5)c[menu_send]=function(){document.location=dle_root+"index.php?do=pm&doaction=newpm&username="+dle_user_profile};if(dle_group==1)c[menu_uedit]=function(){$(this).dialog("close");window.open(""+dle_root+dle_admin+"?mod=editusers&action=edituser&user="+dle_user_profile+"","User","toolbar=0,location=0,status=0, left=0, top=0, menubar=0,scrollbars=yes,resizable=0,width=540,height=500")};
$("#dleprofilepopup").remove();$("body").append(a);$("#dleprofilepopup").dialog({autoOpen:true,show:"fade",hide:"fade",buttons:c,width:450});return false}
function ShowProfile(a,c){if(dle_user_profile==a&&document.getElementById("dleprofilepopup")){$("#dleprofilepopup").dialog("open");return false}var b=new dle_ajax;dle_user_profile=a;dle_user_profile_link=c;b.onShow("");b.setVar("name",a);b.setVar("skin",dle_skin);b.requestFile=dle_root+"engine/ajax/profile.php";b.method="GET";b.onCompletion=ShowPopupProfile;b.sendAJAX("");return false}
function FastSearch(){$("#story").attr("autocomplete","off");$("#story").blur(function(){$("#searchsuggestions").fadeOut()});$("#story").keyup(function(){var a=$(this).val();if(a.length==0)$("#searchsuggestions").fadeOut();else if(dle_search_value!=a&&a.length>3){clearInterval(dle_search_delay);dle_search_delay=setInterval(function(){dle_do_search(a)},600)}})}
function dle_do_search(a){clearInterval(dle_search_delay);$("#searchsuggestions").remove();$("body").append("<div id='searchsuggestions' style='display:none'></div>");$("#searchsuggestions").css({position:"absolute"});$("#searchsuggestions").position({my:"left top",at:"left bottom",of:"#story",collision:"fit flip"});$.post(dle_root+"engine/ajax/search.php",{query:""+a+""},function(c){$("#searchsuggestions").fadeIn();$("#searchsuggestions").html(c)});dle_search_value=a};

function doBlogAddComments(){

	var form = document.getElementById('dle-comments-form');
    var dle_comments_ajax = new dle_ajax();

	if (dle_wysiwyg == "yes") {
		document.getElementById('comments').value = $('#comments').html();
		dle_comments_ajax.setVar("editor_mode", 'wysiwyg');
	} 

	if (form.comments.value == '' || form.name.value == '')
	{
		DLEalert ( dle_req_field, dle_info );
		return false;
	}

	dle_comments_ajax.onShow ('');
	var varsString = "post_id=" + form.post_id.value;
	dle_comments_ajax.setVar("comments", dle_comments_ajax.encodeVAR(form.comments.value));
	dle_comments_ajax.setVar("name", dle_comments_ajax.encodeVAR(form.name.value));
	dle_comments_ajax.setVar("mail", dle_comments_ajax.encodeVAR(form.mail.value));
	dle_comments_ajax.setVar("skin", dle_skin);

	if ( form.sec_code ) {

	   dle_comments_ajax.setVar("sec_code", form.sec_code.value);

    }

	dle_comments_ajax.requestFile = dle_root + "engine/ajax/blog_addcomments.php";
	dle_comments_ajax.method = 'POST';
	dle_comments_ajax.execute = true;
	dle_comments_ajax.effect = 'blind';
	dle_comments_ajax.element = 'dle-ajax-comments';
	dle_comments_ajax.sendAJAX(varsString);

};


function doFriends ( fr_id, event )
{
	var ajax = new dle_ajax();
	ajax.onShow ('');
	var varsString = "fr_id=" + fr_id;
	ajax.setVar("action", event);
	ajax.setVar("skin", dle_skin);
	ajax.requestFile = dle_root + "engine/ajax/addfriend.php";
	ajax.method = 'GET';
	ajax.element = 'addfriends';
	ajax.sendAJAX(varsString);

	return false;
};

function blog_ajax_prep_for_edit( news_id, event )
{
	if ( ! n_cache[ news_id ] || n_cache[ news_id ] == '' )
	{
		n_cache[ news_id ] = document.getElementById( 'news-id-'+news_id ).innerHTML;
	}

	var ajax = new dle_ajax();
	s_id = news_id;
	ajax.onShow ('');
	var varsString = "";
	ajax.setVar("id", news_id);
	ajax.setVar("field", event);
	ajax.setVar("action", "edit");
	ajax.requestFile = dle_root + "engine/ajax/editpost.php";
	ajax.method = 'GET';
	ajax.element = 'news-id-'+news_id;
	ajax.execute = true;
	ajax.onCompletion = whenCompleted;
	ajax.sendAJAX(varsString);

	return false;
};

function dle_blogs_delete( m_id ){
    DLEconfirm( dle_del_agree, dle_confirm, function () {
	    document.location= dle_root + 'index.php?do=deletepost&id=' + m_id + '&hash=' + dle_login_hash;
	} );
};

function blog_ajax_save_for_edit( news_id, event )
{
	var ajax = new dle_ajax();
	var allow_br = 0;
	var news_txt = '';

	if (document.getElementById('allow_br_'+news_id).checked) { allow_br = 1; }

	e_id = news_id;
	ajax.onShow ('');

	if (quick_wysiwyg == "1") {

		news_txt = ajax.encodeVAR( $('#dleeditnews'+news_id).html() );

	} else {

		news_txt = ajax.encodeVAR( document.getElementById('dleeditnews'+news_id).value );

	}

	var news_title = ajax.encodeVAR( document.getElementById('edit-title-'+news_id).value );

	var varsString = "news_txt=" + news_txt;
	ajax.setVar("id", news_id);
	ajax.setVar("allow_br", allow_br);
	ajax.setVar("title", news_title);
	ajax.setVar("field", event);
	ajax.setVar("action", "save");
	ajax.requestFile = dle_root + "engine/ajax/editpost.php";
	ajax.method = 'POST';
	ajax.element = 'news-id-'+news_id;
	ajax.onCompletion = whenCompletedSave;
	ajax.sendAJAX(varsString);

	return false;
};

function MenuBlogsBuild( m_id, event ){

var menu=new Array();

menu[0]='<a onclick="blog_ajax_prep_for_edit(\'' + m_id + '\', \'' + event + '\'); return false;" href="#">' + menu_short + '</a>';

if (dle_admin != '') {

	menu[1]='<a href="' + dle_root + dle_admin + '?mod=editpost&action=editpost&id=' + m_id + '" target="_blank">' + menu_full + '</a>';

}

if (allow_dle_delete_news) {

	menu[2]='<a onclick="dle_blogs_delete (\'' + m_id + '\'); return false;" href="#">' + dle_del_news + '</a>';

}

return menu;
};

function BlogMenuCommBuild( m_id, area ){

var menu=new Array();

menu[0]='<a onclick="blog_ajax_comm_edit(\'' + m_id + '\', \'' + area + '\'); return false;" href="#">' + menu_short + '</a>';
menu[1]='<a href="' + dle_root + '?do=comments&action=blog_comm_edit&id=' + m_id + '&area=' + area + '">' + menu_full + '</a>';

return menu;
};

function blog_ajax_comm_edit( c_id, area )
{
	if ( ! c_cache[ c_id ] || c_cache[ c_id ] == '' )
	{
		c_cache[ c_id ] = document.getElementById( 'comm-id-'+c_id ).innerHTML;
	}

	var ajax = new dle_ajax();
	comm_id = c_id;
	ajax.onShow ('');
	var varsString = "";
	ajax.setVar("id", c_id);
	ajax.setVar("area", area);
	ajax.setVar("action", "edit");
	ajax.requestFile = dle_root + "engine/ajax/blog_editcomments.php";
	ajax.method = 'GET';
	ajax.element = 'comm-id-'+c_id;
	ajax.execute = true;
	ajax.onCompletion = whenCompletedCommentsEdit;
	ajax.sendAJAX(varsString);
	return false;
};

function blog_ajax_save_comm_edit( c_id, area )
{
	var ajax = new dle_ajax();
	var comm_txt = '';

	comm_edit_id = c_id;
	ajax.onShow ('');

	if (dle_wysiwyg == "yes") {

		comm_txt = ajax.encodeVAR( $('#dleeditcomments'+c_id).html() );

	} else {

		comm_txt = ajax.encodeVAR( document.getElementById('dleeditcomments'+c_id).value );

	}

	var varsString = "comm_txt=" + comm_txt;

	ajax.setVar("id", c_id);
	ajax.setVar("area", area);
	ajax.setVar("action", "save");
	ajax.requestFile = dle_root + "engine/ajax/blog_editcomments.php";
	ajax.method = 'POST';
	ajax.element = 'comm-id-'+c_id;
	ajax.onCompletion = whenCompletedSaveComments;
	ajax.sendAJAX(varsString);

	return false;
};

function BlogDeleteComments(id, hash) {

    DLEconfirm( dle_del_agree, dle_confirm, function () {

		var ajax = new dle_ajax();
		ajax.onShow ('');
		var varsString = "id=" + id;
		ajax.setVar("dle_allow_hash", hash);
		ajax.requestFile = dle_root + "engine/ajax/blog_deletecomments.php";
		ajax.method = 'GET';
		ajax.onCompletion = whenCommentsDeleted;
		ajax.sendAJAX(varsString);

	} );

};

function brokenLink( id ) {
	var ajax = new dle_ajax();
	ajax.onShow ('');
	var varsString = "news_id=" + id;
	ajax.setVar("skin", dle_skin);
	ajax.requestFile = dle_root + "engine/ajax/brokenLink.php";
	ajax.method = 'GET';
	ajax.element = 'broken-id-' + id;
	ajax.sendAJAX(varsString);
};

function whenBanUser() {

  setTimeout(function() {
	$("html:not(:animated)"+( ! $.browser.opera ? ",body:not(:animated)" : "")).animate({scrollTop: $("#banid").position().top - 70}, 700);
  }, 100);


};

function ban_users( user_id, status, act )
{
var ajax = new dle_ajax();
ajax.onShow ('');
var varsString = "";
ajax.setVar("user_id", user_id);
ajax.setVar("status", status);
ajax.setVar("action", act);
ajax.setVar("skin", dle_skin);
if (act == '1')
{
var form = document.getElementById('banform');
if (status != 1)
{
ajax.setVar("banned_descr", ajax.encodeVAR(form.banned_descr.value));
ajax.setVar("banned_date", ajax.encodeVAR(form.banned_date.value));
ajax.setVar("banned", ajax.encodeVAR(form.banned.value));
if ( document.getElementById('del_com').checked)
ajax.setVar("del_com", "1");
else
ajax.setVar("del_com", "0");
}
ajax.setVar("name_banned_user", ajax.encodeVAR(form.name_banned_user.value));
}
if (act == '2')
{
var form = document.getElementById('banform_del');
var agree=confirm( dle_del_agree );
if (agree)
{
ajax.setVar("banned_del", ajax.encodeVAR(form.banned_del.value));
ajax.setVar("name_banned_user", ajax.encodeVAR(form.name_banned_user.value));
}
}
ajax.requestFile = dle_root + "engine/ajax/banusers.php";
ajax.method = 'POST';
ajax.onCompletion = whenBanUser;
ajax.element = 'banid';
ajax.sendAJAX(varsString);

return false;
};
