﻿$(function()
{

    $(".chuli").click(function() {
        //ajax 获取服务器数据
        $.ajax
                                ({
                                    url: "main.aspx",
                                    type: "get",
                                    dataType: "html",
                                    data:
                                    {
                                        questions_Id: encodeURI(this.name),
                                        cmd: "sel",
                                        time: new Date().getSeconds()
                                    },
                                    success: function(data) {


                                        var jsonobj = eval('(' + data + ')');

                                        if (data != "") {

                                            var type_name = "";

                                            if (jsonobj.questions_type_Id == 2) {
                                                type_name = "地板常识";
                                            }
                                            if (jsonobj.questions_type_Id == 3) {
                                                type_name = "地板投诉";
                                            }
                                            if (jsonobj.questions_type_Id == 4) {
                                                type_name = "产品选购";
                                            }
                                            if (jsonobj.questions_type_Id == 5) {
                                                type_name = "安装常识";
                                            }
                                            if (jsonobj.questions_type_Id == 6) {
                                                type_name = "售后维权";
                                            }



                                            $("#questions_Body").html(jsonobj.questions_Body);
                                            $("#questions_Results").html(jsonobj.questions_Results);
                                            $("#questions_Id").val(jsonobj.questions_Id);
                                            $("#questions_Datetime").html(new Date(jsonobj.questions_Datetime).toLocaleDateString());
                                            $("#questions_type_Id").html(type_name);


                                        } else {
                                            alert("出现异常！");

                                        }
                                    }

                                });


        //显示对话框
                                showDialog("#questions_dialog");
                                $("#questions_dialog").show();
                                
                              
                                
                                $("#questions_Results").html("");
                                $("#questions_Results").focus();



    });
    //关闭
    $("#ac").click(function() {
        $(window).unbind();
        $("#questions_dialog").hide();
    })




    //每个页面都要配置导航---------------------
    //初始化
    $(".NavMain_Nav li:first").attr("id", "NavMain_Nav_Init_Li");
    $(".NavMain_Nav li:first a").html("首页");
    //每个页面都要配置导航---------------------
    // nav_link 获取焦点
    $(".NavMain_Nav li:not(#NavMain_Nav_Init_Li)").mouseenter(function()
    {
        $(this).css({ "background": "url(index_img/NavMain_Nav_Mouseenter.gif) no-repeat", "width": "89px" });
        //               , "font-size": "14px", "font-weight": "bold"
        $(this).find("a").css("color", "#FFF");
    });
    // nav_link 失去焦点
    $(".NavMain_Nav li:not(#NavMain_Nav_Init_Li)").mouseleave(function()
    {
        $(this).css({ "background": "url(index_img/Nav_Link_Over.gif) no-repeat", "width": "87px" });
        $(this).find("a").css("color", "#525252");
    });
    //搜索类别
    $(".NavMain_Down_Search_Where li").mouseenter(function()
    {
        $(this).siblings("li").css({ "background": "none", "color": "#FFF" });
        $(this).css({ "background": "url(index_img/NavMain_WhereBG.gif) no-repeat", "color": "#1b676a" });
        var a = $(".NavMain_Down_Search_Where li").index(this).toString();

        $("#hidName").val(a);

    });

    $(".NavMain_Station_Con_input").focus(function()
    {
        $(this).val("").css("color", "black");
    });



    //配置所有img带边框颜色获取焦点变色
    $(".ImgBorderInit").mouseenter(function()
    {
        $(this).addClass("ImgBorder_mouseenter");
    });
    //配置所有img带边框颜色失去焦点变色
    $(".ImgBorderInit").mouseleave(function()
    {
        $(this).removeClass("ImgBorder_mouseenter");
    });
    //配置所有img 如果没有图片 设置为默认图片
    $(".ImgBorderInit").each(function(index)
    {
        var ImgPath = $(this).attr("src");
        if (ImgPath.indexOf(".gif") == -1 && ImgPath.indexOf(".jpg") == -1 && ImgPath.indexOf(".jpeg") == -1 && ImgPath.indexOf(".png") == -1)
        {
            $(this).attr("src", "index_img/none.gif");
        };
    })

    //企业新闻特效
    $(".EnterpriseBg232px li").mouseenter(function()
    {
        $(this).siblings().removeClass("EnterpriseBg232px_UlLi_Mouseenter").addClass("EnterpriseBg232px_UlLi_Init");
        $(this).siblings().find("p").hide();
        $(this).siblings().find("div").removeClass("EnterpriseBg232pxTitle_Mouseenter").addClass("EnterpriseBg232pxTitle_Init");
        $(this).removeClass("EnterpriseBg232px_UlLi_Init").addClass("EnterpriseBg232px_UlLi_Mouseenter");
        $(this).find("p").removeClass("EnterpriseBg232pxImg_Init").addClass("EnterpriseBg232pxImg_Mouseenter").show();
        $(this).find("div").removeClass("EnterpriseBg232pxTitle_Init").addClass("EnterpriseBg232pxTitle_Mouseenter");
    });



    //两秒后调用
    var _scrolling = setInterval("AutoScroll()", 6000);
    $("#slide>ul").hover(function()
    {
        //鼠标移动DIV上停止
        clearInterval(_scrolling);
    }, function()
    {
        //离开继续调用
        _scrolling = setInterval("AutoScroll()", 6000);
    });

    //通用选项卡 需配置2个class
    function tabs(tabTit, on, tabCon)
    {
        $(tabCon).each(function() { $(this).children().eq(0).show(); });
        $(tabTit).each(function() { $(this).children().eq(0).addClass(on); });
        $(tabTit).children().hover(function()
        {
            $(this).addClass(on).siblings().removeClass(on);
            var index = $(tabTit).children().index(this);
            $(tabCon).children().eq(index).show().siblings().hide();

            //设置更多的href。 如果用到更多 需要在这里配置全局的
            if ($(this).html() == "产品推荐")
            {
                $("#Product_Status_Link").attr("href", "#");
            }
            if ($(this).html() == "新品上市")
            {
                $("#Product_Status_Link").attr("href", "#");
            }
            if ($(this).html() == "商品热销")
            {
                $("#HotHD_Rating_Link").attr("href", "#");
            }
            if ($(this).html() == "地板测评")
            {
                $("#HotHD_Rating_Link").attr("href", "#");
            }
            if ($(this).html() == "地板市场行情")
            {

                $("#Mart_Rating_Link").attr("href", "information/information_list.aspx?cont_cat_Id=66");
            }
            if ($(this).html() == "坯料市场行情")
            {
                $("#Mart_Rating_Link").attr("href", "information/information_list.aspx?cont_cat_Id=67");
            }

            if ($(this).html() == "促销信息")
            {
                
                $("#HMQ_Mart_link").attr("href", "information/information_list.aspx?cont_cat_Id=50");
            }
            if ($(this).html() == "供求信息")
            {
                $("#HMQ_Mart_link").attr("href", "information/information_list.aspx?cont_cat_Id=33");
            }

            if ($(this).html() == "行业标准")
            {
                $("#A2").attr("href", "information/information_list.aspx?cont_cat_Id=10");
            }
            if ($(this).html() == "地板创新")
            {
                $("#A2").attr("href", "information/information_list.aspx?cont_cat_Id=12");
            }
        });
    }
    tabs(".tab-hd", "active", ".tab-bd");
    tabs(".tab_HotHD", "active", ".tab_HotBD");
    tabs(".tab_MartHD", "active", ".tab_MartBD");
    tabs(".tab_StandardHD", "active", ".tab_StandardBD");
    //推荐产品新款提示曾

    $(".tab-bd").find("div").hover(function(e)
    {
        var offset = $(this).offset();
        var left = offset.left + $(this).width() - 150;
        var top = offset.top + $(this).height() - 340;

        //清空里面的内容 temimgsrc.lastIndexOf("/") + 1
        $("#productTip").empty();
        var tem = ($(this).find("a").attr("href"));
        var Pidtem = tem.substring(tem.lastIndexOf("-") + 1, tem.lastIndexOf("."));
        //判断截取id 是否是数字
        if (!isNaN(Pidtem))
        {
            $.ajax(
                {
                    url: "main.aspx",
                    type: "post",
                    dataType: "html",
                    data: { Pid: Pidtem,
                        cmd: "PTip",
                        time: new Date().getSeconds()
                    },
                    success: function(date)
                    {

                        if (date != "")
                        {
                            $("#productTip").html(date);
                            $("#productTip").css({ "left": left, "top": top }).show();
                        } else { $("#productTip").html(); }
                    }
                });
        }

    }, function(e) { $("#productTip").hide(); });

    $("#SpavingBtn").click(function()
    {
        $("#topBG1").css({ "background": "url(img/铺装工证查询_01.gif) no-repeat" });
        $("#downBG2").css({ "background": "url(img/铺装工证查询_02.gif) no-repeat" });
        $("#supervisionBtn").attr("disabled", "disabled");
        $("#SpavingBtn").attr("disabled", "disabled");
        showDialog("#dialog1");
        $("#dialog1").show(1000);
        $(window).scroll(function()
        {
            showDialog("#dialog1");
            $("#dialog1").show(1000);
        });
        //ajax 获取服务器数据
        $.ajax
                                ({
                                    url: "main.aspx",
                                    type: "post",
                                    dataType: "html",
                                    data:
                                    {
                                        SpavingTxt: encodeURI($("#SpavingTxt").val()),
                                        cmd: "spa",
                                        time: new Date().getSeconds()
                                    },
                                    success: function(data)
                                    {

                                        if (data != "")
                                        {
                                            json = eval(data);
                                            $.each(json, function(InfoIndex, Info)
                                            {
                                                $("#t1").after("<tr name='" + Info["spaving_Card"] + "'><td>" + Info["spaving_Card"] + "</td><td>" + Info["spaving_Name"] + "</td><td>" + Info["spaving_Identity"] + "</td><td>" + Info["spaving_Units"] + "</td><td>" + Info["spaving_Remarks"] + "</td><input  type='hidden' value='" + Info["spaving_Card"] + "'></tr>")
                                            });
                                            $("#listDiv").empty().hide();
                                            $("#listDate").show(600);
                                        } else
                                        {
                                            $("#listDate").hide();
                                            $("#listDiv").empty();
                                            $("#listDate").after("<div id='listDiv' style='text-align:center;color:Red;'>没有搜索到你所查询的内容</div>");
                                        }
                                    }

                                });


    });


    //会员查询按钮点击事件
    $("#woodvipBtn").click(function()
    {



        $("#supervisionBtn").attr("disabled", "disabled");
        $("#SpavingBtn").attr("disabled", "disabled");
        $("#woodvipBtn").attr("disabled", "disabled");

        //ajax 获取服务器数据
        $.ajax
                                ({
                                    url: "main.aspx",
                                    type: "post",
                                    dataType: "html",
                                    data:
                                    {
                                        woodvipTxt: encodeURI($("#woodvipTxt").val()),
                                        cmd: "wood",
                                        time: new Date().getSeconds()
                                    },
                                    success: function(data)
                                    {

                                        if (data != "")
                                        {
                                            $("body").append(data);
                                            showDialog("#woodVipTip");
                                            $(window).scroll(function()
                                            {
                                                showDialog("#woodVipTip");
                                                $("#woodVipTip").show(1000);
                                            });

                                        } else
                                        {
                                            alert("没有查到相关信息!");
                                            $("#SpavingBtn").removeAttr("disabled");
                                            $("#supervisionBtn").removeAttr("disabled");
                                            $("#woodvipBtn").removeAttr("disabled");
                                        }
                                    }

                                });


    });

    //ajax 保存数据
    var json;

    //监理工查询按钮点击事件
    $("#supervisionBtn").click(function()
    {

        $("#topBG1").css({ "background": "url(img/监理工证查询1_01.gif) no-repeat" });
        $("#downBG2").css({ "background": "url(img/监理工证查询1_03.gif) no-repeat" });

        $("#supervisionBtn").attr("disabled", "disabled");
        $("#SpavingBtn").attr("disabled", "disabled");
        showDialog("#dialog1");
        $("#dialog1").show(1000);
        $(window).scroll(function()
        {
            showDialog("#dialog1");
            $("#dialog1").show(1000);
        });
        //ajax 获取服务器数据
        $.ajax
                                ({
                                    url: "main.aspx",
                                    type: "post",
                                    dataType: "html",
                                    data:
                                    {
                                        supervisionTxt: encodeURI($("#supervisionTxt").val()),
                                        cmd: "svb",
                                        time: new Date().getSeconds()
                                    },
                                    success: function(data)
                                    {

                                        if (data != "")
                                        {
                                            json = eval(data);
                                            $.each(json, function(InfoIndex, Info)
                                            {
                                                $("#t1").after("<tr name='" + Info["supervision_Card"] + "'><td>" + Info["supervision_Card"] + "</td><td>" + Info["supervision_Name"] + "</td><td>" + Info["supervision_Identity"] + "</td><td>" + Info["supervision_Units"] + "</td><td>" + Info["supervision_Remarks"] + "</td><input  type='hidden' value='" + Info["supervision_Card"] + "'></tr>")
                                            });
                                            $("#listDiv").empty().hide();
                                            $("#listDate").show(600);
                                        } else
                                        {
                                            $("#listDate").hide();
                                            $("#listDiv").empty();
                                            $("#listDate").after("<div id='listDiv' style='text-align:center;color:Red;'>没有搜索到你所查询的内容</div>");
                                        }
                                    }

                                });


    });
    //设置 提示div的位置
    function showDialog(name)
    {

        var objW = $(window);
        var objC = $(name);
        var brsW = objW.width();
        var brsH = objW.height();
        var sclL = objW.scrollLeft();
        var sclT = objW.scrollTop();

        var curW = objC.width();
        var curH = objC.height();
        var left = sclL + (brsW - curW) / 2;
        var top = sclT + (brsH - curH) / 2;
        objC.css({ "left": left, "top": top });
    };
    $(window).resize(function()
    {
        if (!$("#dialog1").is(":visible"))
        {
            return;
        }
        showDialog();
    });
    //会员关闭提示层按钮
    $(".cbtnwoodvip").live("click", function()
    {


        $("#woodVipTip").remove();

        $("#SpavingBtn").removeAttr("disabled");
        $("#supervisionBtn").removeAttr("disabled");
        $("#woodvipBtn").removeAttr("disabled");


    });
    //关闭提示层按钮
    $(".cbtn").click(function()
    {

        $("#dialog1").hide(1000);

        $("#SpavingBtn").removeAttr("disabled");
        $("#supervisionBtn").removeAttr("disabled");
        $("#woodvipBtn").removeAttr("disabled");


        $("#t1").siblings("tr").remove();

        $(window).unbind();
        $("#divTip").empty().hide();
    });
    //关闭按钮获取焦点css样式
    $(".cbtn").mousemove(function()
    {
        $(".cbtn").css({ "color": "EA5200", "font-weight": "bold" });
    });
    //关闭按钮失去焦点css样式
    $(".cbtn").mouseout(function()
    {
        $(".cbtn").css({ "color": "Black", "font-weight": "normal" });
    });
    //tr 获取焦点事件创建2级提示层
    $("#listDate tr:not(#t1)").live("mouseenter", function(e)
    {
        $("#divTip").empty().hide();
        $(this).css({ "color": "EA5200", "font-weight": "bold", "background-color": "#e6e4ee" });
        var offset = $(this).offset();
        var left = offset.left + $(this).width() - 20;
        var top = offset.top + $(this).height() - 50;
        var IdCard = $(this).attr("name");
        for (var i = 0; i < json.length; i++)
        {
            if (json[i].supervision_Card == IdCard)
            {

                var supervision_Photos = $("#cihidden").val() + "supervision/" + json[i].supervision_Photos;
                var supervision_Sex = json[i].supervision_Sex == 1 ? "男" : "女";
                var supervision_Level = "初级";
                if (json[i].supervision_Level == 2)
                {
                    supervision_Level = "中级";
                }
                if (json[i].supervision_Level == 3)
                {
                    supervision_Level = "高级";
                }

                var imgdiv = "<img src='" + supervision_Photos + "' style='width:114px; height:152px;margin-left:30px; margin-top:15px;border:1px solid #CCCCCC; padding:4px;float:left;'/><div style='float:left; width:120px; height:160px;color:#444444;'><div style='margin:10px;'><ul style='margin-top:20px;line-height:30px;'><li style='font-weight:bold'>性别：" + supervision_Sex + "</li><li style='font-weight:bold'>等级：" + supervision_Level + "证书</li><li style='font-weight:bold'>领证时间</li><li>" + new Date(json[i].supervision_begin_time).toLocaleString() + "</li></ul></div></div>"
            }


            if (json[i].spaving_Card == IdCard)
            {

                var spaving_Photos = $("#cihidden").val() + "spaving/" + json[i].spaving_Photos;
                var spaving_Sex = json[i].spaving_Sex == 1 ? "男" : "女";
                var spaving_Level = "初级";
                if (json[i].spaving_Level == 2)
                {
                    spaving_Level = "中级";
                }
                if (json[i].spaving_Level == 3)
                {
                    spaving_Level = "高级";
                }

                var imgdiv = "<img src='" + spaving_Photos + "' style='width:114px; height:152px;margin-left:30px; margin-top:15px;border:1px solid #CCCCCC; padding:4px;float:left;'/><div style='float:left; width:120px; height:160px;color:#444444;'><div style='margin:10px;'><ul style='margin-top:20px;line-height:30px;'><li style='font-weight:bold'>性别：" + spaving_Sex + "</li><li style='font-weight:bold'>等级：" + spaving_Level + "证书</li><li style='font-weight:bold'>领证时间</li><li>" + new Date(json[i].spaving_begin_time).toLocaleString() + "</li></ul></div></div>"
            }

        };

        $("#divTip").append(imgdiv).css({ "left": left, "top": top }).slideDown(500);
    });
    //tr 失去焦点事件改变css样式
    $("#listDate tr").live("mouseout", function(e)
    {
        $(this).css({ "color": "Black", "font-weight": "normal", "background-color": "#efefef" });
    });
    //失去层焦点 关闭2级提示层
    $("#divTip").live("mouseleave", function()
    {
        $(this).empty().hide();
    });
    //失去层焦点 关闭2级提示层
    $("#sqjddiv").siblings("div").mouseenter(function()
    {

        $("#divTip").empty().hide();
    });
    // 初始化
    $("#supervisionTxt").click(function()
    {
        $(this).val("");
        $(this).css({ "color": "Black" });
    });
    $("#SpavingTxt").click(function()
    {
        $(this).val("");
        $(this).css({ "color": "Black" });
    });
    $("#woodvipTxt").click(function()
    {
        $(this).val("");
        $(this).css({ "color": "Black" });
    });


    //延迟加在图片
    $(".Product_Status img").lazyload({
        threshold: 200,
        placeholder: "../img/grey.gif",
        effect: "fadeIn"
    });
    //延迟加在图片
    //返回顶部
    $('#roll').hide();
    $(window).scroll(function()
    {
        if ($(window).scrollTop() >= 100)
        {
            $('#roll').fadeIn(400);
        }
        else
        {
            $('#roll').fadeOut(200);
        }
    });
    $('#roll_top').click(function() { $('html,body').animate({ scrollTop: '0px' }, 800); });
    $('#roll_bottom').click(function() { $('html,body').animate({ scrollTop: $('#bottombox').offset().top }, 800); });
    //返回顶部

});

