// JavaScript Document

// ロールオーバー
function initRollOverImages() {
	var image_cache = new Object();
	$("img.rover,input.rover").each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_ro;
		$(this).hover(function() { this.src = imgsrc_ro; },function() { this.src = imgsrc; });
	});
}

$(document).ready(initRollOverImages);


//メニューアクティブ化
//画面ロード時にimgタグを_onの付いた画像に張り替える
function Menu_active(id){
	var target_img = "img#"+id;	
	$(target_img).each(function(i) {
		dot = this.src.lastIndexOf('.');
    	var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		this.src = imgsrc_ro;
		//既に割り当てられているロールオーバー関数を上書き
		$(this).hover(function() { this.src = imgsrc_ro; },function() { this.src = imgsrc_ro; });
	});
}

function SideMenu(tag){
	$(tag).each(function(){
		$(this).css('cursor','pointer');
		$(this).hover(function(){
			if(!$(this).hasClass('activ')){
				$(this).attr("src",$(this).attr("src").replace(".gif","_on.gif"));
			}
		},function(){
			if(!$(this).hasClass('activ')){
				$(this).attr("src",$(this).attr("src").replace("_on.gif",".gif"));
			}
		});
		
		$(this).toggle(function(){
			$(this).next().next().show('slow');
			$(this).addClass("activ");
			$(this).attr("src",$(this).attr("src").replace("_on.gif",".gif"));
			$(this).attr("src",$(this).attr("src").replace(".gif","_active.gif"));
		},function(){
			$(this).next().next().hide('slow');
			$(this).removeClass("activ");
			//$(this).attr("src",$(this).attr("src").replace(".gif","_on.gif"));
			$(this).attr("src",$(this).attr("src").replace("_active.gif",".gif"));
		});
	});
}
