$(function() {
  $('.tab_list_li').click(function() {
		var index = $('.tab_list_li').index(this);
		$('.content .content_wrap').css('display','none');
		$('.content .content_wrap').eq(index).css('display','block');
		$('.tab_list_li').removeClass('select');
		$(this).addClass('select')
  });
});

/* 文字数カット処理） */
$(function () {
    var $setElm = $('.cmn-blog .cmn-blog-txt');　// cutTextとついたクラスの要素を取得
    var cutFigure = '30'; // カットする文字数
    var afterTxt = '...>>続きを読む'; // 文字カット後に表示するテキスト

    $setElm.each(function () {　// cutTextとついたクラスのすべての要素に対して文字カットの処理を行う
        var textLength = $(this).text().length; // 各要素の長さを取得
        var textTrim = $(this).text().substr(0, (cutFigure))

        if (cutFigure < textLength) { $(this).html(textTrim + afterTxt).css({ visibility: 'visible' }); } else if (cutFigure >= textLength) {
            // cssで初期表示は非表示にしているので、カット処理後に表示する
            $(this).css({
                visibility: 'visible'
            });
        }
    })
});

/* 文字数カット処理） */
$(function () {
    var $setElm = $('.blog_list .cmn-blog-txt');　// cutTextとついたクラスの要素を取得
    var cutFigure = '220'; // カットする文字数
    var afterTxt = '...>>続きを読む'; // 文字カット後に表示するテキスト

    $setElm.each(function () {　// cutTextとついたクラスのすべての要素に対して文字カットの処理を行う
        var textLength = $(this).text().length; // 各要素の長さを取得
        var textTrim = $(this).text().substr(0, (cutFigure))

        if (cutFigure < textLength) { $(this).html(textTrim + afterTxt).css({ visibility: 'visible' }); } else if (cutFigure >= textLength) {
            // cssで初期表示は非表示にしているので、カット処理後に表示する
            $(this).css({
                visibility: 'visible'
            });
        }
    })
});


/* 画像ロールオーバー（ない場合は透明化） */
$(function(){
var currentFile = location.href.split('/').pop();
var ua = navigator.userAgent;

$('a img').each(function(){
	var imgSrc = $(this).attr('src');
	if(imgSrc.match(/(.*)_off(\..*)/)){
		var repSrc = RegExp.$1+'_on'+RegExp.$2;
		$('<img />').attr('src',repSrc);
		$(this).hover(function(){
			$(this).attr('src',repSrc);
			$(this).css({opacity: '1',filter: 'alpha(opacity=100)'});
		},function(){
			$(this).attr('src',imgSrc);
		});
		}else if(!$(this).hasClass('not')){
			$(this).hover(function(){
			$(this).css({
				opacity: '0.7',
				filter: 'alpha(opacity=60)'
			});
		},function(){
			$(this).css({
				opacity: '1',
				filter: 'alpha(opacity=100)'
		});
		}
		);
	}
	});
});

/* TELボタン */
$(function() {
var ua = navigator.userAgent;
if (ua.indexOf('iPhone') < 0 && ua.indexOf('Android') < 0) { $('a[href^="tel:"]').css({
"cursor": "default",
"text-decoration": "none",
"opacity": "1"}).click(function (event) { event.preventDefault(); });}
});

/* ナビゲーション */
$(function() {
var $header = $('.header');
$('.header .navToggle').click(function(){
	$header.toggleClass('open');
});
});


/* ページトップボタン固定化 */
$(document).ready(function(){
$(".btn-pagetop").hide();
$(".bnr-side").hide();
$(window).on("scroll", function() {
if ($(this).scrollTop() > 100) {
$('.btn-pagetop').fadeIn();
$('.bnr-side').fadeIn();
} else {
$('.btn-pagetop').fadeOut();
$('.bnr-side').fadeOut();
}

scrollHeight = $(document).height(); 
scrollPosition = $(window).height() + $(window).scrollTop(); 
footHeight = $(".ft-copyright").innerHeight();

if ( scrollHeight - scrollPosition  <= footHeight ) {
$(".btn-pagetop").css({
});
} else {
$(".btn-pagetop").css({
});
}
});
// トップへスムーススクロール
$('.btn-pagetop a').click(function () {
	$('body,html').animate({
	scrollTop: 0
}, 500);
	return false;
}); 
});

/* ウインドウリサイズ */
$(document).ready(function() {
	funcResize();
$(window).resize(function() {
	funcResize();
});
  
function funcResize() {
var wid = $(window).width();

//画像の切替
//if( wid < 767 ){
//	$('.switch').each(function(){
//		$(this).attr("src",$(this).attr("src").replace('_pc', '_sp'));
//	});
//
//
//}else{
//	$('.switch').each(function(){
//		$(this).attr("src",$(this).attr("src").replace('_sp', '_pc'));
//	});
//}
//sp_menu(画像の置換)
if( wid < 1023 ){
	$('.header .nav').each(function(){
		$(this).addClass('sp-nav').removeClass('pc-nav');
	});
}else {
	$('.header .nav').each(function(){
		$(this).addClass('pc-nav').removeClass('sp-nav');
	});
}
};
  
});

$(function(){
    $(window).scroll(function (){
        $('.fadein').each(function(){
            var targetElement = $(this).offset().top;
            var scroll = $(window).scrollTop();
            var windowHeight = $(window).height();
            if (scroll > targetElement - windowHeight + 200){
                $(this).css('opacity','1');
                $(this).css('transform','translateY(0)');
            }
        });
    });
});


/*============================
 	course
 ============================*/
(function($) {
	$(function() {
		var accordion = $(".accordion");
		accordion.each(function () {
			var noTargetAccordion = $(this).siblings(accordion);
			$(this).find(".switch").click(function() {
			$(this).next(".contentWrap").slideToggle();
			$(this).toggleClass("open");
			noTargetAccordion.find(".contentWrap").slideUp();
			noTargetAccordion.find(".switch").removeClass("open");
			});
		});
	});
})(jQuery);