$(function () {
	if($.os.name=='iphone' || ($.os.name!='win'&&$.os.name!='mac')) {
		$('html').css('-webkit-text-size-adjust','none');
		$('select[multiple=multiple]').css('height','auto');
	}

	$('a[href*=#]').click(function(event) {
		var $target=$(this.hash);
		var targetY=$target.offset().top;

		/*
		 * 常勤、非常勤タブクリック時、アンカースクロールイベントを回避
		 */
		if($target.attr("id").match(/(?!TabJokin)/) && $target.attr("id").match(/(?!TabHijokin)/)) {
			$('html,body').animate({scrollTop: targetY},'600');
			event.preventDefault();
		}

	});
	$('#footer div.linkbox dl:last-child,#footer div.linkbox dl dd ul li:last-child,#footer ul.navigation li:last-child,#header ul.navigation-sub li:last-child').addClass('last-child');

	function menuShowHide(){
		if(menuFocus==true){
			clearInterval(menuTimer);
			if(swapNav==true){
				openImg.attr("src",openImg_src.replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"));
			}
			$('#header ul.navigation-sub').slideDown(200);
		}else{
			menuTimer = setInterval(function(){
				if(menuFocus==false){
					clearInterval(menuTimer);
					$('#header ul.navigation-sub').slideUp(200,function(){
						if(swapNav==true){
							openImg.attr("src",openImg_src.replace(/^(.+)_on(\.[a-z]+)$/, "$1_off$2"));
						}
					});
				}
			},200);
		}
	}
	$('#header ul.navigation li.area-navigation').mouseover(function() {
		menuFocus = true;
		menuShowHide();
	}).mouseout(function(){
		menuFocus = false;
		menuShowHide();
	});
	var menuFocus = false;
	var openImg = $('#header ul.navigation li.area-navigation img.open-navigation');
	var openImg_src = openImg.attr("src");
	var swapNav = false;
	$('#header ul.navigation li.area-navigation img.open-navigation[src*=_off.]').each(function(){
		swapNav = true;
	});
	menuShowHide();



	function initRollovers(tag) {
		tag.mouseover(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"));
		}).mouseout(function(){
			$(this).attr("src",$(this).attr("src").replace(/^(.+)_on(\.[a-z]+)$/, "$1_off$2"));
		}).each(function(){
			$("<img>").attr("src",$(this).attr("src").replace(/^(.+)_off(\.[a-z]+)$/, "$1_on$2"));
		});
	}
	initRollovers($("img[src*=_off.]"));
	initRollovers($("input[src*=_off.]"));

	$('#bodyContent .section:last-child,#stackContent .section:last-child').addClass('last-section');
	$('a.lightbox').lightBox();
});
