// JavaScript Document $(function() { $(".pagetop").click(function() { $('body,html').animate({scrollTop:0}, 500, 'swing'); return false; }); $('a[href^=#]').click(function() { // var mrg = 0; // if($("body").css("background-size") == "cover"){ var mrg = $("#head").outerHeight() + 10; //var mrg = $("#header #menu").outerHeight() + 10; // } var href= $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top - mrg; if($(this).hasClass("nomrg")){ position = 0; } $('html,body').animate({scrollTop:position}, 500, 'swing');     return false; }); setsize(); imgchg(); setheight(); }); $(window).load(function(){ setsize(); imgchg(); setheight(); movepos(); }); $(window).resize(function () { setsize(); imgchg(); movepos(); }); $(window).scroll(function () { setsize(); imgchg(); }); $(window).on('orientationchange', function(){ setsize(); imgchg(); }); function setsize(){ var hs= $("#head").outerHeight(); $("#container").css("padding-top",hs+"px"); } function setheight(){ //if($('.contents.recruit.detail ul.voice li h4 span').css('display') != 'block'){ // $('.contents.recruit.detail ul.voice li dl dd').matchHeight(); //} } //他ページよりのアンカーリンク function movepos(){ //var mrg = 0; //if($("body").css("background-size") == "cover"){ var mrg = $("#header").outerHeight() + 10; var mrg = $("#header #menu").outerHeight() + 10; //} var href = location.href; if(href.indexOf("#")>=0 || location.search){ var href=href.substring(href.indexOf("#")+1,href.length); if(href.indexOf("?")>=0){ var parm = href.split('?'); href = parm[0]; } }else{ return false; } if(href){ var position = $("#"+href).offset().top; var speed = 500; $('body,html').animate({scrollTop:position-mrg}, speed, 'swing'); } return false; } function imgchg(){ var $el_480 = $('.imgchg_480'); var $el_768 = $('.imgchg_768'); var sp = '_sp.'; var tb = '_tb.'; var pc = '_pc.'; var state = $("#header").css("background-size"); //768以下 $el_768.each(function() { var $this = $(this); var $repstr = $this.attr('src'); var $rep = pc; if ( $repstr.indexOf(pc) != -1) { $rep = pc; } if ( $repstr.indexOf(tb) != -1) { $rep = tb; } if ( $repstr.indexOf(sp) != -1) { $rep = sp; } if(state == 'cover' && $rep != tb){ $this.attr('src', $this.attr('src').replace($rep, tb)); } if(state == 'contain' && $rep != sp){ $this.attr('src', $this.attr('src').replace($rep, sp)); } if(state != 'cover' && state != 'contain' && $rep != pc){ $this.attr('src', $this.attr('src').replace($rep, pc)); } //if ( str.indexOf('hoge') != -1) { }); //480以下 $el_480.each(function() { var $this = $(this); if(state == 'contain'){ $this.attr('src', $this.attr('src').replace(pc, sp)); } else { $this.attr('src', $this.attr('src').replace(sp, pc)); } }); }