var END_POINT = "/ajax";
var buffalo = new Buffalo(END_POINT);

var left_enName = "" ;
var left_id = "";
var timer;

Event.findElementById = function(event, id) {
    var element = Event.element(event);
    while (element.parentNode && (!element.id || (element.id.toUpperCase() != id.toUpperCase()))) {
        element = element.parentNode;
    }
    if (element.id || element.id.toUpperCase() == id.toUpperCase()) {
        return element;
    } else {
        throw new Error();
    }
}

function closeaction(evt) {
    var obj = Try.these(
            function() {return  Event.findElementById(evt, "win1");  },
            function() {return  Event.findElementById(evt, "left_menu"); }
            );
    if (obj == undefined) { 
        $("win1").style.display = "none";
        document.body.onmouseout = null;
        clearTimeout(timer);
    }
}
function showaction(categoryname, enName, language, _this) { 
    document.body.onmousemove = closeaction.bindAsEventListener(this);
    clearTimeout(timer);
    timer = setTimeout(function () {
        var obj = $("win1"); 
        //            获得 广告
        buffalo.remoteCall("ShowArticle.getAdSortAd", [enName,language,GLOBAL_SITEID], function(reply) {
            Buffalo.Bind.bind("winad", reply.getResult());
        });
        //            获得信息
        buffalo.remoteCall("ShowArticle.getArticleList", [enName,language,GLOBAL_SITEID], function(reply) {
            Buffalo.Bind.bind("win_content", reply.getResult());
            $("win_title").innerHTML = "<a href='javascript:'>" + categoryname + $("CATEGORG_SUFFIX").innerHTML + "</a>";
            obj.style.top = (Position.positionedOffset(_this)[1]) + "px";
            obj.style.left = "150px";
            obj.style.display = "block";
        });
    }, 400);

    return false;
}

function indexBlock(id, obj) {
    for (i = 1; i < 7; i++) {
        $('panel_' + i).style.display = "none";
        $('link' + i).className = "userRecommendTab";
    }
    obj.className = obj.className + " mouseHover";
    //alert(obj.className)
    $(id).style.display = "block";
}

// ======  首页产品分类使用的 js ==========================================

function open_one(obj, showDiv)
{
    var a = new Array("c1", "c2");
    for (j = 0; j < a.length; j++) {
        if (a[j] == showDiv) {
            $(a[j]).style.display = "block";
        } else {
            $(a[j]).style.display = "none";
        }

        if ("img" + a[j] == obj.id) {
            $("img" + a[j]).className = "buttonadd3";
        } else {
            $("img" + a[j]).className = "buttonadd4";
        }
    }
}
function open_two(obj, showDiv)
{
    var b = new Array("q1", "q2", "q3", "q4");
    for (j = 0; j < b.length; j++) {
        if (b[j] == showDiv) {
            $(b[j]).style.display = "block";
        } else {
            $(b[j]).style.display = "none";
        }

        if ("img" + b[j] == obj.id) {
            $("img" + b[j]).className = "buttonadd1";
        } else {
            $("img" + b[j]).className = "buttonadd2";
        }
    }
}


function newstation_open(obj, showDiv)
{
    var b = new Array("nso1", "nso2", "nso3", "nso4");
    for (j = 0; j < b.length; j++) {
        if (b[j] == showDiv) {
            $(b[j]).style.display = "block";
        } else {
            $(b[j]).style.display = "none";
        }

        if ("img" + b[j] == obj.id) {
            $("img" + b[j]).className = "Tab Active";
        } else {
            $("img" + b[j]).className = "Tab";
        }
    }
}
function newstation_openone(obj, showDiv)
{
    var b = new Array("nso01", "nso02", "nso03", "nso04");
    for (j = 0; j < b.length; j++) {
        if (b[j] == showDiv) {
            $(b[j]).style.display = "block";
        } else {
            $(b[j]).style.display = "none";
        }

        if ("img" + b[j] == obj.id) {
            $("img" + b[j]).className = "Tab Active";
        } else {
            $("img" + b[j]).className = "Tab";
        }
    }
}


