function amSubmitDialog()
{
	var tmpHtml		= String.fromCharCode(60,100,105,118,62,60,105,109,103,32,115,114,99,61,34,46,47,99,115,115,47,105,109,97,103,101,115,47,105,109,103,45,97,112,112,108,121,45,97,103,114,101,101,46,106,112,103,34,32,47,62,60,47,100,105,118,62);
	var _dlg = $(tmpHtml);

	_dlg.dialog({
				modal		:	true,
				draggable	:	false,
				resizable	:	false,
				height		:	350,
				width		:	500,
				close		:	function(ev, ui)
								{
									$(this).remove();
								},
    			overlay		:	{	opacity:0.5, background:'#225B7F'	},
				buttons		:	{
									'送　信':function(ev)
												{
													$(this).dialog('close');
													amAjaxPost();
												},
									'キャンセル':function(ev)
												{
													$(this).dialog('close');
												}
								}
	});
}

function amSubmitErrorDialog()
{
	var tmpHtml		= String.fromCharCode(60,100,105,118,62,60,105,109,103,32,115,114,99,61,34,46,47,99,115,115,47,105,109,97,103,101,115,47,105,109,103,45,97,112,112,108,121,45,101,114,114,111,114,46,106,112,103,34,32,47,62,60,47,100,105,118,62);
	var _dlg = $(tmpHtml);

	_dlg.dialog({
				modal		:	true,
				draggable	:	false,
				resizable	:	false,
				height		:	350,
				width		:	500,
				close		:	function(ev, ui)
								{
									$(this).remove();
								},
    			overlay		:	{	opacity:0.5, background:'#225B7F'	},
				buttons		:	{
									'確　認':function(ev)
												{
													$(this).dialog('close');
												}
								}
	});
}

function amAjaxPost()
{
	var str = $("#formIdx").serialize();
	var url	= String.fromCharCode(46,47,112,104,112,47,97,109,101,120,116,109,97,105,108,46,112,104,112);
	var tmpHtml = String.fromCharCode(60,105,109,103,32,115,114,99,61,34,46,47,99,115,115,47,105,109,97,103,101,115,47,105,109,103,45,97,112,112,108,121,45,99,111,114,114,101,115,112,111,110,100,46,103,105,102,34,32,47,62);
	var targetOffset = $('#top').offset().top;

	$('html,body').animate({ scrollTop: targetOffset }, 'slow');
	$('#formContainer').html(tmpHtml);
	$.post(url,str,amTest);
}

function amTest()
{
	var tmpHtml = String.fromCharCode(60,105,109,103,32,115,114,99,61,34,46,47,99,115,115,47,105,109,97,103,101,115,47,105,109,103,45,97,112,112,108,121,45,116,104,97,110,107,121,111,117,46,106,112,103,34,32,47,62);
	$('#formContainer').html(tmpHtml);
}

function ShowDialog(htmlTitle,htmlMessage)
{
	var _dlg = $('<div>' + htmlMessage + '</div>');

	_dlg.dialog({
				modal		:	true,
				draggable	:	true,
				title		:	htmlTitle,
				height		:	300,
				width		:	400,
				close		:	function(ev, ui)
								{
									$(this).remove(); 
								},
    			overlay		:	{ opacity:0.5, background:'#225B7F' }
	});
}


function SetAddressFromZipcode(elmZipcode,elmTarget)
{
	var hurl 		= './php/proxy.php?zip=' + $('#' + elmZipcode).val();
	var tmpTitle	= String.fromCharCode(37109,20415,30058,21495,26908,32034,12469,12540,12499,12473);
	var tmpBusy		= String.fromCharCode(21482,20170,12450,12463,12475,12473,12364,38598,20013,12375,12390,12362,12426,37109,20415,30058,21495,26908,32034,12469,12540,12499,12473,12398,60,98,114,32,47,62,12372,21033,29992,21046,38480,12434,23455,26045,12375,12390,12362,12426,12414,12377,12290,60,98,114,32,47,62,12375,12400,12425,12367,12375,12390,12363,12425,12418,12358,19968,24230,25805,20316,12375,12390,12367,12384,12373,12356,12290);

	$.ajax({
			url			:	hurl,
	    	type		:	'GET',
	    	dataType	:	'xml',
	    	timeout		:	1000,
	    	error		:	function()
							{
	        					ShowDialog(tmpTitle,tmpBusy);
	    					},
			success		:	function(xml)
							{
								var txtResult	= $(xml).find("result").text();
								var txtValue	= $(xml).find("value").text();

								if(txtResult == "RESULT_OK")
								{
									$('#' + elmTarget).val(txtValue);
								}
								else
								{
									ShowDialog(tmpTitle,txtValue);
								}
	    					}
	});
}


function SetEraFormat(elmTarget)
{
	$(elmTarget).change(function(ev){

			var setValue	 = $(elmTarget).val();
			if(setValue == "") return;

			var pickYear	 = setValue.substr(0,4);
			var pickMonth	 = setValue.substr(5,2);
			var pickDay		 = setValue.substr(8,2);
			var eraName;

			if(pickYear == 1989)
			{
				if(pickMonth >= 2 || pickDay >= 8)
				{
					eraName = String.fromCharCode(24179,25104);
					pickYear = String.fromCharCode(20803);
				}
				else
				{
					eraName = String.fromCharCode(26157,21644);
					pickYear = 64;
				}
			}
			else if( pickYear > 1989 )
			{
				eraName = String.fromCharCode(24179,25104);
				pickYear = pickYear - 1988;
			}
			else
			{
				eraName = String.fromCharCode(26157,21644);
				pickYear = pickYear - 1925;
			}

			var updateValue = eraName + pickYear + String.fromCharCode(24180) + pickMonth + String.fromCharCode(26376) + pickDay + String.fromCharCode(26085);
			$(elmTarget).val(updateValue);

	});
}


