$(document).ready(function(){
	jQuery("textarea").charCount({allowed:400,warning:400});
	$('.onoff img').each(function(ev){
			preload_img(this);
			$(this).mouseover(function(ev){
				img_on(ev.target);
			}).mouseout(function(ev){
				img_off(ev.target);
			});
	});
	
	
	$('.submit_rollover').each(function(ev){
		$(this).mouseover(function(ev){
			btn_on(ev.target);
		}).mouseout(function(ev){
			btn_off(ev.target);
		});								
	});
	
	$('.search_result_wpr').each(function(ev){
		var boxcount = $(this).find('.search_result_box').length;
		if(boxcount < 3){
			var wprClass = 'search_result_wpr_'+boxcount;
			$(this).addClass(wprClass);
		}
	});
	$('#top_recommend_right_button').click(function(ev){	
		$(this).parent().find('tr').each(function(ev){
			$(this).find('th:first,td:first').appendTo(this);
			$(this).find('th:lt(3),td:lt(3)').show();
			$(this).find('th:gt(2),td:gt(2)').hide();
		});
	});
	
	$('#top_recommend_left_button').click(function(ev){
		$(this).parent().find('tr').each(function(ev){
			$(this).find('th:last,td:last').prependTo(this);
			$(this).find('th:lt(3),td:lt(3)').show();
			$(this).find('th:gt(2),td:gt(2)').hide();
		});	
	});
	
	$('.side_recommend:lt(4)').show();
	$('#sidenavi .side_recommend_nav .pre').hide();
	
	$('#sidenavi .side_recommend_nav .next').click(function(ev){
		$(this).parent().find('.pre').show();
		$(this).hide();
		$('.side_recommend:lt(4)').hide();
		$('.side_recommend:gt(3)').show();
	});

	$('#sidenavi .side_recommend_nav .pre').click(function(ev){
		$(this).parent().find('.next').show();
		$(this).hide();
		$('.side_recommend:gt(3)').hide();
		$('.side_recommend:lt(4)').show();
		
	});

	
	$('.box05').each(function(ev){
		var boxcount = $(this).find('.box05_dl').length;
		if(boxcount < 3){
			var wprClass = 'box05_'+boxcount;
			$(this).addClass(wprClass);
		}
	});
			
		$('#career_model dl').mouseover(function() {
			var tabindex = $(this).parent().find('dl').index(this);
			$(this).parents('#career_model_wpr').find('#career_txt div:not(:eq('+tabindex+'))').hide();
			$(this).parents('#career_model_wpr').find('#career_txt div:eq('+tabindex+')').show();	
		});
		
		$('#career_model dl').mouseout(function() {
			$(this).parents('#career_model_wpr').find('#career_txt div:not(.career_txt_default)').hide();
			$(this).parents('#career_model_wpr').find('#career_txt div.career_txt_default').show();	
		});
		
		
		
		$('.top_new_information_ul li:not(:has(.pic))').addClass('no_icon');

});

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);
}

function btn_on(tgt){
	$(tgt).addClass('on');
}

function btn_off(tgt){
	$(tgt).removeClass('on');
}

(function(A){A.fn.charCount=function(B){var D={allowed:140,warning:25,css:"counter",counterElement:"span",cssWarning:"warning",cssExceeded:"exceeded",counterText:""};var B=A.extend(D,B);function C(G){var E=A(G).val().length;var F=B.allowed-E;if(F<=B.warning&&F>=0){A(G).next().addClass(B.cssWarning)}else{A(G).next().removeClass(B.cssWarning)}if(F<0){A(G).next().addClass(B.cssExceeded)}else{A(G).next().removeClass(B.cssExceeded)}A(G).next().html(B.counterText+F)}this.each(function(){A(this).after("<"+B.counterElement+' class="'+B.css+'">'+B.counterText+"</"+B.counterElement+">");C(this);A(this).keyup(function(){C(this)});A(this).change(function(){C(this)})})}})(jQuery);