function open_three(obj, showDiv)
{
    var c = new Array("d1", "d2");
    for (j = 0; j < c.length; j++) {
        if (c[j] == showDiv) {
            $(c[j]).style.display = "block";
        } else {
            $(c[j]).style.display = "none";
        }

        if ("img" + c[j] == obj.id) {
            $("img" + c[j]).className = "buttonadd5";
        } else {
            $("img" + c[j]).className = "buttonadd6";
        }
    }
}
function open_four(obj, showDiv)
{
    var b = new Array("f1", "f2");
    for (j = 0; j < b.length; j++) {
        if (b[j] == showDiv) {
            $(b[j]).style.display = "block";
        } else {
            $(b[j]).style.display = "none";
        }

        if ("img" + b[j] == obj.id) {
            $("img" + b[j]).className = "buttonadd8";
        } else {
            $("img" + b[j]).className = "buttonadd9";
        }
    }
}
function open9()
{
    $("g1").style.display = "block";
    $("g2").style.display = "none";
    $("pic21").src = "/img/images_index/newsbox_4_head_21.gif";
    $("pic22").src = "/img/images_index/newsbox_4_head_12.gif";
}

function open10()
{
    $("g2").style.display = "block";
    $("g1").style.display = "none";
    $("pic21").src = "/img/images_index/newsbox_4_head_11.gif";
    $("pic22").src = "/img/images_index/newsbox_4_head_22.gif";
}

function open11()
{
    $("g1").style.display = "block";
    $("g2").style.display = "none";
    $("pic21").src = "/img/images_index/newsbox_4_head_21.jpg";
    $("pic22").src = "/img/images_index/newsbox_4_head_12.jpg";
}

function open12()
{
    $("g2").style.display = "block";
    $("g1").style.display = "none";
    $("pic21").src = "/img/images_index/newsbox_4_head_11.jpg";
    $("pic22").src = "/img/images_index/newsbox_4_head_22.jpg";
}

function open13()
{
    $("g1").style.display = "block";
    $("g2").style.display = "none";
    $("pic21").src = "/img/images_index/big5/newsbox_4_head_21.jpg";
    $("pic22").src = "/img/images_index/big5/newsbox_4_head_12.jpg";
}

function open14()
{
    $("g2").style.display = "block";
    $("g1").style.display = "none";
    $("pic21").src = "/img/images_index/big5/newsbox_4_head_11.jpg";
    $("pic22").src = "/img/images_index/big5/newsbox_4_head_22.jpg";
}

function showclick(id) {
    var idArray = new Array('l1', 'l2', 'l3', 'l4', 'l5');
    //$("boxactive").className = activ;
    for (i = 0; i < idArray.length; i++) {
        $(idArray[i]).className = "";
//        $('l'+idArray[i]).style.display =  'none';
    }
    $(id).className = "current";
//    $('l'+id).style.display = 'block';
    if (id == 'l1') {         //供应
        $("searchform").action = "/fore/search_salebizinfo.action?url=search_salebizinfo&headFlag=" + id + "&searchType=1";

    } else if (id == 'l2') { //求购
        $("searchform").action = "/fore/search_buybizinfo.action?url=search_buybizinfo&headFlag=" + id + "&searchType=1";

    } else if (id == 'l3') { //产品
        $("searchform").action = "/fore/search_product.action?url=search_product&headFlag=" + id + "&searchType=1";

    } else if (id == 'l4') { //企业
        $("searchform").action = "/fore/search_shop.action?url=search_shop&headFlag=" + id + "&searchType=1";

    } else if (id == 'l5') { //资讯
        $("searchform").action = "/fore/search_article.action?url=search_article&headFlag=" + id + "&searchType=1";

    }
    $("searchform").headFlag.value = id;
}
// 英文用的搜索部分
function showclick1(activ, id) {
    $("boxactive").className = activ;

    if (id == 'l1') {   //供应
        $("searchform").action = "/fore/search_salebizinfo.action?url=search_salebizinfo&headFlag=active_1&searchType=1";
    } else if (id == 'l2') { //求购
        $("searchform").action = "/fore/search_buybizinfo.action?url=search_buybizinfo&headFlag=active_2&searchType=1";
    } else if (id == 'l3') { //产品
        $("searchform").action = "/fore/search_product.action?url=search_product&headFlag=active_3&searchType=1";
    } else if (id == 'l4') { //企业
        $("searchform").action = "/fore/search_shop.action?url=search_shop&headFlag=active_4&searchType=1";
    } else if (id == 'l5') { //资讯
        $("searchform").action = "/fore/search_article.action?url=search_article&headFlag=active_5&searchType=1";
    }
}


function searchHot(obj) {
    //$("keys").className = "keysc";
    //$("searchbt").className = "searchbtc";
    $("keys").value = obj.innerHTML;
    $("searchform").submit();
}

function submiten() {
    if ($("keys").value == "") {
        alert("Please Enter Keyword!");
        return false;
    }
    return true;
}
function submitzh() {
    if ($("keys").value == "") {
        alert("请输入关键字!");
        return false;
    }
    return true;
}

