");
if ($(".js-recomend_01.long").size()) {
$(".js-recomend_01.long .js-recomend-item ul").bxSlider({
slideWidth : 125,
minSlides : 6,
maxSlides : 7,
slideMargin : 10
});
}
};
/**
* Generate a contents of the deqwas.
* @global
* @see $.recommend01
* @example
* $.recommend01();
*/
$.recommendInner = function () {
if(typeof(tkt_deqwas) !== "undefined" && $(".box_recommend").length) {
if(typeof(tkt_deqwas) !== "undefined" && $(".box_recommend_01").length) {
$.ajax({
url: "/data/deqwas-assets-recommend-bottom.jsp",
type: "POST",
dataType: "html",
data: tkt_deqwas,
success : function(data) {
$(".box_recommend_01 .Section").html(data);
$.recommend01();
}
});
}
}
};
/**
* Comparison a page URL and navigation's URL, if it matches, then grant the "current" class to the parent element.
* @global
* @example
* baseCurrentNav();
*/
var baseCurrentNav = function () {
var $target = $(".js_current_nav");
if (!$target.length) return;
var current_page = window.location.pathname;
var normaliz_current_page = current_page.replace(current_page.split(/.*\/(.*)$/i, 2)[1], "");
$target.find("a").each(function() {
var target_url = $(this).attr("href");
var normaliz_target_url = target_url.replace(target_url.split(/.*\/(.*)$/i, 2)[1], "");
if(normaliz_target_url == normaliz_current_page) {
$(this).closest(".js_current_nav > li").addClass("current");
}
});
};
/**
* Give the current class to the a element whose URL matches the value.
* @global
* @example
* baseContentCurrentNav();
*/
var baseContentCurrentNav = function () {
var $target = $(".js_content_current");
if (!$target.length) return;
if ($(".js_content_current a[href^='" + window.location.pathname + "']").length) {
$(".js_content_current a[href^='" + window.location.pathname + "']").addClass("current");
}
};
/**
* Compare the set date with the current date.
* @global
* @see baseTimeLimitter
* @param {Date} date
* @return {boolean}
*/
var isPeriodDate = function(date) {
var now = new Date();
var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
return today.getTime() <= date.getTime();
};
/**
* Check leap year
* @global
* @see baseTimeLimitter
* @param {Number} year
* @return {Number} if current year is leap year then, return 1, else return 0.
*/
var isUru = function(year) {
return Math.floor((1 / (year % 4 + 1)) * (1 - 1 / (year % 100 + 1)) + (1 / (year % 400 + 1)));
};
/**
* New Icon
* @global
* @see isPeriodDate
* @see isUru
* @see isNotNumber
* @example
* baseTimeLimitter();
*/
var baseTimeLimitter = function() {
$("[data-new-icon-public]").each(function() {
if ($(this).closest(".js_new_icon_off").length) return;
var date = $(this).data("new-icon-public").split("-").map(function(elm) { return parseInt(elm, 10); });
if (date.length === 3) {
var start_date = new Date(date[0], date[1]-1, date[2]);
var year = start_date.getFullYear();
var month = start_date.getMonth() + 1;
var endday = 365;
if ((isUru(year) && month <= 2) || (isUru(year+1) && !(month <= 2))) {
endday = 366;
}
if ($(this).data("new-icon-period")) {
endday = parseInt($(this).data("new-icon-period"), 10);
if (isNotNumber(endday)) {
endday = 365;
}
}
var set_date = new Date(date[0], date[1]-1, date[2] + endday);
if (isPeriodDate(set_date)) {
$(this).addClass("js_new_icon");
}
}
});
};
/**
* Fix the recommendation area on the left side menu to the screen when scrolling. To use it, specify the following class for the html element.
*
* - Specify the class "js_floating_left" with the target parent element.
* - Specify the class "js_floating_item" with the target element.
* - The upper margin when fixing the screen is specified by the "data-floating_margin_top" attribute of the target element.
* - For example:
*
* @global
* @example
* baseScrollLeft();
*/
var baseScrollLeft = function () {
if (!$(".js_floating_left").length) return;
$(window).on("scroll resize" ,function() {
var scroll_top = $(this).scrollTop();
var $target = $(".js_floating_item");
var $container = $("#main");
var side_height = $("#side").height();
var _target_property = {
height: $(".js_floating_item").outerHeight(),
top: $target.data("floating_margin_top") || 0,
all_height: function () {
return this.height + this.top;
}
};
var _container_property = {
height: $container.height(),
offsetTop: $container.offset().top
};
var start = $(".js_floating_left").offset().top - _target_property.top;
var end = _container_property.height - _target_property.all_height();
var end_pos = end + _target_property.top + _container_property.offsetTop;
var scroll_exec = scroll_top - _container_property.offsetTop;
var is_sp = $(this).width() <= 640;
if (window.matchMedia) {
is_sp = window.matchMedia("(max-width: 640px)").matches;
}
if (!is_sp && side_height < _container_property.height) {
if (end >= scroll_exec && start <= scroll_top) {
$target.css({position: "fixed", top: _target_property.top});
} else if (end <= scroll_exec) {
$target.css({position: "absolute", top: end_pos});
} else {
$target.css({position: "static", top: 0});
}
} else {
$target.css({position: "static", top: 0});
}
});
};
var HighlightWords = function(){
return this.init();
};
HighlightWords.prototype = {
init: function(){
this.QUERY_NAME = "gl_keywords";
this.WRAPPER_CLASSNAME = "js_highlight_words";
this.NOWRAP_WORDS = ".prt_header_01,.prt_header_02,.prt_header_03,.prt_header_04,.prt_header_05,.prt_caption_01,.prt_anchor_list,.pager,.back_index,."+this.WRAPPER_CLASSNAME;
this.query = this.getQuery();
return this;
},
executeOn: function(selector){
var $elem = $(selector);
$elem.length && this.query && this.forEachTextNode($elem);
return this;
},
forEachTextNode: function($elem){
var not = this.NOWRAP_WORDS;
var forEachTextNode = this.forEachTextNode.bind(this);
var iterator = this.iterator.bind(this);
var callback = this.highlight.bind(this);
var selector = not ? "> *:not("+not+")" : "> *";
var $contents = $elem.find(selector);
$contents.each(function(i){
iterator(this, this.childNodes[0], callback);
$(this).find(selector).length && forEachTextNode($(this), callback, not);
});
return this;
},
iterator: function(elem, node){
if(!node) return;
var iterator = this.iterator.bind(this);
var callback = this.highlight.bind(this);
this.isTextNode(node) && typeof callback==="function" && callback(elem, node);
node.nextSibling && iterator(elem, node.nextSibling, callback);
},
highlight: function(elem, node){
var query = this.query;
var classname = this.WRAPPER_CLASSNAME;
var s, len = query.length;
if((s = node.data.toLowerCase().indexOf(query.toLowerCase()))!==-1){
var matches = node.splitText(s);
var span = document.createElement("span");
if(classname) span.classList.add(classname);
span.appendChild(document.createTextNode(matches.data.substr(0, len)));
matches.splitText(len);
elem.replaceChild(span, matches);
}
return this;
},
isTextNode: function(node){ return node.nodeType===3; },
getQuery: function(){
var key = this.QUERY_NAME;
var search = window.location.search;
if(!search) return "";
var res = "";
search.replace(/^\?/, "").split("&").forEach(function(q){
q = q.split("=");
if(q.length<2) return;
if(q[0]===key) res = decodeURIComponent(q[1]);
});
return res;
}
};
/**
* Modal display on smartphone when there are two or more phone numbers
* @global
*/
var telModalLink = function () {
$('.js-tel-booth').each(function () {
var $booth = $(this);
var $button = $booth.find('.js-tel-button');
var $modal = $booth.find('.js-tel-modal');
var $telLinks = $modal.find('a[href^=\'tel:\']');
if ($telLinks.length > 1) {
$booth.on('click', '.js-tel-button', function (e) {
e.preventDefault();
$modal.addClass('opened');
});
$modal.on('click', '.js-tel-modal-bg', function () {
$modal.removeClass('opened');
});
$(window).on('keyup', function (e) {
if ($modal.hasClass('opened') && e.keyCode == 27) $modal.removeClass('opened');
});
} else if ($telLinks.length) {
$telLinks.html($button.html());
$button.replaceWith($telLinks);
}
});
};
$(window).on("scroll resize.baseResize", function() {
baseScrollHeader();
baseScrollBottom();
}).one("load", function () {
baseSideNaviAccordion();
baseNavAccordion();
}).on("load", function() {
baseDropDownHeader();
baseScrollSide();
baseCurrentNav();
baseContentCurrentNav();
baseTimeLimitter();
baseScrollLeft();
if(typeof $.fn.bxSlider !== "undefined") {
$(".js_bxslider").bxSlider({ auto: true, useCSS: false });
$(".js_bxslider_fade").bxSlider({mode: "fade", auto: true});
}
if (typeof $.fn.matchHeight !== "undefined") {
var mh_target_list = [];
$("[class*=js_match_height_]").each(function () {
var reg = /^js_match_height_+/;
var class_list = $(this).attr("class").split(/\s+/);
var str = "";
for (var i = 0; i < class_list.length; i++) {
if (reg.test(class_list[i])) {
str = class_list[i];
}
}
if (str) {
mh_target_list.push(str);
}
});
if (mh_target_list) {
var mh_exec_classes = mh_target_list.filter(function(elm, index, arr) {
return arr.indexOf(elm) === index;
});
for (var j = 0; j < mh_exec_classes.length; j++) {
$("." + mh_exec_classes[j]).matchHeight();
}
}
}
}).trigger("resize.baseResize");
$(function() {
var $body = $("body");
var scrlpos = $(window).scrollTop();
/**
* Menu button for Smartphone
*/
var $sp_menu = $("#footer .js_sp_menu");
var $sp_menu_btn = $("#footer .js_menu_button");
if($sp_menu.length){
$sp_menu_btn.css("z-index", -1).on("click", function(e){
e.preventDefault();
if(!$(this).hasClass("pagein")) return;
if(!$body.hasClass("menu-opened")){
scrlpos = $(window).scrollTop();
$body.css({top: -scrlpos}).addClass("menu-opened");
}else{
$body.css("top", "").removeClass("menu-opened");
$(window).scrollTop(scrlpos);
}
});
$(window).on("scroll.ss_spmenu", function(){
var scrltop = $(window).scrollTop();
var showed = $sp_menu_btn.hasClass("pagein");
if((scrltop>0 && showed) || (scrltop<1 && !showed)) return;
if(scrltop>0 && !showed){
$sp_menu_btn.css("z-index", "").addClass("pagein");
}else if(scrltop<1 && showed && !$body.hasClass("menu-opened")){
$sp_menu_btn.removeClass("pagein").on("transitionend.ss_spmenu", function(){
$sp_menu_btn.css("z-index", -1).off("transitionend.ss_spmenu");
});
}
});
if(window.matchMedia){
$(window).on("resize.ss_spmenu", function(){
if(window.matchMedia("(max-width: 640px)").matches){
$body.addClass("view-mode-sp");
}else{
$body.removeClass("view-mode-sp").css("top", "");
}
}).trigger("resize.ss_spmenu");
}
}
/**
* Go back to the top of the page, or got to some contents top by an in-page links href.
*/
$("a[href^='#']").on("click", function(e) {
var navHight = 0;
var scroll_poseed = 500;
var url = $(location).attr("href");
var href= $(this).attr("href");
var $target = $(href == "#" || href == "" ? "html" : href);
var position = $target.offset().top - navHight;
if (url.indexOf("?id=") !== -1) {
var url_scroll_pos = url.scroll_poslit("?id=");
var hash = "#" + url_scroll_pos[url_scroll_pos.length - 1];
var $target2 = $(hash);
var position2 = $target2.offset().top - navHight;
$("html, body").animate({scrollTop: position2}, scroll_poseed, "swing");
} else {
e.preventDefault();
$("html, body").animate({scrollTop: position}, scroll_poseed, "swing");
}
});
/**
* Call function of modal window. Set the "js_modal" class to an HTML Element. Note: case of use the "jQuery.colorbox".
*/
if (typeof $.fn.colorbox !== "undefined") {
var scroll_event = "onwheel" in document ? "wheel" : "onmousewheel" in document ? "mousewheel" : "DOMMouseScroll";
$(".js_modal").colorbox({
current: "{current}/{total}",
maxWidth: "90%",
maxHeight: "90%",
onOpen: function() {
$(document).on(scroll_event, function(e) {
e.preventDefault();
});
$(document).on("touchmove.noScroll", function(e) {
e.preventDefault();
});
},
onClosed: function() {
$(document).off(scroll_event);
$(document).off(".noScroll");
}
});
}
/**
* Disable a Tel link with others than smartphone.
*/
if(!/i(phone|pod|pad)|android|windows.*phone/i.test(navigator.userAgent)){
$(document).on("click", "a[href^='tel:']", function(e){ e.preventDefault(); });
}
/**
* Call function of deqwas.
*/
$.recommendInner();
/**
* Call function of highlight words.
*/
var hlwords = new HighlightWords();
hlwords.executeOn("#main");
/**
* Call function of telModalLink.
*/
telModalLink();
});
/**
* Applicate HTML5 Elements for a browser of not handle HTML5 (for example IE8).
*/
if(!/*@cc_on!@*/0) return;
var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video,main".split(",");
for(var i = 0; i < e.length; i++) {
document.createElement(e[i]);
}
})(jQuery);