var ua = navigator.userAgent;											// ユーザーエージェント
var nHit = ua.indexOf("MSIE");											// 合致した部分の先頭文字の添え字
var bIE = (nHit >=  0);													// IE かどうか
var bVer6 = (bIE && ua.substr(nHit+5, 1) == "6");						// バージョンが 6 かどうか
var bVer7 = (bIE && ua.substr(nHit+5, 1) == "7");						// バージョンが 7 かどうか
var bVer8 = (bIE && ua.substr(nHit+5, 1) == "8");						// バージョンが 8 かどうか
var bStd = (document.compatMode && document.compatMode=="CSS1Compat");	// 標準モードかどうか
var loc = location.href;
var protocol = loc.substr(0, loc.indexOf(':'));
var domain = loc.substr(loc.indexOf(':')+3, loc.substr(protocol.length+3, loc.length).indexOf('/'));
var root="/new/";
domain = protocol + '://' + domain;

function init(){
	if(bVer6 || bVer7){
		$(".menu1img").click( function(){ document.location = $(".menu1 > a").attr("href"); });
		$(".menu2img").click( function(){ document.location = $(".menu2 > a").attr("href"); });
		$(".menu3img").click( function(){ document.location = $(".menu3 > a").attr("href"); });
		$(".menu4img").click( function(){ document.location = $(".menu4 > a").attr("href"); });
		$(".menu5img").click( function(){ document.location = $(".menu5 > a").attr("href"); });
		$(".menu6img").click( function(){ document.location = $(".menu6 > a").attr("href"); });
	}
	if($("#formedical").size()>0){
		if($("#btn_yes") && $("#btn_no")){
			$("#btn_yes").click( function(){ $('#medical').val('yes'); });
			$("#btn_no").click( function(){ $('#medical').val('no'); });
		}
	}
	if($("#recruit_inquiry_form").size()>0){
			$("#btn_reset").click( function(){ inquiryReset(); });
			$("#btn_confirm").click( function(){ if(recruit_inquiryCheck()){ formStatus("confirm"); }; });
			$("#btn_back").click( function(){ inquiryBack(); });
			$("#btn_send").click( function(){ $("#recruit_inquiry_form").submit(); });
			formStatus("normal");
	}
	if($("#inquiry_form").size()>0){
			$("#btn_reset").click( function(){ inquiryReset(); });
			$("#btn_confirm").click( function(){ if(inquiryCheck()){ formStatus("confirm"); }; });
			$("#btn_back").click( function(){ inquiryBack(); });
			$("#btn_send").click( function(){ $("#inquiry_form").submit(); });
			formStatus("normal");
	}
	if($("#news").size()>0 || $("#news1").size()>0){
		if (getCookie("news")=="1"){
			$('#accordion01 ul.list').css('display','none');
			var handler = $('#accordion01 div.list-h'),
			menus = $('#accordion01 ul.list');
			var bgpos = '5px 4px';
			$(handler).css( { backgroundImage:'url(../assets/images/leader1.gif)',backgroundPosition:bgpos,backgroundRepeat:'no-repeat' } );
			var _thisMenu = $(handler).next();
			menus.slideUp();
			_thisMenu.slideDown();
			$(handler).css( { backgroundImage:'url(../assets/images/leader2.gif)',backgroundPosition:bgpos,backgroundRepeat:'no-repeat' } );
		}
	}
	$("button").focus( function(){ "this.blur();" });
}

