(function ($) {
  //创建类
  var Carousel = function (con) {
    var self = this;
    this.con = con;
    this.setDirect();
    this.conItem = con.find("ul.list");
    this.prev = con.find(".prev-btn");
    this.next = con.find(".next-btn");
    this.conItems = con.find("li");
    this.conItemFirst = this.conItems.first();
    this.conItemLast = this.conItems.last();
    this.flag = true;
    //默认配置参数
    this.settings = {
      width: 900, //幻灯片的宽度
      height: 1000, //幻灯片的高度
      postWidth: 658, //第一帧的宽度
      postHeight: 411, //第一帧的高
      scale: 0.8,
      speed: 500,
      verticalAlign: "center",
      autoPlay: false,
      delay: 1000,
    };
    $.extend(this.settings, this.getSetting());
    this.setSettingValue();
    this.setPostOther();
    this.next.on("click", function () {
      if (self.flag) {
        self.flag = false;
        self.rotate("left");
      }
    });
    this.prev.on("click", function () {
      if (self.flag) {
        self.flag = false;
        self.rotate("right");
      }
    });
    if (this.settings.autoPlay) {
      this.autoPlay();
      this.con.hover(
        function () {
          window.clearInterval(self.timer);
        },
        function () {
          self.autoPlay();
        }
      );
    }
  };

  // 登陆之后数据传参
	$.ajax({
    type:"POST",
    url:"/user/checkStu",
    dataType:'json',
    success:function(data){
      if(data.ok){
      //  $("#top_loginarea").html("<br>"+data.name+"（<a style='color:red' href='/user/stuLogin'  target='_blank' cl class='cRed1 bold'>会员中心</a>）"
      //  +"【<a href='javascript:;' onclick='loginout();' style='color:red' class='cRed1 bold'>退出</a>】"
      //  );
       $("#loginI").html("<a href='/user/stuLogin' style='color:white'>会员中心</a>");
       $(".zc_btn_icon").css('display','none');
       $(".loginchanges").html("您好，"+data.name);
       $("#avatar").attr('src','images/Avatar2.jpg')
       
      }			   
    }
  });


	function loginout()
	{
		//登出
		$.ajax({
    		async:true,
    		type:"POST",
    		dataType:'json',
    		url:"../user/loginOut",
    		success:function(data)
    		{
    			if(data)
    			{

    				window.location="http://www.youeclass.com/user/enter.jsp"; //回首页

    			}else
    			{
    				//window.location="/";
    				alert("退出失败");
    			}
    		},
    		error:function()
    		{
    			alert("系统异常");
    		}
    		
    	});
	}







  Function.prototype.makeMulti = function () {
    let l = new String(this);
    l = l.substring(l.indexOf("/*") + 3, l.lastIndexOf("*/"));
    return l;
  };

 

  let string = function () {
	/*
 __   __   ___    _   _   ___    ___   _        _     ___   ___ 
 \ \ / /  / _ \  | | | | | __|  / __| | |      /_\   / __| / __|
  \ V /  | (_) | | |_| | | _|  | (__  | |__   / _ \  \__ \ \__ \
   |_|    \___/   \___/  |___|  \___| |____| /_/ \_\ |___/ |___/
                                                   
*/
  };

  console.log(navigator.userAgent);

  console.log(string.makeMulti());

  window.onload = function () {};

  window.addEventListener("load", function () {
    this.console.log(
      "%c-好--学--未--来--网--络--科--技-\n","color:#0f0;"
    );
    this.console.log(
      " %c Code %c DXL",
      "color:#f00;",
      "font-size:20px;color:#0ff;background:#0c5f52;"
    );
  });

  // var dxl =document.querySelector('lntl_box');
  // onkeydown =function (){
  //     this.alert("测试阶段仅浏览，请勿按动键盘")
  //  }
  //原型方法
  Carousel.prototype = {
    //设置上一张和下一张大小
    setDirect: function () {},
    //自动播放函数
    autoPlay: function () {
      var self = this;
      this.timer = window.setInterval(function () {
        self.next.click();
      }, this.settings.delay);
    },

    //旋转函数
    rotate: function (dir) {
      var _this = this;
      var zIndex = [];
      if (dir === "left") {
        this.conItems.each(function () {
          var prev = $(this).prev().get(0) ? $(this).prev() : _this.conItemLast;
          zIndex.push(prev.css("zIndex"));
          $(this).animate(
            {
              width: prev.width(),
              height: prev.height(),
              top: prev.css("top"),
              left: prev.css("left"),
              opacity: prev.css("opacity"),
            },
            _this.settings.speed,
            function () {
              _this.flag = true;
            }
          );
        });
        this.conItems.each(function (i) {
          $(this).css({ zIndex: zIndex[i] });
        });
      } else if (dir === "right") {
        this.conItems.each(function () {
          var next = $(this).next().get(0)
            ? $(this).next()
            : _this.conItemFirst;
          zIndex.push(next.css("zIndex"));
          $(this).animate(
            {
              width: next.width(),
              height: next.height(),
              top: next.css("top"),
              left: next.css("left"),
              opacity: next.css("opacity"),
              border: "20px solid #fff",
            },
            _this.settings.speed,
            function () {
              _this.flag = true;
            }
          );
        });
        this.conItems.each(function (i) {
          $(this).css({ zIndex: zIndex[i] });
        });
      }
    },

    //设置剩余帧位置关系
    setPostOther: function () {
      var self = this,
        sliceItem = this.conItems.slice(1),
        sliceLength = sliceItem.length,
        rightItem = sliceItem.slice(0, sliceLength / 2),
        leftItem = sliceItem.slice(sliceLength / 2),
        level = Math.floor(sliceLength / 2),
        llevel = level,
        rw = this.settings.postWidth,
        rh = this.settings.postHeight,
        gap = (this.settings.width - this.settings.postWidth) / 2 / level;
      rightItem.each(function (i) {
        rw = rw * self.settings.scale;
        rh = rh * self.settings.scale;
        var j = i;
        $(this).css({
          zIndex: --level,
          width: rw,
          height: rh,
          left:
            (self.settings.width + self.settings.postWidth) / 2 +
            gap * ++i -
            rw,
          top: self.setVerticalAlign(rh),
          opacity: 1 / ++j,
          //border: '20px solid #fff'
        });
      });
      var lw = rightItem.last().width(),
        lh = rightItem.last().height();
      leftItem.each(function (i) {
        $(this).css({
          zIndex: level++,
          width: lw,
          height: lh,
          left: gap * i,
          top: self.setVerticalAlign(lh),
          opacity: 1 / llevel--,
          //border: '20px solid #fff'
        });
        lw = lw / self.settings.scale;
        lh = lh / self.settings.scale;
      });
    },
    //设置对齐方式
    setVerticalAlign: function (h) {
      if (this.settings.verticalAlign === "middle") {
        return (this.settings.height - h) / 2;
      } else if (this.settings.verticalAlign === "top") {
        return 0;
      } else if (this.settings.verticalAlign === "bottom") {
        return this.settings.height - h;
      } else {
        return (this.settings.height - h) / 2;
      }
    },
    //设置配置参数控制幻灯片显示
    setSettingValue: function () {
      this.con.css({
        width: this.settings.width,
        height: this.settings.height,
      });
      this.conItem.css({
        width: this.settings.width,
        height: this.settings.height,
      });
      var w = (this.settings.width - this.settings.postWidth) / 2;
      this.prev.css({
        width: w - 20,
        height: this.settings.height,
        zIndex: Math.ceil(this.conItems.length / 2),
      });
      this.prev.find("img").css({
        width: 50,
        height: 50,
      });
      this.next.css({
        width: w - 20,
        height: this.settings.height,
        zIndex: Math.ceil(this.conItems.length / 2),
      });
      this.next.find("img").css({
        width: 50,
        height: 50,
      });
      this.conItemFirst.css({
        top: 0,
        left: w,
        width: this.settings.postWidth,
        height: this.settings.postHeight,
        zIndex: this.conItems.length,
        //border: '20px solid #fff'
      });
    },
    //接收配置参数
    getSetting: function () {
      var con = this.con.attr("data-setting");
      if (con && con !== "") {
        return $.parseJSON(con);
      } else {
        return "";
      }
    },
  };

  //初始化
  Carousel.init = function (carousel) {
    var _this = this;
    carousel.each(function () {
      new _this($(this));
    });
  };
  window.Carousel = Carousel;
})(jQuery);

