/*
jquery.util.js
Update 2020.08.18
Version 1.2
*/
jQuery(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, "easeInOutQuad");
return false;
});
//---- ルートURL取得
var root;
var js_path = 'js/';
var scripts = document.getElementsByTagName("script");
var i = scripts.length;
while (i--) {
var match = scripts[i].src.match(/(^|.*\/)\/?jquery\.util\.js$/);
if (match) {
root = match[1].replace(js_path,'');
break;
}
}
//---- URLのパターン解析
var url = document.URL;
url = url.replace(root,'');
//---- ロールオーバー
var btnOver = function(){
$('body .over').each(function(i){
var target = $(this);
var img = $(this).find('img');
var src = img.attr('src');
var tmp = new Image();
var hover_tmp = new Image();
var link = $(this).attr('href');
link = link.replace(root,'');
var tmp_url = src.replace(/\.(jpe*g|gif|png)(.*)?$/,'_cr.$1$2');
var hover_url = src.replace(/\.(jpe*g|gif|png)(.*)?$/,'_on.$1$2');
var hover_action = function(){
//onの画像チェック
hover_tmp.src = hover_url;
hover_tmp.onload = function(){
target.hover(
function(){ img.attr('src',hover_url); },
function(){ img.attr('src',src); }
);
}
}
if(url == link){
tmp.onload = function(){
img.attr('src',src.replace(/.(jpe*g|gif|png)(.*)?$/,'_cr.$1$2'));
}
tmp.onerror = function(){
hover_action();
}
tmp.src = tmp_url;
} else {
hover_action();
}
});
}
/* ------ 実行部 -------- */
$(function(){
btnOver();
});
});
$(function(){
//inputボタン画像入れ替え
$('.input_over').mouseover(function(){
$(this).attr('src',$(this).attr('src').replace(/^(.+)(\.[a-z]+)$/, '$1_on$2'));
}).mouseout(function(){
$(this).attr('src',$(this).attr('src').replace(/^(.+)_on(\.[a-z]+)$/, '$1$2'));
}).each(function(){
$('').attr('src',$(this).attr('src').replace(/^(.+)(\.[a-z]+)$/, '$1_on$2'));
});
//button画像入れ替え
$('.btn_over').mouseover(function(){
$(this).children().attr('src',$(this).children().attr('src').replace(/^(.+)(\.[a-z]+)$/, '$1_on$2'));
}).mouseout(function(){
$(this).children().attr('src',$(this).children().attr('src').replace(/^(.+)_on(\.[a-z]+)$/, '$1$2'));
}).each(function(){
$('