﻿function postblog() {
    var uid = __uid;
    if (uid == "0") {
        alert("需要登录后才能发表日志！"); return false;
    }
    else {
        return true;
    }
}

function unlogin() {
    alert("需要登录后才能查看！");
}
function delask() {
    if (window.confirm("确定要删除吗?")) {
        return true;
    }
    else {
        return false;
    }
}

function searchask() {
    var kv = document.getElementById("keyw").value;
    if (kv.length < 2) {
        alert("请填写关键字。关键字长度不小于2个字符")
    }
    else {
        window.location.href = "/home/ask?r=all&key=" + escape(kv) + "";
    }
}
function showUNHTML(n) {
    if (n == 0) {
        document.getElementById("uncloseHTML").style.display = "block";
        document.getElementById("hiJiFenHTML").style.display = "none";
        document.getElementById("ss1").className = "reshow"
        document.getElementById("ss2").className = ""
    }
    else {
        document.getElementById("uncloseHTML").style.display = "none";
        document.getElementById("hiJiFenHTML").style.display = "block";
        document.getElementById("ss1").className = ""
        document.getElementById("ss2").className = "reshow"
    }
}

function setBest(aid) {
    var gUserID = __uid;
    if (gUserID == "0") {
        alert("您还没有登录！"); return false;
    }
    if (window.confirm("确定要设为最佳答案吗?")) {
        var options = {
            method: 'get',
            parameters: "&a=update&id=" + aid,
            onComplete: function(transport) {
                var returnvalue = transport.responseText;
                window.location.reload();
            }
        };
        new Ajax.Request('/home/ask/content.aspx?no-cache=' + Math.random(), options);
    }
    else {
        return false;
    }
}

function EditAskInfo(aid) {
    var options = {
        method: 'get',
        parameters: "&action=a&qID=" + aid,
        onComplete: function(transport) {
            var returnvalue = transport.responseText;
            document.getElementById("askContentSpan").innerHTML = returnvalue;
        }
    };
    new Ajax.Request(RootDir + '/home/ask/edit.aspx?no-cache=' + Math.random(), options);
}

function SaveEdit(aid) {
    var con = document.getElementById("qContent").value;
    var options = {
        method: 'get',
        parameters: "&action=update&content=" + escape(con) + "&qID=" + aid,
        onComplete: function(transport) {
            var returnvalue = transport.responseText;
            //alert(returnvalue);
            //document.getElementById("askContentSpan").innerHTML=returnvalue;
            ShowEdit(aid);
        }
    };
    new Ajax.Request(RootDir + '/home/ask/edit.aspx?no-cache=' + Math.random(), options);
}
function ShowEdit(aid) {
    var options = {
        method: 'get',
        parameters: "&action=show&qID=" + aid,
        onComplete: function(transport) {
            var returnvalue = transport.responseText;
            document.getElementById("askContentSpan").innerHTML = returnvalue;
        }
    };
    new Ajax.Request(RootDir + '/home/ask/edit.aspx?no-cache=' + Math.random(), options);
}
