﻿/// <reference path="../..//js/jquery-1.2.6.min.js" />


jQuery(document).ready(function($) {
    try {
        //联系人双色
        $("li:even", ".contact").addClass("lieven");
        $(".lileft:even", ".contact").addClass("lievenleft");
        $(".lileft:odd", ".contact").css("padding-right", "14px");

        $("li:even", ".detail").addClass("lieven");
        $(".lileft:even", ".detail").addClass("lievenleft");



        //关闭窗口
        $(".closewindow").click(function() {
            window.close();
        });


        //产品class
        $(".productclassli").hover(function() {
            $(this).addClass("productclasslibghover");
        }, function() {
            $(this).removeClass("productclasslibghover");
        });

        //产品列表变色
        $(".productlistitem").hover(
    function() {
        $(this).addClass("productlistitem-color");
    },
    function() {
        $(this).removeClass("productlistitem-color");
    });


        //产品精简更多 定位
        //    var topx = 0;
        //    var leftx = 0;
        //    var widthx = 0;
        //    var heightx = 0;
        //    $(".productclassli").each(function() {
        //        if ($(this).offset().top > topx)
        //            topx = $(this).offset().top;

        //        if ($(this).offset().left > leftx)
        //            leftx = $(this).offset().left;
        //        widthx = parseInt($(this).css("width"));
        //        heightx = parseInt($(this).css("height"));
        //    });

        //    var rtop = topx + heightx / 2;
        //    var rleft = leftx + widthx;

        //    var lwidth = $(".uplittle").offset().left;
        //    var mwidth = $(".downmore").offset().left;
        //    if (lwidth < leftx) { $(".uplittle").css("left", leftx - lwidth+heightx); }
        // $(".uplittle").css({ top: rtop + "px", left: rleft + "px" });
        // $(".downmore").css({ top: rtop + "px", left: rleft + "px" });

        //产品分类列变色
        $(".productclassli").hover(function() {
            $(this).addClass("productclassli-color");
        },
     function() {

         $(this).removeClass("productclassli-color");
     });

        $("a", ".productclassli").click(function() {
            $(this).parent().removeClass("productclassli-color");
            $(this).parent().addClass("productclasslibgclick");
        });


        $(".linkDetail").click(function() {
            var linkmbody = $(".linkmaninfobody");
            if (linkmbody.css("display") != "none") {
                $(".linkmaninfobody").css("display", "none");
            } else {
                $(".linkmaninfobody").css("display", "block");
            }
        });

        //产品行单击事件
        //    $(".pitem").click(function() {

        /* $(".productlistname").click(function() {
        var memberID = $("#hdMemberID").val();
       
        if ($(this).attr("search") != "")
        //window.location.href = "ProductDetail.aspx?id=" + $(this).attr("alt") + $(this).attr("search") + memberNo();
        window.location.href = "/" + memberID + "/product_" + $(this).attr("alt") + ".html?" + $(this).attr("search");
        else
        // window.location.href = "ProductDetail.aspx?id=" + $(this).attr("alt") + memberNo();
        window.location.href = "/" + memberID + "/product_" + $(this).attr("alt") + ".html";
        });*/



        //商机行单击事件
        /*$(".bitem").click(function() {

        var memberID = $("#hdMemberID").val();

        if ($(this).attr("search") != "")
        // window.location.href = "BusinessinfoDetail.aspx?id=" + $(this).attr("alt") + $(this).attr("search") + memberNo();
        window.location.href = "/" + memberID + "/tradeInfo_" + $(this).attr("alt") + ".html?" + $(this).attr("search");
        else
        //window.location.href = "BusinessinfoDetail.aspx?id=" + $(this).attr("alt") + memberNo();
        window.location.href = "/" + memberID + "/tradeInfo_" + $(this).attr("alt") + ".html";
        });*/


        //证书行单击事件
        $(".citem").click(function() {
            var memberID = $("#hdMemberID").val();
            if ($(this).attr("search") != "")
            //window.location.href = "CertDetail.aspx?id=" + $(this).attr("alt") + $(this).attr("search") + memberNo();
            //window.open("CertDetail.aspx?id=" + $(this).attr("alt") + $(this).attr("search") + memberNo());
                window.location.href = "/" + memberID + "/cert_" + $(this).attr("alt") + ".html?" + $(this).attr("search");
            else
            //window.location.href = "CertDetail.aspx?id=" + $(this).attr("alt") + memberNo();
            //window.open("CertDetail.aspx?id=" + $(this).attr("alt") + memberNo());
                window.location.href = "/" + memberID + "/cert_" + $(this).attr("alt") + ".html";
        });


        $(".libackgd").hover(function() {
            $(this).addClass("libg");
        },
    function() {
        $(this).removeClass("libg");
    }
    );






        $(".overimg").each(function(i) {

            var div = document.createElement("div");
            div.className = "overdiv";
            div.id = "overdiv" + i;

            var ths = $(this);
            var top = ths.offset().top;
            var left = ths.offset().left;
            var height = ths.height();
            var width = ths.width();
            var value = eval(ths.attr("titlex"));
            var divtop = top + height - 28 + 2;

            $(div).html("&nbsp;&nbsp;<span style=\"font-size:13px\">" + sSubstr(value.name, 10, "..") + "</span>");
            $(div).css({ left: left + 1, top: divtop, width: width, height: '28px', display: 'block', position: 'absolute' });
            $(div).css("z-index", "100");
            $("body").append(div);
            $(ths).attr("overdiv", i);
        });

        var t;

        $(".overimg").hover(function() {

            try {
                $(".overimg").each(function(i) {
                    var ths = $(this);
                    var top = ths.offset().top;
                    var height = ths.height();
                    var width = ths.width();
                    var top = ths.offset().top;
                    var divtop = top + height - 28 + 2;
                    var value = eval(ths.attr("titlex"));
                    var bdiv = $("#overdiv" + i);

                    if (bdiv.height() != 28) {
                        bdiv.html("&nbsp;&nbsp;<span style=\"font-size:13px\">" + sSubstr(value.name, 10, "..") + "</span>")
                        $(bdiv).css({ top: divtop, height: '28px', display: 'block', position: 'absolute' }).show(1000);
                    }
                });

                var ths = $(this);

                value = eval(ths.attr("titlex"));
                var sPrice = "";
                if (jQuery.trim(value.price) == "") {
                    sPrice = "面议";
                } else {
                    sPrice = value.price + " <span style=\"color:#000000\">" + value.unit + "</span>";
                }
                var html = "";
                if (value.name != "") { html += "<div>&nbsp;&nbsp;<span style=\"font-size:13px\">" + sSubstr(value.name, 10, "..") + "</span></div>"; }
                if (value.series != "") { html += "<div>&nbsp;&nbsp;品牌：" + value.series + "</div>"; }
                if (value.type != "") { html += "<div>&nbsp;&nbsp;型号：" + value.type + "</div>"; }
                if (value.price != "") { html += "<div>&nbsp;&nbsp;价格：<span style=\"color:red\" >" + sPrice + "</span></div>"; }


                var odiv = $(this).attr("overdiv");
                var ohdiv = $("#overdiv" + odiv);


                var top = parseInt(ohdiv.css("top")) - 50;
                var left = parseInt(ohdiv.css("left"));
                var height = parseInt(ohdiv.css("height")) + 50;
                var width = parseInt(ohdiv.css("width"));

                if (parseInt(ohdiv.css("height")) == 28) {

                    ohdiv.html(html);
                    ohdiv.css({ top: top + 'px', height: height + 'px' });
                }
                clearInterval(t);
            } catch (e) { }

        }, function() {
            var ths = $(this);
            t = setTimeout(function() {
                var value = eval(ths.attr("titlex"));

                var odiv = $(ths).attr("overdiv");
                var ohdiv = $("#overdiv" + odiv);


                var top = parseInt(ohdiv.css("top")) + 50;
                var left = parseInt(ohdiv.css("left"));
                var height = parseInt(ohdiv.css("height")) - 50;
                var width = parseInt(ohdiv.css("width"));
                //alert(height);

                ohdiv.html("&nbsp;&nbsp;<span style=\"font-size:13px\">" + sSubstr(value.name, 10, "..") + "</span>");
                ohdiv.css({ top: top + 'px', height: height + 'px' });
            }, 200);

        });

        //遮蔽div[首页图片加蒙城]
        //    $(".overimg").hover(function() {
        //        var ths = $(this);
        //        var top = ths.offset().top;
        //        var left = ths.offset().left;
        //        var height = ths.height();
        //        var width = ths.width();
        //        var value = ths.attr("title");
        //        var divtop = top + height - 30;

        //        $(".overdiv").html("&nbsp;&nbsp;" + value);
        //        $(".overdiv").css({ left: left, top: divtop, width: width, height: '30px', display: 'block' });
        //        clearInterval(t);
        //    },
        //    function() {

        //        t = setTimeout(function() { $(".overdiv").css({ display: 'none' }); }, 200);
        //    });

        $(".overdiv").hover(function() {
            clearInterval(t);

        }, function() {

            var ths = $(this);
            t = setTimeout(function() {
                //  $(".overdiv").css({ display: 'none' });


                //     t = setTimeout(function() {
                //     var value = eval(ths.attr("title"));

                //     var odiv = $(ths).attr("overdiv");
                //     var ohdiv = $("#overdiv" + odiv);


                var top = parseInt(ths.css("top")) + 50;
                var left = parseInt(ths.css("left"));
                var height = parseInt(ths.css("height")) - 50;
                var width = parseInt(ths.css("width"));
                //alert(height);

                ths.html("&nbsp;&nbsp;<span style=\"font-size:13px\">" + sSubstr(value.name, 10, "..") + "</span>");
                ths.css({ top: top + 'px', height: height + 'px' });


            }, 200);
        })


        //详情，单击小图片显示大图片
        $(".littleimg").click(function() {

            var src = $(this).attr("src");

            $(".bigimage").attr("src", src);
            src = src.substring(0, src.lastIndexOf('.')) + "_bg" + src.substring(src.lastIndexOf('.'));
            $(".jqzoom").attr("href", src);
            // alert($(".jqzoom").attr("href"));
        });



        //大图小图显示js
        $(function() {
            var options = {
                //zoomType:'reverse',
                zoomWidth: 500,
                zoomHeight: 250,
                //showEffect:'show',
                //hideEffect:'fadeout',
                //fadeoutSpeed: 'slow',
                title: false

            };
            try {
                $(".jqzoom").jqzoom(options);
            } catch (e) { }
        });




        //火狐浏览器特殊处理
        //$("li", ".detail").css("margin-left", "68px");
        if ($.browser.mozilla || $.browser.safari) {
            $("li", ".detail").css("margin-left", "50px");
            $("li", ".detail").css("width", "618px");
        }

        //用户中所有的A链接处理
        $("a").each(function() {
            if (getArgsone()["membernumber"] != "undefined") {
                try {
                    var ahref = $(this).attr("href");
                    if (ahref.indexOf(".aspx") > 0) {
                        if (ahref.indexOf("?") > 0) {
                            $(this).attr("href", ahref + "&membernumber=" + getArgsone()["membernumber"]);
                        } else {

                            $(this).attr("href", ahref + "?membernumber=" + getArgsone()["membernumber"]);
                        }
                    }
                } catch (e) { }

            }
        })

        //ie6 浏览器
        if (document.all) {
            if (!window.XMLHttpRequest) {
                // jQuery(".titlediv", ".rightDiv").css("width", "815px");
                //  jQuery(".bodydiv", ".rightDiv").css("width", "815px");

                //            $(".leftDiv").css("width", "180px");
                //            $(".btnDiv").css("width", "180px");
                //            $(" .BodyDiv .rightDiv .businessinfo .bodydiv .productlist .productlistbody  .productlistitem div").css("height", "48px");
            } else if (window.XMLHttpRequest) {
                //        jQuery("li", ".detail .bodydiv").css("width", "620px");
                //        jQuery(".detail", ".bodydiv").css("margin-left", "0px");
                //        jQuery(".detail", ".bodydiv").css("padding-left", "-10px");
            }
        }


        //设置底部条的高度
        //alert($("#Div1hidden").offset().top);
        //首先设置一次！
        var div1h = parseInt($("#Div1hidden").offset().top);
        var div2h = parseInt($("#Div2hidden").offset().top);
        var divt = 0;

        if (div1h > div2h) { divt = div1h; } else { divt = div2h; }

        $("#FooterDiv").css({ top: divt + 'px', left: '0px', width: '1004px' });

        //为确保都能设置成功，延时动态设置10次！
        var timenum = 0;
        w();
        function w() {
            setTimeout(function() {

                //循环设置长度
                $(".lileft").each(function() {
                    if (document.all) {
                        //IE 设置 联系人 li 宽度 490px, 样式中默认600
                        $(".liright").css("width", "490px");
                    }
                    $(this).height($(this).parent().children(".liright").height());
                });

                div1h = parseInt($("#Div1hidden").offset().top);
                div2h = parseInt($("#Div2hidden").offset().top);
                divt = 0;
                if (div1h > div2h) { divt = div1h; } else { divt = div2h; }


                $("#FooterDiv").css({ top: divt + 'px', left: '0px', width: '1001px' });
                //alert("1");
                timenum++;
                //if (timenum < 5) {


                w();
                //}

            }, 200);
        }
        // alert($("#Div1hidden").offset().top);

    } catch (e) { } 
});


