var elementId,url,param,confirm_mess;

/*****************************************************************************/

function a_upd (elementId,url,param) {

//	$("loading").style.display  = "block";
//	$(elementId).innerHTML      = "";

//alert ("param " + param);

	var myAjax = new Ajax.Updater(
		elementId,
		url,
		{
			method:'post',
			parameters:param,
			requestHeaders: ['If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT'],
			onComplete: function(request) {
//				$("loading").style.display = "none";
			}
		}
	);

}

/*****************************************************************************/

function a_req (url,param,confirm_mess) {

//	$("loading").style.display = "block";
//	$(elementId).innerHTML     = "";

//alert ("param " + param);

	if (confirm_mess) {
		if (window.confirm(confirm_mess)) {
			var confirm_flg = true;
		} else {
			var confirm_flg = false;
		}
	} else {
		var confirm_flg = true;
	}

	if (confirm_flg) {
		var myAjax = new Ajax.Request(
			url,
			{
				method:'post',
				parameters:param,
				requestHeaders: ['If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT'],
				onComplete:function(request) {
//				$("loading").style.display = "none";
					var res = new Array();
					res = request.responseText.split("|");
					if (res[0]) {//OK
						alert(res[0]);
						if ($("name")) {
							$("name").value         = "";
						}
						if ($("corp_name")) {
							$("corp_name").value    = "";
						}
						if ($("tel")) {
							$("tel").value          = "";
						}
						if ($("post")) {
							$("post").value         = "";
						}
						if ($("addr")) {
							$("addr").value         = "";
						}
						if ($("mail1")) {
							$("mail1").value        = "";
						}
						if ($("mail2")) {
							$("mail2").value        = "";
						}
						if ($("mail2")) {
							$("form_content").value = "";
						}
						contact_scroll();
					} else {//NG
						alert(res[1]);
					}
				}
			}
		);
	}

}

/*****************************************************************************/

function a_req_get_addr (url,param) {

//	$("loading").style.display = "block";
//	$(elementId).innerHTML     = "";

//alert ("param " + param);

	if ($("post").value != "") {
		$("addr").style.backgroundImage = "url(/images/formLoading.gif)";
		$("addr").value = "住所情報検索中";

		var myAjax = new Ajax.Request(
			url,
			{
				method:'post',
				parameters:param,
				requestHeaders: ['If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT'],
				onComplete:function(request) {
					$("addr").style.backgroundImage = "none";
					$("addr").value = request.responseText;
				}
			}
		);
	} else {
		alert ("「-」ハイフン無しの郵便番号数字(半角)7ケタを入力して\n『〒⇒住所検索』ボタンをクリックしてください。\n＜例：4620043＞");
	}
}

function a_req_get_addr_how2 () {
	alert ("「-」ハイフン無しの郵便番号数字(半角)7ケタを入力して\n『〒⇒住所検索』ボタンをクリックしてください。\n＜例：4620043＞");
}

/*****************************************************************************/

function contact_scroll () {

//alert($F("oc_status"));
	$("contact_content").style.display = "block";

	if ($F("oc_status") == "close") {
		move_px = 580;
		$("name").focus();
		$("oc_status").value = "open";
	} else if ($F("oc_status") == "open") {
		move_px = 0;
		$("oc_status").value = "close";
	}

	new Effect.Morph(
		"contact_container",
		{
			style:"padding-top:" + move_px + "px;",
			duration:0.8,
			afterFinish: function() {
				if ($F("oc_status") == "close") {
					$("contact_content").style.display = "none";
				}
			}
		}
	);

}

/*****************************************************************************/

function len_check (elementId,elementnId,maxlen) {
	var v = $(elementId).value;
	var n = $(elementId).value.length;
	var message = "";

	if (n > maxlen) {
		var message = "<strong class=\"warn\">入力できる最大文字数を超えています。</strong><br />";
	}

	$(elementnId).innerHTML = message+n+" / "+maxlen;

}


