// source --> https://mmc-inc.jp/wordpress/wp-content/themes/mmc/js/jscript.js?ver=5.0 
jQuery(document).ready(function($){

  $("a").bind("focus",function(){if(this.blur)this.blur();});
  $("a.target_blank").attr("target","_blank");
  $('.rollover').rollover();

  $("#post_list .meta").each(function() {
   $("li:last-child").addClass("last");
  });

  $("#single_meta li:last-child").addClass("last");
  $("#index_pickup .meta li:last-child").addClass("last");
  $(".recommend_widget li:last-child").addClass("last");
  $(".recommend_widget2 li:last-child").addClass("last");

  $("#comment_area ol > li:even").addClass("even_comment");
  $("#comment_area ol > li:odd").addClass("odd_comment");
  $(".even_comment > .children > li").addClass("even_comment_children");
  $(".odd_comment > .children > li").addClass("odd_comment_children");
  $(".even_comment_children > .children > li").addClass("odd_comment_children");
  $(".odd_comment_children > .children > li").addClass("even_comment_children");
  $(".even_comment_children > .children > li").addClass("odd_comment_children");
  $(".odd_comment_children > .children > li").addClass("even_comment_children");

  $("#trackback_switch").click(function(){
    $("#comment_switch").removeClass("comment_switch_active");
    $(this).addClass("comment_switch_active");
    $("#comment_area").animate({opacity: 'hide'}, 0);
    $("#trackback_area").animate({opacity: 'show'}, 1000);
    return false;
  });

  $("#comment_switch").click(function(){
    $("#trackback_switch").removeClass("comment_switch_active");
    $(this).addClass("comment_switch_active");
    $("#trackback_area").animate({opacity: 'hide'}, 0);
    $("#comment_area").animate({opacity: 'show'}, 1000);
    return false;
  });




function mediaQueryClass(width) {

 if (width > 641) { //PC

   $("html").removeClass("mobile");
   $("html").addClass("pc");

   var n_size=$("#global_menu > ul > li").size();
   var aWidth = 994/n_size;
   $("#global_menu > ul > li").css("width",aWidth+"px");
   $("#global_menu ul ul li").css("width",aWidth+"px");

   $(".menu_button").css("display","none");
   $("#global_menu").show();
   $("#global_menu ul ul").hide();
   $("#global_menu a:has(ul)").removeClass("active_menu").off("click");

   $("#global_menu li").hover(function(){
     $(">ul:not(:animated)",this).slideDown("fast");
     $(this).addClass("active_menu");
    }, function(){
     $(">ul",this).slideUp("fast");
     $(this).removeClass("active_menu");
    });

 } else { //ƒXƒ}ƒz

   $("html").removeClass("pc");
   $("html").addClass("mobile");

   $("#global_menu ul ul").show();
   $("#global_menu > ul > li").css("width", "");
   $("#global_menu ul ul li").css("width", "");
   $("#global_menu ul").removeClass("active_menu");
   $(".menu_button").css("display", "block");
   $("#global_menu li").off('hover');

   $('.menu_button').off('click');

   if($(".menu_button").hasClass("active")) {
     $(".menu_button").removeClass("active")
   };

   $(".menu_button").on('click',function() {
     if($(this).hasClass("active")) {
       $(this).removeClass("active");
       $('#global_menu').hide();
       return false;
     } else {
       $(this).addClass("active");
       $('#global_menu').show();
       return false;
     };
   });

 };
};

mediaQueryClass(document.documentElement.clientWidth);

$(window).bind("resize orientationchange", function() {
  mediaQueryClass(document.documentElement.clientWidth);
})




});
// source --> https://mmc-inc.jp/wordpress/wp-content/themes/mmc/js/scroll.js?ver=5.0 
jQuery.easing.quart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};


jQuery(function($){
	var topBtn = $('#return_top');	
	topBtn.hide();
	$(window).scroll(function () {
		if ($(this).scrollTop() > 100) {
			topBtn.fadeIn();
		} else {
			topBtn.fadeOut();
		}
	});
	topBtn.click(function () {
		$('body,html').animate({
			scrollTop: 0
		}, 500, 'quart');
		return false;
	});
});


