/*********************************************
 * 个性化
 ********************************************/
(function(){
  // 产品
  $('#iprod .main').scroller({
    number: 3,
    offset: 22
  });

  // 案例
  $('#icase .main').scroller({
    number: 5,
    offset: 12
  });
})(window, jQuery);


/*********************************************
 * 通用
 ********************************************/
(function(){
  // 详情页翻页
  $('.relink a').each(function(){
    $(this).attr({'href': $(this).attr('href') + '#container'});
  })

  // 导航
  $('#nav li').each(function(){
    if(!$(this).find('.drop dd').length){
      $(this).find('.drop').remove();
    }
  })

  $('#nav').bind({
    'mouseenter': function(){
      $(this).addClass('active');
    },
    'mouseleave': function(){
      $(this).removeClass('active');
    }
  })

  $('#nav li').bind({
    'mouseenter': function(){
      $(this).addClass('active').find('.drop').stop().slideDown();
    },
    'mouseleave': function(){
      $(this).removeClass('active').find('.drop').stop().slideUp();
    }
  })

  // 菜单
  $('#menu dd').each(function(){
    if(!$(this).find('.drop li').length){
      $(this).find('.drop').remove();
    }
  })

  $('#menu dd').hover(
    function(){
      $(this).addClass('active');
      $(this).children('.drop').stop().slideDown(200);
    },
    function(){
      $(this).removeClass('active');
      if(!$(this).hasClass('current')){
        $(this).children('.drop').stop().slideUp(200);
      }
    }
  )

  // 百度分享-浮窗+图标
  window._bd_share_config={
    "common": {
      "bdSnsKey":{},
      "bdText":"",
      "bdMini":"2",
      "bdMiniList":false,
      "bdPic":"",
      "bdStyle":"0",
      "bdSize":"24"
    },
    "slide": {
      "type":"slide",
      "bdImg":"5",  // 颜色风格
      "bdPos":"left",
      "bdTop":"160.5"
    },
    "share": {}
  };
  with(document)0[(getElementsByTagName('head')[0]||body) .appendChild(createElement('script')) .src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
})();

(function(){
  var $toolbar = $('#toolbar');

  $toolbar.find('.itop').bind('click', function(){
    $('html, body').stop().animate({'scrollTop': 0}, 200);
  })
  
  $toolbar.find('.code a').bind({
    'mouseenter': function(){
      $(this).next().stop().show(200);
    },
    'mouseleave': function(){
      $(this).next().stop().hide(200);
    }
  })
  
  $toolbar.find('.tel a').bind({
    'mouseenter': function(){
      $(this).next().stop().animate({'width': 162}, 200);
    },
    'mouseleave': function(){
      $(this).next().stop().animate({'width': 0}, 200);
    }
  })

  $toolbar.find('.close').bind({
    'click': function(){
      $toolbar.children('.pointer').show(300).next().hide();
    }
  })

  $toolbar.find('.pointer').bind({
    'click': function(){
      $toolbar.children('.inner').show(300).prev().hide();
    }
  })
}());