/*******************************************************************************

 画面別スクリプト

 画面名 : 物件問い合わせ／入力.html

 @auther kawamata@team-lab

 *******************************************************************************/

Event.observe(window, 'load', function(){


//	遷移先URLの定義
//	----------------------------------------------

	var uBtnConfirm = confirmProc;


//	名前属性の定義
//	----------------------------------------------
	var n0111 = 'keiyaku';


//	エレメントの定義
//	----------------------------------------------

	var eBtnConfirm = $("btn_confirm");

	var eForm = $("inquiry-form");

	var e010101 = $('e010101');
	var e010102 = $('e010102');
	var e010103 = $('e010103');
	var e010106 = $('e010106');
	var e010107 = $('e010107');
	var e010201 = $('e010201');
	var e010301 = $('e010301');
	var e010701 = $('e010701');
	var e010801 = $('e010801');
	var e010901 = $('e010901');
//	var e011001 = $('e011001');
	var e011101 = $('e011101');
	var e011102 = $('e011102');
	var e011103 = $('e011103');


//	バリデーションマネージャの設定
//	----------------------------------------------
	var vManager = new Leopalace.Validator.Manager(eForm, {
		moveOnError : true
	});


//	バリデーショングループの設定
//	----------------------------------------------
	var g0101 = new Leopalace.Validator.BasicGroupB(vManager, { chip : "g0101" });
	var g0102 = new Leopalace.Validator.BasicGroupA(vManager, { chip : "g0102" });
	var g0103 = new Leopalace.Validator.BasicGroupA(vManager, { chip : "g0103" });
	var g0107 = new Leopalace.Validator.BasicGroupA(vManager, { chip : "g0107" });
	var g0108 = new Leopalace.Validator.BasicGroupA(vManager, { chip : "g0108" });
	var g0109 = new Leopalace.Validator.BasicGroupA(vManager, { chip : "g0109" });
//	var g0110 = new Leopalace.Validator.BasicGroupB(vManager, { chip : "g0110" });
	var g0111 = new Leopalace.Validator.BasicGroupB(vManager, { chip : "g0111" });


//	バリデーションの設定
//	----------------------------------------------

	new Leopalace.Validator.MaxlengthTextChecker    (g0101, { target : e010107, length : 240 });

	new Leopalace.Validator.RequiredTextChecker     (g0102, { target : e010201 });
	new Leopalace.Validator.MaxlengthTextChecker    (g0102, { target : e010201, length : 13 });

	new Leopalace.Validator.RequiredTextChecker     (g0103, { target : e010301 });
	new Leopalace.Validator.MaxlengthTextChecker    (g0103, { target : e010301, length : 13 });

	new Leopalace.Validator.RequiredAnyChecker      (g0107, { list   : [e010701, e010801] });
	new Leopalace.Validator.MaxlengthTextChecker    (g0107, { target : e010701, length : 100 });
	new Leopalace.Validator.MailAddressTextChecker  (g0107, { target : e010701 });

	new Leopalace.Validator.RequiredAnyChecker      (g0108, { list   : [e010701, e010801] });
	new Leopalace.Validator.MaxlengthTextChecker    (g0108, { target : e010801, length : 13 });
	new Leopalace.Validator.TelnumberTextChecker    (g0108, { target : e010801 });

	new Leopalace.Validator.RequiredTextChecker     (g0109, { target : e010901 });


//	new Leopalace.Validator.MaxlengthTextChecker    (g0110, { target : e011001, length : 13 });
//	new Leopalace.Validator.TelnumberTextChecker    (g0110, { target : e011001 });

	new Leopalace.Validator.CheckboxRequiredChecker (g0111, { name   : n0111 });
	new Leopalace.Validator.RequiredAnyChecker      (g0111, { list : [e011101,e011103] });



//	初期化トリガーの設定
//	----------------------------------------------
	Leopalace.Validator.InitTrigger.attachFocus  ($A([e010107                  ]), g0101);
	Leopalace.Validator.InitTrigger.attachFocus  ($A([e010201                  ]), g0102);
	Leopalace.Validator.InitTrigger.attachFocus  ($A([e010301                  ]), g0103);
	Leopalace.Validator.InitTrigger.attachFocus  ($A([e010701                  ]), g0107);
	Leopalace.Validator.InitTrigger.attachFocus  ($A([e010801                  ]), g0108);
	Leopalace.Validator.InitTrigger.attachFocus  ($A([e010901                  ]), g0109);
//	Leopalace.Validator.InitTrigger.attachFocus  ($A([e011001                  ]), g0110);
	Leopalace.Validator.InitTrigger.attachFocus  ($A([e011103                  ]), g0111);


//	チェックトリガーの設定
//	----------------------------------------------
	Leopalace.Validator.CheckTrigger.attachBlur   ($A([e010107                  ]), g0101);
	Leopalace.Validator.CheckTrigger.attachBlur   ($A([e010201                  ]), g0102);
	Leopalace.Validator.CheckTrigger.attachBlur   ($A([e010301                  ]), g0103);
	Leopalace.Validator.CheckTrigger.attachBlur   ($A([e010701                  ]), g0107);
	Leopalace.Validator.CheckTrigger.attachBlur   ($A([e010801                  ]), g0108);
	Leopalace.Validator.CheckTrigger.attachBlur   ($A([e010901                  ]), g0109);
//	Leopalace.Validator.CheckTrigger.attachBlur   ($A([e011001                  ]), g0110);
	Leopalace.Validator.CheckTrigger.attachOnClick($A([e011101, e011102         ]), g0111);
	Leopalace.Validator.CheckTrigger.attachChange ($A([e011103                  ]), g0111);

	if($('e011201')!=null){//マンスリーにしかない項目を定義、マンスリー用のトリガー設定
		var e011201 = $('e011201');
		// バリデーショングループの設定
		var g0112 = new Leopalace.Validator.BasicGroupB(vManager, { chip : "g0112" });
		// バリデーションの設定
		new Leopalace.Validator.RequiredAnyChecker      (g0112, { list   : [e011201 ] });
		new Leopalace.Validator.RequiredAnyChecker      (g0101, { list   : [e010101, e010102, e010103, e010106] });
		// 初期化トリガーの設定
		Leopalace.Validator.InitTrigger.attachFocus  ($A([e011201                  ]), g0112);
		// チェックトリガーの設定
		Leopalace.Validator.CheckTrigger.attachChange ($A([e011201                  ]), g0112);
		Leopalace.Validator.CheckTrigger.attachOnClick($A([e010101,e010102,e010103,e010106]), g0101);

		//バリデーショントリガーの設定
		//----------------------------------------------
		Leopalace.Validator.ValidationTrigger.attachKeypress($A([
		                                                         //e010107,
		                                                         e010201,
		                                                         e010301,
		                                                         e010701,
		                                                         e010801,
		                                                         e010901,
		                                                         //e011001,
		                                                         e011101,
		                                                         e011201
		                                                         ]), vManager, uBtnConfirm);
		Leopalace.Validator.ValidationTrigger.attachClick($A([eBtnConfirm]), vManager, uBtnConfirm);

		Leopalace.GUIRadio.create("on", "off", {
			"r010101" : "e010101",
			"r010102" : "e010102",
			"r010103" : "e010103",
			"r010106" : "e010106"
		});
	}else{//賃貸にしかない項目を定義、賃貸用のトリガー設定

		var e010104 = $('e010104');
		var e010105 = $('e010105');

//		バリデーションの設定
		new Leopalace.Validator.RequiredAnyChecker      (g0101, { list   : [e010101, e010102, e010103, e010104, e010105, e010106] });
//		チェックトリガーの設定
		Leopalace.Validator.CheckTrigger.attachOnClick($A([e010101,e010102,e010103,e010104,e010105,e010106]), g0101);
		//
		// バリデーショントリガーの設定
		// ----------------------------------------------
		Leopalace.Validator.ValidationTrigger.attachKeypress($A([
		                                                         //e010107,
		                                                         e010201,
		                                                         e010301,
		                                                         e010701,
		                                                         e010801,
		                                                         e010901,
		                                                         //e011001,
		                                                         e011101
		                                                         ]), vManager, uBtnConfirm);
		Leopalace.Validator.ValidationTrigger.attachClick($A([eBtnConfirm]), vManager, uBtnConfirm);

		Leopalace.GUIRadio.create("on", "off", {
			"r010101" : "e010101",
			"r010102" : "e010102",
			"r010103" : "e010103",
			"r010104" : "e010104",
			"r010105" : "e010105",
			"r010106" : "e010106"
		});
	}


	Leopalace.GUIRadio.create("on", "off", {
		"r011101" : "e011101",
		"r011102" : "e011102"
	});

});