//头部下拉
$(function () {
    //头部导航简章下拉
    $(".jianzhang").mouseover(function () {
        $(".jzCon").slideDown("fast")
    }).siblings().mouseover(function () {
        $(".jzCon").slideUp("fast");
    });
    $(".jzCon").mouseleave(function () {
        $(".jzCon").slideUp("fast");
    })

})

//头部下拉
$(function () {
  //控制头部导航报考指南下拉
  $(".bkzn").mouseover(function () {
      $(".bkCon").slideDown("fast");
    }).siblings().mouseover(function () {
      $(".bkCon").slideUp("fast");
    });
  $(".bkCon").mouseleave(function () {
    $(".bkCon").slideUp("fast");
  });


    // 点击返回顶部 与屏幕滑动隐藏
  //   if ($(document).scrollTop() > $(window).height()) {
  //     $(".rightbar2018new .righttop").css("display", "block");
  //   } else {
  //     $(".rightbar2018new .righttop").css("display", "none");
  //   }
  // $(".rightbar2018new .righttop").click(function(){
  //     // $(window).scrollTop(300);
  //     $('body,html').scrollTop(0);
  // });
  window.onscroll = function () {
    if ($(document).scrollTop() > $(window).height()) {
      $(".rightbar2018new .righttop").css("display", "block");
    } else {
      $(".rightbar2018new .righttop").css("display", "none");
    }
  };

  // function dxl() {window.scrollTo(0,0)}
  $(".righttop").click(function () {
    $("body,html").animate(
      {
        scrollTop: 0,
      },
      500
      // 缓动时间为500
    );
    return false;
  });

});




