$(function(){	
	var cache = new Object();
	$("a img[src*='_off.'],input[src*='_off.']").each(function () {
		var offimgs = $(this).attr("src");
		var onimgs = offimgs.replace('_off.','_on.');
		cache[this.src] = new Image();
		cache[this.src].src = onimgs;
		$(this).hover(function () { this.src = onimgs; }, function () { this.src = offimgs; });
	});
	
	$("div.navi>ul>li>a img","#HEADER").parent("a").each(function (){
		$(this).css("background","url("+$("img",this).attr("src").replace(".gif", "_onbg.gif")+") no-repeat left top");
	});
	$("div.navi>ul>li","#HEADER").hover(function(){
		$(this).addClass("hover");
		$("ul:first",this).css("visibility", "visible");
	}, function(){
		$(this).removeClass("hover");
		$("ul:first",this).css("visibility", "hidden");
	});
	
	var searchvalue = 'サイト内検索 　';
	var searchword = 'input#q_head';
	$(searchword).val(searchvalue).focus(function(){
		$(this).css("color","#333333");
		if($(this).val()==searchvalue) $(this).val("");
	}).blur(function(){
		if($(this).val()=="") {
			$(this).css("color","#999999");
			$(this).val(searchvalue);
		}
	});
	$("form#SEARCH").submit(function() {
		if($(searchword).val()!=searchvalue && $(searchword).val()!="") return true;
		else return false;
	});
	
	if ($.browser.msie&&$.browser.version<8) {
		$("#HEADER div.navi>ul>li li:first-child,#CONTENTS #MENU #CATEGORY>ul>li:first-child,#TOPCONTENTS #INFORMATION>ul>li>dl>dt:first-child,#TOPCONTENTS #INFORMATION ul ul>li:first-child,#CONTENTS #MAIN ul.dotline>li:first-child,#CONTENTS #MAIN dl.dotline>dt:first-child,#CONTENTS #MAIN .anchor>ul>li:first-child,#CONTENTS #MAIN .catnavi>ul>li:first-child").addClass("first");
	}
	
	if ($.browser.msie) $("body").attr("id","CONTENTSIE");
	
	$("#CONTENTS #MAIN dl.dotlines>dt").first().addClass("first");
	$("#CONTENTS #MAIN dl.dotlines>dd").first().addClass("first");
	$("#INQUIRY #CONTENTS #MAIN .form dl>dt").first().addClass("first");
	$("#INQUIRY #CONTENTS #MAIN .form dl>dd").first().addClass("first");
	$("#TOPCONTENTS #INFORMATION>ul>li>dl>dd:not(:has('a'))").addClass("nolink");

	$("#MAIN div.parts","#CONTENTS").each(function(){
		$("h5",this).flatHeightsCols(3);
		$("p.flat",this).flatHeightsCols(3);
		$("div.flat",this).flatHeightsCols(3);
	});

	$("#CONTENTS > div.list > ul").each(function(){
		$("> li",this).flatHeightsCols(2);
	});

	$("#CONTENTS #SITEMAP > li").each(function(){
		$("> ul > li",this).flatHeightsCols(2);
	});
	
	$("#CONTENTS a.inqform").click(function(){
		window.open(this.href, "recruit"+$("#CONTENTS a.inqform").index(this), 'width=725, height=760, menubar=no, toolbar=no, scrollbars=yes, resizable=yes');
		return false;
	});

});

var mdhw='<link rel="stylesheet" href="/common/css/script.css" type="text/css" media="screen, projection, print">';
if(navigator.userAgent.indexOf("Mac")!=-1) mdhw+='<link rel="stylesheet" href="/common/css/mac.css" type="text/css" media="screen, projection, print">';
document.write(mdhw);

function setStyle(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
		  a.disabled = true;
		  if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

function getStyle() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}

function getPStyle() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1
			&& a.getAttribute("rel").indexOf("alt") == -1
			&& a.getAttribute("title")
			) return a.getAttribute("title");
	}
	return null;
}

function putCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

window.onload = function(e) {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPStyle();
	setStyle(title);
}

window.onunload = function(e) {
	var title = getStyle();
	putCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPStyle();
setStyle(title);

try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

