//悬浮客服 BY ETS
$(function(){
	//郭广宇
	!(function(){
		//悬浮客服
		var fixdebox = $("#g-fixedbox"),
			fixdeul = $("#g-fixedlist"),
			fixdeli = fixdeul.children("li"),
			fixdeclose = fixdeli.find(".g-fixed-close");

		fixdeli.hover(function(){
			
			$(this).addClass("g-active");
			
		},function(){
			
			$(this).removeClass("g-active");
			
		})
		
		fixdeul.on("click","li",function(){
			$(this).addClass("g-show").siblings().removeClass("g-show");
			
		});
		
		//关闭客服
		fixdeclose.on("click",function(){
			
			$(this).parents("li").removeClass("g-show");
			
			return false;
			
		});
		
		//设置悬浮框位置
		var docWidth = $(window).width();//浏览器宽度
		var fixdeWidth = fixdebox.outerWidth(true); //悬浮框的宽度
		
		if( docWidth > 1400){
			
			fixdebox.css({left :docWidth/2+ 500 +"px"});
			
			$("#g-backtop").css({left :docWidth/2+ 490 +"px"});
			
		}else{
			
			fixdebox.css({left :docWidth - fixdeWidth +"px"});
			$("#g-backtop").css({left :docWidth - $("#g-backtop").outerWidth(true) +"px"});
		}
			
	})();
	
})

//产品详情页行程滚动控制 BY ZZ

$(window).scroll(function () {
    var postionHeight = $(".zz").position().top;
    var headerdatH = $(".z-special").position().top;
    var topToolbar1 = $(".z-dayList");
    var scrollTop = $(document).scrollTop();
    var curDivHeight = $(".z-special").height();
    var postionHeight1 = $(".postionHeight1").position().top;
 
    var topToolbar = $(".z-nav2");
    
    var scrollTop = $(document).scrollTop();
    if (scrollTop >= headerdatH-660 ) {
        topToolbar.css({ 'top': 60 });
        topToolbar.css("position", "fixed");
        topToolbar.css("z-index", "999");
        if ($(".proNavPlacholder").length <= 0) {
            $('<div class="proNavPlacholder"  style="border:none;"></div>').insertBefore($(".z-nav2"))
        }

    } else if (scrollTop < headerdatH) {
        topToolbar.css({ 'top': 146 });//146
        topToolbar.css("position", "static")
        $(".proNavPlacholder").remove()
    }

    if (scrollTop >  postionHeight-400) {
          topToolbar1.css({ 'top': curDivHeight });
          topToolbar1.css("position", "static");
      } else if (scrollTop >headerdatH-60) {
        topToolbar1.css({ 'top': '110px' });
        topToolbar1.css("position", "fixed");
        topToolbar1.css("z-index", "999");
        var minHeight = 0;
        $('.li_day').each(function (n) {
            var height = $(this).offset().top;
            if ((scrollTop - height) < 100 && ((scrollTop - height) >= minHeight || minHeight == 0)) {
                minHeight = scrollTop - height;
                $('.li_day_title a').removeClass("z-current")
                $('.li_day_title a').eq($(this).index()).addClass("z-current");
            }
        });
    }
    else{
          topToolbar1.css({ 'top': curDivHeight });
          topToolbar1.css("position", "static");
      }


    var zXcjs = $(".z-xcjs").position().top;
    var zXcgy = $(".z-xcgy").position().top;
    var zFysm = $(".z-fysm").position().top;
    var zQzxx = $(".z-qzxx").position().top;
    var zYdxz = $(".z-ydxz").position().top;
    if (scrollTop < zXcjs && scrollTop < postionHeight) {
        $('.zproNavL_0').eq(0).addClass("kq-mid-active").siblings().removeClass("kq-mid-active");
    }
    else if (scrollTop > zQzxx-180 && scrollTop < zYdxz-100) {
        $('.zproNavL_0').eq(3).addClass("kq-mid-active").siblings().removeClass("kq-mid-active");
    }

    else if (scrollTop > zFysm-150 && scrollTop < zQzxx) {
        $('.zproNavL_0').eq(2).addClass("kq-mid-active").siblings().removeClass("kq-mid-active");
    }
    else if (scrollTop > zXcjs && scrollTop < zFysm) {
        $('.zproNavL_0').eq(1).addClass("kq-mid-active").siblings().removeClass("kq-mid-active");
    }
    else if (scrollTop > zXcgy && scrollTop < zXcjs+60) {
        $('.zproNavL_0').eq(0).addClass("kq-mid-active").siblings().removeClass("kq-mid-active");
    }
    else{
        $('.zproNavL_0').eq(4).addClass("kq-mid-active").siblings().removeClass("kq-mid-active");
    }
});