function chickwindow() {
    if ($('window_stage').style.display == 'block') {
        $('window_stage').style.display = 'none';
    } else {
        $('window_stage').style.display = 'block';
    }
}

function changeShow_first(obj, showDiv) {
    var a = new Array("k1", "k2", "k3", "k4");
    for (j = 0; j < a.length; j++) {
        if (a[j] == showDiv) {
            $(a[j]).style.display = "block";
        } else {
            $(a[j]).style.display = "none";
        }

        if ("img" + a[j] == obj.id) {
            $("img" + a[j]).className = "buttonadd1";
        } else {
            $("img" + a[j]).className = "buttonadd2";
        }
    }
}

function changeShow_two(obj, showDiv) {
    var a = new Array("sd1", "sd2", "sd3", "sd4");
    for (j = 0; j < a.length; j++) {
        if (a[j] == showDiv) {
            $(a[j]).style.display = "block";
        } else {
            $(a[j]).style.display = "none";
        }

        if ("img" + a[j] == obj.id) {
            $("img" + a[j]).className = "buttonadd1";
        } else {
            $("img" + a[j]).className = "buttonadd2";
        }
    }
}

function enterSubmit(e) {
    e = e || event;
    if (e.keyCode == 13) {
        $('loginform').submit();
    }

}
function showDisplay(id) {

    if ($(id).style.display == "block") {
        $(id).style.display = "none";
    }
    else if ($(id).style.display == "none") {
        $(id).style.display = "block";
    }
}

function searchtype(id, keys, language, siteid) {
    window.location
    if (id == "saleTitle") {
        window.location = "/fore/search_salebizinfo.action?url=search_salebizinfo&headFlag=active_1&searchType=1&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "saleTitleContent") {
        window.location = "/fore/search_salebizinfo.action?url=search_salebizinfo&headFlag=active_1&searchType=2&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "buyTitle") {
        window.location = "/fore/search_buybizinfo.action?url=search_buybizinfo&headFlag=active_2&searchType=1&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "buyTitleContent") {
        window.location = "/fore/search_buybizinfo.action?url=search_buybizinfo&headFlag=active_2&searchType=2&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "productName") {
        window.location = "/fore/search_product.action?url=search_product&headFlag=active_3&searchType=1&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "productNameDes") {
        window.location = "/fore/search_product.action?url=search_product&headFlag=active_3&searchType=2&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "shopName") {
        window.location = "/fore/search_shop.action?url=search_shop&headFlag=active_4&searchType=1&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "shopNameDes") {
        window.location = "/fore/search_shop.action?url=search_shop&headFlag=active_4&searchType=2&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "articleTitle") {
        window.location = "/fore/search_article.action?url=search_article&headFlag=active_5&searchType=1&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
    if (id == "articleTitleContent") {
        window.location = "/fore/search_article.action?url=search_article&headFlag=active_5&searchType=2&keys=" + keys + "&language=" + language + "&siteid=" + siteid
    }
}
function isEmpty(theStr)
{
    if ((theStr == null) || (theStr.length == 0 ))
        return true
    else return(false);
}
function isTime(theStr) {
    var colonDex = theStr.indexOf(':');
    if ((colonDex < 1) || (colonDex > 2)) {
        return(false);
    }
    else {
        var hh = theStr.substring(0, colonDex);
        var ss = theStr.substring(colonDex + 1, theStr.length);
        if ((hh.length < 1) || (hh.length > 2) || (!isInt(hh))) {
            return(false);
        }
        else if ((ss.length < 1) || (ss.length > 2) || (!isInt(ss))) {
            return(false);
        }
        else if ((!isBetween(hh, 0, 23)) || (!isBetween(ss, 0, 59))) {
            return(false);
        }
        else {
            return(true);
        }
    }
}
function isEmail(theStr) {
    var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
    var re = new RegExp(regu);
    if (isEmpty(theStr)) {
        return(true);
    }
    if ((theStr.search(re) == -1))
    {
        return(true);
    }
    else
    {
        return(false);
    }
}

function chick() {
    $("keys").className = "keysc";
    $("searchbt").className = "searchbtc";
}
function onbutl() {
    if ($("keys").value == "") {
        $("keys").className = "keys";
        $("searchbt").className = "searchbt";
    } else {
        $("searchbt").className = "searchbtc";
    }
    //$("searchbt").className = "searchbt";
}

function mouseover() {
    $("searchbt").className = "searchbtc";
}
function mouseout() {
    $("searchbt").className = "searchbt";

}