function inquiryReset(){
	errmsg("", 0);
	//if ($("#matter1").size()>0)         { $("#matter1").css({backgroundColor:""}); }
	//if ($("#matter2").size()>0)         { $("#matter2").css({backgroundColor:""}); }
	if ($("#sei").size()>0)          { $("#sei").css({backgroundColor:""}); }
	if ($("#mei").size()>0)          { $("#mei").css({backgroundColor:""}); }
	if ($("#sei_kana").size()>0)     { $("#sei_kana").css({backgroundColor:""}); }
	if ($("#mei_kana").size()>0)     { $("#mei_kana").css({backgroundColor:""}); }
	//if ($("#sex1").size()>0)         { $("#sex1").css({backgroundColor:""}); }
	//if ($("#sex2").size()>0)         { $("#sex2").css({backgroundColor:""}); }
	if ($("#birth_year").size()>0)   { $("#birth_year").css({backgroundColor:""}); }
	if ($("#birth_month").size()>0)  { $("#birth_month").css({backgroundColor:""}); }
	if ($("#birth_day").size()>0)    { $("#birth_day").css({backgroundColor:""}); }
	if ($("#email").size()>0)        { $("#email").css({backgroundColor:""}); }
	if ($("#email_check1").size()>0) { $("#email_check1").css({backgroundColor:""}); }
	if ($("#email_check2").size()>0) { $("#email_check2").css({backgroundColor:""}); }
	if ($("#belong").size()>0)       { $("#belong").css({backgroundColor:""}); }
	if ($("#zip").size()>0)          { $("#zip").css({backgroundColor:""}); }
	if ($("#prefecture").size()>0)   { $("#prefecture").css({backgroundColor:""}); }
	if ($("#address").size()>0)      { $("#address").css({backgroundColor:""}); }
	if ($("#tel").size()>0)          { $("#tel").css({backgroundColor:""}); }
	if ($("#contentstext").size()>0) { $("#contentstext").css({backgroundColor:""}); }
}
function inquiryBack(){
	// console.log("戻るボタンが押された");
	formStatus("normal");
}

function formStatus(s){
	// 入力と確認の切り替え;
	if (s=="normal"){
		$("#buttons_normal").css({display:"block"});
		$("#buttons_confirm").css({display:"none"});
		$("#msg").css({display:"block",color:""});
		putmsg("", 0);
	}else if(s=="confirm"){
		$("#buttons_normal").css({display:"none"});
		$("#buttons_confirm").css({display:"block"});
		$("#msg").css({display:"block",color:"rgb(0,0,240)"})
		putmsg("以下の内容で送信します。<br />よろしければ、送信ボタンを押してください。<br />", 0);
	}
	for(i=1; i<15; i++){
		if (s=="normal"){
			if ($("#input"+i).size()>0)  { $("#input"+i).css({display:"block"}); }
			if ($("#confirm"+i).size()>0){ $("#confirm"+i).css({display:"none"}); }
		}else if(s=="confirm"){
			if ($("#input"+i).size()>0)  { $("#input"+i).css({display:"none"}); }
			if ($("#confirm"+i).size()>0){ $("#confirm"+i).css({display:"block"}); }
		}
	}
}

