/*==============================================

 * js公共库方法

 * Copyright 2016 xb, Inc. Author WANGHAO 

 * Licensed under the MIT license

 */

$(document).ready(function(){



	/*导航控制*/

	;(function($){

        //顶级导航控制
        var win_height = $(window).height();
        var win_width = $(window).width();
        var header_height = $('.header').css('height');
        var navSide =  $('.nav-top');
        var btnNavTop = $('#btn-nav');

        //二级导航控制
        var btnNavSecond = $('.btn-nav-second');
        var navSecond = $('.menu');

        btnNavTop.on('click',function(){
              win_height = $(window).height();
            win_width = $(window).width();
            //初始化高度
            navSide.css({'width':win_width,'height':win_height,'top':header_height}).stop(true,true).fadeIn(300);

            $(window).resize(function() {
                win_height = $(window).height();
                win_width = $(window).width();
                navSide.css({'width':win_width,'height':win_height,'top':header_height});  
            })
            //如果二级菜单打开了，就要关闭
            if(navSecond.hasClass('on')){
               btnNavSecond.click();
            }
            if(navSide.hasClass('on')){

                navSide.removeClass('on').stop(true,true).fadeOut();

                  $('#pageMask').remove();
                  $(window).off();
                  //$("div").detach("#pageMask");
                  

            }else{

                navSide.addClass('on');

              $('body').append('<div id="pageMask" style="position:fixed;left:0;top:0;">');
              $('#pageMask').css({'width':win_width,'height':win_height});
            }

        }) 

        //绑定事件
        btnNavSecond.click(function(){
          //如果顶级菜单打开了就要关闭
          if(navSide.hasClass('on')){
             btnNavTop.click();
          }
          if(navSecond.hasClass('on')){
             navSecond.stop(true,true).slideUp(300);
             navSecond.removeClass('on');
          }else{
            navSecond.stop(true,true).slideDown(300);
            navSecond.addClass('on');
          }

        })

        // 首页幻灯

        var swiper1 = new Swiper('#index-slider', {

            pagination: '.swiper-pagination',

            paginationClickable: true,

            // spaceBetween: 30,

            centeredSlides: true,

            autoplay: 2500,

            // autoplayDisableOnInteraction: false

        });
    

        // 新闻交易动态slider

        var swiper2 = new Swiper('#course-container', {

            scrollbar: '.swiper-scrollbar',
            scrollbarHide: true,
            slidesPerView: '2',
            spaceBetween: 10,
            grabCursor: true,
            scrollbarHide:false
        });

         var swiper3 = new Swiper('#teacher-container', {

            scrollbar: '.swiper-scrollbar',
            scrollbarHide: true,
            slidesPerView: '2',
            spaceBetween: 10,
            grabCursor: true,
            scrollbarHide:false
        });




        //子导航
        var initialSlide = $('.navbar .nav').find('li.active').index();
        //alert(initialSlide)
        var mySwiper2 = new Swiper('.navbar .swiper-container',{
          scrollbar:'.swiper-scrollbar' ,
          scrollbarHide:true,
          slidesPerView: 4,
          paginationClickable: true,
          spaceBetween: 10,
          initialSlide:initialSlide
        }); 


        $('.btn-back').click(function(){
            window.history.back();
        })
  
    //详情tab
    // $("#myTabs").tabs("#myTabContent > div",{event:'click',tab:'div',effect: 'fade',current:'active',tabs:'li'});
	})(jQuery)

	
//end ready

})