function H$(i) { return document.getElementById(i) }
function H$$(c, p) { return p.getElementsByTagName(c) }
var Vip_slider = function()
{
    function inits(o)
    {
        this.id = o.id;
        this.at = o.auto ? o.auto : 3;
        this.o = 0;
        this.pos();

    }
    inits.prototype = {
        pos: function()
        {
            clearInterval(this.__b);
            this.o = 0;
            var el = H$(this.id), li = H$$('li', el), l = li.length;
            var _t = li[l - 1].offsetHeight;
            var cl = li[l - 1].cloneNode(true);
            cl.style.opacity = 0; cl.style.filter = 'alpha(opacity=0)';
            el.insertBefore(cl, el.firstChild);
            el.style.top = -_t + 'px';
            this.anim();
        },
        anim: function()
        {
            var _this = this;
            this.__a = setInterval(function() { _this.animH() }, 20);
        },
        animH: function()
        {
            var _t = parseInt(H$(this.id).style.top), _this = this;
            if (_t >= -1)
            {
                clearInterval(this.__a);
                H$(this.id).style.top = 0;
                var list = H$$('li', H$(this.id));
                H$(this.id).removeChild(list[list.length - 1]);
                this.__c = setInterval(function() { _this.animO() }, 20);
                //this.auto();
            } else
            {
                var __t = Math.abs(_t) - Math.ceil(Math.abs(_t) * .07);
                H$(this.id).style.top = -__t + 'px';
            }
        },
        animO: function()
        {
            this.o += 2;
            if (this.o == 100)
            {
                clearInterval(this.__c);
                H$$('li', H$(this.id))[0].style.opacity = 1;
                H$$('li', H$(this.id))[0].style.filter = 'alpha(opacity=100)';
                this.auto();
            } else
            {
                H$$('li', H$(this.id))[0].style.opacity = this.o / 100;
                H$$('li', H$(this.id))[0].style.filter = 'alpha(opacity=' + this.o + ')';
            }
        },
        auto: function()
        {
            var _this = this;
            this.__b = setInterval(function() { _this.pos() }, this.at * 1000);
        }
    }
    return inits;
} ();
//企业新闻滑动
function AutoScroll()
{
    var _scroll = $("#slide>ul");
    //ul往左边移动138px
    _scroll.animate({ marginLeft: "-138px" }, 100, function()
    {
        //把第一个li丢最后面去
        _scroll.css({ marginLeft: 0 }).find("li:first").appendTo(_scroll);
    });
}

        lastScrollY = 0;
        function heartBeat() {
            var diffY;
            if (document.documentElement && document.documentElement.scrollTop)
                diffY = document.documentElement.scrollTop;
            else if (document.body)
                diffY = document.body.scrollTop
            else
            { /*Netscape stuff*/ }
            percent = .1 * (diffY - lastScrollY);
            if (percent > 0) percent = Math.ceil(percent);
            else percent = Math.floor(percent);
            document.getElementById("lovexin12").style.top = parseInt(document.getElementById
("lovexin12").style.top) + percent + "px";
            document.getElementById("lovexin14").style.top = parseInt(document.getElementById
("lovexin12").style.top) + percent + "px";
            lastScrollY = lastScrollY + percent;
        }
        suspendcode12 = "<DIV id=\"lovexin12\" style='left:2px;POSITION:absolute;TOP:320px;'><a href='http://www.domotexasiachinafloor.com'><img src='ad_img/shbl.gif'></a></div>"
        suspendcode14 = "<DIV id=\"lovexin14\" style='right:2px;POSITION:absolute;TOP:320px;'><a href='http://www.domotexasiachinafloor.com'><img src='ad_img/shbl.gif'></a></div>"
        document.write(suspendcode12);
        document.write(suspendcode14);
        window.setInterval("heartBeat()", 1);

