//ロールオーバー
$(function(over){
    $("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"))
    })

  
//タブUIを実装する
$("div.pannel div:not("+$("ul.tab li a.selected").attr("href")+")").hide()
$("ul.tab li a").click(function(){
$("ul.tab li a").removeClass("selected")
$(this).addClass("selected")
$("div.pannel div").hide()
$($(this).attr("href")).show()
return false
})
    
//現在位置の画像にstayをつける
var url = document.URL.split('/');
    $('#gnavi ul li a').each(function(){
    var gnavi_href = $(this).attr('href').split('/');
  if (gnavi_href[3] == url[3]) {
//$(this).parent().addClass("stay");
//if ($(this).hasClass(url[3])) {
var img = $(this).children().eq(0);
img.attr('src', img.attr('src').replace(/^(.+)(\.[a-z]+)$/, "$1_stay$2"));
img.unbind('mouseover');
img.unbind('mouseout');
    }
    });
    
    /*
    $('#featureTabs li a').each(function(){
var img = $(this).children().eq(0);
var class = $(this);
if(class=='current'){
img.attr('src', img.attr('src').replace(/^(.+)(\.[a-z]+)$/, "$1_stay$2"));
img.unbind('mouseover');
img.unbind('mouseout');
}
    });
    */
    
//ローカルナビゲーションに第2階層のフォルダ名をclassとして指定する
    $('ul.level01 li').each(function(){
    var href = $(this).children().eq(0).attr('href').split('/');
$(this).addClass(href[4]);
if (href[4] == 'list') {
$(this).hide();
}
if (href[4] == 'movabletype') {
$(this).hide();
}
if (href[4] == 'compar') {
$(this).hide();
}
    });
    
//外部リンクに自動的にextRefを付与する
$("#main a[target='_blank']").addClass('extRef');
$("#main a[target='_blank'] img").parent('a').removeClass('extRef');
$("#main a[target='_blank'] img").parent('a').addClass('noneextRef');

//角丸のあった場所
    
//.columnframeの最後のddの下線を消す
    $('.columnframe dl').each(function(){
    $(this).children('dd:last').addClass('last');
    });
    
//.simpleframeの最後のddの下線を消す
    $('.simpleframe dl').each(function(){
    $(this).children('dd:last').addClass('last');
    });
    
//.columnframeの最後のliの下線を消す
    $('.columnframe ul').each(function(){
    $(this).children('li:last').addClass('last');
    });

    $('.articletext').each(function(){
    $(this).children('p:last').addClass('last');
    });
    
    $('.sub ul').each(function(){
    $(this).children('li:last').addClass('last');
    });


//$("table tr:last-child").addClass('sfooter');
//$("table tr:first-child").addClass('sheader');

    $('.columns ul').each(function(){
    $(this).children('li:last').addClass('last');
    });
    $('.columns_two ul').each(function(){
    $(this).children('li:last').addClass('last');
    });

    $('div').each(function(){
    $(this).children('span:first').addClass('first');
    });
    $('div').each(function(){
    $(this).children('span:last').addClass('last');
    });

    $('.thumbnail').each(function(){
$(this).parent().addClass("article");
    });

//topicPath
    $('#topicPath ul').each(function(){
    $(this).children('li:last').addClass('last');
    });


    
//.newsの最後のliの下線を消す
    $('.news ul').each(function(){
    $(this).children('li:last').addClass('last');
    });
    //topicPathの最後の矢印を消す
    $('#topicPath li:last span').hide();
//.latest_newsの最後のliの下線を消す
    $('.latest_news').each(function(){
    $(this).children('dl:last').addClass('last');
    });




//メニュー
    $('#localNavi_inner .current').each(function(){
        //$(this).removeClass("current");
        $class= $(this).attr("class");
        $(this).removeClass($class);
        $class+="current";
        $(this).addClass($class);
//        $(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_on$2"))   
    });
    
    $('#localNavi_inner .level02').each(function(){
      $(this).children('li:last').addClass('last');
    });

