
//滚动监听
window.onscroll = function() {
  	var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  	if(scrollTop>=300){
          document.getElementById("topButton").style.display='block';
        }
        else{
          document.getElementById("topButton").style.display='none';
        }
  	if(scrollTop>=50){
  		var box=document.getElementsByClassName("menuLi");
  		for(var i=0;i<box.length;i++){
  			box[i].style.color="#EE587B";
  			box[i].style.backgroundColor="rgb(235,235,235)";
  		}
  		box[0].style.backgroundColor="#EE587B";
  		box[0].style.color="white";
  	}
  	if(scrollTop>=700){
  		var box=document.getElementsByClassName("menuLi");
  		for(var i=0;i<box.length;i++){
  			box[i].style.color="#EE587B";
  			box[i].style.backgroundColor="rgb(235,235,235)";
  		}
  		box[1].style.backgroundColor="#EE587B";
  		box[1].style.color="white";
  	}
}
//滚动控制
function scrollMove(){
        var scrollInterval;
        function animate(to = 0, time = 300){
        	window.clearInterval(scrollInterval);
            var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop || 0;
            var step = (scrollTop - to) / 100;
            scrollInterval = window.setInterval(function(){
                window.scrollTo(0, scrollTop - step);
                scrollTop -= step;
                //console.log(scrollTop);
                if((step <= 0 && scrollTop >= to) || (step > 0 && scrollTop <= to)){
                    window.scrollTo(0, to);
                    window.clearInterval(scrollInterval);
                }
            }, time / 100);
        }
        return animate;
}
var scrollM=scrollMove();
function scrollControl(n){
// 	clearInterval(scrollTime);
// 		var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; 
// 		var num=0;
// 			if(scrollTop>n){
// 				num=scrollTop-n;
// 			}
// 			else{
// 				num=n-scrollTop;
// 			}
// 			console.log(num);
// 			if(num>10){
// 				scrollTime=setInterval(function(){
// 					if(scrollTop<n){
// 						scrollValue=document.documentElement.scrollTop || document.body.scrollTop;
// 						if(scrollValue>=n){
// 							console.log(n);
// 							window.scrollTo(0,n);
// 							window.clearInterval(scrollTime);
// 						}
// 						scrollValue=scrollValue+num/50;
// 						console.log(scrollValue);
// 						window.scrollTo(0,scrollValue);
// 					}
// 					else{
// 						scrollValue=document.documentElement.scrollTop || document.body.scrollTop;
// 						if(scrollValue<=n){
// 							console.log(n);
// 							window.scrollTo(0,n);
// 							window.clearInterval(scrollTime);
// 						}
// 						scrollValue=scrollValue-num/50;
// 						// document.documentElement.scrollTop=scrollValue;
// 						// document.body.scrollTop=scrollValue;
// 						window.scrollTo(0,scrollValue);
// 					}
// 				},1);
// 			}
	scrollM(n,200);
}