/*
$("#FooterDiv").css({ top: $("#Div1hidden").offset().top + 'px', left: '0px', width: '1004px' });

//为确保都能设置成功，延时动态设置10次！
var timenum = 0;
w();
function w() {
setTimeout(function() {
$("#FooterDiv").css({ top: $("#Div1hidden").offset().top + 'px', left: '0px', width: '1004px' });
//alert("1");
timenum++;
//if (timenum < 100) {
w();
//}

}, 200);
}
// alert($("#Div1hidden").offset().top);

});
*/


//翻页下拉设置
function changePage(ths) {
    var href = window.location.href;

    var url = href.substr(0, href.indexOf("?") + 1)
    var para = "";

    for (var i = 0; i < getArgs().aid.length; i++) {
        if (getArgs().aid[i].toLowerCase() != "page") {
            para += "&" + getArgs().aid[i] + "=" + getArgs().aval[i];
        } else {
            para += "&" + getArgs().aid[i] + "=" + ths.value;
        }
    }
    para = para.substr(1);


    window.location.href = url + para;
}





//加入收藏夹
function addCookie() {
    var homepage = window.location.href;
    var title = jQuery.trim(jQuery("title").html());
    if (document.all) {
        window.external.addFavorite(homepage, title);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(title, homepage, "");
    }
}


