$(document).ready(function(){
	$('.onoff img,#hnav img,.bnav img').each(function(ev){
			preload_img(this);
			$(this).mouseover(function(ev){
				img_on(ev.target);
			}).mouseout(function(ev){
				img_off(ev.target);
			});
	});

	$('.cont table td').has('a').click(function(e){
		location.href = $(this).find('a').attr('href');
	});
	
	$('.cont table td').has('a').addClass('rollover').mouseover(function(){
		$(this).addClass('hover');
	}).mouseout(function(){
		$(this).removeClass('hover');
	});

	$('.cont table#top_profile td:nth-child(odd)').addClass("tl");
	$('.cont table#top_profile td:nth-child(even)').addClass("tr");
	$('.cont table#top_business td:nth-child(odd)').addClass("tl");
	$('.cont table#top_business td:nth-child(even)').addClass("tr");
	$('.cont table#top_gallrey td:nth-child(odd)').addClass("tl");
	$('.cont table#top_gallrey td:nth-child(even)').addClass("tr");
	$('.cont table#top_recruit td:nth-child(odd)').addClass("tl");
	$('.cont table#top_recruit td:nth-child(even)').addClass("tr");

	$('.cont table#top_profile tr:last-child').addClass("last");
	var td_count=$('.cont table#top_profile tr:last-child td').size();
	if((td_count%2) == 1){
		$('.cont table#top_profile tr:last-child td').after('<td class="tr">&nbsp;</td>');
	}
	$('.cont table#top_gallrey tr:last-child').addClass("last");
	var td_count=$('.cont table#top_gallrey tr:last-child td').size();
	if((td_count%2) == 1){
		$('.cont table#top_gallrey tr:last-child td').after('<td class="tr">&nbsp;</td>');
	}
	$('.cont table#top_business tr:last-child').addClass("last");
	var td_count=$('.cont table#top_business tr:last-child td').size();
	if((td_count%2) == 1){
		$('.cont table#top_business tr:last-child td').after('<td class="tr">&nbsp;</td>');
	}
	$('.cont table#top_recruit tr:last-child').addClass("last");
	var td_count=$('.cont table#top_recruit tr:last-child td').size();
	if((td_count%2) == 1){
		$('.cont table#top_recruit tr:last-child td').after('<td class="tr">&nbsp;</td>');
	}

	$("#right .bn").click(function(e){
		location.href = $(this).find('a').attr('href');
	}).mouseover(function(){
		$(this).find('dl').addClass('hover');
	}).mouseout(function(){
		$(this).find('dl').removeClass('hover');
	});

	$('.img3s dl:nth-child(1n)').addClass("l_02");
	$('.img3s dl:nth-child(2n)').addClass("c_02");
	$('.img3s dl:nth-child(3n)').addClass("r_02");

	$('.type01 tr:nth-child(1)').addClass("top");

	$('.type02 tbody tr:nth-child(1)').addClass("line");

	$('.type03 tbody tr:nth-child(1)').addClass("line");

	$('.type04 tr:nth-child(1)').addClass("top");

	$('.news dt:first-child').addClass("top");
	$('.news dd:nth-child(2)').addClass("top");

	$('.rnav .rnav_in ul li:last-child').addClass("last");

	var dlHeight=0;
	$('.info dl').each(function(){
		var thisHeight=$(this).height();
		if(dlHeight < thisHeight){
			dlHeight=thisHeight;
		}
	});
	var newHeight=dlHeight+"px";
	$('.info dl').each(function(){
		$(this).css("height",newHeight);
	});

	var recruitsideCount=$('.rnav .rnav_in li').size();
	if(recruitsideCount == 0){
		$('.rnav').css("display","none");
	}

});

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);
}
