

function searchAddressFromZip(zip1, pref, city){

	var zip = $(zip1).val();

	if(!zip.match(/^[0-9]{3}-[0-9]{4}$/)){
		alert("郵便番号の書式が正しくありません。");
		return;
	}

	var url = "/orders/zip?zip=" + zip + "&mode=zip";

	$.get(url, function(text){

		if(!text || text == "" || text == " "){
			alert("ご指定の郵便番号が見つかりませんでした。");
			return;
		}

		var json = eval("(" + text + ")");

		if(json.zip_code){

			var childs = $(pref).children();
			for(var i in childs){
				if( childs[i].text == json.pref_name){
					$(pref).val(childs[i].value);
					break;
				}
			}
			// 市区町村
			$(city).val(json.city_name + json.town_name);
		}


	});



}