//设为首页
function setHomepage() {
    var homepage = window.location.href;

    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(homepage);

    }
    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', homepage);
    }
}





/**//**
      * 提取URL中的参数
      */

function getArgs() {
    //加上substring的意义是去掉查询字符串中的？号。
    //var query = window.location.search.substring(1);

    //定义一个数组，用于存放取出来的字符串参数。
    //    var argsArr =  new Object();
    var arrid = new Array();
    var arrval = new Array();
    var j = 0;
    //获取URL中的查询字符串参数
    var query = window.location.search;
    query = query.substring(1);

    //这里的pairs是一个字符串数组
    var pairs = query.split("&"); //name=myname&password=1234&sex=male&address=nanjing

    for (var i = 0; i < pairs.length; i++) {
        var sign = pairs[i].indexOf("=");
        //如果没有找到=号，那么就跳过，跳到下一个字符串（下一个循环）。
        if (sign == -1) {
            continue;
        }

        var aKey = pairs[i].substring(0, sign);
        var aValue = pairs[i].substring(sign + 1);

        //        argsArr[aKey] = aValue;
        arrid[j] = aKey;
        arrval[j] = aValue;
        j++;

    }
    return { aid: arrid, aval: arrval }

}



/**//**
      * 提取URL中的参数
      */

