$(function () {
    $(window).scroll(function(){
        var top=document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
        // console.log(top);
        if(top==0){
            $(".toTop").hide();
        }else{
            $(".toTop").show();
        }
        if(top>300){
            $(".m-header").addClass("m-header-fix");
        }else{
            $(".m-header").removeClass("m-header-fix");
        }
    });
    $(".toTop").click(function () {
        $('html,body').animate({scrollTop:0},1000);
    });
    $(".header .center-head .right .search").click(function () {
        $(".search-content").fadeIn(300);
    });
    $(".search-content .search-box .close").click(function () {
        $(".search-content").fadeOut(300);
    });
});
$(document).ready(function(){
    var p=0,t=0;
    $(window).scroll(function(){
        p=document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
        // console.log("p==")
        // console.log(p)
        if(t<p && p>0){//下滚
            $(".header").fadeOut(300);
            t = p;
            // console.log(1)
        }
        else{
            if(t>p && p>100){//上滚
                $(".header").addClass("header-fix");
                $(".header-fix").fadeIn(300);
                $(".header-fix").find(".logo-01").addClass("hide");
    			$(".header-fix").find(".logo-02").removeClass("hide");
                $(".header-fix").find(".search").css({backgroundImage:'url(/templates/default/images/search01.png)'});
                t = p;
                // console.log(2)
            }else{
                $(".header").removeClass("header-fix");
                $(".header-fix").fadeOut(300);
                $(".header").fadeIn(300);
                $(".header").find(".logo-01").removeClass("hide");
    			$(".header").find(".logo-02").addClass("hide");
                $(".header").find(".search").css({backgroundImage:'url(/templates/default/images/search.png)'});
                t = p;
                // console.log(3)
            }
        }
        // setTimeout(function(){t = p;},0);
    });
});
// 头部展开
$(".header .center-head .right .nav > li").hover(function () {
    $(".nav-content-bg").stop().fadeIn(300);
    $(".header").addClass("header-fix");
    $(".header-fix").find(".logo-01").addClass("hide");
    $(".header-fix").find(".logo-02").removeClass("hide");
    $(".header-fix").find(".search").css({backgroundImage:'url(/templates/default/images/search01.png)'});
},function () {
    $(".nav-content-bg").stop().fadeOut(300);
    $(".header").removeClass("header-fix");
    $(".header").find(".logo-01").removeClass("hide");
    $(".header").find(".logo-02").addClass("hide");
    $(".header").find(".search").css({backgroundImage:'url(/templates/default/images/search.png)'});
});
//手机导航
$(".m-header .icon").click(function () {
	$(".m-cover").fadeIn(300);
});
$(".m-cover .icon").click(function () {
	$(".m-cover").fadeOut(300);
});

// 选择链接
$(".friend-href .select").click(function () {
   $(this).find(".down-box").slideToggle(500);
});
$(".select .down-box li").click(function () {
	var val=$(this).text();
	console.log(val);
	$(this).parents(".select").find("span").text(val);
	$(this).parents(".select").find("input").val(val);
});