// JavaScript Document
$(function() {
    var retime = 1
    var time = 0

    var showpiclist = function() {
        if (time == 4) { time = 0 }
        if (retime == 4) { retime = 0 }
        $(".flapic img:eq(" + time + ")").fadeTo(830, 0)
        $(".flapic img:eq(" + retime + ")").fadeTo(830, 1)

        time += 1
        retime += 1

    }

    $('body').everyTime('4s', showpiclist)

    $(".next").click(function() {
        showpiclist()
    })

    $(".prev").click(function() {
        if (retime == 1) {
            retime == 5
            time == 4
            $(".flapic img:eq(2)").fadeTo(830, 0)
            $(".flapic img:eq(1)").fadeTo(830, 0)
            $(".flapic img:eq(0)").fadeTo(830, 0)
        }
        time -= 1
        retime -= 1
        $(".flapic img:eq(" + time + ")").fadeTo(830, 1)
        $(".flapic img:eq(" + retime + ")").fadeTo(830, 0)
    })
    $("#news tbody").children("tr").hover(function() {
        $(this).css("background", "#eee")
    }, function() {
        $(this).css("background", "0")
    })

    $(".lxbg").fadeTo(222, 0.44)

    $(".zhaobg").fadeTo(222, 0.55)

    $(".zhanbg").fadeTo(222, 0.33)

    $(".jianbg").fadeTo(222, 0.33)

    $(".zhao").hover(function() {
        $(".zhaobg").fadeTo(422, 0.22, function() { $(".zhaobg").fadeTo(422, 0.55) })
    }, function() {
        $(".zhaobg").fadeTo(422, 0.55)
    })

    $(".zhan").hover(function() {
        $(".zhanbg").fadeTo(422, 0.11, function() { $(".zhanbg").fadeTo(422, 0.33) })
    }, function() {
        $(".zhanbg").fadeTo(422, 0.33)
    })

    $(".jian").hover(function() {
        $(".jianbg").fadeTo(422, 0.11, function() { $(".jianbg").fadeTo(422, 0.33) })
    }, function() {
        $(".jianbg").fadeTo(422, 0.33)
    })

    $(".nav,.nav-ch").hover(function() {
        $(".navbg").fadeTo(222, 0.3)
        $(this).children("div").show(222)
        $(this).nextAll().children("div").hide(122)
        $(this).prevAll().children("div").hide(122)
        $(".xybg").text("")
    })

    //	$(".navch").mouseout(function(){
    //		$(".navch").fadeTo(122,0)
    //		$(".navbg").fadeTo(122,0)
    //		})

    //    $(".navbg").mouseout(function(event){
    //		var str=String(event.target.nodeName)
    //        if(str != "SPAN"){
    //			  $(this).hide()
    //			  $(".navch").hide()
    //			}
    //		  })

    $(document).click(function(event) {

        $(".navch,.navbg").hide(122);
        $(".xybg").text("　鑫雅橱柜欢迎您")
    });

    //	$(".navbg").mouseout(function(){
    //		$(this).fadeTo(122,0)
    //		})

    $(".inp").focus(function() {
        if ($(this).val().replace(/^\s+|\s+$/g, "") == "产品搜索" || $(this).val().replace(/^\s+|\s+$/g, "") == "") {
            $(this).val("")
        }
    })

    $(".inp").blur(function() {
        if ($(this).val() == "") {
            $(this).val("      产品搜索")
        }
    })

    $(".flag").mouseover(function() {
        $(this).css({ "background": "#af0005", "color": "#fff" })
        $(this).parent().prevAll("a").children(".flag").css({ "background": "white", "color": "black" })
        $(this).parent().nextAll("a").children(".flag").css({ "background": "white", "color": "black" })

        if ($(this).text() == "企业新闻") {
            $(".news tbody:eq(0)").show();
            $(".news tbody:eq(1)").hide();
        }

        if ($(this).text() == "行业新闻") {
            $(".news tbody:eq(0)").hide();
            $(".news tbody:eq(1)").show();
        }
    })

    var t = 0;
    var i = 0;

    $(".td").each(function(index) {
        i = index
    })

    var next = function() {
        t += 1
        if (t > i) {
            //$(".next").css("background","url(Img/nexth.gif)")
            t = 0
            $("#fla table").animate({ left: "" + (-1010 * t) + "px" }, "slow");
        }
        else {
            $("#fla table").animate({ left: "" + (-1010 * t) + "px" }, "slow");
            $(".prev").css("background", "url(Img/prev.gif)")
        } 
    }

    $(".next").click(next)


    $(".prev").click(function() {
        t -= 1
        if (t < 0) {
            $(".prev").css("background", "url(Img/prevh.gif)")
            t += 1
        }
        else {
            $("#fla table").animate({ left: "" + (-1010 * t) + "px" }, "slow");
            $(".next").css("background", "url(Img/next.gif)")
        }

    })

    $('body').everyTime("3s", next)

    $("#float1 img,#float2 img").click(function() {
        $("#float1,#float2").hide(500)
    })

    $(".picshow img").mouseover(function() {
        $(this).fadeTo(230, 0.2, function() {
            $(this).fadeTo(130, 1)
        })
    })

})
	
	

	
	
	
	
	
