/*蓝科企业网站系统PHP版
http://www.lankecms.com*/
$(document).ready(function(){
  //返回顶部
  $("#gototop").click(function(){
      $("html,body").animate({scrollTop :0}, 800);return false;
  });
  // $("#gotocate").click(function(){
  //      $("html,body").animate({scrollTop:$("#categories").offset().top},800);return false;
  // });
  // 搜索
  $("#small_search").click(function(){
      $("#topsearch").slideToggle();
  });
  // 友情链接
  $("#link_btn").click(function(){
      if ($(".link_list").css('display') == "none"){
        $("#link_btn").addClass("glyphicon-minus");
      }else{
        $("#link_btn").removeClass("glyphicon-minus");
      }
      $(".link_list").slideToggle();
  });
  $("#tags_btn").click(function(){
      if ($(".tags_rows").css('display') == "none"){
        $("#tags_btn").addClass("glyphicon-minus");
      }else{
        $("#tags_btn").removeClass("glyphicon-minus");
      }
      $(".tags_rows").slideToggle();
  });
  if($(window).width()>768){
      //鼠标划过就展开子菜单
      $('ul.nav li.dropdown').hover(function() {
        $(this).find('.dropdown-menu').stop(true, true).slideDown();
      }, function() {
        $(this).find('.dropdown-menu').stop(true, true).slideUp();
      });
  }
  //scrollTop
  $(window).scroll(function(){
      var scrolls = $(window).scrollTop()
      // if (scrolls > 160) {
      //   $("#top_nav").addClass("navbar-fixed-top")
      // }else{
      //   $("#top_nav").removeClass("navbar-fixed-top")
      // }
  });
  //左侧导航菜单
  // if ($("#firstpane .menu_body:eq(0)").text().replace(/[\r\n ]/g,"").length>0) {
  //   $("#firstpane .menu_body:eq(0)").show().prev().html("-").prev().addClass("left_active");
  // };
  $("ul.menu_body").each(function(){
   if ($(this).text().replace(/[\r\n ]/g,"").length<=0) {$(this).prev().remove();} //去掉span
  });
  $("#firstpane span.menu_head").click(function(){
      var spanatt = $(this).next("ul.menu_body").css('display');
      if (spanatt == "block"){
          var spantext = "+";
           $(this).prev().removeClass("left_active");
      }else{
          var spantext = "-";
          $(this).prev().addClass("left_active");
      }
      $(this).html(spantext).addClass("current").next("ul.menu_body").slideToggle(300).siblings("ul.menu_body");
  });


  // 要素资源 流动效果
  // function groupSlideB(){
  //   imgScroll.rolling({
  //     name:'line_resource',
  //     width:'198px',
  //     height:'116px',
  //     direction:'left',
  //     speed:10,
  //     addcss:true
  //   });
  //   imgScroll.rolling({
  //     name:'g2',
  //     width:'198px',
  //     height:'116px',
  //     direction:'right',
  //     speed:10,
  //     addcss:true
  //   });
  //   imgScroll.rolling({
  //     name:'g3',
  //     width:'198px',
  //     height:'116px',
  //     direction:'left',
  //     speed:10,
  //     addcss:true
  //   });
  // }
  // groupSlideB()


  $(function(){
    $("#header").load("../public/header1.html","",function(){
      $('.header').addClass('on');

      //移动端展开nav
      $('#navToggle').on('click',function(){
        $('.m_nav').addClass('open');
      })
      //关闭nav
      $('.m_nav .top .closed').on('click',function(){
        $('.m_nav').removeClass('open');
      })
      //二级导航  移动端
      $(".m_nav .ul li").click(function() {
        $(this).children("div.dropdown_menu").slideToggle('slow')
          $(this).siblings('li').children('.dropdown_menu').slideUp('slow');        
      });

    
    });
    $("#footer").load("../public/footer.html");
  });
  

  
});


  // 获取url参数
  function GetQueryString(name)
  {
       var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
       var r = window.location.search.substr(1).match(reg);
       if(r!=null)return  unescape(r[2]); return null;
  }