function submitSt() {
    var name = $("#author_name").val();
    var type = $("#type:checked").val();
    var text = $("#status_text").val();
   var bot = $("input[name='sendmail_bot_secure']").val();
    if(name.length < 2) {
        $("#AN_err").text("Ваше имя слишком короткое!");
        $("#sub").val("Ошибочка... Попробуй еще!");
        return false;
    }
    $("#AN_err").text("");
    if(text.length < 20) {
        $("#ST_err").text("Ваш статус слишком короткий!");
        $("#sub").val("Ошибочка... Попробуй еще!");
        return false;
    }
    $("#ST_err").text("");
    var params = {name: name, type: type, text: text, named: 'subSt', bot: bot};
    $("#sub").val("Сохраняем...");
    $("#sub").attr("disabled","disabled");
    $.post(
            "/get_status.php",
            params,
            success,
            "json"
          );
}
function success(data) {
    if(data.res == 200) {
	if(data.bt)
		$("#bot_secure").attr("src", "bot_secure.php?q="+data.bt);
        $("#status_text").val("");
        $("#sub").val("Сохранено удачно. Добавим еще?");
        $("#close_but").val("Не хочу :(");
        $("#sub").removeAttr("disabled");
    } else {
	if(data.bt)
		$("#bot_secure").attr("src", "bot_secure.php?q="+data.bt);
        $("#sub").val(data.err+". Попробуем еще?");
        $("#close_but").val("Не хочу :(");
        $("#sub").removeAttr("disabled");
    }
}
$(document).ready(function () {
    $("label#labelst").mouseover(function(){
        $(this).addClass('hover');
        $(this).mouseout(function(){
            $(this).removeClass('hover');
        });
    });
    $("label#labelst").click(function(){
        $("label#labelst").removeClass('active');
        $(this).addClass('active');
        $('input', this).get(0).click();
    });
    $(".rnd-btn").mouseover(function(){
        $(this).addClass('hover');
        $(this).mouseout(function(){
            $(this).removeClass('hover');
        });
    });
    $(".rnd-btn").click(function(){
        get_random();
    });
    $(".rnd-btn").ready(function(){
        get_random();
    });
});
function get_random(data) {
    $.post(
            "/get_status.php",
            {named:"get_random"},
            the_random,
            "json"
          );
}
function the_random(data) {
    if(data.res == 200) {
        $(".random-text").html(data.txt);
    }
}
function close_dialog() {
    $('#dialog-form').dialog('close');
}
function strait(id, type) {
    var params = {stid: id, type: type, named: 'rait'};
    $.post(
            "/get_status.php",
            params,
            success_rait,
            "json"
          );
}
function success_rait(data) {
    if(data.res == '200') {
        var val = +$("#rait-"+data.stid).text();
        if(data.type == "plus")
            val += 1;
        else
            val -= 1;
        $("#rait-"+data.stid).text(val.toString());
        $("#rait-pls-"+data.stid).css("display","none");
        $("#rait-mns-"+data.stid).css("display","none");
    }
}
function addslashes(str) {
    str=str.replace(/\\/g,'\\\\');
    str=str.replace(/\'/g,'\\\'');
    str=str.replace(/\"/g,'\\"');
    str=str.replace(/\0/g,'\\0');
    str=str.replace(/\&/g,'\\&');
    return str;
}

