﻿var sobj;
function getResult(url, obj) {
    sobj = obj;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (req) {
        req.open("GET", url, true);
        req.onreadystatechange = complete;
        req.send(null);
    }
}
function complete() {
    if (req.readyState == 4) {
        if (req.status == 200) {
            if (CheckNull(req.responseText)) {
                if ("en" == sobj)
                    alert("not find");
                else
                    alert("未找到");
            }
            else
                window.location.href = req.responseText;
        }
    }
}

function CheckNull(str) {
    if (str.replace(/^\s+|\s+$/g, '').length == 0) {
        return true;
    }
    return false;
}
function search(obj) {

    var key = document.getElementById("search_text");
    if (CheckNull(key.value)) {
        key.focus();
        if ("en" == obj)
            alert("plase input keyword");
        else
            alert("请输入关键字");
    }
    else
        getResult("/search.aspx?key=" + encodeURI(key.value), obj);
}
