// JavaScript Document
$(function() {
$('a[href^="#"],a[href*="#"]').on('click',function() {
var mrg = $("#head").outerHeight() + 10;
mrg = $("#head #logo").outerHeight() + 40;
href = $(this).attr("href");
var hrefs=href.substring(href.indexOf("#")+1,href.length);
href = "#"+hrefs;
var target = $(href == "#" || href == "" ? 'html' : href);
if(target.length){
var position = target.offset().top - mrg;
$('body,html').animate({scrollTop:position}, 500, 'swing');
return false;
}
});
/**アコーディオン開閉**/
$('#head #hmenu > div ul.menu#menu-hmenu2 li.search a').stop().on('click',function (e) {
e.preventDefault();
$('#head #searchwrap').stop().slideToggle();
$(this).toggleClass('open');
});
$('#head #hmenu > div ul.menu#menu-hmenu2 li.en > a').stop().on('click',function (e) {
e.preventDefault();
$('#head #hmenu > div ul.menu#menu-hmenu2 li.en > ul').stop().slideToggle();
});
$('#head #hmenu > div ul.menu#menu-hmenu2 li.tel a').stop().on('click',function (e) {
e.preventDefault();
location.href='tel:0352872941';
});
$('#menubtn').stop().on('click',function (e) {
e.preventDefault();
$('#head #header > div ul.menu#menu-gmenu').stop().slideToggle();
$(this).toggleClass('open');
});
$('#side > .sidetit').stop().on('click',function (e) {
if($(this).css('background-size')=='cover'){
e.preventDefault();
$(this).stop().next('div').slideToggle();
$(this).toggleClass('open');
}else{
$(this).removeClass('open');
}
});
$("a:has(img)").addClass("noicon");
$('.entry #contents .mw_wp_form td input#facility').attr('readonly',true);
setsize();
//本アップ対応
$("li.off a, #entrymenu > li > a").click(function(e) {
e.preventDefault;
return false;
});
//telリンク
if(uaname != "sp"){
$(".tel a").click(function(e) {
e.preventDefault;
return false;
});
}
if($('.mwform-zip-field').length){
$('.mwform-zip-field > input:first-child').attr('id','zip');
$('.mwform-zip-field > input:last-child').attr('id','zip1');
}
if($('input.hidden').length){
$('input.hidden').attr('readonly','readonly');
}
if($('.entry #contents tr:first-child td select').length){
$('.entry #contents tr:first-child td select').attr('readonly','readonly');
}
if($('.mw_wp_form').length){
var val = $('#jobget').val();
if(val){
$('#jobset').val(val);
}
}
if($('.mw_wp_form.mw_wp_form_input table tr:last-child td .business-description').length){
let att = $('.mw_wp_form.mw_wp_form_input table tr:last-child td .business-description span');
$('.mw_wp_form.mw_wp_form_input table tr:last-child td .business-description').remove();
$('.mw_wp_form.mw_wp_form_input table tr:last-child td .mwform-checkbox-field-text').html(att);
}
//カウンセリングフォーム
if($('table.c_contact').length){
$('td.hope_program input').on('change click',function(){
const val = $(this).val();
console.log(val);
if(val=='学部留学' || val=='語学+学部留学'){
if($('table.c_contact').attr('data-type')!=1){
$('table.c_contact td.period select').val('1学期(3~4カ月)');
$('table.c_contact td.period .othertxt input').val('');
$('table.c_contact td.conditions input[type="checkbox"]').prop('checked', false);
$('table.c_contact td.conditions .othertxt input').val('');
$('table.c_contact td.desired input[type="checkbox"]').prop('checked', false);
$('table.c_contact td.desired .othertxt input').val('');
$('table.c_contact td.stay input[type="radio"]').prop('checked', false);
}
if($('table.c_contact').attr('data-type')==2){
//$('table.c_contact td.destination select').val('アメリカ');
$('table.c_contact td.destination input[type="checkbox"]').prop('checked', false);
}
$('table.c_contact').attr('data-type',1);
}
if(val=='語学留学'){
if($('table.c_contact').attr('data-type')==1){
$('table.c_contact td.period select').val('2/3月~8/9月');
$('table.c_contact td.period .othertxt input').val('');
$('table.c_contact td.conditions input[type="checkbox"]').prop('checked', false);
$('table.c_contact td.conditions .othertxt input').val('');
$('table.c_contact td.desired input[type="checkbox"]').prop('checked', false);
$('table.c_contact td.desired input[value="未該当"]').prop('checked', true);
$('table.c_contact td.desired .othertxt input').val('');
$('table.c_contact td.stay .othertxt input').val('');
$('table.c_contact td.stay input[name="stay-reason"]').val('');
$('table.c_contact td.stay input[value="未該当"]').prop('checked', true);
}
if($('table.c_contact').attr('data-type')!=2){
//$('table.c_contact td.destination select').val('アメリカ');
$('table.c_contact td.destination input[type="checkbox"]').prop('checked', false);
}
$('table.c_contact').attr('data-type',2);
}
if(val=='その他'){
if($('table.c_contact').attr('data-type')==1){
$('table.c_contact td.period select').val('2/3月~8/9月');
$('table.c_contact td.period .othertxt input').val('');
$('table.c_contact td.conditions input[type="checkbox"]').prop('checked', false);
$('table.c_contact td.conditions .othertxt input').val('');
$('table.c_contact td.desired input[type="checkbox"]').prop('checked', false);
$('table.c_contact td.desired input[value="未該当"]').prop('checked', true);
$('table.c_contact td.desired .othertxt input').val('');
$('table.c_contact td.stay .othertxt input').val('');
$('table.c_contact td.stay input[name="stay-reason"]').val('');
$('table.c_contact td.stay input[value="未該当"]').prop('checked', true);
}
if($('table.c_contact').attr('data-type')==2){
//$('table.c_contact td.destination select').val('アメリカ');
$('table.c_contact td.destination input[type="checkbox"]').prop('checked', false);
}
$('table.c_contact').attr('data-type',3);
}
});
//3つまで
$('table.c_contact[data-type="1"] td.conditions input[type="checkbox"]').on('change',function(){
let checkboxes = $('table.c_contact[data-type="1"] td.conditions input:checkbox:checked').length;
if(checkboxes > 3) {
$(this).prop("checked", false);
alert('チェックは3つまで可能です');
}
});
$('table.c_contact[data-type="1"] td.destination input[type="checkbox"]').on('change',function(){
let checkboxes = $('table.c_contact td.destination input:checkbox:checked').length;
if(checkboxes > 3) {
$(this).prop("checked", false);
alert('チェックは3つまで可能です');
}
});
$('table.c_contact td.desired input[type="checkbox"]').on('change',function(){
let checkboxes = $('table.c_contact td.desired input:checkbox:checked').length;
if(checkboxes > 3) {
$(this).prop("checked", false);
alert('チェックは3つまで可能です');
}
});
$('table.c_contact td.score input[type="checkbox"]').on('change click',function(){
//if(!$(this).prop('checked')){
$('table.c_contact td.score input[type="text"]').val('');
$('table.c_contact td.score input[type="date"]').val('');
$('table.c_contact td.score input[type="radio"]').prop('checked', false);
//$('table.c_contact td.score span[data-name="ielts6"] .wpcf7-list-item.last input').prop('checked', true);
//}
});
//その他のチェックを外したら空白に
$('table.c_contact input[type="checkbox"],table.c_contact input[type="radio"]').on('change click',function(){
if(!$(this).parents('.wpcf7-form-control').find('input[value*="その他"]').prop('checked')){
$(this).parents('.wpcf7-form-control-wrap').next('.othertxt').find('input').val('');
}
if(!$('td.overseas input[value="旅行(国記入)"]').prop('checked')){
$('td.overseas span[data-name="travel-country"] input').val('');
}
if(!$('td.overseas input[value="海外研修(国、期間記入)"]').prop('checked')){
$('td.overseas span[data-name="training-details"] input').val('');
}
if(!$('td.overseas input[value="その他').prop('checked')){
$('td.overseas span[data-name="other-experience"] input').val('');
}
});
$('table.c_contact select').on('change',function(){
if(!$(this).val()!='その他'){
$(this).parents('.wpcf7-form-control-wrap').next('.othertxt').find('input').val('');
}
});
}
$('#contents.faq .faq_box dt').on('click',function(){
$(this).toggleClass('open');
$(this).next('dd').stop().slideToggle(300);
});
});
if(navigator.userAgent.match(/MSIE 10/i) || navigator.userAgent.match(/Trident\/7\./) || navigator.userAgent.match(/Edge\/12\./)) {
$('body').on("mousewheel", function () {
event.preventDefault();
var wd = event.wheelDelta;
var csp = window.pageYOffset;
window.scrollTo(0, csp - wd);
});
}
$(window).on('load',function(){
setsize();
movepos();
});
$(window).on('resize',function () {
setsize();
//movepos();
});
$(window).on('scroll',function () {
//setsize();
});
$(window).on('orientationchange', function(){
setsize();
});
function setsize(){
var hsize = $("#head").outerHeight();
if($('#head #header #logo img').css('width') == '160px'){
hsize = hsize - $("#menu").outerHeight();
}else{
$('#menubtn').removeClass('open');
$('#head #header > div ul.menu#menu-gmenu').removeAttr('style');
}
$("#container").css("padding-top",hsize+"px");
$('.contents#prestige ul li p').matchHeight();
$('#event dt').matchHeight();
$('#event dd > p').matchHeight();
//$('#event dd ul.eventlist').matchHeight();
$('#event dd').matchHeight();
$('#topics li').matchHeight();
$('#other li a').matchHeight();
if($('#pickup li .img').css('display')=='inline-block'){
$('#pickup li > .detail,#pickup li > .img img').matchHeight();
}else{
$('#pickup li .detail').matchHeight();
}
$('.contents .wrap.session > div').matchHeight();
if($('#side > .sidetit').css('background-size')!='cover'){
$('#side > .sidetit + div').removeAttr('style');
}
}
//他ページよりのアンカーリンク
function movepos(){
var mrg = $("#head").outerHeight();
console.log(mrg);
var href = location.href;
if(href.indexOf("#")>=0 || location.search){
var hrefs=href.substring(href.indexOf("#")+1,href.length);
href = hrefs;
var position = $("#"+href).offset().top;
var speed = 500;
$('body,html').animate({scrollTop:position-mrg}, speed, 'swing');
}else{
return false;
}
var hashString = location.hash.substr(1);
history.replaceState('', document.title, window.location.pathname);
}
function formcheck(){
var flag = $('.loginform > form input#login_password').val();
var flag2 = $('.loginform > form input#login_username').val();
if(flag=='' || flag2==''){
window.alert('未入力の項目があります'); // 入力漏れがあれば警告ダイアログを表示
return false; // 送信を中止
}else{
return true; // 送信を実行
}
}