window.onload = function(){ $(function(){ /* トップのメインビジュをフェードインアウトで切り替える */ $('#fade').bxSlider({ mode: 'fade', auto: true, speed: 2000, pause: 7000, pager: false, controls: false }); /* ファイル名_off.jpg 等の画像をホバー時、 ファイル名_on.jpg へ差し替えます */ images = $('img'); for ( var i = 0; i < images.length; i++ ) { if ( images[i].getAttribute('src').match("_off_add.") ) { images[i].onmouseover = function() { this.setAttribute("src", this.getAttribute("src").replace("_off_add.", "_on_add.")); }; images[i].onmouseout = function() { this.setAttribute("src", this.getAttribute("src").replace("_on_add.", "_off_add.")); }; }; }; /* 開閉式コンテンツの作成 .toggleがボタンとなり、直後の要素が開閉式になります */ $('.toggle').css('cursor','pointer'); $('.toggle').next().css('display','none'); $('.toggle:target').next().css('display','block'); $('.toggle').click(function(e){ e.preventDefault(); $(this).next().slideToggle(); }); /* ページ内リンクの移動をスクロールに リンク先がシャープで始まる a.anchor に適応されます */ $('a.anchor').click(function(){ href = $(this).attr('href'); if (href=='#') $('html, body').animate({scrollTop: 0},600); else $('html, body').animate({scrollTop: $(href).offset().top},600); return false; }); /* リンク先の画像をライトボックスで表示 rel="lightbox" の付く aタグ に適応されます */ $('a[rel*=lightbox]').lightBox({ imageBtnClose: '/images/common/lightbox-btn-close.gif', imageLoading: '/images/common/lightbox-ico-loading.gif', imageBtnPrev: '/images/common/lightbox-btn-prev.gif', imageBtnNext: '/images/common/lightbox-btn-next.gif' }); /* 画面右下のボタンのオンオフ制御 */ $('.backtotop').hide(); $(window).scroll(function(){ if ($(this).scrollTop() > 200) { $('.backtotop').fadeIn(); } else { $('.backtotop').fadeOut(); } }); }); }