function inquiryCheck(){
	// お問い合わせ入力チェック
	var ret = true;
	
	inquiryReset();
	
	//-- お問い合わせ内容
	if (!checkRadio("matter") ){ 
		errmsg("お問い合わせ内容：必須項目です<br />");
		$("matter1").css({backgroundColor:"rgb(255,240,240)"});
		$("matter2").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else{
		putHtml("confirm1", $('input[name="matter"]:checked').val() );
	}
	//-- 氏名（漢字）
	if (!checkInput("sei") && !checkInput("mei") ){ 
		errmsg("氏名（漢字）：必須項目です<br />");
		$("sei").css({backgroundColor:"rgb(255,240,240)"});
		$("mei").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else{
		$('input[name="sei"]').val( hantozen_kana( $('input[name="sei"]').val() ) );
		$('input[name="mei"]').val( hantozen_kana( $('input[name="mei"]').val() ) );
		putHtml("confirm2", $('input[name="sei"]').val()+' '+$('input[name="mei"]').val() );
	}
	//-- 氏名（カナ）
	$('input[name="sei_kana"]').val( hantozen_kana( $('input[name="sei_kana"]').val() ) );
	$('input[name="mei_kana"]').val( hantozen_kana( $('input[name="mei_kana"]').val() ) );
	if (!checkInput("sei_kana") && !checkInput("mei_kana") ){ 
		errmsg("氏名（カナ）：必須項目です<br />");
		$("sei_kana").css({backgroundColor:"rgb(255,240,240)"});
		$("mei_kana").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else if (!patternCheck("sei_kana")){
		ret = false;
	}else {
		putHtml("confirm3", $('input[name="sei_kana"]').val()+' '+$('input[name="mei_kana"]').val() );
	}
	//-- メールアドレス
	$('input[name="email"]').val( zentohan( $('input[name="email"]').val() ) );
	$('input[name="email_check1"]').val( zentohan( $('input[name="email_check1"]').val() ) );
	$('input[name="email_check2"]').val( zentohan( $('input[name="email_check2"]').val() ) );
	if (!checkInput("email")){ 
		errmsg("メールアドレス：必須項目です<br />");
		$("email").css({backgroundColor:"rgb(255,240,240)"});
		ret = false;
	} else if(!checkInput("email_check1") || !checkInput("email_check2") ){
		errmsg("メールアドレス（確認用）：入力してください<br />");
		$("email_check1").css({backgroundColor:"rgb(255,240,240)"});
		$("email_check2").css({backgroundColor:"rgb(255,240,240)"});
		ret = false;
	}else if (!patternCheck("email")){
		ret = false;
	}else {
		putHtml("confirm4", $('input[name="email"]').val() );
		putHtml("confirm5", "**********" );
	}
	
	//-- 職業
	//checkInput("occupation");
	$('input[name="occupation"]').val( hantozen_kana( $('input[name="occupation"]').val() ) );
	putHtml("confirm6", $('input[name="occupation"]').val() );
	//-- 施設名/会社名
	if (!checkInput("belong") ){ 
		errmsg("施設名/会社名：必須項目です<br />");
		$("belong").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else {
		$('input[name="belong"]').val( hantozen_kana( $('input[name="belong"]').val() ) );
		putHtml("confirm7", $('input[name="belong"]').val() );
	}
	//-- 都道府県
	//checkSelect("prefecture");
	putHtml("confirm8", $('select[name="prefecture"]').val() );
	//-- ご意見ご質問
	if (!checkTextarea("contentstext")){
		errmsg("ご意見ご質問：必須項目です<br />");
		$("contentstext").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else {
		$('textarea[name="contentstext"]').val( hantozen_kana( $('textarea[name="contentstext"]').val() ) );
		//$("#confirm9").html( $('textarea[name="contentstext"]').val().replace(/\n/g, '<br />') );
		putHtml("confirm9", $('textarea[name="contentstext"]').val() );
	}
	return ret;
}
function recruit_inquiryCheck(){
	// お問い合わせ（採用情報）入力チェック
	var ret = true;
	
	inquiryReset();
	
	//-- 氏名（漢字）
	if (!checkInput("sei") && !checkInput("mei") ){ 
		errmsg("氏名（漢字）：必須項目です<br />");
		$("sei").css({backgroundColor:"rgb(255,240,240)"});
		$("mei").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else{
		$('input[name="sei"]').val( hantozen_kana( $('input[name="sei"]').val() ) );
		$('input[name="mei"]').val( hantozen_kana( $('input[name="mei"]').val() ) );
		putHtml("confirm1", $('input[name="sei"]').val()+'　'+$('input[name="mei"]').val() );
	}
	//-- 氏名（カナ）
	$('input[name="sei_kana"]').val( hantozen_kana( $('input[name="sei_kana"]').val() ) );
	$('input[name="mei_kana"]').val( hantozen_kana( $('input[name="mei_kana"]').val() ) );
	if (!checkInput("sei_kana") && !checkInput("mei_kana") ){ 
		errmsg("氏名（カナ）：必須項目です<br />");
		$("sei_kana").css({backgroundColor:"rgb(255,240,240)"});
		$("mei_kana").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else if (!patternCheck("sei_kana")){
		ret = false;
	}else{
		putHtml("confirm2", $('input[name="sei_kana"]').val()+'　'+$('input[name="mei_kana"]').val() );
	}
	//-- 性別
	if (!checkRadio("sex") ){ 
		errmsg("性別：必須項目です<br />");
		$("sex1").css({backgroundColor:"rgb(255,240,240)"});
		$("sex2").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else{
		putHtml("confirm3", $('input[name="sex"]:checked').val() );
	}
	//-- 生年月日
	if (!checkSelect("birth_year") || !checkSelect("birth_month") || !checkSelect("birth_day")){ 
		errmsg("生年月日：必須項目です<br />");
		$("birth_year").css({backgroundColor:"rgb(255,240,240)"});
		$("birth_month").css({backgroundColor:"rgb(255,240,240)"});
		$("birth_day").css({backgroundColor:"rgb(255,240,240)"});
		ret = false; 
	}else{
		putHtml("confirm4", $('select[name="birth_year"]').val()+'年'+$('select[name="birth_month"]').val()+'月'+$('select[name="birth_day"]').val()+'日' );
	}
	//-- メールアドレス
	$('input[name="email"]').val( zentohan( $('input[name="email"]').val() ) );
	$('input[name="email_check1"]').val( zentohan( $('input[name="email_check1"]').val() ) );
	$('input[name="email_check2"]').val( zentohan( $('input[name="email_check2"]').val() ) );
	if (!checkInput("email")){ 
		errmsg("メールアドレス：必須項目です<br />");
		$("email").css({backgroundColor:"rgb(255,240,240)"});
		ret = false;
	}else if (!patternCheck("email")){
		ret = false;
	}else{
		putHtml("confirm5", $('input[name="email"]').val() );
		putHtml("confirm6", "**********" );
	}
	//-- 職業
	//checkInput("occupation");
	$('input[name="occupation"]').val( hantozen_kana( $('input[name="occupation"]').val() ) );
	putHtml("confirm7", $('input[name="occupation"]').val() );
	//-- 会社名／学校名
	//checkInput("belong");
	$('input[name="belong"]').val( hantozen_kana( $('input[name="belong"]').val() ) );
	putHtml("confirm8", $('input[name="belong"]').val() );
	//-- 郵便番号
	$('input[name="zip"]').val( zentohan( $('input[name="zip"]').val() ) );
	if (!checkInput("zip")){
		errmsg("郵便番号：必須項目です<br />");
		$("zip").css({backgroundColor:"rgb(255,240,240)"});
		ret = false;
	}else if (!patternCheck("zip")){
		ret = false;
	}else{
		putHtml("confirm9", $('input[name="zip"]').val() );
	}
	//-- 都道府県
	if (!checkSelect("prefecture")){
		errmsg("都道府県：必須項目です<br />");
		$("prefecture").css({backgroundColor:"rgb(255,240,240)"});
		ret = false;
	}else{
		putHtml("confirm10", $('select[name="prefecture"]').val() );
	}
	//-- 市区群町番地
	if (!checkInput("address")){
		errmsg("市区群町番地：必須項目です<br />");
		$("address").css({backgroundColor:"rgb(255,240,240)"});
		ret = false;
	}else{
		$('input[name="address"]').val( hantozen_kana( $('input[name="address"]').val() ) );
		putHtml("confirm11", $('input[name="address"]').val() );
	}
	//-- 建物名・部屋番号
	//checkInput("building");
	$('input[name="building"]').val( hantozen_kana( $('input[name="building"]').val() ) );
	putHtml("confirm12", $('input[name="building"]').val() );
	//-- 電話番号
	$('input[name="tel"]').val( zentohan( $('input[name="tel"]').val() ) );
	if (!checkInput("tel")){
		errmsg("電話番号：必須項目です<br />");
		$("tel").css({backgroundColor:"rgb(255,240,240)"});
		ret = false;
	}else if (!patternCheck("tel")){
		ret = false;
	}else if (!patternCheck("tel")){
		ret = false;
	}else{
		putHtml("confirm13", $('input[name="tel"]').val() );
	}
	//-- お問い合わせ内容
	if (!checkTextarea("contentstext")){
		errmsg("お問い合わせ内容：必須項目です<br />");
		$("contentstext").css({backgroundColor:"rgb(255,240,240)"});
		ret = false;
	}else {
		$('textarea[name="contentstext"]').val( hantozen_kana( $('textarea[name="contentstext"]').val() ) );
		//$("#confirm14").html( $('textarea[name="contentstext"]').val().replace(/\n/g, '<br />') );
		putHtml("confirm14", $('textarea[name="contentstext"]').val() );
	}
	return ret;
}

function putHtml(sid, s){
	$("#"+sid).html( htmlEscape(s).replace(/\n/g, '<br />') );
}

function htmlEscape(s){
  s = s.replace(/&/g, '&amp;');
  s = s.replace(/</g, '&lt;');
  s = s.replace(/>/g, '&gt;');
  s = s.replace(/\n/g, '<br />');
  return s;
}

//var xxhtmlEscape = (function(){
//  var map = {"<":"&lt;", ">":"&gt;", "&":"&amp;", "'":"&#39;", "\"":"&quot;", " ":"&nbsp;"};
//  var replaceStr = function(s){ return map[s]; };
//  return function(str) { return str.replace(/<|>|&|'|"|\s/g, replaceStr); };
//})();

function patternCheck(sid){
	var ret = true;
	if(sid == "zip"){
		if ($("#zip").size()>0){
			e = $("#zip");
			if (!checkZip(e.val())){
				errmsg("郵便番号：ハイフンを入れて正しく入力してください<br />");
				e.css({backgroundColor:"rgb(255,240,240)"});
				ret = false;
			}
		}
	}else if(sid == "tel"){
		if ($("#tel").size()>0){
			e = $("#tel");
			if (!checkTel(e.val())){
				errmsg("電話番号：ハイフンを入れて正しく入力してください<br />");
				e.css({backgroundColor:"rgb(255,240,240)"});
				ret = false;
			}
		}
	}else if(sid == "sei_kana"){
		if ($("#sei_kana").size()>0){
			e1 = $("#sei_kana");
			e2 = $("#mei_kana");
			if (!checkZenkakuKatakana(e1.val()+e2.val())){
				errmsg("氏名（カナ）：全角カタカナで入力してください<br />");
				e1.css({backgroundColor:"rgb(255,240,240)"});
				e2.css({backgroundColor:"rgb(255,240,240)"});
				ret = false;
			}
		}
	}else if(sid == "email"){
		if ($("#email").size()>0){
			e = $("#email");
			if (!checkEmail(e.val())){
				errmsg("メールアドレス：メールアドレスを正しく入力してください<br />");
				e.css({backgroundColor:"rgb(255,240,240)"});
				ret = false;
			} else if(!checkInput("email_check1") || !checkInput("email_check2") ){
				errmsg("メールアドレス（確認用）：入力してください<br />");
				$("email_check1").css({backgroundColor:"rgb(255,240,240)"});
				$("email_check2").css({backgroundColor:"rgb(255,240,240)"});
				ret = false;
			}else if (!checkEmailConfirm( e.val(), $("#email_check1").val(), $("#email_check2").val() ) ){
				errmsg("メールアドレス（確認用）：メールアドレスが一致しません<br />");
				$("#email_check1").css({backgroundColor:"rgb(255,240,240)"});
				$("#email_check2").css({backgroundColor:"rgb(255,240,240)"});
				ret = false;
			}
		}
	}
	return ret;
}

function errmsg(s, new_or_add){
	//-- メッセージ出力 --
	//	0: 新規
	//	1: 追加
	//--------------------
	var msg = $("#msg").html();
	if (new_or_add == 0){
		msg = "";
	}
	$("#msg").css({display:"block",color:"rgb(255,0,0)"});
	msg = msg + s;
	$("#msg").html(msg);
}
function putmsg(s, new_or_add){
	//-- メッセージ出力 --
	//	0: 新規
	//	1: 追加
	//--------------------
	var msg = $("#msg").html();
	if (new_or_add == 0){
		msg = "";
	}
	msg = msg + s;
	$("#msg").html(msg);
}
function zentohan(s){
	//-- 全角半角変換 --
	if (s.length>0){
		var han= '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_-.,,:;+()-=#& ';
		var zen= '１２３４５６７８９０ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ＠＿－．，、：；＋（）ー＝＃＆　';
		for(i=0;i<zen.length;i++){
			if (bIE && (bVer7 || bVer6)){
				s = s.replaceAll(zen[i], han[i]);
			}else{
				var regex = new RegExp(zen[i],"gm");
				s = s.replace(regex, han[i]);
			}
		}
	}
	return s.trim();
}
function hantozen_kana(s){
	//-- 半角全角変換 --
	if (s.length>0){
		var han = new Array("ｶﾞ", "ｷﾞ", "ｸﾞ", "ｹﾞ", "ｺﾞ", "ｻﾞ", "ｼﾞ", "ｽﾞ", "ｾﾞ", "ｿﾞ", "ﾀﾞ", "ﾁﾞ", "ﾂﾞ", "ﾃﾞ", "ﾄﾞ", "ﾊﾞ", "ﾊﾟ", "ﾋﾞ", "ﾋﾟ", "ﾌﾞ", "ﾌﾟ", "ﾍﾞ", "ﾍﾟ", "ﾎﾞ", "ﾎﾟ", "ｳﾞ", "ｧ", "ｱ", "ｨ", "ｲ", "ｩ", "ｳ", "ｪ", "ｴ", "ｫ", "ｵ", "ｶ", "ｷ", "ｸ", "ｹ", "ｺ", "ｻ", "ｼ", "ｽ", "ｾ", "ｿ", "ﾀ", "ﾁ", "ｯ", "ﾂ", "ﾃ", "ﾄ", "ﾅ", "ﾆ", "ﾇ", "ﾈ", "ﾉ", "ﾊ", "ﾋ", "ﾌ", "ﾍ", "ﾎ", "ﾏ", "ﾐ", "ﾑ", "ﾒ", "ﾓ", "ｬ", "ﾔ", "ｭ", "ﾕ", "ｮ", "ﾖ", "ﾗ", "ﾘ", "ﾙ", "ﾚ", "ﾛ", "ﾜ", "ｦ", "ﾝ", "｡", "｢", "｣", "､", "･", "ｰ", "ﾞ", "ﾟ");
		var zen  = new Array("ガ", "ギ", "グ", "ゲ", "ゴ", "ザ", "ジ", "ズ", "ゼ", "ゾ", "ダ", "ヂ", "ヅ", "デ", "ド", "バ", "パ", "ビ", "ピ", "ブ", "プ", "ベ", "ペ", "ボ", "ポ", "ヴ", "ァ", "ア", "ィ", "イ", "ゥ", "ウ", "ェ", "エ", "ォ", "オ", "カ", "キ", "ク", "ケ", "コ", "サ", "シ", "ス", "セ", "ソ", "タ", "チ", "ッ", "ツ", "テ", "ト", "ナ", "ニ", "ヌ", "ネ", "ノ", "ハ", "ヒ", "フ", "ヘ", "ホ", "マ", "ミ", "ム", "メ", "モ", "ャ", "ヤ", "ュ", "ユ", "ョ", "ヨ", "ラ", "リ", "ル", "レ", "ロ", "ワ", "ヲ", "ン", "。", "「", "」", "、", "・", "ー", "゛", "゜");
		for (i=0; i<=zen.length; i++) { //89文字あるのでその分だけ繰り返す
			s = s.replaceAll(han[i], zen[i]);
		}
	}
	return s.trim();
}
String.prototype.replaceAll = function (org, dest){  
	return this.split(org).join(dest);  
}  
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, "");
}
function checkZip(s){
	//-- 郵便番号のチェック --
	return s.match(/^\S+\-\S/);
}
function checkTel(s){
	//-- 電話番号のチェック --
	return s.match(/^\S+\-\S+\-\S+$/);
}
function checkNumber(s){
	//-- 数字のチェック --
	return s.match(/^[0-9]+$/);
}
function checkAlph(s){
	//-- 英字のチェック --
	return s.match(/^[a-zA-Z]+$/);
}
function checkZenkakuHiragana(s){
	//-- 全角ひらがなのチェック --
	return s.match(/^[¥u3041-¥u3093]+$/);
}
function checkZenkakuKatakana(s){
	//-- 全角カタカナのチェック --
	return s.match(/^[\u30A0-\u30FF]+$/);
}
function checkAscii(s){
	//-- アスキー文字（制御記号除く）のチェック --
	return s.match(/^[¥x20-¥x7E]+$/);
}
function checkEmail(s){
	//-- メールアドレスのチェック --
	return s.match(/^\S+@\S+\.\S+$/);
}
function checkEmailConfirm(s, c1, c2){
	//-- メールアドレス（確認用）とのチェック --
	var chk_mail = c1+'@'+c2;
	return (s==chk_mail)
}
function checkRadio(fld){
	//ラジオボックスのチェック
	var ret = true;
	if($('input[name="'+fld+'"]:checked').val()==undefined){
		ret = false;
	}
	return ret;
}
function checkInput(fld){
	//inputのチェック
	var ret = true;
	if($('input[name="'+fld+'"]').val()==''){
		ret = false;
	}
	return ret;
}
function checkTextarea(fld){
	//teatareaのチェック
	var ret = true;
	if($('textarea[name="'+fld+'"]').val()==''){
		ret = false;
	}
	return ret;
}
function checkSelect(fld){
	//selectのチェック
	var ret = true;
	if($('select[name="'+fld+'"]').val()==''){
		ret = false;
	}
	return ret;
}

jQuery(document).ready(function() {
});

$(function(){
	if ($('#accordion01').size()>0){
		$('#accordion01 ul.list').css('display','none');
		
		var handler = $('#accordion01 div.list-h'),
		menus = $('#accordion01 ul.list');
		var bgpos = '5px 4px';
		$(handler).css( { backgroundImage:'url(../assets/images/leader1.gif)',backgroundPosition:bgpos,backgroundRepeat:'no-repeat' } );
		handler.click(function(){
			var _thisMenu = $(this).next();
			if(_thisMenu.is(':visible')){
				_thisMenu.show();
				_thisMenu.slideUp();
				menus.slideUp();
				$(this).css( { backgroundImage:'url(../assets/images/leader1.gif)',backgroundPosition:bgpos,backgroundRepeat:'no-repeat' } );
				setCookie("news", "0");
			} else {
				menus.slideUp();
				_thisMenu.slideDown();
				$(this).css( { backgroundImage:'url(../assets/images/leader2.gif)',backgroundPosition:bgpos,backgroundRepeat:'no-repeat' } );
				setCookie("news", "1");
			}
		});
	}
});

//*-- onload --*//
if(window.addEventListener){
	window.addEventListener("load", init, false);
}else if(window.attachEvent){
	window.attachEvent("onload", init);
}

function smoothScrolling() {
	var target = $.support.boxModel ?
			/Opera/.test(navigator.appName) ? 'html' : 'html, body'
			: 'body';
				
	$(target).animate({
		scrollTop: 0,
		scrollLeft: 0
	}, {
		duration: 500,
		queue: false
	});
}

function getCookie(key,  tmp1, tmp2, xx1, xx2, xx3) {
	tmp1 = " " + document.cookie + ";";
	xx1 = xx2 = 0;
	len = tmp1.length;
	while (xx1 < len) {
		xx2 = tmp1.indexOf(";", xx1);
		tmp2 = tmp1.substring(xx1 + 1, xx2);
		xx3 = tmp2.indexOf("=");
		if (tmp2.substring(0, xx3) == key) {
			return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
		}
		xx1 = xx2 + 1;
	}
	return("");
}
function setCookie(key, val, tmp) {
	tmp = key + "=" + escape(val) + "; ";
	// tmp += "path=" + location.pathname + "; ";
	// tmp += "expires=Tue, 31-Dec-2030 23:59:59; ";
	document.cookie = tmp;
}
function clearCookie(key) {
	document.cookie = key + "=" + "xx; expires=Tue, 1-Jan-1980 00:00:00;";
}

