var httpObj;var httpObj2;var timerId;var timerId2;var timeout_sec=10;function formSubmit(){var choice_select=document.getElementById('choice');var choice_opt_num=choice_select.length;var i;var area_txt="";var kenno="";var u_choice_select=document.getElementById('u_choice');var u_choice_opt_num=u_choice_select.length;var s;var unyu_txt="";if(choice_opt_num==0&&u_choice_opt_num==0){document.getElementById('form').submit();}else if(choice_opt_num!=0&&u_choice_opt_num==0){for(i=choice_opt_num-1;i>=0;i--){var choice_opt=choice_select.options[i];choice_opt.selected=true;if(choice_opt.selected==true){var choice_opt_text=choice_opt.text;var choice_opt_value=choice_opt.value;}if(!i){area_txt+=choice_opt_text;kenno+=choice_opt_value;}else{area_txt+=choice_opt_text+',';kenno+=choice_opt_value+',';}}document.getElementById('area').innerHTML=area_txt;document.getElementById('ken_no').innerHTML=kenno;document.getElementById('form').submit();}else if(choice_opt_num==0&&u_choice_opt_num!=0){for(s=u_choice_opt_num-1;s>=0;s--){var u_choice_opt=u_choice_select.options[s];u_choice_opt.selected=true;if(u_choice_opt.selected==true){var u_choice_opt_text=u_choice_opt.text;}if(!s){unyu_txt+=u_choice_opt_text;}else{unyu_txt+=u_choice_opt_text+',';}}document.getElementById('unyu').innerHTML=unyu_txt;document.getElementById('form').submit();}else if(choice_opt_num!=0&&u_choice_opt_num!=0){for(i=choice_opt_num-1;i>=0;i--){var choice_opt=choice_select.options[i];choice_opt.selected=true;if(choice_opt.selected==true){var choice_opt_text=choice_opt.text;var choice_opt_value=choice_opt.value;}if(!i){area_txt+=choice_opt_text;kenno+=choice_opt_value;}else{area_txt+=choice_opt_text+',';kenno+=choice_opt_value+',';}}document.getElementById('area').innerHTML=area_txt;document.getElementById('ken_no').innerHTML=kenno;for(s=u_choice_opt_num-1;s>=0;s--){var u_choice_opt=u_choice_select.options[s];u_choice_opt.selected=true;if(u_choice_opt.selected==true){var u_choice_opt_text=u_choice_opt.text;}if(!s){unyu_txt+=u_choice_opt_text;}else{unyu_txt+=u_choice_opt_text+',';}}document.getElementById('unyu').innerHTML=unyu_txt;document.getElementById('form').submit();}}function eliminateDropdownList(){var select_node=document.getElementById('shikutyo');var opt_num=select_node.length;var i;for(i=opt_num-1;i>=0;i--){select_node.remove(i);}}function eliminateDropdownList2(){var select_node=document.getElementById('unyu_name');var opt_num=select_node.length;var i;for(i=opt_num-1;i>=0;i--){select_node.remove(i);}}function generateDropdownList(text_data){var lines=text_data.split("\n");var select_node=document.getElementById('shikutyo');for(i=0;i<lines.length;i++){if(lines[i]==''){break;}var parts=lines[i].split(",");var code=parts[0];var item=parts[1];var opt=document.createElement('option');opt.value=code;opt.text=item;try{select_node.add(opt,null);}catch(ex){select_node.add(opt,-1);}}}function printShikutyoList(e){eliminateDropdownList();var target_node=document.getElementsByName('ken')[0].childNodes;var id_value;for(i=0;i<target_node.length;i++){if(target_node[i].selected){id_value=target_node[i].id;}}if(id_value=='all'||'hokaido'||id_value=='aomori'||id_value=='iwate'||id_value=='miyagi'||id_value=='akita'||id_value=='yamagata'||id_value=='fukushima'||id_value=='ibaraki'||id_value=='totigi'||id_value=='gunma'||id_value=='saitama'||id_value=='tiba'||id_value=='tokyo'||id_value=='kanagawa'||id_value=='yamanashi'||id_value=='nigata'||id_value=='toyama'||id_value=='ishikawa'||id_value=='fukui'||id_value=='nagano'||id_value=='gifu'||id_value=='shizuoka'||id_value=='aiti'||id_value=='mie'||id_value=='shiga'||id_value=='kyoto'||id_value=='osaka'||id_value=='hyogo'||id_value=='nara'||id_value=='wakayama'||id_value=='totori'||id_value=='shimane'||id_value=='okayama'||id_value=='hiroshima'||id_value=='yamaguti'||id_value=='tokushima'||id_value=='kagawa'||id_value=='ehime'||id_value=='kouti'||id_value=='fukuoka'||id_value=='saga'||id_value=='nagasaki'||id_value=='kumamoto'||id_value=='oita'||id_value=='miyazaki'||id_value=='kagoshima'||id_value=='okinawa'){target_url='/form/txt/'+id_value+'.txt';httpRequest(target_url,generateDropdownList);}}function printUnyuList(e){eliminateDropdownList2();var target_node=document.getElementsByName('unyu_ken')[0].childNodes;var id_value;for(i=0;i<target_node.length;i++){if(target_node[i].selected){id_value=target_node[i].id;}}if(id_value=='uall'||'uhokaido'||id_value=='uaomori'||id_value=='uiwate'||id_value=='umiyagi'||id_value=='uakita'||id_value=='uyamagata'||id_value=='ufukushima'||id_value=='uibaraki'||id_value=='utotigi'||id_value=='ugunma'||id_value=='usaitama'||id_value=='utiba'||id_value=='utokyo'||id_value=='ukanagawa'||id_value=='uyamanashi'||id_value=='unigata'||id_value=='utoyama'||id_value=='uishikawa'||id_value=='ufukui'||id_value=='unagano'||id_value=='ugifu'||id_value=='ushizuoka'||id_value=='uaiti'||id_value=='umie'||id_value=='ushiga'||id_value=='ukyoto'||id_value=='uosaka'||id_value=='uhyogo'||id_value=='unara'||id_value=='uwakayama'||id_value=='utotori'||id_value=='ushimane'||id_value=='uokayama'||id_value=='uhiroshima'||id_value=='uyamaguti'||id_value=='utokushima'||id_value=='ukagawa'||id_value=='uehime'||id_value=='ukouti'||id_value=='ufukuoka'||id_value=='usaga'||id_value=='unagasaki'||id_value=='ukumamoto'||id_value=='uoita'||id_value=='umiyazaki'||id_value=='ukagoshima'||id_value=='uokinawa'){target_url='/form/utxt/'+id_value+'.txt';httpRequest3(target_url,generateDropdownList3);}}function addShikutyo(){var shikutyo_select=document.getElementById('shikutyo');var choice_select=document.getElementById('choice');var shikutyo_opt_num=shikutyo_select.length;var i;for(i=shikutyo_opt_num-1;i>=0;i--){var shikutyo_opt=shikutyo_select.options[i];if(shikutyo_opt.selected==true){var shikutyo_opt_text=shikutyo_opt.text;var shikutyo_opt_value=shikutyo_opt.value;shikutyo_select.remove(i);var choice_opt=document.createElement('option');choice_opt.text=shikutyo_opt_text;choice_opt.value=shikutyo_opt_value;try{choice_select.add(choice_opt,null);}catch(ex){choice_select.add(choice_opt,-1);}}}}function addUnyu(){var unyu_select=document.getElementById('unyu_name');var u_choice_select=document.getElementById('u_choice');var unyu_opt_num=unyu_select.length;var i;for(i=unyu_opt_num-1;i>=0;i--){var unyu_opt=unyu_select.options[i];if(unyu_opt.selected==true){var unyu_opt_text=unyu_opt.text;var unyu_opt_value=unyu_opt.value;unyu_select.remove(i);var u_choice_opt=document.createElement('option');u_choice_opt.text=unyu_opt_text;u_choice_opt.value=unyu_opt_value;try{u_choice_select.add(u_choice_opt,null);}catch(ex){u_choice_select.add(u_choice_opt,-1);}}}}function delShikutyo(){var shikutyo_select=document.getElementById('shikutyo');var choice_select=document.getElementById('choice');var choice_opt_num=choice_select.length;var i;for(i=choice_opt_num-1;i>=0;i--){var choice_opt=choice_select.options[i];if(choice_opt.selected==true){var choice_opt_text=choice_opt.text;var choice_opt_value=choice_opt.value;choice_select.remove(i);var shikutyo_opt=document.createElement('option');shikutyo_opt.text=choice_opt_text;shikutyo_opt.value=choice_opt_value;try{shikutyo_select.add(shikutyo_opt,null);}catch(ex){shikutyo_select.add(shikutyo_opt,-1);}}}}function delUnyu(){var unyu_select=document.getElementById('unyu_name');var u_choice_select=document.getElementById('u_choice');var u_choice_opt_num=u_choice_select.length;var i;for(i=u_choice_opt_num-1;i>=0;i--){var u_choice_opt=u_choice_select.options[i];if(u_choice_opt.selected==true){var u_choice_opt_text=u_choice_opt.text;var u_choice_opt_value=u_choice_opt.value;u_choice_select.remove(i);var unyu_opt=document.createElement('option');unyu_opt.text=u_choice_opt_text;unyu_opt.value=u_choice_opt_value;try{unyu_select.add(unyu_opt,null);}catch(ex){unyu_select.add(unyu_opt,-1);}}}}function generateDropdownList2(text_data){var lines=text_data.split("\n");eliminateDropdownList();var select_node=document.getElementById('shikutyo');for(i=0;i<lines.length;i++){if(lines[i]==''){break;}var parts=lines[i].split(",");var code=parts[0];var shikutyo=parts[1];var opt=document.createElement('option');opt.value=code;opt.text=shikutyo;try{select_node.add(opt,null);}catch(ex){select_node.add(opt,-1);}}}function generateDropdownList3(text_data){var lines=text_data.split("\n");eliminateDropdownList2();var select_node=document.getElementById('unyu_name');for(i=0;i<lines.length;i++){if(lines[i]==''){break;}var parts=lines[i].split(",");var code=parts[0];var unyu_name=parts[1];var opt=document.createElement('option');opt.value=code;opt.text=unyu_name;try{select_node.add(opt,null);}catch(ex){select_node.add(opt,-1);}}}function httpRequest2(target_url,funcitonReference){try{if(window.XMLHttpRequest){httpObj=new XMLHttpRequest();}else if(window.ActiveXObject){httpObj=new ActiveXObject("Microsoft.XMLHTTP");}else{httpObj=false;}}catch(e){httpObj=false;}if(!httpObj){httpObjGenerateFail();}timerId=setInterval('timeoutCheck()',1000);httpObj.open("GET",target_url,true);httpObj.onreadystatechange=function(){if(httpObj.readyState==4){clearInterval(timerId);if(httpObj.status==200){funcitonReference(httpObj.responseText);}else{alert(httpObj.status+' : '+httpObj.statusText);return false;}}};httpObj.send('');}function getTargetNode(e){var target_node;if(e.target){target_node=e.target;}else{target_node=e.srcElement;}if(target_node.nodeType==3){target_node=target_node.parentNode;}return target_node;}function httpRequest(target_url,funcitonReference){try{if(window.XMLHttpRequest){httpObj=new XMLHttpRequest();}else if(window.ActiveXObject){httpObj=new ActiveXObject("Microsoft.XMLHTTP");}else{httpObj=false;}}catch(e){httpObj=false;}if(!httpObj){httpObjGenerateFail();}timerId=setInterval('timeoutCheck()',1000);httpObj.open("GET",target_url,true);httpObj.onreadystatechange=function(){if(httpObj.readyState==4){clearInterval(timerId);if(httpObj.status==200){funcitonReference(httpObj.responseText);}else{alert(httpObj.status+' : '+httpObj.statusText);return false;}}};httpObj.send('');}function httpRequest3(target_url,funcitonReference){try{if(window.XMLHttpRequest){httpObj2=new XMLHttpRequest();}else if(window.ActiveXObject){httpObj2=new ActiveXObject("Microsoft.XMLHTTP");}else{httpObj2=false;}}catch(e){httpObj2=false;}if(!httpObj2){httpObjGenerateFail();}timerId2=setInterval('timeoutCheck()',1000);httpObj2.open("GET",target_url,true);httpObj2.onreadystatechange=function(){if(httpObj2.readyState==4){clearInterval(timerId2);if(httpObj2.status==200){funcitonReference(httpObj2.responseText);}else{alert(httpObj2.status+' : '+httpObj2.statusText);return false;}}};httpObj2.send('');}function httpObjGenerateFail(){alert('ご利用のブラウザではご利用頂けません。');return false;}function timeoutCheck(){timeout_sec--;if(timeout_sec<=0){clearInterval(timerId);httpObj.abort();alert('地域メニューの読み込みエラーです。再度選択を行って下さい。');return false;}}function timeoutCheck2(){timeout_sec--;if(timeout_sec<=0){clearInterval(timerId2);httpObj.abort();alert('地域メニューの読み込みエラーです。再度選択を行って下さい。');return false;}}function selectText(){var txt=document.getElementById("link_txt");txt.select();}function setListeners(e){var grp=document.getElementsByName('ken')[0];addListener(grp,'change',printShikutyoList,false);printShikutyoList();var addBtn=document.getElementById('addBtn');addListener(addBtn,'click',addShikutyo,false);var delBtn=document.getElementById('delBtn');addListener(delBtn,'click',delShikutyo,false);var unyu=document.getElementsByName('unyu_ken')[0];addListener(unyu,'change',printUnyuList,false);printUnyuList();var uaddBtn=document.getElementById('uaddBtn');addListener(uaddBtn,'click',addUnyu,false);var udelBtn=document.getElementById('udelBtn');addListener(udelBtn,'click',delUnyu,false);var orderBtn=document.getElementById('orderBtn');addListener(orderBtn,'click',formSubmit,false);}function addListener(elem,eventType,func,cap){if(elem.addEventListener){elem.addEventListener(eventType,func,cap);}else if(elem.attachEvent){elem.attachEvent('on'+eventType,func);}else{alert('ご利用のブラウザはサポートされていません。');return false;}}function nextMove(){if(document.getElementById('yubin1').value.length>=3){document.getElementById('yubin2').focus();}}addListener(window,'load',setListeners,false);
