//ロールオーバー
$(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('/');

    $('ul#navimage li a').each(function(){
    var gnavi_href = $(this).attr('href').split('/');
$('h1#check').text(url[4]);
  if (gnavi_href[1] == 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');
    }
if(url.length==4){
$('img.home').attr('src','/common/images/gnavi/home_stay.gif');
$('img.home').unbind('mouseover');
    $('img.home').unbind('mouseout');
}
  });
  
  $('ul.level01 li a').each(function(){
    var local_href = $(this).attr('href').split('/');
  if (local_href[2] == url[4]) {
   $(this).parent().addClass("current");
    }
  });
  
  $('ul.level00 li a').each(function(){
    var local_href = $(this).attr('href').split('/');
  if (local_href[1] == url[3]) {
   $(this).parent().addClass("current");
 $('img.home').attr('src','/common/images/gnavi/home_stay.gif');
$('img.home').unbind('mouseover');
    $('img.home').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');
}
    });
    */
    
//ローカルナビゲーションに第3階層のフォルダ名を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();
}
    });

//ローカルナビゲーションに第2階層フォルダ名をclassとして指定する
    $('ul.level00 li').each(function(){
    var href = $(this).children().eq(0).attr('href').split('/');
$(this).addClass(href[3]);
if (href[3] == 'list') {
$(this).hide();
}
if (href[3] == 'movabletype') {
$(this).hide();
}
if (href[3] == '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);
});


//アコーディオンの実装（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;
    });
});
*/

$(function(){
$("input#formSearchText").val("サイト内検索").css("color","#CCC").one("focus",function(){
$(this).val("").css("color","#000");
}).blur(function(){
if($(this).val()==""){
$(this).val("サイト内検索").css("color","#CCC").one("focus",function(){
$(this).val("").css("color","#000");
});
}
});
});

function newM(y,m,d)
{
newday=new Date(y+"/"+m+"/"+d);
oldday= new Date();
n=(oldday-newday)/(1000*60*60*24);
if (n <=7)document.write("<span class='point_new'><img src='/common/images/new_icon.gif' width='32' height='20' alt='NEW' /></span>");
}



//折りたたみメニュー
function doToggleClassName(obj, onClassName, offClassName){obj.className = (obj.className != onClassName) ? onClassName : offClassName;}
function getParentObj(obj){return obj.parentElement || obj.parentNode;}


//アコーディオンの実装（FAQ）

$(function () {
    $("a[rel*=',']").click(function () {
        return winPop(this.href, this.rel)
    });
    function winPop(url, rel) {
        var sets = rel.split(',');
        var popN = sets[0];
        var popW = sets[1];
        var popH = sets[2];
        var left = (screen.width - popW) / 2;
        var top = (screen.height - popH) / 2;
        newWin = window.open(url, popN, 'width=' + popW + ',height=' + popH + ',top=' + top + ', left=' + left + ',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
        if (window.focus) {
            newWin.focus()
        }
        return false;
    };
});
