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 SO() {
    txt = k("s").value;
    if (txt == "请输入您要搜索的内容！" || txt == "") {
        alert("请输入要搜索的内容！");
        return false;
    }
    window.location.href = "/s?s=" + txt; 
}
function GO(n) {
    location.href = "/class?" + k("cid").value + "_" + k("od").value + "_" + k(n).value + ".html";
}
function GO1(n) {
    location.href = "/class1?" + k("cid").value + "_" + k("od").value + "_" + k(n).value + ".html";
}
function GO2(n) {
    location.href = "/replay?" + k("id").value +  "_" + k(n).value + ".html";
}
function GO3(n) {
    location.href = "/s?s=" + k("sss").value + "&o=" + k("od").value + "&p=" + k(n).value ;
}
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);
}

function onlyNum() {
    c = event.keyCode;
    return (c >= 48 && c <= 57); //|| (c== 46)
}
function onlyDecimal() {
    c = event.keyCode;
    return (c >= 48 && c <= 57) || (c == 46);
}

function onlyChar() {
    c = event.keyCode;
    if (!(c == 46) && !(c == 8) && !(c == 37) && !(c == 39))
        if (!((c >= 48 && c <= 57) || (c >= 96 && c <= 105)))
            event.returnValue = false;
}

function onlyNumPaste() {
    return !clipboardData.getData('text').match(/\D/);
}

