﻿//菜单效果切换
function menuTab(id){
    document.getElementById(id).className = "menu_aboutUs_down2";
}

function subMenuTab(id){
    var objId = 0;
    for(var i=0;i<6;i++){
        document.getElementById("subMenu"+i).className = "subMenuHidden"+i;
        if(id == document.getElementById("subMenu"+i).id) document.getElementById(id).className = "subMenuShow"+i;
    }
}

function menuFocus(){
    for(var i=0;i<6;i++){
        document.getElementById("subMenu"+i).className = "subMenuHidden"+i;
        if(document.getElementById("Me"+i).className == "menu_aboutUs_down2") document.getElementById("subMenu"+i).className = "subMenuShow"+i;
    }
}

//分类菜单效果切换
function prodTypeCss(id){
    if(document.getElementById(id) != null){
        var listNodes = document.getElementById("prodTypeList").getElementsByTagName("div");
        var len = listNodes.length;
        for(var i=0 ;i<len-1;i++){
            if(listNodes[i].className == "product_detail_list_show") listNodes[i].className = "product_detail_list_hidden";
        }
        if(document.getElementById(id).className == "product_detail_list_hidden"){
            document.getElementById(id).className = "product_detail_list_show";
        }else {document.getElementById(id).className = "product_detail_list_show"};
    }
}
//行业分类菜单效果
function hangyeTypeCss(id){
    if(document.getElementById(id) != null){
        var listNodes = document.getElementById("hangyeTypeList").getElementsByTagName("div");
        var len = listNodes.length;
        for(var i=0 ;i<len-1;i++){
            if(listNodes[i].className == "product_detail_list_show") listNodes[i].className = "product_detail_list_hidden";
        }
        if(document.getElementById(id).className == "product_detail_list_hidden"){
            document.getElementById(id).className = "product_detail_list_show";
        }else {document.getElementById(id).className = "product_detail_list_show"};
    }
}

// 二级分类效果切换
function subTypeFocus(obj,isFocus){
    if(isFocus){obj.className = "prodtypesub2";}
    else {obj.className = "prodtypesub1"};
}


//处理图片自适应大小
function fixImage(i,w,h){ 
    var ow = i.width; 
    var oh = i.height; 
    var rw = w/ow; 
    var rh = h/oh; 
    var r = Math.min(rw,rh); 
    if (w ==0 && h == 0){ 
        r = 1; 
    }else if (w == 0){ 
        r = rh<1?rh:1; 
    }else if (h == 0){ 
        r = rw<1?rw:1; 
    } 
    if (ow!=0 && oh!=0){ 
    i.width = ow * r; 
    i.height = oh * r; 
    }else{ 
      var __method = this, args = $A(arguments); 
        window.setTimeout(function() { 
          fixImage.apply(__method, args); 
        }, 500); 
    } 
    i.onload = function(){} 
} 

//新开窗口浏览图片
function viewProdPic(url){
    window.open(url,"","scrollbars=yes,status=yes,resizable=yes,top=0,left=0,width="+(screen.availWidth-10)+",height="+(screen.availHeight-30));
}

//友情链接弹出窗口
function openfriendPage(url){
    window.open(url,"","");
}


//收藏
function addBookmark(title) {
    var url=parent.location.href;
    if (window.sidebar) { 
        window.sidebar.addPanel(title, url,""); 
    } else if( document.all ) {
        window.external.AddFavorite(url, title);
    } else if( window.opera && window.print ) {
        return true;
    }
}

//设为首页
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('抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入"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',vrl);
         }
    }
}

//获取地址栏参数值
RequestUrlParam = { 
    QueryString : function(item){ 
    var svalue = location.search.match(new RegExp('[\?\&]' + item + '=([^\&]*)(\&?)','i')); 
    return svalue ? svalue[1] : svalue;
    }
}

function getMenuId(Id){
    var title;
    switch (Id)
    {
        case 2:
        case 3:
        case 4:
        case 5:
            title = "0";
            break;

        case 6:
        case 7:
        case 8:
            title = "5";
            break;

        case 9:
            title = "1";
            break;

        case 10:
            title = "2";
            break;

        case 11:
            title = "3";
            break;

        case 12:
            title = "4";
            break;

        default:
            title = "0";
            break;
    }
    return title; 
}



