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