function getArgsone() {
    //加上substring的意义是去掉查询字符串中的？号。
    //var query = window.location.search.substring(1);

    //定义一个数组，用于存放取出来的字符串参数。
    var argsArr = new Object();

    //获取URL中的查询字符串参数
    var query = window.location.search;
    query = query.substring(1);

    //这里的pairs是一个字符串数组
    var pairs = query.split("&"); //name=myname&password=1234&sex=male&address=nanjing

    for (var i = 0; i < pairs.length; i++) {
        var sign = pairs[i].indexOf("=");
        //如果没有找到=号，那么就跳过，跳到下一个字符串（下一个循环）。
        if (sign == -1) {
            continue;
        }

        var aKey = pairs[i].substring(0, sign);
        var aValue = pairs[i].substring(sign + 1);

        argsArr[aKey] = aValue;


    }
    return argsArr;

}


//返回会员编号
function memberNo() {
    if (getArgsone()["membernumber"] != "undefined") {
        return "&membernumber=" + getArgsone()["membernumber"];
    }

    return "";
}


function sSubstr(str, len, ex) {

    if (str.length > 10) {
        return str.substr(0, len) + ex;
    }
    return str;
}



/*添加会员管理入口*/
jQuery(".managerlogin").attr("href", "http://www.china-dirs.com/Login.aspx?ComeUrl=home");
jQuery(".managerlogin").attr("target", "_blank");


   
   