$(document).ready(function(){
	$('.onoff img,.top_bn img,.info dd.h img,.lbnr img,.cmn_about img,.cmn_relation img').each(function(ev){
			preload_img(this);
			$(this).mouseover(function(ev){
				img_on(ev.target);
			}).mouseout(function(ev){
				img_off(ev.target);
			});
	});
	$('table.oddeven').each(function(ev){
	$(this).find('tr:even').addClass('even');
	$(this).find('tr:odd').addClass('odd');
	$(this).find('tr:last').addClass('last');
	});
});



$(function(){
	
	$('input[type="text"]#site_search').each(function(){
	 
		this.value = $(this).attr('title');
		$(this).addClass('text-label');
	 
		$(this).focus(function(){
			if(this.value == $(this).attr('title')) {
				this.value = '';
				$(this).removeClass('text-label');
			}
		});
	 
		$(this).blur(function(){
			if(this.value == '') {
				this.value = $(this).attr('title');
				$(this).addClass('text-label');
			}
		});
	});

	$('.cmn_link .row').click(function(e){
		location.href = $(this).find('dl a').attr('href');
	});
	
	$('.cmn_link .row img').each(function(ev){
		preload_img(this);
	});
	
	$('.cmn_link .row').mouseover(function(){
		$(this).addClass('hover');
		img_on($(this).find('dt img'));
		img_on($(this).find('dd img'));
	}).mouseout(function(){
		$(this).removeClass('hover');
		img_off($(this).find('dt img'));
		img_off($(this).find('dd img'));
	});

	$('.lnav .in .in_in ul li:last-child').addClass("last");

	$('table.type01 tbody tr:last-child').addClass("last");

	$('table.type02 tbody tr:first-child').addClass("top");
	$('table.type02 tbody tr:last-child').addClass("last");

	var lnav_c=$('.lnav li').length;
	if(lnav_c < 1){
		$('.lnav').after($('<h2><a href="./"><img src="../img/lnavi_shita.gif" alt="" /></a></h2>'));
		$('.lnav').css("display","none");
	}

	var bnavH=0;
	$('.bnav li .in_in').each(function(){
		var thisH=$(this).height();
		if(bnavH < thisH){
			bnavH=thisH;
		}
	});
	var bnavTxt=bnavH+"px";
	$('.bnav li .in_in').each(function(){
		$(this).css("height",bnavTxt);
	});

});



function img_on(tgt){
	var src=$(tgt).attr('src');
	var newsrc=src.replace("_off","_on");
	$(tgt).attr('src',newsrc);
}

function img_off(tgt){
	var src=$(tgt).attr('src');
	var newsrc=src.replace("_on","_off");
	$(tgt).attr('src',newsrc);
}

function preload_img(tgt){
	var src=$(tgt).attr('src');
	var newsrc=src.replace("_off","_on");
	$('<img>').attr('src', newsrc);
}
