var toTopP = '<div class=\"toTopJS\"><a href=\"#top\">ページトップへ戻る</a></div>';

$(document).ready(function($){
	//画像入れ替え系
	initRollOverImages();
	
	/* ページトップリンクをつける */
	$('#contents .sectionH2:not(.firstChild)').append(toTopP);
  
	var h = $('#contents').css("height");
  $('#sidebar').css("height", h);
  $('#body_bg').css("height", h);
});

/* 画像のロールオーバー関数 class="mouseon"をつけると、発動。画像名＋ONにチェンジ。 */
function initRollOverImages() {
	var image_cache = new Object();
	$("img.mouseon").each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_on = this.src.substr(0, dot) + 'ON' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		$(this).hover(
		function() { this.src = imgsrc_on; },
		function() { this.src = imgsrc; });
	});
}


