/* =============================================== # class="imgover" の要素に、マウスオーバーで  "_o.gif" の画像と入れ替える =============================================== */ function initRollovers() { if (!document.getElementById) return var aPreLoad = new Array(); var sTempSrc; var aImages = document.getElementsByTagName('img'); for (var i = 0; i < aImages.length; i++) { if (aImages[i].className == 'imgover') { var src = aImages[i].getAttribute('src'); var ftype = src.substring(src.lastIndexOf('.'), src.length); var hsrc = src.replace(ftype, '_o' + ftype); aImages[i].setAttribute('hsrc', hsrc); aPreLoad[i] = new Image(); aPreLoad[i].src = hsrc; aImages[i].onmouseover = function() { sTempSrc = this.getAttribute('src'); this.setAttribute('src', this.getAttribute('hsrc')); } aImages[i].onmouseout = function() { if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o' + ftype, ftype); this.setAttribute('src', sTempSrc); } } } } window.onload = initRollovers; try { window.addEventListener("load", initRollovers, false); } catch (e) { window.attachEvent("onload", initRollovers); } /* =============================================== # スムーズスクロール =============================================== */ jQuery(function() { // #で始まるアンカーをクリックした場合に処理 $('a[href^=#]').click(function() { // スクロールの速度 var speed = 400; // ミリ秒 // アンカーの値取得 var href = $(this).attr("href"); // 移動先を取得 var target = $(href == "#" || href == "" ? 'html' : href); // 移動先を数値で取得 var position = target.offset().top; // スムーススクロール $('body,html').animate({ scrollTop: position }, speed, 'swing'); return false; }); }); // page Topフェードイン・アウト $(function() { $(window).bind("scroll", function() { if ($(this).scrollTop() > 150) { $("#pagetop").fadeIn(); } else { $("#pagetop").fadeOut(); } // ドキュメントの高さ scrollHeight = $(document).height(); // ウィンドウの高さ+スクロールした高さ→ 現在のトップからの位置 scrollPosition = $(window).height() + $(window).scrollTop(); // フッターの高さ footHeight = $("footer").height(); // スクロール位置がフッターまで来たら if (scrollHeight - scrollPosition <= footHeight) { // ページトップリンクをフッターに固定 $("#pagetop a").css({ "position": "absolute", "bottom": "0px" }); } else { // ページトップリンクを右下に固定 $("#pagetop a").css({ "position": "fixed", "bottom": "0px" }); } }); });