﻿function addFavorite() {
    if (document.all) {
        window.external.addFavorite("http://" + window.location.host, "Frost");
    }
    else if (window.sidebar) {
        window.sidebar.addPanel("日利达太阳能", "http://" + window.location.host, "");
    }
}
function setHomepage() {
    if (document.all) {
        document.body.style.behavior = "url(#default#homepage)";
        document.body.setHomePage("http://" + window.location.host);
    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("该操作被浏览器拒绝，假如想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
            }
        }
        var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref("browser.startup.homepage", "http://" + window.location.host);
    }
}
function articleSearch() {
    var key = document.getElementById("SearchKey").value;
    window.location.href = "/Home/Search.aspx?searchKey="+escape(key);
}
function SearchHighlight(idVal, keyword) {
    var pucl = document.getElementById(idVal);
    if ("" == keyword) return;
    var temp = pucl.innerHTML;
    var htmlReg = new RegExp("\<.*?\>", "i");
    var arrA = new Array();
    for (var i = 0; true; i++) {
        var m = htmlReg.exec(temp);
        if (m) {
            arrA[i] = m;
        }
        else {
        }
        temp = temp.replace(m, "{[(" + i + ")]}");
        break;
    }
    words = unescape(keyword.replace(/\+/g, ' ')).split(/\s+/);
    for (w = 0; w < words.length; w++) {
        var r = new RegExp("(" + words[w].replace(/[(){}.+*?^$|\\\[\]]/g, "\\$&") + ")", "ig");
        temp = temp.replace(r, "<font style='color:Red;'>$1</font>");
    }
    for (var i = 0; i < arrA.length; i++) {
        temp = temp.replace("{[(" + i + ")]}", arrA[i]);
    }
    pucl.innerHTML = temp;
}

function InitKf() {
    $("body").append(
            '<div class="kfBox">' +
                '<div class="kfCon">' +
                    '<div class="top"></div>' +
                    '<div class="kfMain">' +
                        '<div class="kfMHead">在线客服</div>' +
                        '<div class="kfMCon">' +
                            '<p><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1580954600&site=qq&menu=yes" title="点击这里给我发消息"><img style="border-style: none;" align="absmiddle" src="http://wpa.qq.com/pa?p=2:1580954600:4" alt="" />&nbsp;&nbsp;QQ在线客服</a></p>' +
                        '</div>' +
                    '</div>' +
                    '<div class="bottom"></div>' +
                '</div>' +
                '<div class="kfView">' +
                '</div>' +
            '</div>');
    $(".kfBox").hover(function() {
        $(".kfBox .kfCon").stop();
        $(".kfBox .kfView").hide();
        $(".kfBox .kfCon").show();
        $(".kfBox .kfCon").width(33).animate({ "width": "146px" }, 100);
    }, function() {
        $(".kfBox .kfCon").stop();
        $(".kfBox .kfCon").animate({ "width": "33px" }, 100, function() {
            $(".kfBox .kfCon").hide();
            $(".kfBox .kfView").show();
        });
    });
    setInterval(function() {
        var oTop = parseInt($(".kfBox").css("top"));
        var top = parseInt($(window).height() / 2 + $(window).scrollTop() - $(".kfBox").height() / 2);
        if (oTop != top) {
            var d = Math.ceil((top - oTop) / 15);
            $(".kfBox").css("top", oTop + d + "px");
        }
    }, 1);
}
