function authUser(){
    var fe = document.forms["authUserForm"].elements;
    $.post("/auth",{"l":$(fe["Login"]).val(),"p":$(fe["Password"]).val()},function(user,stateU){
        window.location.reload();
    },"json");
}

function editUsrInfo(){
    var tableE = document.getElementById("editing");
    tableE.style.display = "";
    var tableV = document.getElementById("view");
    tableV.style.display = "none";
}
function subscribeMe(btn){
  var email = document.getElementById("sb-inp-2").value;

  if(!email.match(/^[-_a-zA-Z0-9\.]+[@][a-z0-9\.]+[\.][a-z]+/)) {
  	alert('Указанный адрес электронной почты не правильного формата!');
  	return;
  }
  $.post("/subscribe/",{'mail':email},function(){
      $(btn).parent().html("<div class=\"lbl\"><img src=\"/title-subscribe.png\" width=\"82\" height=\"13\" alt=\"Рассылка\" /></div><span style=\"margin-top:12px;font-weight:bold;\">Ваш адрес внесен в список рассылки.</span>");
  },"json");
}
// Блок комментарив
function addComment(btn){
	 var cmtConte = document.getElementById("commentsList");
		var cmtText = document.getElementById("leave-comm");
		var cmtNic = document.getElementById("authorcomment");
		var mod = btn.getAttribute("mod");
		var ntype = btn.getAttribute("ntype");
		var objid = btn.getAttribute("objid");
		var p = document.createElement("P");
        $.post("/addc/",{'textcoment':cmtText.value, 'nic':cmtNic.value,'ntype': ntype, 'mod':mod,'objid':objid},function(){
            window.location.reload();
        },"json");
}
function answerToCmt(obj,mod){
	var path = window.location.pathname.split('/');
	 var prnt = obj.parentNode.parentNode.parentNode.parentNode.parentNode;
	 var txt = prnt.getElementsByTagName("TEXTAREA");
	 txt = txt[0];
     $.post("/articles/comment/get/",{'coment':obj.getAttribute("comid"),'mod':path[1]},function(retcmt){
        var br1 = (txt.value=="")? "":"\n";
	 			txt.value = txt.value+" "+br1+retcmt.blockcmt+"\n\n\n";
        txt.focus();
     },"html");
}
//Блок комментариев
function loadavatar(btn){
	var frm = btn.form;
    $.post("/site_users/loadavatare/",$(frm).serialize(),function(){
        window.location.reload();
    },"json");
}
