﻿
var pageUrl = "";
var pageUrl2 = "";
pageUrl = "http://" + window.location.host + "/";
pageUrl2 = window.location.href;
pageUrl2 = pageUrl2.toLowerCase();

/*搜索文本框焦点事件*/
function fEvent(sType, oInput, tiptext) {

    switch (sType) {
        case "focus":
            if (oInput.value == "请输入搜索关键字") {
                oInput.value = "";
                oInput.style.color = "#000"
            }
            trag = true;
            oInput.isfocus = true;
        case "mouseover":
            // oInput.style.borderColor = '#9ecc00';
            break;
        case "blur":
            if (oInput.value == "") {
                oInput.value = "请输入搜索关键字";
                oInput.style.color = "#999"
            }
            oInput.isfocus = false;
        case "mouseout":
            if (!oInput.isfocus) {
                //    oInput.style.borderColor='#84a1bd';
            }
            break;
    }
}
/*搜索点击事件*/
function Search_Click() {
    var keyword = document.getElementById('ctl00_ContentPlaceHolder1_Search1_txtKeyword').value;
    keyword = keyword.replace(/(^\s*)|(\s*$)/g, "");
    if (keyword == '请输入搜索关键字' || keyword == "") {
        document.getElementById("ctl00_ContentPlaceHolder1_Search1_txtKeyword").value = '';
        alert('请输入查询关键字!');
        return false;
    }
    else {
        var url = "Search.aspx";
        url += "?keyword=" + escape(keyword);
        window.open(pageUrl + url);
        // window.location.href =pageUrl + url;
    }
}
/*选项卡切换功能*/
function setTab(name, cursel, n) {
    for (i = 1; i <= n; i++) {
        var menu = document.getElementById(name + i);
        var con = document.getElementById("con_" + name + "_" + i);
        menu.className = i == cursel ? "hover" : "";
        con.style.display = i == cursel ? "block" : "none";
    }
}


//收藏夹
function addFavorite() {
    if (document.all) {
        window.external.addFavorite(pageUrl, '金太阳教育网-专注研发中小学英语学习软件');
    }
    else if (window.sidebar) {
        window.sidebar.addPanel('金太阳教育网-专注研发中小学英语学习软件', pageUrl, "");
    }
}
//设为首页
function setHomepage() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(pageUrl);

    }
    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', pageUrl);
    }
}


/*三态高亮菜单*/
// 作者:biny
// 时间:2009-2-26
// 作用:此脚本用于设置三态导航菜单的高亮显示.

function getObj(objName) { return (document.getElementById(objName)); }


//鼠标滑过效果
function overme(o) {
    if (o.className != "cur")
        o.className = "over"; /*翻滚色样式*/
}
//鼠标移开后效果
function outme(o) {
    if (o.className != "cur")
        o.className = "normal"; /*翻滚色样式*/
}

/*产品查看左侧滑动菜单功能函数*/
var currTId0 = null;
var currDId0 = null;
function mouseOver0(obj, tag0, tag1, id) {
    if (currTId0 != null) {
        if (getObj(currTId0)) getObj(currTId0).style.display = "block";
        if (getObj(currDId0)) getObj(currDId0).style.display = "none";
    }

    var Tid = tag0 + id;
    var Did = tag1 + id;
    if (getObj(Tid)) getObj(Tid).style.display = "none";
    if (getObj(Did)) getObj(Did).style.display = "block";
    currTId0 = Tid;
    currDId0 = Did;
}
var currTId1 = null;
var currDId1 = null;
function mouseOver1(obj, tag0, tag1, id) {
    if (currTId1 != null) {
        if (getObj(currTId1)) getObj(currTId1).style.display = "block";
        if (getObj(currDId1)) getObj(currDId1).style.display = "none";
    }

    var Tid = tag0 + id;
    var Did = tag1 + id;
    if (getObj(Tid)) getObj(Tid).style.display = "none";
    if (getObj(Did)) getObj(Did).style.display = "block";
    currTId1 = Tid;
    currDId1 = Did;
}
var currTId2 = null;
var currDId2 = null;
function mouseOver2(obj, tag0, tag1, id) {
    if (currTId2 != null) {
        if (getObj(currTId2)) getObj(currTId2).style.display = "block";
        if (getObj(currDId2)) getObj(currDId2).style.display = "none";
    }

    var Tid = tag0 + id;
    var Did = tag1 + id;
    if (getObj(Tid)) getObj(Tid).style.display = "none";
    if (getObj(Did)) getObj(Did).style.display = "block";
    currTId2 = Tid;
    currDId2 = Did;
}

/*分类选中功能*/
var temp0; /*菜单数量*/

var ChooseMenu = function() {

    var obj = document.getElementById("product_list"); /*ul的id*/
    if (obj != undefined) {
        var obj_a = obj.getElementsByTagName("a");
        number = obj_a.length;
        for (var i = 0, j = obj_a.length; i < j; i++) {
            obj_a[i].index = i;
            obj_a[i].onclick = function() { click0(this) };
        }
        var cout = 0;
        var thisHREF = document.location.href;
        for (var k = 0, f = obj_a.length; k < f; k++) {
            if (thisHREF.toString() == (obj_a[k].toString())) {
                obj_a[k].className = "cur";
                cout = 1;
            }
        }
    }
}
function click0(o) {

    var obj = getObj("product_list");
    var obj_a = obj.getElementsByTagName("a");
    for (var i = 0, j = obj_a.length; i < j; i++) {
        obj_a[i].className = "normal";
    }
    o.className = "cur";
    o.blur();
    temp0 = o.index
}


//获取当前访问页的文件名称
function queryString(val) {
    thisHREF = document.location.href;
    tmpHPage = thisHREF.split("/");
    thisHPage = tmpHPage[tmpHPage.length - 1];
    if (thisHPage.indexOf("?") != -1) {
        thisHPage = thisHPage.substring(0, thisHPage.indexOf("?"));
    }
    return thisHPage;
}
//获取URL中指定参数的值，参数name为URL参数名，返回改参数名的参数值
function GetQueryStringRegExp(name) {
    var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
     if (reg.test(location.href)) {
        var tempstr = RegExp.$2.replace(/\+/g, " ");
        tempstr = tempstr.replace("#none","");
        return unescape(tempstr);
    }
    else
    { return ""; }
}

/*函数功能
动态设置菜单的选择高度状态
*/
function setMenuLight() {
    var pagename = queryString();
    var rootmenuid = GetQueryStringRegExp("parentid");
    if (rootmenuid == "" || rootmenuid == undefined) {
         try
        {
            rootmenuid = parentid;
        }
        catch (e) 
        {}
    }
    if (rootmenuid != "0") {
        pagename = pagename.toLowerCase();
        switch (pagename) {
            case "prolist.aspx":    //首页的名称
            case "proview.aspx":
                document.getElementById(rootmenuid).className = "cur";
                break;
            case "default.aspx":
            case "":
                //   首页
                document.getElementById("rootmenu0").className = "cur";
            default:
                break;
        }
    }

}