(function (window, document, $) {


  $(function(){
      $('[data-ctytrnbtn]').on("click", function () {
      var prifid = $(this).attr("data-ctytrnbtn");
      $('#overlay').fadeIn("fast");
      $('[data-ctytrn="' + prifid + '"]').fadeIn("fast");
      //togglemodal();
    });
    $('#overlay, [data-mdlcls]').on("click", function () {
      $('#overlay').fadeOut("fast");
      $('[data-ctytrn]').fadeOut("fast");
      //togglemodal();
    });
  });

  $(window).on("load",function(){

    var urllocation = $(location).attr('href');
    if(urllocation.indexOf("mdlopenline") >= 0){
      $('#stationline_btn').trigger("click");
    } else if(urllocation.indexOf("mdlopenarea") >= 0){
      $('#region_btn').trigger("click");
    }



   $(window).on("scroll",function(){
      var winscl = $(this).scrollTop();
      if(winscl > 100) {
        $('#bottomfix').addClass("show");
      } else {
        $('#bottomfix').removeClass("show");
      }


      // 右のメニュースクロールで固定
      // if ($(this).scrollTop() > 330) {
      //   $('#cht_Topfixed').addClass("show");
      // } else {
      //   $('#cht_Topfixed').removeClass("show");
      // }
      

    });

  });

  // 右のメニュースクロールで固定
  var $target = $('#cht_Topfixed');
  var offset, width;
  function update() {
    offset = $target.offset();
    width  = $target.outerWidth();
  }
  update();
  $(window).on('scroll resize', function () {
    if ($(window).scrollTop() > offset.top) {
      $target.addClass('is-fixed').css({
        left: offset.left,
        width: width
      });
    } else {
      $target.removeClass('is-fixed').removeAttr('style');
    }
  });


})(window, document, jQuery);