﻿function AddFavorite(sURL, sTitle) {
    try {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
function SetHome(obj, vrl) {
    try {
        obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
    }
    catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', vrl);
        }
    }
}
function SubmitKeyClick(button) {
    document.onkeydown = function(event) {
        event = event ? event : (window.event ? window.event : null);
        //event.srcElement.type  事件发生对象的类型
        if (event.keyCode == 13) {
            document.getElementById(button).click();
        }
    }
}

//顶部广告申缩代码
var intervalId = null;
function slideAd(id, nStayTime, sState, nMaxHth, nMinHth) {
    this.stayTime = nStayTime * 1000 || 3000;
    this.maxHeigth = nMaxHth || 90;
    this.minHeigth = nMinHth || 1;
    this.state = sState || "down";
    var obj = document.getElementById(id);
    if (intervalId != null) window.clearInterval(intervalId);
    function openBox() {
        var h = obj.offsetHeight;
        obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2)) + "px";
        if (obj.offsetHeight > this.maxHeigth) {
            window.clearInterval(intervalId);
            intervalId = window.setInterval(closeBox, this.stayTime);
        }
        if (obj.offsetHeight < this.minHeigth) {
            window.clearInterval(intervalId);
            obj.style.display = "none";
        }
    }
    function closeBox() {
        slideAd(id, this.stayTime, "up", nMaxHth, nMinHth);
    }
    intervalId = window.setInterval(openBox, 10);
}

//卡片切换
function secBoard(title,content,n) {
    var arrtitle = document.getElementById(title).getElementsByTagName("div");
    var arrcontent = document.getElementById(content).getElementsByTagName("div");
    for (i = 0; i < arrtitle.length; i++)
        arrtitle[i].className = "nocurrent";
    arrtitle[n].className = "current";
    for (i = 0; i < arrcontent.length; i++)
        arrcontent[i].style.display = "none";
    arrcontent[n].style.display = "block";
}

//设置服务分类的鼠标状态
function CategoryOn(id) {
    document.getElementById('housekeeping').className = "out";
    document.getElementById('nurse').className = "out";
    document.getElementById('specialservices').className = "out";
    document.getElementById(id).className = "on";
};

//移出服务分类时去掉边框
function CategoryOut(id) {
    document.getElementById(id).className = "out";
    document.getElementById('nurse').className = "on";
};