function k(id) {
    return document.getElementById(id);
}
function setHome() {
    if (document.all) {
        document.body.style.behavior ="url(#default#homepage)";
        document.body.setHomePage(window.location.href);
    } else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            } catch (e) {
                alert("您的浏览器不支持自动自动设置首页，请使用浏览器菜单手动设置!");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', window.location.href);
    } else {
        alert("您的浏览器不支持自动自动设置首页, 请使用浏览器菜单手动设置!");
    }  
}
function addFav() {
    try {
        if (document.all)
            window.external.addFavorite(location.href, document.title);
        else (window.sidebar)
            window.sidebar.addPanel(location.href, document.title, "");      
    } catch (e) { alert("加入收藏失败，请按Ctrl+D进行添加"); }   
}  

function OnSel() {
    txt = k("searchKey").value;
    if (txt == "请输入您要搜索的内容！" || txt == "") {
        alert("请输入要搜索的内容！");
        return false;
    }
    url = "/search/?s=" + txt;
    window.location.href = url;
}

function GetLogin() {
    ajax.get("/Service/GetLoginc.aspx?m=" + Math.random(),GetLoginResult);
}
function GetLoginResult(a) {
    k("toplogin").innerHTML = a; //+ k("topright").innerHTML
}

function LgUser() {  
    if (k("tuser").value == "用户名/邮箱/qq/手机" || k("tuser").value.length < 5) {
        alert("请输入一个账户名！");
        return;
    }
    if (k("tpass").value.length < 4) {
        alert("请输入密码！");
        return;
    }
    ajax.post("/service/Getloginu.aspx", getloginu, "u=" + k("tuser").value + "&p=" + k("tpass").value + "&t=" + k("ttype").value);
}

function getloginu(a) {
    if (a == "登录成功") {
        GetLogin();  
    }
    alert(a);    
}