// //スムーズスクロール
// jQuery(function(){
// 	// #で始まるアンカーをクリックした場合に処理
// 	jQuery('.scroll').click(function() {
// 		// スクロールの速度
// 		var speed = 400; // ミリ秒
// 		// アンカーの値取得
// 		var href= jQuery(this).attr("href");
// 		// 移動先を取得
// 		var target = jQuery(href == "#" || href == "" ? 'html' : href);
// 		// 移動先を数値で取得
// 		var position = target.offset().top;
// 		// スムーススクロール
// 		jQuery('body,html').animate({scrollTop:position}, speed, 'swing');
// 		return false;
// 	});
// });

//スムーズスクロール
jQuery(function(){
	// #で始まるアンカーをクリックした場合に処理
	var headerheight = 50; //ヘッダの高さ
	jQuery('.scroll').click(function() {
		// スクロールの速度
		var speed = 500; // ミリ秒
		// アンカーの値取得
		var href= jQuery(this).attr("href");
		// 移動先を取得
		var target = jQuery(href == "#" || href == "" ? 'html' : href);
		// 移動先を数値で取得
		var position = target.offset().top-headerheight; //ヘッダの高さ分位置をズラす
		// スムーススクロール
		jQuery('body,html').animate({scrollTop:position}, speed, 'swing');
		return false;
	});
});


// $(window).resize(function(){
//     var w = $(window).width();
//     var x = 640;
//     if (w <= x) {
// 		//スムーズスクロール
// 		jQuery(function(){
// 			// #で始まるアンカーをクリックした場合に処理
// 			var headerheight = 123; //ヘッダの高さ
// 			jQuery('.scroll').click(function() {
// 				// スクロールの速度
// 				var speed = 500; // ミリ秒
// 				// アンカーの値取得
// 				var href= jQuery(this).attr("href");
// 				// 移動先を取得
// 				var target = jQuery(href == "#" || href == "" ? 'html' : href);
// 				// 移動先を数値で取得
// 				var position = target.offset().top-headerheight; //ヘッダの高さ分位置をズラす
// 				// スムーススクロール
// 				jQuery('body,html').animate({scrollTop:position}, speed, 'swing');
// 				return false;
// 			});
// 		});
//     } else {
// 		//スムーズスクロール
// 		jQuery(function(){
// 			// #で始まるアンカーをクリックした場合に処理
// 			var headerheight = 123; //ヘッダの高さ
// 			jQuery('.scroll').click(function() {
// 				// スクロールの速度
// 				var speed = 500; // ミリ秒
// 				// アンカーの値取得
// 				var href= jQuery(this).attr("href");
// 				// 移動先を取得
// 				var target = jQuery(href == "#" || href == "" ? 'html' : href);
// 				// 移動先を数値で取得
// 				var position = target.offset().top-headerheight; //ヘッダの高さ分位置をズラす
// 				// スムーススクロール
// 				jQuery('body,html').animate({scrollTop:position}, speed, 'swing');
// 				return false;
// 			});
// 		});
// });



// $(function() {
// 	var w = $(window).width();
// 	var x = 640;
// 		if (w <= x) {

// 			jQuery(function(){
// 				// #で始まるアンカーをクリックした場合に処理
// 				var headerheight = 123; //ヘッダの高さ
// 				jQuery('.scroll').click(function() {
// 					// スクロールの速度
// 					var speed = 400; // ミリ秒
// 					// アンカーの値取得
// 					var href= jQuery(this).attr("href");
// 					// 移動先を取得
// 					var target = jQuery(href == "#" || href == "" ? 'html' : href);
// 					// 移動先を数値で取得
// 					var position = target.offset().top-headerheight; //ヘッダの高さ分位置をズラす
// 					// スムーススクロール
// 					jQuery('body,html').animate({scrollTop:position}, speed, 'swing');
// 					return false;
// 				});
// 			});


// 		});
// 	}
// });

