
jQuery("#pref_cd").change(initAll);jQuery("#prefix").change(getCityInfo);function initAll(){document.getElementById('post_num1').value="";document.getElementById('post_num2').value="";var sIndex=document.getElementById('pref_cd').selectedIndex;if(sIndex==0){for(i=10;i>0;i--){document.getElementById('prefix').options[i]=null;}
document.getElementById('prefix').options[0].text="　　　　　　　----- ";}else{document.getElementById('prefix').selectedIndex=0;document.getElementById('prefix').options[0].text="▼頭文字選択";document.getElementById('prefix').options[1]=new Option("あ行","1");document.getElementById('prefix').options[2]=new Option("か行","2");document.getElementById('prefix').options[3]=new Option("さ行","3");document.getElementById('prefix').options[4]=new Option("た行","4");document.getElementById('prefix').options[5]=new Option("な行","5");document.getElementById('prefix').options[6]=new Option("は行","6");document.getElementById('prefix').options[7]=new Option("ま行","7");document.getElementById('prefix').options[8]=new Option("や行","8");document.getElementById('prefix').options[9]=new Option("ら行","9");document.getElementById('prefix').options[10]=new Option("わ行","10");}
numofcity=document.getElementById('city_name').length;for(i=numofcity;i>0;i--){document.getElementById('city_name').options[i]=null;}
numoftown=document.getElementById('town_name').length;for(i=numoftown;i>0;i--){document.getElementById('town_name').options[i]=null;}
document.getElementById('city_name').selectedIndex=0;document.getElementById('city_name').options[0].text="　　　　　　　----- ";document.getElementById('town_name').selectedIndex=0;document.getElementById('town_name').options[0].text="　　　　　　　----- ";}
function getCityInfo(){var sIndex=document.getElementById('prefix').selectedIndex;var query=document.getElementById('prefix').options[sIndex].value;if(sIndex==0){document.getElementById('post_num1').value="";document.getElementById('post_num2').value="";document.getElementById('city_name').options[0].text="　　　　　　　----- ";numofcity=document.getElementById('city_name').length;for(i=numofcity;i>0;i--){document.getElementById('city_name').options[i]=null;}}else{document.getElementById('city_name').options[0].text="読み込み中...";jQuery("img#spinner1").fadeIn("fast");var url='/getzipcd/getzipcd.php';var params={param1:1,param2:jQuery('#pref_cd').val(),param3:query};jQuery.get(url,params,function(message,status){if('error'!=status){displaycitylist(message);}else{alert('読み込みに失敗しました');}});}
numoftown=document.getElementById('town_name').length;for(i=numoftown;i>0;i--){document.getElementById('town_name').options[i]=null;}
document.getElementById('town_name').selectedIndex=0;document.getElementById('town_name').options[0].text="　　　　　　　----- ";}
function getTownInfo(){var sIndex=document.getElementById('city_name').selectedIndex;var query=document.getElementById('city_name').options[sIndex].text;if(sIndex==0){document.getElementById('post_num1').value="";document.getElementById('post_num2').value="";document.getElementById('town_name').options[0].text="　　　　　　　----- ";numoftown=document.getElementById('town_name').length;for(i=numoftown;i>0;i--){document.getElementById('town_name').options[i]=null;}}else{document.getElementById('town_name').options[0].text="読み込み中...";jQuery("img#spinner2").fadeIn("fast");var url='/getzipcd/getzipcd.php';var params={param1:2,param2:jQuery('#pref_cd').val(),param3:jQuery('#prefix').val(),param4:query};jQuery.get(url,params,function(message,status){if('error'!=status){displaytownlist(message);}else{alert('読み込みに失敗しました');}});}}
function getZipInfo(){var sIndex=document.getElementById('town_name').selectedIndex;var zipcode=document.getElementById('town_name').options[sIndex].value;if(sIndex==0){document.getElementById('post_num1').value="";document.getElementById('post_num2').value="";}else{var zip1=zipcode.substring(0,3);var zip2=zipcode.substring(3);document.getElementById('post_num1').value=zip1;document.getElementById('post_num2').value=zip2;setTimeout(function(){jQuery("a#cross-cancel").parents().find(".stripNav ul li a:eq("+(parseInt(jQuery("a#cross-cancel").attr("href").slice(1))-1)+")").trigger('click');},1*300);}}
function displaycitylist(transport){jQuery("#city_name").replaceWith(transport);jQuery("img#spinner1").fadeOut("slow");}
function displaytownlist(transport){jQuery("#town_name").replaceWith(transport);jQuery("img#spinner2").fadeOut("slow");}