$(function(){
// エリア選択時の背景色切り替え
$(".large").click(function(){switchBackground($(this).attr('id'));});
$(".middle").click(function(){switchBackground(null);});
// ネット予約可能なレッスンチェックボックスON/OFFのhiddenを変更
$("#internet").change(function(){
if ($("#internetReservationChecked").val()=="true") {
$("#internetReservationChecked").val("false");
}else{
$("#internetReservationChecked").val("true");
}
});
// カレンダー表示の切替処理
$("#calendarOn").click(function(){
calendarDsp('show');
});
$("#calendarOff").click(function(){
calendarDsp('close');
});
switchBackground($(".large:checked").attr('id'));
initCategoryLabel('ym');
initCategoryLabel('place');
initCategoryLabel('content');
initCategoryLabel('feature');
$('a.place').click(function(){$(".middle + label").removeClass('bg_pink');});
// カレンダー表示切替の初期処理
calendarDsp(null);
});
function calendarDsp(dspClick) {
if($(".weeksLesson")[0]){
return;
}
var date=new Date();
//cookieは1日間有効
date.setTime(date.getTime() + (24*60*60*1000));
var dsp = $.cookie('calendar_dsp');
if(dspClick != null){
dsp = dspClick;
}
if(dsp =='close' || dsp == null){
$('#schedule').hide();
$('#calendarOn').show();
$('#calendarOff').hide();
$.cookie('calendar_dsp','close',{expires: date,path: "/" });
}else {
$('#schedule').slideDown("fast");
$('#calendarOn').hide();
$('#calendarOff').show();
$.cookie('calendar_dsp','show',{expires: date,path: "/" });
}
}
function switchBackground(id) {
$(".middle + label").removeClass('bg_pink');
if(id){
//largeエリアが選択された為、middleエリアを初期化
$(".middle").prop('checked', false);
if($("#"+id).hasClass('unselected')){
//largeエリア未選択時は、middleエリアを全選択する
$("[id^="+ id + "m]").prop('checked', true);
$("."+id+" + label").toggleClass('bg_pink');
$("#"+id).removeClass('unselected');
$("#"+id).addClass('selected');
}else{
//largeエリア選択時は、middleエリアを全選択解除する
$("[id^="+ id + "m]").prop('checked', false);
$("#"+id).prop('checked', false);
$("#"+id).removeClass('selected');
$("#"+id).addClass('unselected');
}
}else{
$(".large").prop('checked', false);
$(".large").removeClass('selected');
$(".large").addClass('unselected');
}
initCategoryLabel('place');
}
$(function(){
// #で始まるアンカーをクリックした場合に処理
$('a[href^=#]').click(function() {
// スクロールの速度
var speed = 400; // ミリ秒
// アンカーの値取得
var href= $(this).attr("href");
// 移動先を取得
var target = $(href == "#" || href == "" ? 'html' : href);
// 移動先を数値で取得
var position = target.offset().top;
// スムーススクロール
$('body,html').animate({scrollTop:position}, speed, 'swing');
return false;
});
});