﻿// JScript 文件

//设置为首页
function defaulhome(){
	this.home.style.behavior='url(#default#homepage)';
	this.home.setHomePage('http://www.zjfsi.com/');
}
//收藏本站
function addBookMark(){
        bookmarkurl="http://www.zjfsi.com";
        bookmarktitle="中国氟硅网";
        if (document.all)
        window.external.AddFavorite(bookmarkurl,bookmarktitle);
}
    
 //$寻找脚本对象
    function $(elementName)
    { return document.getElementById(elementName); }

function LTrim(str) {
    var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(0)) != -1) {
        var j = 0, i = s.length; while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
        { j++; }
        s = s.substring(j, i);
    }
    return s;
}

function RTrim(str) {
    var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(s.length - 1)) != -1) {
        var i = s.length - 1; while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        { i--; }
        s = s.substring(0, i + 1);
    }
    return s;
}

function Trim(str)
{ return RTrim(LTrim(str)); }
function isEmpty(Obj) {
    if (Trim(Obj.value) == "") {
        if (Obj.disabled == false && Obj.readOnly == false)
            Obj.focus(); return true;
    }
    else
        return false;
}

//搜索换样式 getObject 
function getObject(objectId) {
    if (document.getElementById && document.getElementById(objectId)) {
        // W3C DOM
        return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
        // MSIE 4 DOM
        return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
        // NN 4 DOM.. note: this won't find nested layers
        return document.layers[objectId];
    } else {
        return false;
    }
}

/*下边是搜索处样式的变化*/
function showsearch(m, n, count) {
    for (var i = 1; i <= count; i++) {
        if (i == n) {
            if (i == 7) {
                getObject(m + "_" + i).className = "selectTag";
            }
            else {
                getObject(m + "_" + i).className = "selectTag";
            }

        }
        else {
            if (i == 7) {
                getObject(m + "_" + i).className = "";
            }
            else {
                getObject(m + "_" + i).className = "";
            }
        }
    }
    if (n == 1) {
        topSearchUrl = "/Product/ProductList.aspx?key=";
    }
    //企业
    else if (n == 2) {
        topSearchUrl = "/Company/CompanyList.aspx?key=";
    }
    //商机
    else if (n == 3) {
        topSearchUrl = "/Offer/SupplyList.aspx?key=";
    }
    //资讯
    else if (n == 4) {
        topSearchUrl = "/Offer/DemandList.aspx?key=";
    }
    //文献
    else if (n == 5) {
        topSearchUrl = "/News/NewsList.aspx?key=";
    }
    //专家
    else if (n == 6) {
        topSearchUrl = "/Article/ArticleList.aspx?key=";
    }
    //专家
    else if (n == 7) {
        topSearchUrl = "/FileDownLoad/FileDownLoadList.aspx?key=";
    }
    //默认
    else {
        topSearchUrl = "/Product/ProductList.aspx?key=";
    }
}


//search
function filterStrForSearch(str) {
    if (str.length == 0)
        return ""; str = str.replace(/\#|\&|\*|\_|\[|\]|\||\/|\<|\>|\?|\!|\:|\"|\'|\%|\./g, ""); return str;
}
function _cancelBubble(event) { e = event ? event : window.event; if (window.event) { e.cancelBubble = true; } else { e.stopPropagation(); } }
function InitMenu() {
    var url = location.href.toLowerCase();
    if ($("7_1").className = "selectTag" == true)
    { topSearchUrl = "/Product/ProductList.aspx?key="; }
    else if ($("7_2").className = "selectTag" == true)
    { topSearchUrl = "/Company/CompanyList.aspx?key="; }
    else if ($("7_3").className = "selectTag" == true)
    { topSearchUrl = "/Offer/SupplyList.aspx?key="; }
    else if ($("7_4").className = "selectTag" == true)
    { topSearchUrl = "/Offer/OfferList.aspx?key="; }
    else if ($("7_5").className = "selectTag" == true)
    { topSearchUrl = "/News/NewsList.aspx?key="; }
    else if ($("7_6").className = "selectTag" == true)
    { topSearchUrl = "/Article/ArticleList.aspx?key="; }
    else if ($("7_7").className = "selectTag" == true)
    { topSearchUrl = "/FileDownLoad/FileDownLoadList.aspx?key="; }
    else { topSearchUrl = "/Product/ProductList.aspx?key="; }
}
function initTxtSearchKey(obj) {
    if (Trim(obj.value) == "")
    { obj.value = ""; }
}
function TopSearchAll() {
    var searchText = $("txtSearchText");
    if (Trim(searchText.value) == "")
    { alert("请输入搜索关键词！"); searchText.focus(); return false; }
    else {
        if (filterStrForSearch(Trim(searchText.value)) == "")
        { alert("关键词中带非法字符，请重新输入！"); searchText.value = ""; searchText.focus(); return false; }
        else {
            document.location = topSearchUrl + encodeURI(filterStrForSearch(Trim(searchText.value))); return true;
        }
    }
}
