/* ****************************************************************** @This javascript Information{ JS File Name:common.js } ****************************************************************** */ /*=================================================================== 1:imgover setting ===================================================================*/ if(typeof jQuery != "undefined"){ /* img input */ $(function(){ $('img.imgover,input[type=image].imgover').each(function(){ var imgOut = new Image(); imgOut.src = $(this).attr('src'); var imgOver = new Image(); if(imgOut.src.match(/.gif$/)){ imgOver.src = $(this).attr('src').replace('.gif','_on.gif'); }else if(imgOut.src.match(/.jpg$/)){ imgOver.src = $(this).attr('src').replace('.jpg','_on.jpg'); }else if(imgOut.src.match(/.png$/)){ imgOver.src = $(this).attr('src').replace('.png','_on.png'); } $(this) .mouseover(function(){$(this).attr('src',imgOver.src);}) .mouseout( function(){$(this).attr('src',imgOut.src);}); }); }); /* fade */ $(function(){ $('a img.imgfade,input.imgfade,a.imgfade,#header_inq a,#pankuzu a').hover( function(){ $(this).fadeTo(100,0.6); }, function(){ $(this).fadeTo(100,1.0); } ); }); } /*=================================================================== 2:scroll setting ===================================================================*/ $(function(){ $('a[href^=#]').click(function(){ var speed = 500; var href= $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top; $("html, body").animate({scrollTop:position}, speed, "swing"); return false; }); }); /*=================================================================== 3:smart navi setting ===================================================================*/ $(function(){ var spBtnTo = $('#navi .sp_gnavi_btn'); var spGnavi =$('#navi ul'); spBtnTo.click(function(){ spGnavi.stop().slideToggle('fast'); }); }); /*=================================================================== 4:top slide setting ===================================================================*/ $(window).load(function () { $('.swipeshow .slides').slick({ autoplay: true, autoplaySpeed: 6000, arrows: false, pauseOnHover: false, }); }); /*=================================================================== 5:SP Menu setting ===================================================================*/ (function ($) { $.fn.eventToggle = function( fn ) { // Save reference to arguments for access in closure var args = arguments, guid = fn.guid || jQuery.guid++, i = 0, toggler = function( event ) { // Figure out which function to execute var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); // Make sure that clicks stop event.preventDefault(); // and execute the function return args[ lastToggle ].apply( this, arguments ) || false; }; // link all the functions, so any of them can unbind this click handler toggler.guid = guid; while ( i < args.length ) { args[ i++ ].guid = guid; } return this.click( toggler ); }; })(jQuery); /*=================================================================== 6:side setting ===================================================================*/ var firstFlg = false; if ($.cookie("slideOpenFlg") == "true" && $(window).width() >= 880) firstFlg = true; $(function(){ var topBnr = $('#main_v'); var contents = $('#contents'); var sideBox = $("#side_box"); var btnSide = $("#side_box #btn_side"); if ($(window).width() < 880) { btnSide.eventToggle(function(){ sideBox.animate({ 'width': '290px' }, 300); $(this).css({ 'transform': 'rotateY(180deg)', 'background-position': '12px center' }); $.cookie("slideOpenFlg", "true", { path: '/' }); }, function(){ sideBox.css({ 'width': '0px' }); $(this).css({ 'transform': 'rotateY(0deg)', 'background-position': '8px center' }); $.cookie("slideOpenFlg", "false", { path: '/' }); }); } else { btnSide.eventToggle(function(){ if (firstFlg) { firstFlg = false; sideBox.animate({'width': '0px'}, 300); topBnr.animate({'left' : 0 }, 300); contents.animate({'left' : 0 }, 300); } else { firstFlg = true; sideBox.css({'width': '0px'}); topBnr.css({'left' : 0 }); contents.css({'left' : 0 }); } $(this).css({ 'transform': 'rotateY(0deg)', 'background-position': '8px center' }); $.removeCookie("slideOpenFlg"); $.cookie("slideOpenFlg", "false", { path: '/' }); }, function(){ sideBox.animate({ 'width': '290px' }); $(this).css({ 'transform': 'rotateY(180deg)', 'background-position': '12px center' }); topBnr.animate({'left' : -145 }, 300); contents.animate({'left' : -145 }, 300); firstFlg = true; $.removeCookie("slideOpenFlg"); $.cookie("slideOpenFlg", "true", { path: '/' }); }); } }); /*=================================================================== 7:Top Tab setting ===================================================================*/ $(function(){ var topTabBtn = $("#top_05 #pc_tab_menu ul li span"); topTabBtn.click(function(){ var tab = $(this).parents("li").attr("id"); var num = tab.split("_"); var con = "#tabcont_" + num[1]; topTabBtn.parents("li").removeClass("active"); $(this).parents("li").addClass("active"); $(".top_tab_earch").hide(); $(con).fadeIn(); }); $('[name=sp_tab_menu]').change(function() { var vall = $('[name=sp_tab_menu]').val(); var num_sp = vall.split("_"); var consp = "#tabcont_" + num_sp[1]; topTabBtn.parents("li").removeClass("active"); $(this).parents("li").addClass("active"); $(".top_tab_earch").hide(); $(consp).fadeIn(); }); }); /*=================================================================== 8:form height setting ===================================================================*/ $(window).load(function(){ var maxHeight = $("#bg_main").outerHeight(); $("#conf_win").css({ "height" : maxHeight + "px" }); var winClose = $("#btn_close_win a, #btn_submit a"); var confBox = $("#conf_win"); winClose.click(function(){ confBox.fadeOut('fast'); }); }); /*=================================================================== 9:sp select link setting ===================================================================*/ function dropsort() { var browser = document.sort_form.sort.value; location.href = browser } /*=================================================================== 10: ===================================================================*/ /*=================================================================== 11:side opening motion ===================================================================*/ $(function(){ if ($(window).width() < 880) { } else { var sideBox = $("#side_box"); var btnSide = $("#side_box #btn_side"); var topBnr = $('#main_v'); var contents = $('#contents'); if (typeof $.cookie("slideOpenFlg") === "undefined") { sideBox.animate({'width': '290px'}, 300); $.cookie("slideOpenFlg", "true", { path: '/' }); } else if ($.cookie("slideOpenFlg") == "true") { sideBox.css({'width': '290px'}); btnSide.css({ 'transform': 'rotateY(180deg)', 'background-position': '12px center' }); topBnr.css({'left' : "-145px" }); contents.css({'left' : "-145px" }); } else { btnSide.click(); } } }); /*=================================================================== 12: ===================================================================*/ /*=================================================================== 13: ===================================================================*/ $(function(){ $(window).load(function() { var lsH = $(window).height(); if ($(window).height() < 500) { $('#navi ul').css('max-height', lsH - 110); $('#navi ul').css('overflow-y', 'scroll'); } else { $('#navi ul').css('max-height', 'none'); $('#navi ul').css('overflow-y', 'hidden'); } }); $(window).resize(function() { var lsH = $(window).height(); if ($(window).height() < 500) { $('#navi ul').css('max-height', lsH - 110); $('#navi ul').css('overflow-y', 'scroll'); } else { $('#navi ul').css('max-height', 'none'); $('#navi ul').css('overflow-y', 'hidden'); } }); }); /*=================================================================== 14: ===================================================================*/ $(function(){ $(window).bind("load", function(){ var param = parseURLParams(location.search); if(document.URL.match(/price/) && param['target'].length > 0) { setTimeout(function() { var targetPosition = $("#"+param['target']).offset().top; if ($(window).width() > 880) { $("html,body").scrollTop(targetPosition - 119); } else { $("html,body").scrollTop(targetPosition - 59); } }, 10); } }); }); /*=================================================================== 15:GETパラメーターをKey,Valueに分解する ===================================================================*/ function parseURLParams(url) { url = url.replace(/#.*/ , ""); var params = url.split("?"); var urlParams = null; if (params.length > 1) { var urlParams = new Array(); var parseParams = params[1].split("&"); for (var i = 0; i < parseParams.length; i++) { var kv = parseParams[i].split("="); if (kv.length == 2) { var key = kv[0]; urlParams[key] = kv[1]; } } } return urlParams; }