//ROLLOVER
j$(function(){
    j$("img.over").mouseover(function(){
        j$(this).attr("src",j$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_over$2"))
    }).mouseout(function(){
        j$(this).attr("src",j$(this).attr("src").replace(/^(.+)_over(\.[a-z]+)$/, "$1$2"));
    }).each(function(){
        j$("<img>").attr("src",j$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_over$2"))
    })

//STAY
var url = document.URL.split('/');
j$('ul#gnaviSecond li').each(function(){
//imgタグに stayをつける
if (j$(this).hasClass(url[3])) {
    var img = j$(this).children().eq(0).children().eq(0);
    img.attr('src', img.attr('src').replace(/^(.+)(\.[a-z]+)$/, "$1_stay$2"));
    img.unbind('mouseover');
    img.unbind('mouseout');
    }else if (j$(this).hasClass(url[4])) {
    var img = j$(this).children().eq(0).children().eq(0);
    img.attr('src', img.attr('src').replace(/^(.+)(\.[a-z]+)$/, "$1_stay$2"));
    img.unbind('mouseover');
    img.unbind('mouseout');
    }
});

//年別
    j$('ul#yearNavi li').each(function(){
        var a = j$(this).children().eq(0);
        if (a.attr('href') == location.href)
            j$(this).addClass('current');
    });
    
//外部リンクに extRefを付与する
    j$("#main a[target='_blank']").addClass('extRef');
})

//縞模様のテーブル
j$(document).ready(function(){
  j$("#main div.shimaTable table").each(function(){
    j$(this).find("tr:even").addClass("even");
  });
});

// 検索文字列
jQuery(function($) {
var placeHolder = 'Google検索';
j$("input#searchTxt")
.focus(function() {
var self = j$(this);
if (self.val() === placeHolder) self.val("");
j$(this).css('color', '#333');
})
.blur(function() {
var self = j$(this);
if (self.val() === "") self.val(placeHolder);
j$(this).css('color', '#aaa');
});
});

// 検索文字列ブログ検索
jQuery(function($) {
var placeHolder2 = 'コンテンツ内検索';
j$("input.searchBox")
.focus(function() {
var self = j$(this);
if (self.val() === placeHolder2) self.val("");
j$(this).css('color', '#333');
})
.blur(function() {
var self = j$(this);
if (self.val() === "") self.val(placeHolder2);
j$(this).css('color', '#aaa');
});
});

//インライン要素の背景
j$.fn.extend({
inlineBgFix: function() {
if (j$.browser.msie && j$.browser.version < 8.0) {
j$(this)
.addClass('inline-bg-fix')
.prepend('<span class="linkExternalIcon">&nbsp;</span>')
}
}
});

j$.fn.extend({
inlineBgFix3: function() {
if (j$.browser.msie && j$.browser.version < 9.0) {
j$(this)
.addClass('inline-bg-fix')
.prepend('<span class="linkFreeDialIcon">&nbsp;</span>')
}
}
});

j$.fn.extend({
inlineBgFix2: function() {
if (j$.browser.msie && j$.browser.version < 8.0) {
j$(this)
.addClass('inline-bg-fix')
.prepend('<span class="linkPDFIcon">&nbsp;</span>')
}
}
});

j$.fn.extend({
inlineBgFix4: function() {
if (j$.browser.msie && j$.browser.version < 9.0) {
j$(this)
.addClass('inline-bg-fix')
.prepend('<span class="linkSpanIcon">&nbsp;</span>')
}
}
});


j$(function() {
j$('a.linkExternal').inlineBgFix();
j$('a.linkPDF').inlineBgFix2();
j$('.linkFreeDial').inlineBgFix3();
j$('a.linkIcon').inlineBgFix4();
});

j$(function(){
  j$('a[href^=#]').click(function() {
    // スクロールの速度
    var speed = 400;// ミリ秒
    // アンカーの値取得
    var href= j$(this).attr("href");
    // 移動先を取得
    var target = j$(href == "#" || href == "" ? 'html' : href);
    // 移動先を数値で取得
    var position = target.offset().top;
    // スムーススクロール
    j$(j$.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
    return false;
  });
});