//角丸の設定    

    DD_roundies.addRule('.news' , '3px' ,true);
    DD_roundies.addRule('.latest_news' , '3px' ,true);
    DD_roundies.addRule('.irData' , '5px' ,true);
    DD_roundies.addRule('.mailmagazine' , '5px' ,true);
    //DD_roundies.addRule('#topicPath' , '3px' ,true);
    //DD_roundies.addRule('#footer' , '5px 5px 0px 0px' ,true);
    //DD_roundies.addRule('#footerNavi' , '5px' ,true);
    DD_roundies.addRule('.simpleframe' , '3px' ,true);
    DD_roundies.addRule('.columnframe' , '3px' ,true);
    DD_roundies.addRule('h3' , '3px 3px 0px 0px' ,true);
    DD_roundies.addRule('body#news h3' , '0px 0px 0px 0px' ,true);
    DD_roundies.addRule('.articleimage' , '3px' ,true);
    DD_roundies.addRule('.irStockMarket' , '5px' ,true);
    DD_roundies.addRule('.thumbnail' , '5px' ,true);
    DD_roundies.addRule('.privacy' , '5px' ,true);

});




//スムーズスクロール
$(document).ready(function(){
    $('a[href^=#]').click(function(){
        var target;
        target = $( $(this).attr('href') );
        if (target.length == 0) {
            return;
        }
        $('html, body').animate({scrollTop: target.offset().top});
        return false;
    });
});

$(document).ready(function() {
    var max = 0;
    $("label").each(function(){
        if ($(this).width() > max)
            max = $(this).width();    
    });
    $("label").width(max);
});


//文字の大きさ変更
$(function(){
//$("p").css("font-size",$.cookie('fsize'));
var $ss = $.cookie('fsize');

if($ss=="fontS"){
font($ss,$(".fontSize .small a"));
}else if($ss=="fontM"){
font($ss,$(".fontSize .mid a"));
}else if($ss=="fontL"){
font($ss,$(".fontSize .big a"));
}else{
font("fontM",$(".fontSize .small a"));
}


});
function font(size,obj){

//$("body").css("font-size",size);

$("body").removeClass("fontS");
$("body").removeClass("fontM");
$("body").removeClass("fontL");

$("body").addClass(size);

$(".fontSize .small a img").attr("src",$(".fontSize .small a img").attr("src").replace(/^(.+)_stay(\.[a-z]+)$/, "$1$2"));
$(".fontSize .mid a img").attr("src",$(".fontSize .mid a img").attr("src").replace(/^(.+)_stay(\.[a-z]+)$/, "$1$2"));
$(".fontSize .big a img").attr("src",$(".fontSize .big a img").attr("src").replace(/^(.+)_stay(\.[a-z]+)$/, "$1$2"));
$(".fontSize .small a img").attr("src",$(".fontSize .small a img").attr("src").replace(/^(.+)_over(\.[a-z]+)$/, "$1$2"));
$(".fontSize .mid a img").attr("src",$(".fontSize .mid a img").attr("src").replace(/^(.+)_over(\.[a-z]+)$/, "$1$2"));
$(".fontSize .big a img").attr("src",$(".fontSize .big a img").attr("src").replace(/^(.+)_over(\.[a-z]+)$/, "$1$2"));
$(obj).children().eq(0).attr("src",$(obj).children().eq(0).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_stay$2"));
$.cookie("fsize",size,{expires:30,path:'/'});
}

/*

$(document).ready(function() {
$.featureList(
$("#featureTabs li a"),
$("#output li"), {
start_item:0
}
);
});
*/
//アコーディオンの実装（FAQ）
$(document).ready(function() {
$(".faqnavi dt").hover(function(){
$(this).css("cursor","pointer"); 
},function(){
$(this).css("cursor","default"); 
});
$(".faqnavi dd").css("display","none");
$(".faqnavi dt").click(function(){
$(this).next().slideToggle("fast");
});
$(".faqnavi img").click(function(){
$(this).parent().slideToggle("fast");
});

});


//colorboxの実装
$(document).ready(function(){
    $("a[rel='image']").colorbox();
    //$(".iframe").colorbox({width:"680px", height:"90%", iframe:true});
    $(".iframe").colorbox({width:"643px",height:"90%", iframe:true});
    $("#click").click(function(){
       $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
       return false;
    });
});