// $(window).resize(function(){
// 	var w = $(window).width();
// 	var x = 640;
// 	if (w <= x) {
// 		//スムーズスクロール
// 		jQuery(function(){
// 			// #で始まるアンカーをクリックした場合に処理
// 			var headerheight = 123; //ヘッダの高さ
// 			jQuery('.scroll').click(function() {
// 				// スクロールの速度
// 				var speed = 400; // ミリ秒
// 				// アンカーの値取得
// 				var href= jQuery(this).attr("href");
// 				// 移動先を取得
// 				var target = jQuery(href == "#" || href == "" ? 'html' : href);
// 				// 移動先を数値で取得
// 				var position = target.offset().top-headerheight; //ヘッダの高さ分位置をズラす
// 				// スムーススクロール
// 				jQuery('body,html').animate({scrollTop:position}, speed, 'swing');
// 				return false;
// 			});
// 		});
// 	} else {
// 	}
// });
// source --> https://mmc-inc.jp/wordpress/wp-content/themes/mmc/js/comment.js?ver=5.0 
/*
Author: mg12
Author URI: http://www.neoease.com/
*/
(function() {

function $(id) {
	return document.getElementById(id);
}

function reply(authorId, commentId, commentBox) {
	var author = MGJS.$(authorId).innerHTML;
	var insertStr = '<a href="#' + commentId + '">@' + author.replace(/\t|\n|\r\n/g, "") + '</a> \n';

	appendReply(insertStr, commentBox);
}

function quote(authorId, commentId, commentBodyId, commentBox) {
	var author = MGJS.$(authorId).innerHTML;
	var comment = MGJS.$(commentBodyId).innerHTML;

	var insertStr = '<blockquote cite="#' + commentBodyId + '">';
	insertStr += '\n<a href="#' + commentId + '">' + author.replace(/\t|\n|\r\n/g, "") + '</a> :';
	insertStr += comment.replace(/\t/g, "");
	insertStr += '</blockquote>\n';

	insertQuote(insertStr, commentBox);
}

function appendReply(insertStr, commentBox) {
	if(MGJS.$(commentBox) && MGJS.$(commentBox).type == 'textarea') {
		field = MGJS.$(commentBox);

	} else {
		alert("The comment box does not exist!");
		return false;
	}

	if (field.value.indexOf(insertStr) > -1) {
		alert("You've already appended this reply!");
		return false;
	}

	if (field.value.replace(/\s|\t|\n/g, "") == '') {
		field.value = insertStr;
	} else {
		field.value = field.value.replace(/[\n]*$/g, "") + '\n\n' + insertStr;
	}
	field.focus();
}

function insertQuote(insertStr, commentBox) {
	if(MGJS.$(commentBox) && MGJS.$(commentBox).type == 'textarea') {
		field = MGJS.$(commentBox);

	} else {
		alert("The comment box does not exist!");
		return false;
	}

	if(document.selection) {
		field.focus();
		sel = document.selection.createRange();
		sel.text = insertStr;
		field.focus();

	} else if (field.selectionStart || field.selectionStart == '0') {
		var startPos = field.selectionStart;
		var endPos = field.selectionEnd;
		var cursorPos = startPos;
		field.value = field.value.substring(0, startPos)
					+ insertStr
					+ field.value.substring(endPos, field.value.length);
		cursorPos += insertStr.length;
		field.focus();
		field.selectionStart = cursorPos;
		field.selectionEnd = cursorPos;

	} else {
		field.value += insertStr;
		field.focus();
	}
}


window['MGJS'] = {};
window['MGJS']['$'] = $;
window['MGJS_CMT'] = {};
window['MGJS_CMT']['reply'] = reply;
window['MGJS_CMT']['quote'] = quote;

})();
// source --> https://mmc-inc.jp/wordpress/wp-content/themes/mmc/js/rollover.js?ver=5.0 
/**
 * jQuery.rollover
 *
 * @version  1.0.2
 * @author   rew <rewish.org@gmail.com>
 * @link     http://rewish.org/javascript/jquery_rollover_plugin
 * @license  http://rewish.org/license/mit The MIT License
 *
 * Inspired by:
 * Telepath Labs (http://dev.telepath.co.jp/labs/article.php?id=15)
 *
 */
jQuery.fn.rollover = function(suffix) {
	suffix = suffix || '_on';
	return this.not('[src*="'+ suffix +'."]').each(function() {
		var img = jQuery(this);
		var src = img.attr('src');
		var _on = [
			src.substr(0, src.lastIndexOf('.')),
			src.substring(src.lastIndexOf('.'))
		].join(suffix);
		jQuery('<img>').attr('src', _on);
		img.hover(
			function() { img.attr('src', _on); },
			function() { img.attr('src', src); }
		);
	});
};