/*

nikkansports.com 世界陸上2007 config.js

DATE      : 2007/08/17
COPYRIGHT : Nikkan Sports News.
WRITER    : Chiaki Hatanaka


 */



// -------------------------------------------------------------------
// ロールオーバー
// -------------------------------------------------------------------
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match(/_off\./))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace(/_off\./, "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace(/_on\./, "_off."));
				}
			}
		}
	}
}

if (window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if (window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}




// -------------------------------------------------------------------
// for jQuery
// -------------------------------------------------------------------
$(function(){



	// グローバルナビ画像を <body> の class により差し替える
	var bodyClass = $('body').attr('class');

	switch(bodyClass) {
		case "athleticsTop":
		$('#pageMenu ol li:nth-child(1)').find('a').html('<img src="/sports/athletics/2007/img/menu-top_on.gif" alt="特集トップ" width="46" height="24" />');
		break;

		case "athleticsPhoto":
		$('#pageMenu ol li:nth-child(2)').find('a').html('<img src="/sports/athletics/2007/img/menu-photo_on.gif" alt="写真ニュース" width="84" height="24" />');
		break;

		case "athleticsSchedule":
		$('#pageMenu ol li:nth-child(3)').find('a').html('<img src="/sports/athletics/2007/img/menu-schedule_on.gif" alt="競技日程" width="63" height="24" />');
		break;

		case "athleticsTv":
		$('#pageMenu ol li:nth-child(4)').find('a').html('<img src="/sports/athletics/2007/img/menu-tv_on.gif" alt="ＴＶ放送予定" width="81" height="24" />');
		break;

		case "athleticsResult":
		$('#pageMenu ol li:nth-child(5)').find('a').html('<img src="/sports/athletics/2007/img/menu-result_on.gif" alt="種目別結果" width="75" height="24" />');
		break;

		case "athleticsJapan":
		$('#pageMenu ol li:nth-child(6)').find('a').html('<img src="/sports/athletics/2007/img/menu-japan_on.gif" alt="日本代表" width="62" height="24" />');
		break;

		case "athleticsPlayer":
		$('#pageMenu ol li:nth-child(7)').find('a').html('<img src="/sports/athletics/2007/img/menu-player_on.gif" alt="注目選手紹介" width="63" height="24" />');
		break;

		case "athleticsOutline":
		$('#pageMenu ol li:nth-child(8)').find('a').html('<img src="/sports/athletics/2007/img/menu-outline_on.gif" alt="大会概要" width="64" height="24" />');
		break;
	}


	// 奇数、偶数をクラスとして追加
	$('table').each(function(){
		$(this).find('tr:odd').addClass('odd');
		$(this).find('tr:even').addClass('even');
	});
	
	// :first-child, :last-childをクラスとして追加
	$('.line').each(function(){
		$('li:first-child').addClass('firstChild');
		$('li:last-child').addClass('lastChild');
	});

	// :hoverをクラスとして追加
	$('tr').hover(function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});




});


