/*
 * jQuery plugin - Copyright (c) 2008 stepin program
 *
 * Dual licensed under the MIT licenses:
 *
 */

/* 使い方
 * 適用させたいテーブルにhover_tableというIDを付与する。
 * テーブルには<thead>、<tbody>を正しく書き込んでください。
 * 下の変数に色指定をしてください。
 * このプラグインはjQueryと併用してください。jQuery 1.2.6で動作確認しています。
 */

var base_col = "#f5f5f5";	/* <td>部の背景色 */
var target_col = "#ecf2f8";	/* カーソルを追う十字の色 */
var point_col = "#d7e5f1";	/* 十字の中心の色 */

$(hoverTable);
function hoverTable(){
	var line_size = $("table#tableselect tbody td").size() / $("table#tableselect tbody tr").size();
	$("table#tableselect tbody").css("background-color", base_col);
	$("table#tableselect tbody tr").hover(
		function(){
		$(this).css("background-color", target_col);
		},
		function(){
		$(this).css("background-color", "");
		}
	);
	$("table#tableselect tbody td").hover(
		function(){
		var this_index = $("table#tableselect tbody td").index(this);
		var deno = Math.floor(this_index / line_size);
		var index = this_index - (line_size * deno -1);
		$("table#tableselect tbody td:nth-child("+index+")").css("background-color", target_col);
		},
		function(){
		$("table#tableselect tbody td").css("background-color","");
		}
	);
	$("table#tableselect tbody td").hover(
		function(){
		$(this).css("background-color", point_col);
		},
		function(){
		$(this).css("background-color","");
		}
	);
}

/* 横ストライプ */
$(stripeTable);
function stripeTable(){
	$("table#stripe1 tbody tr:even").css("background-color","#cfe3be");
	$("table#stripe1 tbody tr:odd").css("background-color","#d1e2ea");
}

/* 縦ストライプ */
$(stripeTable2);
function stripeTable2(){
	$("table#stripe2 tbody tr td:nth-child(even)").css("background-color","#cfe3be");
	$("table#stripe2 tbody tr td:nth-child(odd)").css("background-color","#d1e2ea");
}

/* 格子模様 */
$(checkTable);
function checkTable(){
	$("table#check_table tbody tr:nth-child(odd) td:nth-child(odd), table#check_table tbody tr:nth-child(even) td:nth-child(even)")
		.css("background-color","#7f7f7f");
}

